diff --git a/.travis.yml b/.travis.yml
index b43f50859..64249c6cf 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,7 +7,6 @@ before_script:
install: mvn install -DskipTests=true -Dgpg.skip=true -Dmaven.javadoc.skip=true -B -V
jdk:
- - oraclejdk7
- oraclejdk8
sudo: false
diff --git a/ChangeLog b/ChangeLog
index 8f299418b..44adbc2b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,18 @@
-v3.1.0 (2016-XX-XX)
+v4.0.0 (2016-10-17)
+---------------------------
+* replaced API
+* replaced protocol http with VelocyStream
+* added VelocyPack support
+* added multi document operations (insert, delete, update, replace)
+
+v3.1.0 (2016-10-17)
---------------------------
* removed Methods with collectionId (long) from ArangoDriver (Id is only for internal usage)
* changed Revision from long to String
* removed Methods with documentId (long) from ArangoDriver
* added profile flag to AqlQueryOptions (issue #47)
-v3.0.4 (2016-XX-XX)
+v3.0.4 (2016-10-17)
---------------------------
* fixed edges deserializer (issue #50)
diff --git a/LICENSE b/LICENSE
index 267b169b0..8dada3eda 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Apache License
+ Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
@@ -186,7 +186,7 @@ Apache License
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright 2015 ArangoDB GmbH
+ Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/README.md b/README.md
index cab20aa8a..a8798a6b3 100644
--- a/README.md
+++ b/README.md
@@ -6,21 +6,18 @@
2.7: [](https://travis-ci.org/arangodb/arangodb-java-driver)
3.0: [](https://travis-ci.org/arangodb/arangodb-java-driver)
3.1: [](https://travis-ci.org/arangodb/arangodb-java-driver)
-
+4.0: [](https://travis-ci.org/arangodb/arangodb-java-driver)
master: [](https://travis-ci.org/arangodb/arangodb-java-driver)
-This library is a Java driver for ArangoDB.
-
-Supported version: ArangoDB 3.1.X
-
-(Use ```arangodb-java-driver 2.7.4``` for ArangoDB 2.7.x and ArangoDB 2.8.x)
+## Supported versions
-# Required
-
-* [ArangoDB](https://github.com/arangodb/arangodb) version 3.1.X
-* Java 1.6 later
-
-# Basics
+
+arangodb-java-driver | ArangoDB | network protocol | Java version |
+4.0.x | 3.1.x | VelocyStream | 1.6+ |
+3.1.x | 3.1.x | HTTP | 1.6+ |
+3.0.x | 3.0.x | HTTP | 1.6+ |
+2.7.4 | 2.7.x and 2.8.x | HTTP | 1.6+ |
+
## Maven
@@ -33,25 +30,13 @@ ArangoDB 3.1.X
com.arangodb
arangodb-java-driver
- 3.0.0
-
- ....
-
-```
-
-ArangoDB 2.7.x and ArangoDB 2.8.x:
-```XML
-
-
- com.arangodb
- arangodb-java-driver
- 2.7.4
+ 4.0.0
....
```
-If you want to test with a snapshot version (e.g. 3.1.0-SNAPSHOT), add the staging repository of oss.sonatype.org to your pom.xml:
+If you want to test with a snapshot version (e.g. 4.0.0-SNAPSHOT), add the staging repository of oss.sonatype.org to your pom.xml:
```XML
@@ -62,332 +47,16 @@ If you want to test with a snapshot version (e.g. 3.1.0-SNAPSHOT), add the stagi
```
+## Compile java driver
-## Driver Setup
-
-Setup with default configuration:
-
-``` Java
- // Initialize configure
- ArangoConfigure configure = new ArangoConfigure();
- configure.init();
-
- // Create Driver (this instance is thread-safe)
- ArangoDriver arangoDriver = new ArangoDriver(configure);
-
-```
-
-
-The driver is configured with some default values:
-
-
-property-key | description | default value |
-host | ArangoDB host | 127.0.0.1 |
-port | ArangoDB port | 8529 |
-maxPerConnection | Max http connection per host. | 20 |
-maxTotalConnection | Max http connection per configure. | 20 |
-user | Basic Authentication User | |
-password | Basic Authentication Password | |
-proxy.host | proxy host | |
-proxy.port | proxy port | |
-connectionTimeout | socket connect timeout(millisecond) | -1 |
-timeout | socket read timeout(millisecond) | -1 |
-retryCount | http retry count | 3 |
-defaultDatabase | default database | |
-enableCURLLogger | logging flag by curl format for debug | false |
-useSsl | use HTTPS connection | false |
-property-key | description | default value |
-arangoHost | ArangoDB host and port | 127.0.0.1:8529 |
-fallbackArangoHost | fallback ArangoDB host and port | |
-
-
-To customize the configuration the parameters can be changed in the code...
-
-``` Java
- // Initialize configure
- ArangoConfigure configure = new ArangoConfigure();
- configure.setArangoHost(new ArangoHost("192.168.182.50", 8888));
- configure.init();
-
- // Create Driver (this instance is thread-safe)
- ArangoDriver arangoDriver = new ArangoDriver(configure);
-
-```
-... or with a properties file (arangodb.properties)
-
-``` Java
- // Initialize configure
- ArangoConfigure configure = new ArangoConfigure();
- configure.loadProperties();
- configure.init();
-
- // Create Driver (this instance is thread-safe)
- ArangoDriver arangoDriver = new ArangoDriver(configure);
-
-```
-
-Example for arangodb.properties:
-``` Java
-arangoHost=192.168.182.50:8888
-user=root
-password=
-enableCURLLogger=true
-
-```
-
-
-# Basic database operations
-## create database
-``` Java
- // create database
- arangoDriver.createDatabase("myDatabase");
- // and set as default
- arangoDriver.setDefaultDatabase("myDatabase");
-
-```
-
-## changing the database
-This ArangoDB driver is thread-safe. Unfortunately the ArangoDriver#setDefaultDatabase() is not (yet). So its recommended to create a new driver instance, if you want to change the database.
-
-``` Java
- //Driver instance to database "_system" (default database)
- ArangoDriver driverSystem = new ArangoDriver(configure);
- //Driver instance to database "mydb2"
- ArangoDriver driverMyDB = new ArangoDriver(configure, "mydb2");
-
-```
-
-## drop database
-``` Java
- // drop database
- arangoDriver.deleteDatabase("myDatabase");
-
-```
-
-# Basic collection operations
-## create collection
-``` Java
- // create collection
- CollectionEntity myArangoCollection = ArangoCollectionarangoDriver.createCollection("myCollection");
-
-```
-
-## delete collection by name
-``` Java
- // delete database
- arangoDriver.deleteCollection("myCollection");
-
-```
-
-## delete collection by id
-``` Java
- // delete database
- arangoDriver.deleteCollection(myArangoCollection.getId());
-
-```
-
-# Basic document operations
-
-For the next examples we use a small object:
-
-``` Java
-public class MyObject {
-
- private String name;
- private int age;
-
- public MyObject(String name, int age) {
- this.name = name;
- this.age = age;
- }
-
- /*
- * + getter and setter
- */
-
-
-}
-```
-
-## create document
-``` Java
- // create document
- MyObject myObject = new MyObject("Homer", 38);
- DocumentEntity myDocument = arangoDriver.createDocument("myCollection", myObject);
-
-```
-
-When creating a document, the attributes of the object will be stored as key-value pair
-E.g. in the previous example the object was stored as follows:
-``` properties
-"name" : "Homer"
-"age" : "38"
-```
-
-
-## delete document
-``` Java
- // delete document
- arangoDriver.deleteDocument(myDocument.getDocumentHandle());
-
-```
-
-# AQL
-## Executing an AQL statement
-
-E.g. get all Simpsons aged 3 or older in ascending order:
-
-``` Java
- arangoDriver.deleteDatabase("myDatabase");
- arangoDriver.createDatabase("myDatabase");
- arangoDriver.setDefaultDatabase("myDatabase");
- CollectionEntity myArangoCollection = arangoDriver.createCollection("myCollection");
-
- arangoDriver.createDocument("myCollection", new MyObject("Homer", 38));
- arangoDriver.createDocument("myCollection", new MyObject("Marge", 36));
- arangoDriver.createDocument("myCollection", new MyObject("Bart", 10));
- arangoDriver.createDocument("myCollection", new MyObject("Lisa", 8));
- arangoDriver.createDocument("myCollection", new MyObject("Maggie", 2));
-
- String query = "FOR t IN myCollection FILTER t.age >= @age SORT t.age RETURN t";
- Map bindVars = new MapBuilder().put("age", 3).get();
-
- DocumentCursor documentCursor = arangoDriver.executeDocumentQuery(
- query, bindVars, driver.getDefaultAqlQueryOptions(), MyObject.class);
-
- for (DocumentEntity documentEntity : documentCursor.asList()) {
- MyObject obj = documentEntity.getEntity();
- System.out.println(obj.getName());
- }
-```
-
-instead of using a ```for``` statement you can also use an DocumentEntitiy or an entity iterator:
-``` Java
- Iterator> iterator = documentCursor.iterator();
- while (iterator.hasNext()) {
- DocumentEntity documentEntity = iterator.next();
- MyObject obj = documentEntity.getEntity();
- System.out.println(obj.getName());
- }
-
- Iterator iterator = documentCursor.entityIterator();
- while (iterator.hasNext()) {
- MyObject obj = iterator.next();
- System.out.println(obj.getName());
- }
-```
-
-#User Management
-If you are using [authentication] (https://docs.arangodb.com/Manual/GettingStarted/Authentication.html) you can manage users with the driver.
-
-##add user
-``` Java
- //username, password, active, extras
- arangoDriver.createUser("myUser", "myPassword", true, null);
-```
-
-##list users
-``` Java
- List users = arangoDriver.getUsers();
- for(UserEntity user : users) {
- System.out.println(user.getName())
- }
-```
-
-
-##DELETE user
-``` Java
- arangoDriver.deleteUser("myUser");
-```
-
-
-#Graphs
-This driver supports the new [graph api](https://docs.arangodb.com/HTTP/Gharial/index.html).
-
-Some of the basic graph operations are described in the following:
-
-##add graph
-A graph consists of vertices and edges (stored in collections). Which collections are used within a graph is defined via edge definitions. A graph can contain more than one edge definition, at least one is needed.
-
-``` Java
- List edgeDefinitions = new ArrayList();
- EdgeDefinitionEntity edgeDefinition = new EdgeDefinitionEntity();
- // define the edgeCollection to store the edges
- edgeDefinition.setCollection("myEdgeCollection");
- // define a set of collections where an edge is going out...
- List from = new ArrayList();
- // and add one or more collections
- from.add("myCollection1");
- from.add("myCollection2");
- edgeDefinition.setFrom(from);
-
- // repeat this for the collections where an edge is going into
- List to = new ArrayList();
- to.add("myCollection1");
- to.add("myCollection3");
- edgeDefinition.setTo(to);
-
- edgeDefinitions.add(edgeDefinition);
-
- // A graph can contain additional vertex collections, defined in the set of orphan collections
- List orphanCollections = new ArrayList();
- orphanCollections.add("myCollection4");
- orphanCollections.add("myCollection5");
-
- // now it's possible to create a graph (the last parameter is the waitForSync option)
- GraphEntity graph = arangoDriver.createGraph("myGraph", edgeDefinitions, orphanCollections, true);
-```
-
-##delete graph
-
-A graph can be deleted by its name
-
-``` Java
- arangoDriver.deleteGraph("myGraph");
-```
-
-##add vertex
-
-Vertices are stored in the vertex collections defined above.
-
-``` Java
- MyObject myObject1 = new MyObject("Homer", 38);
- MyObject myObject2 = new MyObject("Marge", 36);
- DocumentEntity vertexFrom = arangoDriver.graphCreateVertex(
- "myGraph",
- "collection1",
- myObject1,
- true);
-
- DocumentEntity vertexTo = arangoDriver.graphCreateVertex(
- "myGraph",
- "collection3",
- myObject2,
- true);
-```
-
-## add edge
-
-Now an edge can be created to set a relation between vertices
-
-``` Java
- EdgeEntity> edge = arangoDriver.graphCreateEdge(
- "myGraph",
- "myEdgeCollection",
- null,
- vertexFrom.getDocumentHandle(),
- vertexTo.getDocumentHandle(),
- null,
- null);
-```
-# Compile java driver
```
- mvn clean install -DskipTests=true -Dgpg.skip=true -Dmaven.javadoc.skip=true -B
+mvn clean install -DskipTests=true -Dgpg.skip=true -Dmaven.javadoc.skip=true -B
```
# Learn more
* [ArangoDB](https://www.arangodb.com/)
* [ChangeLog](ChangeLog)
+* [Documentation](docs/documentation.md)
* [Examples](src/test/java/com/arangodb/example)
* [Tutorial](https://www.arangodb.com/tutorial-java/)
-* [JavaDoc](http://arangodb.github.io/arangodb-java-driver/javadoc-3_1/index.html)
+* [JavaDoc](http://arangodb.github.io/arangodb-java-driver/javadoc-4_0/index.html)
diff --git a/docs/aql.md b/docs/aql.md
new file mode 100644
index 000000000..d6a9ee28c
--- /dev/null
+++ b/docs/aql.md
@@ -0,0 +1,41 @@
+# AQL
+## Executing an AQL statement
+
+Every AQL operations works with POJOs (e.g. MyObject), VelocyPack (VPackSlice) and Json (String).
+
+E.g. get all Simpsons aged 3 or older in ascending order:
+
+``` Java
+ arangoDB.createDatabase("myDatabase");
+ ArangoDatabase db = arangoDB.db("myDatabase");
+
+ db.createCollection("myCollection");
+ ArangoCollection collection = db.collection("myCollection");
+
+ collection.insertDocument(new MyObject("Homer", 38));
+ collection.insertDocument(new MyObject("Marge", 36));
+ collection.insertDocument(new MyObject("Bart", 10));
+ collection.insertDocument(new MyObject("Lisa", 8));
+ collection.insertDocument(new MyObject("Maggie", 2));
+
+ Map bindVars = new HashMap<>();
+ bindVars.put("age", 3);
+
+ ArangoCursor cursor = db.query(query, bindVars, null, MyObject.class);
+
+ for(; cursor.hasNext;) {
+ MyObject obj = cursor.next();
+ System.out.println(obj.getName());
+ }
+```
+
+or return the AQL result as VelocyPack:
+
+``` Java
+ ArangoCursor cursor = db.query(query, bindVars, null, VPackSlice.class);
+
+ for(; cursor.hasNext;) {
+ VPackSlice obj = cursor.next();
+ System.out.println(obj.get("name").getAsString());
+ }
+```
diff --git a/docs/basic_operations.md b/docs/basic_operations.md
new file mode 100644
index 000000000..0e3f568db
--- /dev/null
+++ b/docs/basic_operations.md
@@ -0,0 +1,125 @@
+# Basic database operations
+## create database
+``` Java
+ // create database
+ arangoDB.createDatabase("myDatabase");
+
+```
+
+## drop database
+``` Java
+ // drop database
+ arangoDB.db("myDatabase").drop();
+
+```
+
+# Basic collection operations
+## create collection
+``` Java
+ // create collection
+ arangoDB.db("myDatabase").createCollection("myCollection", null);
+
+```
+
+## delete collection by name
+``` Java
+ // delete collection
+ arangoDB.db("myDatabase").collection("myCollection").drop();
+
+```
+
+## delete all documents in the collection
+``` Java
+ arangoDB.db("myDatabase").collection("myCollection").truncate();
+```
+
+# Basic document operations
+
+Every document operations works with POJOs (e.g. MyObject), VelocyPack (VPackSlice) and Json (String).
+
+For the next examples we use a small object:
+
+``` Java
+ public class MyObject {
+
+ private String key;
+ private String name;
+ private int age;
+
+ public MyObject(String name, int age) {
+ this();
+ this.name = name;
+ this.age = age;
+ }
+
+ public MyObject() {
+ super();
+ }
+
+ /*
+ * + getter and setter
+ */
+
+ }
+```
+
+## insert document
+``` Java
+ MyObject myObject = new MyObject("Homer", 38);
+ arangoDB.db("myDatabase").collection("myCollection").insertDocument(myObject);
+
+```
+
+When creating a document, the attributes of the object will be stored as key-value pair
+E.g. in the previous example the object was stored as follows:
+``` properties
+ "name" : "Homer"
+ "age" : "38"
+```
+
+
+## delete document
+``` Java
+ arangoDB.db("myDatabase").collection("myCollection").deleteDocument(myObject.getKey);
+
+```
+
+## update document
+``` Java
+ arangoDB.db("myDatabase").collection("myCollection").updateDocument(myObject.getKey, myUpdatedObject);
+
+```
+
+## replace document
+``` Java
+ arangoDB.db("myDatabase").collection("myCollection").replaceDocument(myObject.getKey, myObject2);
+
+```
+
+## read document by key (as JavaBean)
+``` Java
+ MyObject document = arangoDB.db("myDatabase").collection("myCollection").getDocument(myObject.getKey, MyObject.class);
+ document.getName();
+ document.getAge();
+
+```
+
+## read document (as VelocyPack)
+``` Java
+ VPackSlice document = arangoDB.db("myDatabase").collection("myCollection").getDocument(myObject.getKey, VPackSlice.class);
+ document.get("name").getAsString();
+ document.get("age").getAsInt();
+
+```
+
+## read document (as Json)
+``` Java
+ arangoDB.db("myDatabase").collection("myCollection").getDocument(myObject.getKey, String.class);
+
+```
+
+## read document by id
+``` Java
+ arangoDB.db("myDatabase").getDocument("myCollection/myKey", MyObject.class);
+
+```
diff --git a/docs/documentation.md b/docs/documentation.md
new file mode 100644
index 000000000..1cc0e48a7
--- /dev/null
+++ b/docs/documentation.md
@@ -0,0 +1,10 @@
+#Documentation overview
+
+* [Driver Setup](setup.md)
+* [Basic database operations](basic_operations.md)
+* [Multi document operations](multi_operations.md)
+* [serialization/deserialization](serialization.md)
+* [User Management](user_management.md)
+* [AQL](aql.md)
+* [Graphs](graphs.md)
+* [Foxx](foxx.md)
\ No newline at end of file
diff --git a/docs/foxx.md b/docs/foxx.md
new file mode 100644
index 000000000..060ebb7c8
--- /dev/null
+++ b/docs/foxx.md
@@ -0,0 +1,14 @@
+# Foxx
+##execute a service
+``` Java
+ Request request = new Request("mydb", RequestType.GET, "/my/foxx/service")
+ Response response = arangoDB.execute(request);
+
+```
+
+##execute a service (async)
+``` Java
+ Request request = new Request("mydb", RequestType.GET, "/my/foxx/service")
+ CompletableFuture response = arangoDB.executeAsync(request);
+
+```
\ No newline at end of file
diff --git a/docs/graphs.md b/docs/graphs.md
new file mode 100644
index 000000000..682db27d5
--- /dev/null
+++ b/docs/graphs.md
@@ -0,0 +1,58 @@
+#Graphs
+This driver supports the [graph api](https://docs.arangodb.com/HTTP/Gharial/index.html).
+
+Some of the basic graph operations are described in the following:
+
+##add graph
+A graph consists of vertices and edges (stored in collections). Which collections are used within a graph is defined via edge definitions. A graph can contain more than one edge definition, at least one is needed.
+
+``` Java
+ Collection edgeDefinitions = new ArrayList<>();
+ EdgeDefinition edgeDefinition = new EdgeDefinition();
+ // define the edgeCollection to store the edges
+ edgeDefinition.collection("myEdgeCollection");
+ // define a set of collections where an edge is going out...
+ edgeDefinition.from("myCollection1", "myCollection2");
+
+ // repeat this for the collections where an edge is going into
+ edgeDefinition.to("myCollection1", "myCollection3");
+
+ edgeDefinitions.add(edgeDefinition);
+
+ // A graph can contain additional vertex collections, defined in the set of orphan collections
+ GraphCreateOptions options = new GraphCreateOptions();
+ options.orphanCollections("myCollection4", "myCollection5");
+
+ // now it's possible to create a graph
+ arangoDB.db("myDatabase").createGraph("myGraph", edgeDefinitions, options);
+
+```
+
+##delete graph
+
+A graph can be deleted by its name
+
+``` Java
+ arangoDB.db("myDatabase").graph("myGraph").drop();
+```
+
+##add vertex
+
+Vertices are stored in the vertex collections defined above.
+
+``` Java
+ MyObject myObject1 = new MyObject("Homer", 38);
+ MyObject myObject2 = new MyObject("Marge", 36);
+ arangoDB.db("myDatabase").graph("myGraph").vertexCollection("collection1").insertVertex(myObject1, null);
+ arangoDB.db("myDatabase").graph("myGraph").vertexCollection("collection3").insertVertex(myObject2, null);
+
+```
+
+## add edge
+
+Now an edge can be created to set a relation between vertices
+
+``` Java
+ arangoDB.db("myDatabase").graph("myGraph").edgeCollection("myEdgeCollection").insertEdge(myEdgeObject, null);
+
+```
diff --git a/docs/multi_operations.md b/docs/multi_operations.md
new file mode 100644
index 000000000..95aab7b69
--- /dev/null
+++ b/docs/multi_operations.md
@@ -0,0 +1,41 @@
+# Multi document operations
+
+## insert documents
+``` Java
+ Collection documents = new ArrayList<>;
+ documents.add(myObject1);
+ documents.add(myObject2);
+ documents.add(myObject3);
+ arangoDB.db("myDatabase").collection("myCollection").insertDocuments(documents);
+
+```
+
+## delete documents
+``` Java
+ Collection keys = new ArrayList<>;
+ keys.add(myObject1.getKey());
+ keys.add(myObject2.getKey());
+ keys.add(myObject3.getKey());
+ arangoDB.db("myDatabase").collection("myCollection").deleteDocuments(keys);
+
+```
+
+## update documents
+``` Java
+ Collection documents = new ArrayList<>;
+ documents.add(myObject1);
+ documents.add(myObject2);
+ documents.add(myObject3);
+ arangoDB.db("myDatabase").collection("myCollection").updateDocuments(documents);
+
+```
+
+## replace documents
+``` Java
+ Collection documents = new ArrayList<>;
+ documents.add(myObject1);
+ documents.add(myObject2);
+ documents.add(myObject3);
+ arangoDB.db("myDatabase").collection("myCollection").replaceDocuments(documents);
+
+```
diff --git a/docs/serialization.md b/docs/serialization.md
new file mode 100644
index 000000000..28705ed41
--- /dev/null
+++ b/docs/serialization.md
@@ -0,0 +1,75 @@
+# serialization / deserialization
+## JavaBeans
+The driver can serialize/deserialize JavaBeans. They need at least a constructor without parameter.
+
+``` Java
+ public class MyObject {
+
+ private String name;
+ private Gender gender;
+ private int age;
+
+ public MyObject() {
+ super();
+ }
+
+ }
+```
+
+## internal fields
+To use Arango-internal fields (like _id, _key, _rev, _from, _to) in your JavaBeans, use the annotation `DocumentField`.
+
+``` Java
+ public class MyObject {
+
+ @DocumentField(Type.KEY)
+ private String key;
+
+ private String name;
+ private Gender gender;
+ private int age;
+
+ public MyObject() {
+ super();
+ }
+
+ }
+```
+
+## serialized fieldnames
+To use a different serialized name for a field, use the annotation `SerializedName`.
+
+``` Java
+ public class MyObject {
+
+ @SerializedName("title")
+ private String name;
+
+ private Gender gender;
+ private int age;
+
+ public MyObject() {
+ super();
+ }
+
+ }
+```
+
+## ignore fields
+To ignore fields at serialization/deserialization, use the annotation `Expose`
+
+``` Java
+ public class MyObject {
+
+ @Expose
+ private String name;
+ @Expose(serialize = true, deserialize = false)
+ private Gender gender;
+ private int age;
+
+ public MyObject() {
+ super();
+ }
+
+ }
+```
diff --git a/docs/setup.md b/docs/setup.md
new file mode 100644
index 000000000..b2252d874
--- /dev/null
+++ b/docs/setup.md
@@ -0,0 +1,46 @@
+# Driver Setup
+
+Setup with default configuration, this automatically loads a properties file arangodb.properties if exists in the classpath:
+
+``` Java
+ // this instance is thread-safe
+ ArangoDB arangoDB = new ArangoDB.Builder().build();
+
+```
+
+
+The driver is configured with some default values:
+
+
+property-key | description | default value |
+arangodb.host | ArangoDB host | 127.0.0.1 |
+arangodb.port | ArangoDB port | 8529 |
+arangodb.timeout | socket connect timeout(millisecond) | 0 |
+arangodb.user | Basic Authentication User | |
+arangodb.password | Basic Authentication Password | |
+arangodb.useSsl | use SSL connection | false |
+harangodb.chunksize | VelocyStream Chunk content-size(bytes) | 30000 |
+
+
+To customize the configuration the parameters can be changed in the code...
+
+``` Java
+ ArangoDB arangoDB = new ArangoDB.Builder().host("192.168.182.50").port(8888).build();
+
+```
+... or with a custom properties file (my.properties)
+
+``` Java
+ InputStream in = MyClass.class.getResourceAsStream("my.properties");
+ ArangoDB arangoDB = new ArangoDB.Builder().loadProperties(in).build();
+
+```
+
+Example for arangodb.properties:
+``` Java
+ arangodb.host=127.0.0.1
+ arangodb.port=8529
+ arangodb.user=root
+ arangodb.password=
+
+```
\ No newline at end of file
diff --git a/docs/user_management.md b/docs/user_management.md
new file mode 100644
index 000000000..96d8a4ddc
--- /dev/null
+++ b/docs/user_management.md
@@ -0,0 +1,31 @@
+#User Management
+If you are using [authentication] (https://docs.arangodb.com/Manual/GettingStarted/Authentication.html) you can manage users with the driver.
+
+##add user
+``` Java
+ //username, password
+ arangoDB.createUser("myUser", "myPassword");
+```
+
+##grant user access to database
+``` Java
+ arangoDB.db("myDatabase").grantAccess("myUser");
+````
+
+##revoke user access to database
+``` Java
+ arangoDB.db("myDatabase").revokeAccess("myUser");
+````
+
+##list users
+``` Java
+ Collection users = arangoDB.getUsers();
+ for(UserResult user : users) {
+ System.out.println(user.getUser())
+ }
+```
+
+##delete user
+``` Java
+ arangoDB.deleteUser("myUser");
+```
diff --git a/pom.xml b/pom.xml
index 1f0a192a6..549d31afd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,8 +4,8 @@
com.arangodb
arangodb-java-driver
- 3.1.0
- 2012
+ 4.0.0
+ 2016
jar
arangodb-java-driver
@@ -20,22 +20,15 @@
+
+ UTF-8
+ 1.7.13
+ 1.1.3
+ 1.3
+ 4.12
+
+
-
- tamtam180
- tamtam180
- http://mt.orz.at/
-
-
- gschwab
- gschwab
- https://github.com/gschwab
-
-
- scottashton
- scottashton
- https://github.com/scottashton
-
a-brandt
a-brandt
@@ -165,9 +158,9 @@
maven-surefire-plugin
2.19.1
- 0
- com/arangodb/ArangoTestSuite.java
+ **/*Test.java
+ **/*Example.java
@@ -200,66 +193,61 @@
-
- UTF-8
- 4.1
- 2.5
- 4.5.1
- 1.7.13
- 1.1.3
- 1.3
- 4.12
-
-
-
- com.google.code.gson
- gson
- ${gson.version}
- compile
-
-
- org.apache.httpcomponents
- httpclient
- ${httpclient.version}
- jar
- compile
-
org.slf4j
slf4j-api
- ${slf4j-api.version}
- jar
- compile
+
+
+ com.googlecode.json-simple
+ json-simple
ch.qos.logback
logback-classic
- ${logback-classic.version}
- jar
- provided
+ test
junit
junit
- ${junit.version}
test
org.hamcrest
hamcrest-all
- ${hamcrest-all.version}
test
-
- org.json
- json
- 20140107
- test
-
-
-
+
+
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j-api.version}
+
+
+ com.googlecode.json-simple
+ json-simple
+ 1.1.1
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback-classic.version}
+
+
+ junit
+ junit
+ ${junit.version}
+
+
+ org.hamcrest
+ hamcrest-all
+ ${hamcrest-all.version}
+
+
+
https://github.com/arangodb/arangodb-java-driver
diff --git a/src/main/java/com/arangodb/ArangoClient.java b/src/main/java/com/arangodb/ArangoClient.java
deleted file mode 100644
index 4735c98e2..000000000
--- a/src/main/java/com/arangodb/ArangoClient.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2012 tamtam180
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.arangodb;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import com.arangodb.entity.ImportResultEntity;
-
-/**
- * @author tamtam180 - kirscheless at gmail.com
- *
- */
-public class ArangoClient {
-
- public static final int DEFAULT_IMPORT_BUFFER_SIZE = 1000;
-
- protected ArangoDriver driver;
-
- public ArangoClient(ArangoConfigure configure) {
- driver = new ArangoDriver(configure);
- }
-
- private void importDocumentsImpl(String collectionName, List values, ImportResultEntity total)
- throws ArangoException {
- ImportResultEntity result = driver.importDocuments(collectionName, values);
- total.setCreated(total.getCreated() + result.getCreated());
- total.setErrors(total.getErrors() + result.getErrors());
- total.setEmpty(total.getEmpty() + result.getEmpty());
- total.setUpdated(total.getUpdated() + result.getUpdated());
- total.setIgnored(total.getIgnored() + result.getIgnored());
- total.getDetails().addAll(result.getDetails());
- }
-
- public ImportResultEntity importRawJsonDocuments(String collectionName, Iterator itr, int bufferCount)
- throws ArangoException {
-
- int tmpBufferCount = bufferCount;
- if (tmpBufferCount <= 0) {
- tmpBufferCount = DEFAULT_IMPORT_BUFFER_SIZE;
- }
-
- ImportResultEntity total = new ImportResultEntity();
-
- ArrayList buffers = new ArrayList(tmpBufferCount);
- while (itr.hasNext()) {
- buffers.add(itr.next());
- if (buffers.size() % tmpBufferCount == 0) {
- importDocumentsImpl(collectionName, buffers, total);
- buffers.clear();
- }
- }
- if (!buffers.isEmpty()) {
- importDocumentsImpl(collectionName, buffers, total);
- }
-
- return total;
-
- }
-
-}
diff --git a/src/main/java/com/arangodb/ArangoCollection.java b/src/main/java/com/arangodb/ArangoCollection.java
new file mode 100644
index 000000000..e7bd5809c
--- /dev/null
+++ b/src/main/java/com/arangodb/ArangoCollection.java
@@ -0,0 +1,700 @@
+/*
+ * DISCLAIMER
+ *
+ * Copyright 2016 ArangoDB GmbH, Cologne, Germany
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright holder is ArangoDB GmbH, Cologne, Germany
+ */
+
+package com.arangodb;
+
+import java.util.Collection;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.arangodb.entity.CollectionEntity;
+import com.arangodb.entity.CollectionPropertiesEntity;
+import com.arangodb.entity.CollectionRevisionEntity;
+import com.arangodb.entity.DocumentCreateEntity;
+import com.arangodb.entity.DocumentDeleteEntity;
+import com.arangodb.entity.DocumentUpdateEntity;
+import com.arangodb.entity.IndexEntity;
+import com.arangodb.entity.MultiDocumentEntity;
+import com.arangodb.internal.InternalArangoCollection;
+import com.arangodb.internal.ArangoExecutorSync;
+import com.arangodb.internal.velocystream.ConnectionSync;
+import com.arangodb.model.CollectionPropertiesOptions;
+import com.arangodb.model.DocumentCreateOptions;
+import com.arangodb.model.DocumentDeleteOptions;
+import com.arangodb.model.DocumentExistsOptions;
+import com.arangodb.model.DocumentReadOptions;
+import com.arangodb.model.DocumentReplaceOptions;
+import com.arangodb.model.DocumentUpdateOptions;
+import com.arangodb.model.FulltextIndexOptions;
+import com.arangodb.model.GeoIndexOptions;
+import com.arangodb.model.HashIndexOptions;
+import com.arangodb.model.PersistentIndexOptions;
+import com.arangodb.model.SkiplistIndexOptions;
+import com.arangodb.velocystream.Response;
+
+/**
+ * @author Mark - mark at arangodb.com
+ *
+ */
+public class ArangoCollection extends InternalArangoCollection {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ArangoCollection.class);
+
+ protected ArangoCollection(final ArangoDatabase db, final String name) {
+ super(db.executor(), db.name(), name);
+ }
+
+ /**
+ * Creates a new document from the given document, unless there is already a document with the _key given. If no
+ * _key is given, a new unique _key is generated automatically.
+ *
+ * @see API
+ * Documentation
+ * @param value
+ * A representation of a single document (POJO, VPackSlice or String for Json)
+ * @return information about the document
+ * @throws ArangoDBException
+ */
+ public DocumentCreateEntity insertDocument(final T value) throws ArangoDBException {
+ return executor.execute(insertDocumentRequest(value, new DocumentCreateOptions()),
+ insertDocumentResponseDeserializer(value));
+ }
+
+ /**
+ * Creates a new document from the given document, unless there is already a document with the _key given. If no
+ * _key is given, a new unique _key is generated automatically.
+ *
+ * @see API
+ * Documentation
+ * @param value
+ * A representation of a single document (POJO, VPackSlice or String for Json)
+ * @param options
+ * Additional options, can be null
+ * @return information about the document
+ * @throws ArangoDBException
+ */
+ public DocumentCreateEntity insertDocument(final T value, final DocumentCreateOptions options)
+ throws ArangoDBException {
+ return executor.execute(insertDocumentRequest(value, options), insertDocumentResponseDeserializer(value));
+ }
+
+ /**
+ * Creates new documents from the given documents, unless there is already a document with the _key given. If no
+ * _key is given, a new unique _key is generated automatically.
+ *
+ * @see API
+ * Documentation
+ * @param values
+ * A List of documents (POJO, VPackSlice or String for Json)
+ * @return information about the documents
+ * @throws ArangoDBException
+ */
+ public MultiDocumentEntity> insertDocuments(final Collection values)
+ throws ArangoDBException {
+ final DocumentCreateOptions params = new DocumentCreateOptions();
+ return executor.execute(insertDocumentsRequest(values, params),
+ insertDocumentsResponseDeserializer(values, params));
+ }
+
+ /**
+ * Creates new documents from the given documents, unless there is already a document with the _key given. If no
+ * _key is given, a new unique _key is generated automatically.
+ *
+ * @see API
+ * Documentation
+ * @param values
+ * A List of documents (POJO, VPackSlice or String for Json)
+ * @param options
+ * Additional options, can be null
+ * @return information about the documents
+ * @throws ArangoDBException
+ */
+ public MultiDocumentEntity> insertDocuments(
+ final Collection values,
+ final DocumentCreateOptions options) throws ArangoDBException {
+ final DocumentCreateOptions params = (options != null ? options : new DocumentCreateOptions());
+ return executor.execute(insertDocumentsRequest(values, params),
+ insertDocumentsResponseDeserializer(values, params));
+ }
+
+ /**
+ * Reads a single document
+ *
+ * @see API
+ * Documentation
+ * @param key
+ * The key of the document
+ * @param type
+ * The type of the document (POJO class, VPackSlice or String for Json)
+ * @return the document identified by the key
+ * @throws ArangoDBException
+ */
+ public T getDocument(final String key, final Class type) {
+ executor.validateDocumentKey(key);
+ try {
+ return executor.execute(getDocumentRequest(key, new DocumentReadOptions()), type);
+ } catch (final ArangoDBException e) {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(e.getMessage(), e);
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Reads a single document
+ *
+ * @see API
+ * Documentation
+ * @param key
+ * The key of the document
+ * @param type
+ * The type of the document (POJO class, VPackSlice or String for Json)
+ * @param options
+ * Additional options, can be null
+ * @return the document identified by the key
+ * @throws ArangoDBException
+ */
+ public T getDocument(final String key, final Class type, final DocumentReadOptions options)
+ throws ArangoDBException {
+ executor.validateDocumentKey(key);
+ try {
+ return executor.execute(getDocumentRequest(key, options), type);
+ } catch (final ArangoDBException e) {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(e.getMessage(), e);
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Replaces the document with key with the one in the body, provided there is such a document and no precondition is
+ * violated
+ *
+ * @see API
+ * Documentation
+ * @param key
+ * The key of the document
+ * @param value
+ * A representation of a single document (POJO, VPackSlice or String for Json)
+ * @return information about the document
+ * @throws ArangoDBException
+ */
+ public DocumentUpdateEntity replaceDocument(final String key, final T value) throws ArangoDBException {
+ return executor.execute(replaceDocumentRequest(key, value, new DocumentReplaceOptions()),
+ replaceDocumentResponseDeserializer(value));
+ }
+
+ /**
+ * Replaces the document with key with the one in the body, provided there is such a document and no precondition is
+ * violated
+ *
+ * @see API
+ * Documentation
+ * @param key
+ * The key of the document
+ * @param value
+ * A representation of a single document (POJO, VPackSlice or String for Json)
+ * @param options
+ * Additional options, can be null
+ * @return information about the document
+ * @throws ArangoDBException
+ */
+ public DocumentUpdateEntity replaceDocument(
+ final String key,
+ final T value,
+ final DocumentReplaceOptions options) throws ArangoDBException {
+ return executor.execute(replaceDocumentRequest(key, value, options),
+ replaceDocumentResponseDeserializer(value));
+ }
+
+ /**
+ * Replaces multiple documents in the specified collection with the ones in the values, the replaced documents are
+ * specified by the _key attributes in the documents in values.
+ *
+ * @see API
+ * Documentation
+ * @param values
+ * A List of documents (POJO, VPackSlice or String for Json)
+ * @return information about the documents
+ * @throws ArangoDBException
+ */
+ public MultiDocumentEntity> replaceDocuments(final Collection values)
+ throws ArangoDBException {
+ final DocumentReplaceOptions params = new DocumentReplaceOptions();
+ return executor.execute(replaceDocumentsRequest(values, params),
+ replaceDocumentsResponseDeserializer(values, params));
+ }
+
+ /**
+ * Replaces multiple documents in the specified collection with the ones in the values, the replaced documents are
+ * specified by the _key attributes in the documents in values.
+ *
+ * @see API
+ * Documentation
+ * @param values
+ * A List of documents (POJO, VPackSlice or String for Json)
+ * @param options
+ * Additional options, can be null
+ * @return information about the documents
+ * @throws ArangoDBException
+ */
+ public MultiDocumentEntity> replaceDocuments(
+ final Collection values,
+ final DocumentReplaceOptions options) throws ArangoDBException {
+ final DocumentReplaceOptions params = (options != null ? options : new DocumentReplaceOptions());
+ return executor.execute(replaceDocumentsRequest(values, params),
+ replaceDocumentsResponseDeserializer(values, params));
+ }
+
+ /**
+ * Partially updates the document identified by document-key. The value must contain a document with the attributes
+ * to patch (the patch document). All attributes from the patch document will be added to the existing document if
+ * they do not yet exist, and overwritten in the existing document if they do exist there.
+ *
+ * @see API
+ * Documentation
+ * @param key
+ * The key of the document
+ * @param value
+ * A representation of a single document (POJO, VPackSlice or String for Json)
+ * @return information about the document
+ * @throws ArangoDBException
+ */
+ public DocumentUpdateEntity updateDocument(final String key, final T value) throws ArangoDBException {
+ return executor.execute(updateDocumentRequest(key, value, new DocumentUpdateOptions()),
+ updateDocumentResponseDeserializer(value));
+ }
+
+ /**
+ * Partially updates the document identified by document-key. The value must contain a document with the attributes
+ * to patch (the patch document). All attributes from the patch document will be added to the existing document if
+ * they do not yet exist, and overwritten in the existing document if they do exist there.
+ *
+ * @see API
+ * Documentation
+ * @param key
+ * The key of the document
+ * @param value
+ * A representation of a single document (POJO, VPackSlice or String for Json)
+ * @param options
+ * Additional options, can be null
+ * @return information about the document
+ * @throws ArangoDBException
+ */
+ public DocumentUpdateEntity updateDocument(
+ final String key,
+ final T value,
+ final DocumentUpdateOptions options) throws ArangoDBException {
+ return executor.execute(updateDocumentRequest(key, value, options), updateDocumentResponseDeserializer(value));
+ }
+
+ /**
+ * Partially updates documents, the documents to update are specified by the _key attributes in the objects on
+ * values. Vales must contain a list of document updates with the attributes to patch (the patch documents). All
+ * attributes from the patch documents will be added to the existing documents if they do not yet exist, and
+ * overwritten in the existing documents if they do exist there.
+ *
+ * @see API
+ * Documentation
+ * @param values
+ * A list of documents (POJO, VPackSlice or String for Json)
+ * @return information about the documents
+ * @throws ArangoDBException
+ */
+ public MultiDocumentEntity> updateDocuments(final Collection values)
+ throws ArangoDBException {
+ final DocumentUpdateOptions params = new DocumentUpdateOptions();
+ return executor.execute(updateDocumentsRequest(values, params),
+ updateDocumentsResponseDeserializer(values, params));
+ }
+
+ /**
+ * Partially updates documents, the documents to update are specified by the _key attributes in the objects on
+ * values. Vales must contain a list of document updates with the attributes to patch (the patch documents). All
+ * attributes from the patch documents will be added to the existing documents if they do not yet exist, and
+ * overwritten in the existing documents if they do exist there.
+ *
+ * @see API
+ * Documentation
+ * @param values
+ * A list of documents (POJO, VPackSlice or String for Json)
+ * @param options
+ * Additional options, can be null
+ * @return information about the documents
+ * @throws ArangoDBException
+ */
+ public MultiDocumentEntity> updateDocuments(
+ final Collection values,
+ final DocumentUpdateOptions options) throws ArangoDBException {
+ final DocumentUpdateOptions params = (options != null ? options : new DocumentUpdateOptions());
+ return executor.execute(updateDocumentsRequest(values, params),
+ updateDocumentsResponseDeserializer(values, params));
+ }
+
+ /**
+ * Removes a document
+ *
+ * @see API
+ * Documentation
+ * @param key
+ * The key of the document
+ * @param type
+ * The type of the document (POJO class, VPackSlice or String for Json). Only necessary if
+ * options.returnOld is set to true, otherwise can be null.
+ * @param options
+ * Additional options, can be null
+ * @return information about the document
+ * @throws ArangoDBException
+ */
+ public DocumentDeleteEntity deleteDocument(final String key) throws ArangoDBException {
+ return executor.execute(deleteDocumentRequest(key, new DocumentDeleteOptions()),
+ deleteDocumentResponseDeserializer(Void.class));
+ }
+
+ /**
+ * Removes a document
+ *
+ * @see API
+ * Documentation
+ * @param key
+ * The key of the document
+ * @param type
+ * The type of the document (POJO class, VPackSlice or String for Json). Only necessary if
+ * options.returnOld is set to true, otherwise can be null.
+ * @param options
+ * Additional options, can be null
+ * @return information about the document
+ * @throws ArangoDBException
+ */
+ public DocumentDeleteEntity deleteDocument(
+ final String key,
+ final Class type,
+ final DocumentDeleteOptions options) throws ArangoDBException {
+ return executor.execute(deleteDocumentRequest(key, options), deleteDocumentResponseDeserializer(type));
+ }
+
+ /**
+ * Removes multiple document
+ *
+ * @see API
+ * Documentation
+ * @param keys
+ * The keys of the documents
+ * @param type
+ * The type of the documents (POJO class, VPackSlice or String for Json). Only necessary if
+ * options.returnOld is set to true, otherwise can be null.
+ * @return information about the documents
+ * @throws ArangoDBException
+ */
+ public MultiDocumentEntity> deleteDocuments(final Collection keys)
+ throws ArangoDBException {
+ return executor.execute(deleteDocumentsRequest(keys, new DocumentDeleteOptions()),
+ deleteDocumentsResponseDeserializer(Void.class));
+ }
+
+ /**
+ * Removes multiple document
+ *
+ * @see API
+ * Documentation
+ * @param keys
+ * The keys of the documents
+ * @param type
+ * The type of the documents (POJO class, VPackSlice or String for Json). Only necessary if
+ * options.returnOld is set to true, otherwise can be null.
+ * @param options
+ * Additional options, can be null
+ * @return information about the documents
+ * @throws ArangoDBException
+ */
+ public MultiDocumentEntity> deleteDocuments(
+ final Collection keys,
+ final Class type,
+ final DocumentDeleteOptions options) throws ArangoDBException {
+ return executor.execute(deleteDocumentsRequest(keys, options), deleteDocumentsResponseDeserializer(type));
+ }
+
+ /**
+ * Checks if the document exists by reading a single document head
+ *
+ * @see API
+ * Documentation
+ * @param key
+ * The key of the document
+ * @return true if the document was found, otherwise false
+ */
+ public Boolean documentExists(final String key) {
+ return documentExists(key, new DocumentExistsOptions());
+ }
+
+ /**
+ * Checks if the document exists by reading a single document head
+ *
+ * @see API
+ * Documentation
+ * @param key
+ * The key of the document
+ * @param options
+ * Additional options, can be null
+ * @return true if the document was found, otherwise false
+ */
+ public Boolean documentExists(final String key, final DocumentExistsOptions options) {
+ try {
+ executor.communication().execute(documentExistsRequest(key, options));
+ return true;
+ } catch (final ArangoDBException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Creates a hash index for the collection if it does not already exist.
+ *
+ * @see API Documentation
+ * @param fields
+ * A list of attribute paths
+ * @param options
+ * Additional options, can be null
+ * @return information about the index
+ * @throws ArangoDBException
+ */
+ public IndexEntity createHashIndex(final Collection fields, final HashIndexOptions options)
+ throws ArangoDBException {
+ return executor.execute(createHashIndexRequest(fields, options), IndexEntity.class);
+ }
+
+ /**
+ * Creates a skip-list index for the collection, if it does not already exist.
+ *
+ * @see API
+ * Documentation
+ * @param fields
+ * A list of attribute paths
+ * @param options
+ * Additional options, can be null
+ * @return information about the index
+ * @throws ArangoDBException
+ */
+ public IndexEntity createSkiplistIndex(final Collection fields, final SkiplistIndexOptions options)
+ throws ArangoDBException {
+ return executor.execute(createSkiplistIndexRequest(fields, options), IndexEntity.class);
+ }
+
+ /**
+ * Creates a persistent index for the collection, if it does not already exist.
+ *
+ * @see API
+ * Documentation
+ * @param fields
+ * A list of attribute paths
+ * @param options
+ * Additional options, can be null
+ * @return information about the index
+ * @throws ArangoDBException
+ */
+ public IndexEntity createPersistentIndex(final Collection fields, final PersistentIndexOptions options)
+ throws ArangoDBException {
+ return executor.execute(createPersistentIndexRequest(fields, options), IndexEntity.class);
+ }
+
+ /**
+ * Creates a geo-spatial index for the collection, if it does not already exist.
+ *
+ * @see API
+ * Documentation
+ * @param fields
+ * A list of attribute paths
+ * @param options
+ * Additional options, can be null
+ * @return information about the index
+ * @throws ArangoDBException
+ */
+ public IndexEntity createGeoIndex(final Collection fields, final GeoIndexOptions options)
+ throws ArangoDBException {
+ return executor.execute(createGeoIndexRequest(fields, options), IndexEntity.class);
+ }
+
+ /**
+ * Creates a fulltext index for the collection, if it does not already exist.
+ *
+ * @see API
+ * Documentation
+ * @param fields
+ * A list of attribute paths
+ * @param options
+ * Additional options, can be null
+ * @return information about the index
+ * @throws ArangoDBException
+ */
+ public IndexEntity createFulltextIndex(final Collection fields, final FulltextIndexOptions options)
+ throws ArangoDBException {
+ return executor.execute(createFulltextIndexRequest(fields, options), IndexEntity.class);
+ }
+
+ /**
+ * Returns all indexes of the collection
+ *
+ * @see API
+ * Documentation
+ * @return information about the indexes
+ * @throws ArangoDBException
+ */
+ public Collection getIndexes() throws ArangoDBException {
+ return executor.execute(getIndexesRequest(), getIndexesResponseDeserializer());
+ }
+
+ /**
+ * Removes all documents from the collection, but leaves the indexes intact
+ *
+ * @see API
+ * Documentation
+ * @return information about the collection
+ * @throws ArangoDBException
+ */
+ public CollectionEntity truncate() throws ArangoDBException {
+ return executor.execute(truncateRequest(), CollectionEntity.class);
+ }
+
+ /**
+ * Counts the documents in a collection
+ *
+ * @see API
+ * Documentation
+ * @return information about the collection, including the number of documents
+ * @throws ArangoDBException
+ */
+ public CollectionPropertiesEntity count() throws ArangoDBException {
+ return executor.execute(countRequest(), CollectionPropertiesEntity.class);
+ }
+
+ /**
+ * Drops the collection
+ *
+ * @see API
+ * Documentation
+ * @throws ArangoDBException
+ */
+ public void drop() throws ArangoDBException {
+ executor.execute(dropRequest(), Void.class);
+ }
+
+ /**
+ * Loads a collection into memory.
+ *
+ * @see API
+ * Documentation
+ * @return information about the collection
+ * @throws ArangoDBException
+ */
+ public CollectionEntity load() throws ArangoDBException {
+ return executor.execute(loadRequest(), CollectionEntity.class);
+ }
+
+ /**
+ * Removes a collection from memory. This call does not delete any documents. You can use the collection afterwards;
+ * in which case it will be loaded into memory, again.
+ *
+ * @see API
+ * Documentation
+ * @return information about the collection
+ * @throws ArangoDBException
+ */
+ public CollectionEntity unload() throws ArangoDBException {
+ return executor.execute(unloadRequest(), CollectionEntity.class);
+ }
+
+ /**
+ * Returns information about the collection
+ *
+ * @see API
+ * Documentation
+ * @return information about the collection
+ * @throws ArangoDBException
+ */
+ public CollectionEntity getInfo() throws ArangoDBException {
+ return executor.execute(getInfoRequest(), CollectionEntity.class);
+ }
+
+ /**
+ * Reads the properties of the specified collection
+ *
+ * @see API
+ * Documentation
+ * @return properties of the collection
+ * @throws ArangoDBException
+ */
+ public CollectionPropertiesEntity getProperties() throws ArangoDBException {
+ return executor.execute(getPropertiesRequest(), CollectionPropertiesEntity.class);
+ }
+
+ /**
+ * Changes the properties of a collection
+ *
+ * @see API
+ * Documentation
+ * @param options
+ * Additional options, can be null
+ * @return properties of the collection
+ * @throws ArangoDBException
+ */
+ public CollectionPropertiesEntity changeProperties(final CollectionPropertiesOptions options)
+ throws ArangoDBException {
+ return executor.execute(changePropertiesRequest(options), CollectionPropertiesEntity.class);
+ }
+
+ /**
+ * Renames a collection
+ *
+ * @see API
+ * Documentation
+ * @param newName
+ * The new name
+ * @return information about the collection
+ * @throws ArangoDBException
+ */
+ public CollectionEntity rename(final String newName) throws ArangoDBException {
+ return executor.execute(renameRequest(newName), CollectionEntity.class);
+ }
+
+ /**
+ * Retrieve the collections revision
+ *
+ * @see API
+ * Documentation
+ * @return information about the collection, including the collections revision
+ * @throws ArangoDBException
+ */
+ public CollectionRevisionEntity getRevision() throws ArangoDBException {
+ return executor.execute(getRevisionRequest(), CollectionRevisionEntity.class);
+ }
+
+}
diff --git a/src/main/java/com/arangodb/ArangoConfigure.java b/src/main/java/com/arangodb/ArangoConfigure.java
deleted file mode 100644
index e96ca73e3..000000000
--- a/src/main/java/com/arangodb/ArangoConfigure.java
+++ /dev/null
@@ -1,546 +0,0 @@
-/*
- * Copyright (C) 2012 tamtam180
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.arangodb;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import javax.net.ssl.SSLContext;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.arangodb.http.BatchHttpManager;
-import com.arangodb.util.IOUtils;
-
-/**
- * Configure of ArangoDB.
- *
- * @author tamtam180 - kirscheless at gmail.com
- * @author a-brandt
- *
- */
-public class ArangoConfigure {
-
- private static Logger logger = LoggerFactory.getLogger(ArangoConfigure.class);
-
- /** default host of ArangoDB */
- private static final String DEFAULT_HOST = "127.0.0.1";
- /** default port of ArangoDB */
- private static final int DEFAULT_PORT = 8529;
-
- /** default */
- private static final int DEFAULT_MAX_PER_CONNECTION = 20;
- /** default maximum conections */
- private static final int DEFAULT_MAX_CONNECTION = 20;
-
- /** default property file */
- private static final String DEFAULT_PROPERTY_FILE = "/arangodb.properties";
-
- private List arangoHosts;
- private int currentArangoHost;
-
- /** connection timeout(ms) */
- private int connectionTimeout = -1;
- /** socket read timeout(ms) */
- private int timeout = -1;
-
- /** max connection per configure */
- private int maxTotalConnection;
- /** max connection per host */
- private int maxPerConnection;
-
- /** Basic auth user */
- private String user;
- /** Basic auth password */
- private String password;
-
- /** proxy-host */
- private String proxyHost;
- /** proxy-port */
- private int proxyPort;
-
- /** http retry count */
- private int retryCount = 3;
-
- /**
- * number of connect retries (0 means infinite)
- */
- private int connectRetryCount = 3;
-
- /**
- * milliseconds
- */
- private int connectRetryWait = 1000;
-
- /** Default Database */
- String defaultDatabase;
-
- private boolean enableCURLLogger = false;
-
- private int validateAfterInactivity = -1;
-
- private boolean useSsl = false;
-
- private SSLContext sslContext = null;
-
- /**
- * the default ArangoDB cursor batch size
- */
- private int batchSize = 20;
-
- BatchHttpManager httpManager;
-
- public ArangoConfigure() {
- init(DEFAULT_PROPERTY_FILE);
- }
-
- public ArangoConfigure(final String propertyPath) {
- init(propertyPath);
- }
-
- private void init(final String propertyPath) {
- arangoHosts = new ArrayList();
- final ArangoHost defaultHost = new ArangoHost(DEFAULT_HOST, DEFAULT_PORT);
- arangoHosts.add(defaultHost);
- currentArangoHost = 0;
-
- this.maxPerConnection = DEFAULT_MAX_PER_CONNECTION;
- this.maxTotalConnection = DEFAULT_MAX_CONNECTION;
- loadProperties(propertyPath);
- }
-
- /**
- * Load configure from arangodb.properties in classpath, if exists.
- */
- public void loadProperties() {
- loadProperties(DEFAULT_PROPERTY_FILE);
- }
-
- /**
- * Load configure from "propertyPath" in classpath, if exists.
- *
- * @param propertyPath
- */
- public void loadProperties(final String propertyPath) {
- InputStream in = null;
- try {
- in = getClass().getResourceAsStream(propertyPath);
- if (in != null) {
- logger.debug("load property: file={}", propertyPath);
-
- loadProperties(in);
- }
- } catch (final IOException e) {
- logger.warn("load property error", e);
- } finally {
- if (in != null) {
- IOUtils.close(in);
- }
- }
- }
-
- private void loadProperties(final InputStream in) throws IOException {
-
- final Properties prop = new Properties();
- prop.load(in);
-
- //
- final String port = prop.getProperty("port");
- if (port != null) {
- arangoHosts.get(0).setPort(Integer.parseInt(port));
- }
-
- final String host = prop.getProperty("host");
- if (host != null) {
- arangoHosts.get(0).setHost(host);
- }
-
- final String arangoHost = prop.getProperty("arangoHost");
- if (arangoHost != null) {
- final ArangoHost ah = parseArangoHost(arangoHost);
- if (ah != null) {
- arangoHosts.get(0).setHost(ah.getHost());
- arangoHosts.get(0).setPort(ah.getPort());
- }
- }
-
- final String fallbackArangoHost = prop.getProperty("fallbackArangoHost");
- if (fallbackArangoHost != null) {
- final ArangoHost ah = parseArangoHost(fallbackArangoHost);
- if (ah != null) {
- addFallbackArangoHost(ah);
- }
- }
-
- final String timeoutProperty = prop.getProperty("timeout");
- if (timeoutProperty != null) {
- setTimeout(Integer.parseInt(timeoutProperty));
- }
-
- final String connectionTimeoutProperty = prop.getProperty("connectionTimeout");
- if (connectionTimeoutProperty != null) {
- setConnectionTimeout(Integer.parseInt(connectionTimeoutProperty));
- }
-
- final String proxyHostProperty = prop.getProperty("proxy.host");
- if (proxyHostProperty != null) {
- setProxyHost(proxyHostProperty);
- }
-
- final String proxyPortProperty = prop.getProperty("proxy.port");
- if (proxyPortProperty != null) {
- setProxyPort(Integer.parseInt(proxyPortProperty));
- }
-
- final String maxPerConnectionProperty = prop.getProperty("maxPerConnection");
- if (maxPerConnectionProperty != null) {
- setMaxPerConnection(Integer.parseInt(maxPerConnectionProperty));
- }
-
- final String maxTotalConnectionProperty = prop.getProperty("maxTotalConnection");
- if (maxTotalConnectionProperty != null) {
- setMaxTotalConnection(Integer.parseInt(maxTotalConnectionProperty));
- }
-
- final String retryCountProperty = prop.getProperty("retryCount");
- if (retryCountProperty != null) {
- setRetryCount(Integer.parseInt(retryCountProperty));
- }
-
- final String connnectRetryCount = prop.getProperty("connnectRetryCount");
- if (connnectRetryCount != null) {
- setConnectRetryCount(Integer.parseInt(connnectRetryCount));
- }
-
- final String connectRetryWaitProperty = prop.getProperty("connectRetryWait");
- if (connectRetryWaitProperty != null) {
- setConnectRetryWait(Integer.parseInt(connectRetryWaitProperty));
- }
-
- final String userProperty = prop.getProperty("user");
- if (userProperty != null) {
- setUser(userProperty);
- }
-
- final String passwordProperty = prop.getProperty("password");
- if (passwordProperty != null) {
- setPassword(passwordProperty);
- }
-
- final String defaultDatabaseProperty = prop.getProperty("defaultDatabase");
- if (defaultDatabaseProperty != null) {
- setDefaultDatabase(defaultDatabaseProperty);
- }
-
- final String enableCURLLoggerProperty = prop.getProperty("enableCURLLogger");
- if (enableCURLLoggerProperty != null) {
- setEnableCURLLogger(Boolean.parseBoolean(enableCURLLoggerProperty));
- }
-
- final String validateAfterInactivityProperty = prop.getProperty("validateAfterInactivity");
- if (validateAfterInactivityProperty != null) {
- setValidateAfterInactivity(Integer.parseInt(validateAfterInactivityProperty));
- }
-
- final String batchSizeProperty = prop.getProperty("batchSize");
- if (batchSizeProperty != null) {
- setBatchSize(Integer.parseInt(batchSizeProperty));
- }
-
- final String useSslProperty = prop.getProperty("useSsl");
- if (useSslProperty != null) {
- setUseSsl(Boolean.parseBoolean(useSslProperty));
- }
- }
-
- private ArangoHost parseArangoHost(final String str) {
- if (str == null) {
- return null;
- }
-
- final String[] split = str.split(":", 2);
- if (split.length != 2) {
- return null;
- }
-
- return new ArangoHost(split[0], Integer.parseInt(split[1]));
- }
-
- public void init() {
- this.httpManager = new BatchHttpManager(this);
- this.httpManager.init();
- }
-
- public void shutdown() {
- if (httpManager != null) {
- httpManager.destroy();
- httpManager = null;
- }
- }
-
- public String getBaseUrl() {
- final ArangoHost currentHost = getCurrentHost();
-
- return (useSsl ? "https://" : "http://") + currentHost.getHost() + ":" + currentHost.getPort();
- }
-
- public String getEndpoint() {
- final ArangoHost currentHost = getCurrentHost();
-
- return (useSsl ? "ssl://" : "tcp://") + currentHost.getHost() + ":" + currentHost.getPort();
- }
-
- private ArangoHost getCurrentHost() {
- return arangoHosts.get(currentArangoHost);
- }
-
- public boolean hasFallbackHost() {
- return arangoHosts.size() > 1;
- }
-
- public ArangoHost changeCurrentHost() {
- currentArangoHost++;
-
- if (currentArangoHost >= arangoHosts.size()) {
- currentArangoHost = 0;
- }
-
- return getCurrentHost();
- }
-
- public static String getDefaultHost() {
- return DEFAULT_HOST;
- }
-
- public static int getDefaultMaxPerConnection() {
- return DEFAULT_MAX_PER_CONNECTION;
- }
-
- public static int getDefaultMaxConnection() {
- return DEFAULT_MAX_CONNECTION;
- }
-
- /**
- * Get the default database host name and port
- *
- * @return the host name and port
- */
- public ArangoHost getArangoHost() {
- return arangoHosts.get(0);
- }
-
- public int getConnectionTimeout() {
- return connectionTimeout;
- }
-
- public int getTimeout() {
- return timeout;
- }
-
- public int getMaxTotalConnection() {
- return maxTotalConnection;
- }
-
- public int getMaxPerConnection() {
- return maxPerConnection;
- }
-
- public String getProxyHost() {
- return proxyHost;
- }
-
- public int getProxyPort() {
- return proxyPort;
- }
-
- /**
- * Set the host name and port of the database
- *
- * @param arangoHost
- * the host name and port
- */
- public void setArangoHost(final ArangoHost arangoHost) {
- final ArangoHost host = arangoHosts.get(0);
- host.setHost(arangoHost.getHost());
- host.setPort(arangoHost.getPort());
- }
-
- /**
- * Set the host name and port of the fallback database
- *
- * @param arangoHost
- * the host name and port
- */
- public void addFallbackArangoHost(final ArangoHost arangoHost) {
- arangoHosts.add(arangoHost);
- }
-
- public void setConnectionTimeout(final int connectionTimeout) {
- this.connectionTimeout = connectionTimeout;
- }
-
- public void setTimeout(final int timeout) {
- this.timeout = timeout;
- }
-
- public void setMaxTotalConnection(final int maxTotalConnection) {
- this.maxTotalConnection = maxTotalConnection;
- }
-
- public void setMaxPerConnection(final int maxPerConnection) {
- this.maxPerConnection = maxPerConnection;
- }
-
- public void setProxyHost(final String proxyHost) {
- this.proxyHost = proxyHost;
- }
-
- public void setProxyPort(final int proxyPort) {
- this.proxyPort = proxyPort;
- }
-
- public int getRetryCount() {
- return retryCount;
- }
-
- public void setRetryCount(final int retryCount) {
- this.retryCount = retryCount;
- }
-
- public BatchHttpManager getHttpManager() {
- return httpManager;
- }
-
- public void setHttpManager(final BatchHttpManager httpManager) {
- this.httpManager = httpManager;
- }
-
- public String getUser() {
- return user;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setUser(final String user) {
- this.user = user;
- }
-
- public void setPassword(final String password) {
- this.password = password;
- }
-
- public String getDefaultDatabase() {
- return defaultDatabase;
- }
-
- /**
- * Set the default database for the driver TODO: _system has to be a valid parameter
- *
- * @param defaultDatabase
- */
- public void setDefaultDatabase(final String defaultDatabase) {
- this.defaultDatabase = defaultDatabase;
- }
-
- public boolean isEnableCURLLogger() {
- return enableCURLLogger;
- }
-
- public void setEnableCURLLogger(final boolean enableCURLLogger) {
- this.enableCURLLogger = enableCURLLogger;
- }
-
- public int getValidateAfterInactivity() {
- return validateAfterInactivity;
- }
-
- public void setValidateAfterInactivity(final int validateAfterInactivity) {
- this.validateAfterInactivity = validateAfterInactivity;
- }
-
- public int getConnectRetryCount() {
- return connectRetryCount;
- }
-
- /**
- * Set number of connect retries (0 means infinite)
- *
- * @param connectRetryCount
- * number of connect retries
- */
- public void setConnectRetryCount(final int connectRetryCount) {
- this.connectRetryCount = connectRetryCount;
- }
-
- public int getConnectRetryWait() {
- return connectRetryWait;
- }
-
- /**
- * Set wait time for a connect retry
- *
- * @param connectRetryWait
- * milliseconds to wait
- */
- public void setConnectRetryWait(final int connectRetryWait) {
- this.connectRetryWait = connectRetryWait;
- }
-
- public int getBatchSize() {
- return batchSize;
- }
-
- public void setBatchSize(final int batchSize) {
- this.batchSize = batchSize;
- }
-
- public boolean getUseSsl() {
- return useSsl;
- }
-
- /**
- * Configure the client to use HTTPS or HTTP
- *
- * @param useSsl
- * set true to use HTTPS (default false)
- */
- public void setUseSsl(final boolean useSsl) {
- this.useSsl = useSsl;
- }
-
- public SSLContext getSslContext() {
- return sslContext;
- }
-
- /**
- * Set SSL contest for HTTPS connections.
- *
- * (do not use setSslTrustStore() together with setSslContext())
- *
- * @param sslContext
- */
- public void setSslContext(final SSLContext sslContext) {
- this.sslContext = sslContext;
- }
-
-}
diff --git a/src/main/java/com/arangodb/ArangoCursor.java b/src/main/java/com/arangodb/ArangoCursor.java
new file mode 100644
index 000000000..bda830f0a
--- /dev/null
+++ b/src/main/java/com/arangodb/ArangoCursor.java
@@ -0,0 +1,126 @@
+/*
+ * DISCLAIMER
+ *
+ * Copyright 2016 ArangoDB GmbH, Cologne, Germany
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright holder is ArangoDB GmbH, Cologne, Germany
+ */
+
+package com.arangodb;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import com.arangodb.entity.CursorEntity;
+import com.arangodb.entity.CursorEntity.Extras;
+import com.arangodb.entity.CursorEntity.Stats;
+import com.arangodb.entity.CursorEntity.Warning;
+import com.arangodb.internal.ArangoCursorExecute;
+import com.arangodb.internal.ArangoCursorIterator;
+import com.arangodb.internal.InternalArangoDatabase;
+
+/**
+ * @author Mark - mark at arangodb.com
+ *
+ */
+public class ArangoCursor implements Iterator, Closeable {
+
+ private final Class type;
+ protected final ArangoCursorIterator iterator;
+ private final String id;
+ private final Integer count;
+ private final Extras extra;
+ private final boolean cached;
+ private final ArangoCursorExecute execute;
+
+ public ArangoCursor(final InternalArangoDatabase, ?, ?> db, final ArangoCursorExecute execute,
+ final Class type, final CursorEntity result) {
+ super();
+ this.execute = execute;
+ this.type = type;
+ count = result.getCount();
+ extra = result.getExtra();
+ cached = result.getCached().booleanValue();
+ iterator = new ArangoCursorIterator(this, execute, db, result);
+ id = result.getId();
+ }
+
+ /**
+ * @return id of temporary cursor created on the server
+ */
+ public String getId() {
+ return id;
+ }
+
+ public Class getType() {
+ return type;
+ }
+
+ /**
+ * @return the total number of result documents available (only available if the query was executed with the count
+ * attribute set)
+ */
+ public Integer getCount() {
+ return count;
+ }
+
+ public Stats getStats() {
+ return extra != null ? extra.getStats() : null;
+ }
+
+ public Collection getWarnings() {
+ return extra != null ? extra.getWarnings() : null;
+ }
+
+ /**
+ * @return indicating whether the query result was served from the query cache or not
+ */
+ public boolean isCached() {
+ return cached;
+ }
+
+ @Override
+ public void close() throws IOException {
+ execute.close(id);
+ }
+
+ @Override
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ @Override
+ public T next() {
+ return iterator.next();
+ }
+
+ public List asListRemaining() {
+ final List remaining = new ArrayList();
+ while (hasNext()) {
+ remaining.add(next());
+ }
+ return remaining;
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/main/java/com/arangodb/ArangoDB.java b/src/main/java/com/arangodb/ArangoDB.java
new file mode 100644
index 000000000..48ef297a7
--- /dev/null
+++ b/src/main/java/com/arangodb/ArangoDB.java
@@ -0,0 +1,418 @@
+/*
+ * DISCLAIMER
+ *
+ * Copyright 2016 ArangoDB GmbH, Cologne, Germany
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright holder is ArangoDB GmbH, Cologne, Germany
+ */
+
+package com.arangodb;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Properties;
+
+import javax.net.ssl.SSLContext;
+
+import com.arangodb.entity.ArangoDBVersion;
+import com.arangodb.entity.LogEntity;
+import com.arangodb.entity.UserEntity;
+import com.arangodb.internal.ArangoDBConstants;
+import com.arangodb.internal.ArangoExecutor.ResponseDeserializer;
+import com.arangodb.internal.ArangoExecutorSync;
+import com.arangodb.internal.CollectionCache;
+import com.arangodb.internal.CollectionCache.DBAccess;
+import com.arangodb.internal.DocumentCache;
+import com.arangodb.internal.InternalArangoDB;
+import com.arangodb.internal.velocypack.VPackConfigure;
+import com.arangodb.internal.velocystream.Communication;
+import com.arangodb.internal.velocystream.CommunicationSync;
+import com.arangodb.internal.velocystream.ConnectionSync;
+import com.arangodb.model.LogOptions;
+import com.arangodb.model.UserCreateOptions;
+import com.arangodb.model.UserUpdateOptions;
+import com.arangodb.velocypack.VPack;
+import com.arangodb.velocypack.VPackDeserializer;
+import com.arangodb.velocypack.VPackInstanceCreator;
+import com.arangodb.velocypack.VPackParser;
+import com.arangodb.velocypack.VPackSerializer;
+import com.arangodb.velocypack.exception.VPackException;
+import com.arangodb.velocystream.Request;
+import com.arangodb.velocystream.Response;
+
+/**
+ * @author Mark - mark at arangodb.com
+ *
+ */
+public class ArangoDB extends InternalArangoDB {
+
+ public static class Builder {
+
+ private static final String PROPERTY_KEY_HOST = "arangodb.host";
+ private static final String PROPERTY_KEY_PORT = "arangodb.port";
+ private static final String PROPERTY_KEY_TIMEOUT = "arangodb.timeout";
+ private static final String PROPERTY_KEY_USER = "arangodb.user";
+ private static final String PROPERTY_KEY_PASSWORD = "arangodb.password";
+ private static final String PROPERTY_KEY_USE_SSL = "arangodb.usessl";
+ private static final String PROPERTY_KEY_V_STREAM_CHUNK_CONTENT_SIZE = "arangodb.chunksize";
+ private static final String DEFAULT_PROPERTY_FILE = "/arangodb.properties";
+
+ private String host;
+ private Integer port;
+ private Integer timeout;
+ private String user;
+ private String password;
+ private Boolean useSsl;
+ private SSLContext sslContext;
+ private Integer chunksize;
+ private final VPack.Builder vpackBuilder;
+ private final CollectionCache collectionCache;
+ private final VPackParser vpackParser;
+
+ public Builder() {
+ super();
+ vpackBuilder = new VPack.Builder();
+ collectionCache = new CollectionCache();
+ vpackParser = new VPackParser();
+ VPackConfigure.configure(vpackBuilder, vpackParser, collectionCache);
+ loadProperties(ArangoDB.class.getResourceAsStream(DEFAULT_PROPERTY_FILE));
+ }
+
+ public Builder loadProperties(final InputStream in) {
+ if (in != null) {
+ final Properties properties = new Properties();
+ try {
+ properties.load(in);
+ host = getProperty(properties, PROPERTY_KEY_HOST, host, ArangoDBConstants.DEFAULT_HOST);
+ port = Integer
+ .parseInt(getProperty(properties, PROPERTY_KEY_PORT, port, ArangoDBConstants.DEFAULT_PORT));
+ timeout = Integer.parseInt(
+ getProperty(properties, PROPERTY_KEY_TIMEOUT, timeout, ArangoDBConstants.DEFAULT_TIMEOUT));
+ user = getProperty(properties, PROPERTY_KEY_USER, user, null);
+ password = getProperty(properties, PROPERTY_KEY_PASSWORD, password, null);
+ useSsl = Boolean.parseBoolean(
+ getProperty(properties, PROPERTY_KEY_USE_SSL, useSsl, ArangoDBConstants.DEFAULT_USE_SSL));
+ chunksize = Integer.parseInt(getProperty(properties, PROPERTY_KEY_V_STREAM_CHUNK_CONTENT_SIZE,
+ chunksize, ArangoDBConstants.CHUNK_DEFAULT_CONTENT_SIZE));
+ } catch (final IOException e) {
+ throw new ArangoDBException(e);
+ }
+ }
+ return this;
+ }
+
+ private String getProperty(
+ final Properties properties,
+ final String key,
+ final T currentValue,
+ final T defaultValue) {
+ return properties.getProperty(key,
+ currentValue != null ? currentValue.toString() : defaultValue != null ? defaultValue.toString() : null);
+ }
+
+ public Builder host(final String host) {
+ this.host = host;
+ return this;
+ }
+
+ public Builder port(final Integer port) {
+ this.port = port;
+ return this;
+ }
+
+ public Builder timeout(final Integer timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+
+ public Builder user(final String user) {
+ this.user = user;
+ return this;
+ }
+
+ public Builder password(final String password) {
+ this.password = password;
+ return this;
+ }
+
+ public Builder useSsl(final Boolean useSsl) {
+ this.useSsl = useSsl;
+ return this;
+ }
+
+ public Builder sslContext(final SSLContext sslContext) {
+ this.sslContext = sslContext;
+ return this;
+ }
+
+ public Builder chunksize(final Integer chunksize) {
+ this.chunksize = chunksize;
+ return this;
+ }
+
+ public Builder registerSerializer(final Class clazz, final VPackSerializer serializer) {
+ vpackBuilder.registerSerializer(clazz, serializer);
+ return this;
+ }
+
+ public Builder registerDeserializer(final Class clazz, final VPackDeserializer deserializer) {
+ vpackBuilder.registerDeserializer(clazz, deserializer);
+ return this;
+ }
+
+ public Builder regitserInstanceCreator(final Class clazz, final VPackInstanceCreator creator) {
+ vpackBuilder.regitserInstanceCreator(clazz, creator);
+ return this;
+ }
+
+ public ArangoDB build() {
+ return new ArangoDB(
+ new CommunicationSync.Builder().host(host).port(port).timeout(timeout).user(user).password(password)
+ .useSsl(useSsl).sslContext(sslContext).chunksize(chunksize),
+ vpackBuilder.build(), vpackBuilder.serializeNullValues(true).build(), vpackParser, collectionCache);
+ }
+
+ }
+
+ public ArangoDB(final CommunicationSync.Builder commBuilder, final VPack vpack, final VPack vpackNull,
+ final VPackParser vpackParser, final CollectionCache collectionCache) {
+ super(new ArangoExecutorSync(commBuilder.build(vpack, collectionCache), vpack, vpackNull, vpackParser,
+ new DocumentCache(), collectionCache));
+ final Communication cacheCom = commBuilder.build(vpack, collectionCache);
+ collectionCache.init(new DBAccess() {
+ @Override
+ public ArangoDatabase db(final String name) {
+ return new ArangoDatabase(cacheCom, vpackNull, vpack, vpackParser, executor.documentCache(), null,
+ name);
+ }
+ });
+ }
+
+ protected ArangoExecutorSync executor() {
+ return executor;
+ }
+
+ public void shutdown() {
+ executor.communication().disconnect();
+ }
+
+ /**
+ * Returns a handler of the system database
+ *
+ * @return database handler
+ */
+ public ArangoDatabase db() {
+ return db(ArangoDBConstants.SYSTEM);
+ }
+
+ /**
+ * Returns a handler of the database by the given name
+ *
+ * @param name
+ * Name of the database
+ * @return database handler
+ */
+ public ArangoDatabase db(final String name) {
+ return new ArangoDatabase(this, name);
+ }
+
+ /**
+ * creates a new database
+ *
+ * @see API
+ * Documentation
+ * @param name
+ * Has to contain a valid database name
+ * @return true if the database was created successfully.
+ * @throws ArangoDBException
+ */
+ public Boolean createDatabase(final String name) throws ArangoDBException {
+ return executor.execute(createDatabaseRequest(name), createDatabaseResponseDeserializer());
+ }
+
+ /**
+ * @see API
+ * Documentation
+ * @return a list of all existing databases
+ * @throws ArangoDBException
+ */
+ public Collection getDatabases() throws ArangoDBException {
+ return executor.execute(getDatabasesRequest(db().name()), getDatabaseResponseDeserializer());
+ }
+
+ /**
+ * @see API
+ * Documentation
+ * @return a list of all databases the current user can access
+ * @throws ArangoDBException
+ */
+ public Collection getAccessibleDatabases() throws ArangoDBException {
+ return executor.execute(getAccessibleDatabasesRequest(db().name()), getDatabaseResponseDeserializer());
+ }
+
+ /**
+ * Returns the server name and version number.
+ *
+ * @see API
+ * Documentation
+ * @return the server version, number
+ * @throws ArangoDBException
+ */
+ public ArangoDBVersion getVersion() throws ArangoDBException {
+ return executor.execute(getVersionRequest(), ArangoDBVersion.class);
+ }
+
+ /**
+ * Create a new user. This user will not have access to any database. You need permission to the _system database in
+ * order to execute this call.
+ *
+ * @see API Documentation
+ * @param user
+ * The name of the user
+ * @param passwd
+ * The user password
+ * @return information about the user
+ * @throws ArangoDBException
+ */
+ public UserEntity createUser(final String user, final String passwd) throws ArangoDBException {
+ return executor.execute(createUserRequest(db().name(), user, passwd, new UserCreateOptions()),
+ UserEntity.class);
+ }
+
+ /**
+ * Create a new user. This user will not have access to any database. You need permission to the _system database in
+ * order to execute this call.
+ *
+ * @see API Documentation
+ * @param user
+ * The name of the user
+ * @param passwd
+ * The user password
+ * @param options
+ * Additional options, can be null
+ * @return information about the user
+ * @throws ArangoDBException
+ */
+ public UserEntity createUser(final String user, final String passwd, final UserCreateOptions options)
+ throws ArangoDBException {
+ return executor.execute(createUserRequest(db().name(), user, passwd, options), UserEntity.class);
+ }
+
+ /**
+ * Removes an existing user, identified by user. You need access to the _system database.
+ *
+ * @see API Documentation
+ * @param user
+ * The name of the user
+ * @throws ArangoDBException
+ */
+ public void deleteUser(final String user) throws ArangoDBException {
+ executor.execute(deleteUserRequest(db().name(), user), Void.class);
+ }
+
+ /**
+ * Fetches data about the specified user. You can fetch information about yourself or you need permission to the
+ * _system database in order to execute this call.
+ *
+ * @see API Documentation
+ * @param user
+ * The name of the user
+ * @return information about the user
+ * @throws ArangoDBException
+ */
+ public UserEntity getUser(final String user) throws ArangoDBException {
+ return executor.execute(getUserRequest(db().name(), user), UserEntity.class);
+ }
+
+ /**
+ * Fetches data about all users. You can only execute this call if you have access to the _system database.
+ *
+ * @see API
+ * Documentation
+ * @return informations about all users
+ * @throws ArangoDBException
+ */
+ public Collection getUsers() throws ArangoDBException {
+ return executor.execute(getUsersRequest(db().name()), getUsersResponseDeserializer());
+ }
+
+ /**
+ * Partially updates the data of an existing user. The name of an existing user must be specified in user. You can
+ * only change the password of your self. You need access to the _system database to change the active flag.
+ *
+ * @see API Documentation
+ * @param user
+ * The name of the user
+ * @param options
+ * Properties of the user to be changed
+ * @return information about the user
+ * @throws ArangoDBException
+ */
+ public UserEntity updateUser(final String user, final UserUpdateOptions options) throws ArangoDBException {
+ return executor.execute(updateUserRequest(db().name(), user, options), UserEntity.class);
+ }
+
+ /**
+ * Replaces the data of an existing user. The name of an existing user must be specified in user. You can only
+ * change the password of your self. You need access to the _system database to change the active flag.
+ *
+ * @see API
+ * Documentation
+ * @param user
+ * The name of the user
+ * @param options
+ * Additional properties of the user, can be null
+ * @return information about the user
+ * @throws ArangoDBException
+ */
+ public UserEntity replaceUser(final String user, final UserUpdateOptions options) throws ArangoDBException {
+ return executor.execute(replaceUserRequest(db().name(), user, options), UserEntity.class);
+ }
+
+ /**
+ * Generic Execute. Use this method to execute custom FOXX services.
+ *
+ * @param request
+ * VelocyStream request
+ * @return VelocyStream response
+ * @throws ArangoDBException
+ */
+ public Response execute(final Request request) throws ArangoDBException {
+ return executor.execute(request, new ResponseDeserializer() {
+ @Override
+ public Response deserialize(final Response response) throws VPackException {
+ return response;
+ }
+ });
+ }
+
+ /**
+ * Returns fatal, error, warning or info log messages from the server's global log.
+ *
+ * @see API
+ * Documentation
+ * @param options
+ * Additional options, can be null
+ * @return the log messages
+ * @throws ArangoDBException
+ */
+ public LogEntity getLogs(final LogOptions options) throws ArangoDBException {
+ return executor.execute(getLogsRequest(options), LogEntity.class);
+ }
+
+}
diff --git a/src/test/java/com/arangodb/TestInterfaceInstanceCreator.java b/src/main/java/com/arangodb/ArangoDBException.java
similarity index 51%
rename from src/test/java/com/arangodb/TestInterfaceInstanceCreator.java
rename to src/main/java/com/arangodb/ArangoDBException.java
index 3ef2b9206..4339e3f3b 100644
--- a/src/test/java/com/arangodb/TestInterfaceInstanceCreator.java
+++ b/src/main/java/com/arangodb/ArangoDBException.java
@@ -1,42 +1,39 @@
-/*
- * Copyright (C) 2015 tporadowski
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.arangodb;
-
-import java.lang.reflect.Type;
-
-import com.google.gson.InstanceCreator;
-
-/**
- * @author tporadowski - tomasz at poradowski.com
- */
-public class TestInterfaceInstanceCreator implements
- InstanceCreator {
-
- private int counter;
-
- @Override
- public TestInterface createInstance(Type type) {
- return new TestInterfaceImpl("name " + counter++);
- }
-
- /**
- * @return the counter
- */
- public int getCounter() {
- return counter;
- }
-}
+/*
+ * DISCLAIMER
+ *
+ * Copyright 2016 ArangoDB GmbH, Cologne, Germany
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright holder is ArangoDB GmbH, Cologne, Germany
+ */
+
+package com.arangodb;
+
+/**
+ * @author Mark - mark at arangodb.com
+ *
+ */
+public class ArangoDBException extends RuntimeException {
+
+ private static final long serialVersionUID = 6165638002614173801L;
+
+ public ArangoDBException(final String message) {
+ super(message);
+ }
+
+ public ArangoDBException(final Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/src/main/java/com/arangodb/ArangoDatabase.java b/src/main/java/com/arangodb/ArangoDatabase.java
new file mode 100644
index 000000000..0ba0cc288
--- /dev/null
+++ b/src/main/java/com/arangodb/ArangoDatabase.java
@@ -0,0 +1,634 @@
+/*
+ * DISCLAIMER
+ *
+ * Copyright 2016 ArangoDB GmbH, Cologne, Germany
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright holder is ArangoDB GmbH, Cologne, Germany
+ */
+
+package com.arangodb;
+
+import java.util.Collection;
+import java.util.Map;
+
+import com.arangodb.entity.AqlExecutionExplainEntity;
+import com.arangodb.entity.AqlFunctionEntity;
+import com.arangodb.entity.AqlParseEntity;
+import com.arangodb.entity.CollectionEntity;
+import com.arangodb.entity.CursorEntity;
+import com.arangodb.entity.DatabaseEntity;
+import com.arangodb.entity.EdgeDefinition;
+import com.arangodb.entity.GraphEntity;
+import com.arangodb.entity.IndexEntity;
+import com.arangodb.entity.QueryCachePropertiesEntity;
+import com.arangodb.entity.QueryEntity;
+import com.arangodb.entity.QueryTrackingPropertiesEntity;
+import com.arangodb.entity.TraversalEntity;
+import com.arangodb.internal.ArangoCursorExecute;
+import com.arangodb.internal.ArangoExecutorSync;
+import com.arangodb.internal.CollectionCache;
+import com.arangodb.internal.DocumentCache;
+import com.arangodb.internal.InternalArangoDatabase;
+import com.arangodb.internal.velocystream.Communication;
+import com.arangodb.internal.velocystream.ConnectionSync;
+import com.arangodb.model.AqlFunctionCreateOptions;
+import com.arangodb.model.AqlFunctionDeleteOptions;
+import com.arangodb.model.AqlFunctionGetOptions;
+import com.arangodb.model.AqlQueryExplainOptions;
+import com.arangodb.model.AqlQueryOptions;
+import com.arangodb.model.CollectionCreateOptions;
+import com.arangodb.model.CollectionsReadOptions;
+import com.arangodb.model.DocumentReadOptions;
+import com.arangodb.model.GraphCreateOptions;
+import com.arangodb.model.TransactionOptions;
+import com.arangodb.model.TraversalOptions;
+import com.arangodb.velocypack.Type;
+import com.arangodb.velocypack.VPack;
+import com.arangodb.velocypack.VPackParser;
+import com.arangodb.velocystream.Request;
+import com.arangodb.velocystream.Response;
+
+/**
+ * @author Mark - mark at arangodb.com
+ *
+ */
+public class ArangoDatabase extends InternalArangoDatabase {
+
+ protected ArangoDatabase(final ArangoDB arangoDB, final String name) {
+ super(arangoDB.executor(), name);
+ }
+
+ protected ArangoDatabase(final Communication communication, final VPack vpacker,
+ final VPack vpackerNull, final VPackParser vpackParser, final DocumentCache documentCache,
+ final CollectionCache collectionCache, final String name) {
+ super(new ArangoExecutorSync(communication, vpacker, vpackerNull, vpackParser, documentCache, collectionCache),
+ name);
+ }
+
+ protected ArangoExecutorSync executor() {
+ return executor;
+ }
+
+ /**
+ * Returns a handler of the collection by the given name
+ *
+ * @param name
+ * Name of the collection
+ * @return collection handler
+ */
+ public ArangoCollection collection(final String name) {
+ return new ArangoCollection(this, name);
+ }
+
+ /**
+ * Creates a collection
+ *
+ * @see API
+ * Documentation
+ * @param name
+ * The name of the collection
+ * @return information about the collection
+ * @throws ArangoDBException
+ */
+ public CollectionEntity createCollection(final String name) throws ArangoDBException {
+ return executor.execute(createCollectionRequest(name, new CollectionCreateOptions()), CollectionEntity.class);
+ }
+
+ /**
+ * Creates a collection
+ *
+ * @see API
+ * Documentation
+ * @param name
+ * The name of the collection
+ * @param options
+ * Additional options, can be null
+ * @return information about the collection
+ * @throws ArangoDBException
+ */
+ public CollectionEntity createCollection(final String name, final CollectionCreateOptions options)
+ throws ArangoDBException {
+ return executor.execute(createCollectionRequest(name, options), CollectionEntity.class);
+ }
+
+ /**
+ * Returns all collections
+ *
+ * @see API
+ * Documentation
+ * @return list of information about all collections
+ * @throws ArangoDBException
+ */
+ public Collection getCollections() throws ArangoDBException {
+ return executor.execute(getCollectionsRequest(new CollectionsReadOptions()),
+ getCollectionsResponseDeserializer());
+ }
+
+ /**
+ * Returns all collections
+ *
+ * @see API
+ * Documentation
+ * @param options
+ * Additional options, can be null
+ * @return list of information about all collections
+ * @throws ArangoDBException
+ */
+ public Collection getCollections(final CollectionsReadOptions options) throws ArangoDBException {
+ return executor.execute(getCollectionsRequest(options), getCollectionsResponseDeserializer());
+ }
+
+ /**
+ * Returns an index
+ *
+ * @see API Documentation
+ * @param id
+ * The index-handle
+ * @return information about the index
+ * @throws ArangoDBException
+ */
+ public IndexEntity getIndex(final String id) throws ArangoDBException {
+ return executor.execute(getIndexRequest(id), IndexEntity.class);
+ }
+
+ /**
+ * Deletes an index
+ *
+ * @see API Documentation
+ * @param id
+ * The index-handle
+ * @return the id of the index
+ * @throws ArangoDBException
+ */
+ public String deleteIndex(final String id) throws ArangoDBException {
+ return executor.execute(deleteIndexRequest(id), deleteIndexResponseDeserializer());
+ }
+
+ /**
+ * Drop an existing database
+ *
+ * @see API
+ * Documentation
+ * @return true if the database was dropped successfully
+ * @throws ArangoDBException
+ */
+ public Boolean drop() throws ArangoDBException {
+ return executor.execute(dropRequest(), createDropResponseDeserializer());
+ }
+
+ /**
+ * Grants access to the database dbname for user user. You need permission to the _system database in order to
+ * execute this call.
+ *
+ * @see
+ * API Documentation
+ * @param user
+ * The name of the user
+ * @throws ArangoDBException
+ */
+ public void grantAccess(final String user) throws ArangoDBException {
+ executor.execute(grantAccessRequest(user), Void.class);
+ }
+
+ /**
+ * Revokes access to the database dbname for user user. You need permission to the _system database in order to
+ * execute this call.
+ *
+ * @see
+ * API Documentation
+ * @param user
+ * The name of the user
+ * @throws ArangoDBException
+ */
+ public void revokeAccess(final String user) throws ArangoDBException {
+ executor.execute(revokeAccessRequest(user), Void.class);
+ }
+
+ /**
+ * Create a cursor and return the first results
+ *
+ * @see API
+ * Documentation
+ * @param query
+ * contains the query string to be executed
+ * @param bindVars
+ * key/value pairs representing the bind parameters
+ * @param options
+ * Additional options, can be null
+ * @param type
+ * The type of the result (POJO class, VPackSlice, String for Json, or Collection/List/Map)
+ * @return cursor of the results
+ * @throws ArangoDBException
+ */
+ public ArangoCursor query(
+ final String query,
+ final Map bindVars,
+ final AqlQueryOptions options,
+ final Class type) throws ArangoDBException {
+ final Request request = queryRequest(query, bindVars, options);
+ final CursorEntity result = executor.execute(request, CursorEntity.class);
+ return new ArangoCursor(this, new ArangoCursorExecute() {
+ @Override
+ public CursorEntity next(final String id) {
+ return executor.execute(queryNextRequest(id), CursorEntity.class);
+ }
+
+ @Override
+ public void close(final String id) {
+ executor.execute(queryCloseRequest(id), Void.class);
+ }
+ }, type, result);
+ }
+
+ /**
+ * Explain an AQL query and return information about it
+ *
+ * @see API
+ * Documentation
+ * @param query
+ * the query which you want explained
+ * @param bindVars
+ * key/value pairs representing the bind parameters
+ * @param options
+ * Additional options, can be null
+ * @return information about the query
+ * @throws ArangoDBException
+ */
+ public AqlExecutionExplainEntity explainQuery(
+ final String query,
+ final Map bindVars,
+ final AqlQueryExplainOptions options) throws ArangoDBException {
+ return executor.execute(explainQueryRequest(query, bindVars, options), AqlExecutionExplainEntity.class);
+ }
+
+ /**
+ * Parse an AQL query and return information about it This method is for query validation only. To actually query
+ * the database, see {@link ArangoDatabase#query(String, Map, AqlQueryOptions, Class)}
+ *
+ * @see API
+ * Documentation
+ * @param query
+ * the query which you want parse
+ * @return imformation about the query
+ * @throws ArangoDBException
+ */
+ public AqlParseEntity parseQuery(final String query) throws ArangoDBException {
+ return executor.execute(parseQueryRequest(query), AqlParseEntity.class);
+ }
+
+ /**
+ * Clears the AQL query cache
+ *
+ * @see API
+ * Documentation
+ * @throws ArangoDBException
+ */
+ public void clearQueryCache() throws ArangoDBException {
+ executor.execute(clearQueryCacheRequest(), Void.class);
+ }
+
+ /**
+ * Returns the global configuration for the AQL query cache
+ *
+ * @see API
+ * Documentation
+ * @return configuration for the AQL query cache
+ * @throws ArangoDBException
+ */
+ public QueryCachePropertiesEntity getQueryCacheProperties() throws ArangoDBException {
+ return executor.execute(getQueryCachePropertiesRequest(), QueryCachePropertiesEntity.class);
+ }
+
+ /**
+ * Changes the configuration for the AQL query cache. Note: changing the properties may invalidate all results in
+ * the cache.
+ *
+ * @see API
+ * Documentation
+ * @param properties
+ * properties to be set
+ * @return current set of properties
+ * @throws ArangoDBException
+ */
+ public QueryCachePropertiesEntity setQueryCacheProperties(final QueryCachePropertiesEntity properties)
+ throws ArangoDBException {
+ return executor.execute(setQueryCachePropertiesRequest(properties), QueryCachePropertiesEntity.class);
+ }
+
+ /**
+ * Returns the configuration for the AQL query tracking
+ *
+ * @see API
+ * Documentation
+ * @return configuration for the AQL query tracking
+ * @throws ArangoDBException
+ */
+ public QueryTrackingPropertiesEntity getQueryTrackingProperties() throws ArangoDBException {
+ return executor.execute(getQueryTrackingPropertiesRequest(), QueryTrackingPropertiesEntity.class);
+ }
+
+ /**
+ * Changes the configuration for the AQL query tracking
+ *
+ * @see API
+ * Documentation
+ * @param properties
+ * properties to be set
+ * @return current set of properties
+ * @throws ArangoDBException
+ */
+ public QueryTrackingPropertiesEntity setQueryTrackingProperties(final QueryTrackingPropertiesEntity properties)
+ throws ArangoDBException {
+ return executor.execute(setQueryTrackingPropertiesRequest(properties), QueryTrackingPropertiesEntity.class);
+ }
+
+ /**
+ * Returns a list of currently running AQL queries
+ *
+ * @see API
+ * Documentation
+ * @return a list of currently running AQL queries
+ * @throws ArangoDBException
+ */
+ public Collection getCurrentlyRunningQueries() throws ArangoDBException {
+ return executor.execute(getCurrentlyRunningQueriesRequest(), new Type>() {
+ }.getType());
+ }
+
+ /**
+ * Returns a list of slow running AQL queries
+ *
+ * @see API
+ * Documentation
+ * @return a list of slow running AQL queries
+ * @throws ArangoDBException
+ */
+ public Collection getSlowQueries() throws ArangoDBException {
+ return executor.execute(getSlowQueriesRequest(), new Type>() {
+ }.getType());
+ }
+
+ /**
+ * Clears the list of slow AQL queries
+ *
+ * @see API
+ * Documentation
+ * @throws ArangoDBException
+ */
+ public void clearSlowQueries() throws ArangoDBException {
+ executor.execute(clearSlowQueriesRequest(), Void.class);
+ }
+
+ /**
+ * Kills a running query. The query will be terminated at the next cancelation point.
+ *
+ * @see API
+ * Documentation
+ * @param id
+ * The id of the query
+ * @throws ArangoDBException
+ */
+ public void killQuery(final String id) throws ArangoDBException {
+ executor.execute(killQueryRequest(id), Void.class);
+ }
+
+ /**
+ * Create a new AQL user function
+ *
+ * @see API
+ * Documentation
+ * @param name
+ * the fully qualified name of the user functions
+ * @param code
+ * a string representation of the function body
+ * @param options
+ * Additional options, can be null
+ * @throws ArangoDBException
+ */
+ public void createAqlFunction(final String name, final String code, final AqlFunctionCreateOptions options)
+ throws ArangoDBException {
+ executor.execute(createAqlFunctionRequest(name, code, options), Void.class);
+ }
+
+ /**
+ * Remove an existing AQL user function
+ *
+ * @see API
+ * Documentation
+ * @param name
+ * the name of the AQL user function
+ * @param options
+ * Additional options, can be null
+ * @throws ArangoDBException
+ */
+ public void deleteAqlFunction(final String name, final AqlFunctionDeleteOptions options) throws ArangoDBException {
+ executor.execute(deleteAqlFunctionRequest(name, options), Void.class);
+ }
+
+ /**
+ * Gets all reqistered AQL user functions
+ *
+ * @see API
+ * Documentation
+ * @param options
+ * Additional options, can be null
+ * @return all reqistered AQL user functions
+ * @throws ArangoDBException
+ */
+ public Collection getAqlFunctions(final AqlFunctionGetOptions options) throws ArangoDBException {
+ return executor.execute(getAqlFunctionsRequest(options), new Type>() {
+ }.getType());
+ }
+
+ /**
+ * Returns a handler of the graph by the given name
+ *
+ * @param name
+ * Name of the graph
+ * @return graph handler
+ */
+ public ArangoGraph graph(final String name) {
+ return new ArangoGraph(this, name);
+ }
+
+ /**
+ * Create a new graph in the graph module. The creation of a graph requires the name of the graph and a definition
+ * of its edges.
+ *
+ * @see API
+ * Documentation
+ * @param name
+ * Name of the graph
+ * @param edgeDefinitions
+ * An array of definitions for the edge
+ * @return information about the graph
+ * @throws ArangoDBException
+ */
+ public GraphEntity createGraph(final String name, final Collection edgeDefinitions)
+ throws ArangoDBException {
+ return executor.execute(createGraphRequest(name, edgeDefinitions, new GraphCreateOptions()),
+ createGraphResponseDeserializer());
+ }
+
+ /**
+ * Create a new graph in the graph module. The creation of a graph requires the name of the graph and a definition
+ * of its edges.
+ *
+ * @see API
+ * Documentation
+ * @param name
+ * Name of the graph
+ * @param edgeDefinitions
+ * An array of definitions for the edge
+ * @param options
+ * Additional options, can be null
+ * @return information about the graph
+ * @throws ArangoDBException
+ */
+ public GraphEntity createGraph(
+ final String name,
+ final Collection edgeDefinitions,
+ final GraphCreateOptions options) throws ArangoDBException {
+ return executor.execute(createGraphRequest(name, edgeDefinitions, options), createGraphResponseDeserializer());
+ }
+
+ /**
+ * Lists all graphs known to the graph module
+ *
+ * @see API
+ * Documentation
+ * @return graphs stored in this database
+ * @throws ArangoDBException
+ */
+ public Collection getGraphs() throws ArangoDBException {
+ return executor.execute(getGraphsRequest(), getGraphsResponseDeserializer());
+ }
+
+ /**
+ * Execute a server-side transaction
+ *
+ * @see API
+ * Documentation
+ * @param action
+ * the actual transaction operations to be executed, in the form of stringified JavaScript code
+ * @param type
+ * The type of the result (POJO class, VPackSlice or String for Json)
+ * @param options
+ * Additional options, can be null
+ * @return the result of the transaction if it succeeded
+ * @throws ArangoDBException
+ */
+ public T transaction(final String action, final Class type, final TransactionOptions options)
+ throws ArangoDBException {
+ return executor.execute(transactionRequest(action, options), transactionResponseDeserializer(type));
+ }
+
+ /**
+ * Retrieves information about the current database
+ *
+ * @see API
+ * Documentation
+ * @return information about the current database
+ * @throws ArangoDBException
+ */
+ public DatabaseEntity getInfo() throws ArangoDBException {
+ return executor.execute(getInfoRequest(), getInfoResponseDeserializer());
+ }
+
+ /**
+ * Execute a server-side traversal
+ *
+ * @see API
+ * Documentation
+ * @param vertexClass
+ * The type of the vertex documents (POJO class, VPackSlice or String for Json)
+ * @param edgeClass
+ * The type of the edge documents (POJO class, VPackSlice or String for Json)
+ * @param options
+ * Additional options
+ * @return Result of the executed traversal
+ * @throws ArangoDBException
+ */
+ public TraversalEntity executeTraversal(
+ final Class vertexClass,
+ final Class edgeClass,
+ final TraversalOptions options) throws ArangoDBException {
+ final Request request = executeTraversalRequest(options);
+ return executor.execute(request, executeTraversalResponseDeserializer(vertexClass, edgeClass));
+ }
+
+ /**
+ * Reads a single document
+ *
+ * @see API
+ * Documentation
+ * @param id
+ * The id of the document
+ * @param type
+ * The type of the document (POJO class, VPackSlice or String for Json)
+ * @return the document identified by the id
+ * @throws ArangoDBException
+ */
+ public T getDocument(final String id, final Class type) throws ArangoDBException {
+ executor.validateDocumentId(id);
+ final String[] split = id.split("/");
+ return collection(split[0]).getDocument(split[1], type);
+ }
+
+ /**
+ * Reads a single document
+ *
+ * @see API
+ * Documentation
+ * @param id
+ * The id of the document
+ * @param type
+ * The type of the document (POJO class, VPackSlice or String for Json)
+ * @param options
+ * Additional options, can be null
+ * @return the document identified by the id
+ * @throws ArangoDBException
+ */
+ public T getDocument(final String id, final Class type, final DocumentReadOptions options)
+ throws ArangoDBException {
+ executor.validateDocumentId(id);
+ final String[] split = id.split("/");
+ return collection(split[0]).getDocument(split[1], type, options);
+ }
+
+ /**
+ * Reload the routing table.
+ *
+ * @see API
+ * Documentation
+ * @throws ArangoDBException
+ */
+ public void reloadRouting() throws ArangoDBException {
+ executor.execute(reloadRoutingRequest(), Void.class);
+ }
+
+}
diff --git a/src/main/java/com/arangodb/ArangoDriver.java b/src/main/java/com/arangodb/ArangoDriver.java
deleted file mode 100644
index 9370d6c0a..000000000
--- a/src/main/java/com/arangodb/ArangoDriver.java
+++ /dev/null
@@ -1,4183 +0,0 @@
-/*
- * Copyright (C) 2012 tamtam180
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.arangodb;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Proxy;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import com.arangodb.entity.AdminLogEntity;
-import com.arangodb.entity.AqlFunctionsEntity;
-import com.arangodb.entity.ArangoUnixTime;
-import com.arangodb.entity.ArangoVersion;
-import com.arangodb.entity.BatchResponseEntity;
-import com.arangodb.entity.BooleanResultEntity;
-import com.arangodb.entity.CollectionEntity;
-import com.arangodb.entity.CollectionKeyOption;
-import com.arangodb.entity.CollectionOptions;
-import com.arangodb.entity.CollectionsEntity;
-import com.arangodb.entity.CursorEntity;
-import com.arangodb.entity.DatabaseEntity;
-import com.arangodb.entity.DefaultEntity;
-import com.arangodb.entity.DeletedEntity;
-import com.arangodb.entity.DocumentEntity;
-import com.arangodb.entity.EdgeDefinitionEntity;
-import com.arangodb.entity.EdgeEntity;
-import com.arangodb.entity.Endpoint;
-import com.arangodb.entity.GraphEntity;
-import com.arangodb.entity.GraphsEntity;
-import com.arangodb.entity.ImportResultEntity;
-import com.arangodb.entity.IndexEntity;
-import com.arangodb.entity.IndexType;
-import com.arangodb.entity.IndexesEntity;
-import com.arangodb.entity.JobsEntity;
-import com.arangodb.entity.PlainEdgeEntity;
-import com.arangodb.entity.QueriesResultEntity;
-import com.arangodb.entity.QueryCachePropertiesEntity;
-import com.arangodb.entity.QueryTrackingPropertiesEntity;
-import com.arangodb.entity.ReplicationApplierConfigEntity;
-import com.arangodb.entity.ReplicationApplierStateEntity;
-import com.arangodb.entity.ReplicationInventoryEntity;
-import com.arangodb.entity.ReplicationLoggerConfigEntity;
-import com.arangodb.entity.ReplicationLoggerStateEntity;
-import com.arangodb.entity.ReplicationSyncEntity;
-import com.arangodb.entity.RestrictType;
-import com.arangodb.entity.ScalarExampleEntity;
-import com.arangodb.entity.ShortestPathEntity;
-import com.arangodb.entity.SimpleByResultEntity;
-import com.arangodb.entity.StatisticsDescriptionEntity;
-import com.arangodb.entity.StatisticsEntity;
-import com.arangodb.entity.StringsResultEntity;
-import com.arangodb.entity.TransactionEntity;
-import com.arangodb.entity.TransactionResultEntity;
-import com.arangodb.entity.TraversalEntity;
-import com.arangodb.entity.UserEntity;
-import com.arangodb.entity.marker.VertexEntity;
-import com.arangodb.http.BatchHttpManager;
-import com.arangodb.http.BatchPart;
-import com.arangodb.http.HttpManager;
-import com.arangodb.http.HttpResponseEntity;
-import com.arangodb.http.InvocationHandlerImpl;
-import com.arangodb.impl.ImplFactory;
-import com.arangodb.impl.InternalBatchDriverImpl;
-import com.arangodb.util.AqlQueryOptions;
-import com.arangodb.util.DumpHandler;
-import com.arangodb.util.GraphEdgesOptions;
-import com.arangodb.util.GraphQueryUtil;
-import com.arangodb.util.GraphVerticesOptions;
-import com.arangodb.util.ImportOptions;
-import com.arangodb.util.ImportOptionsJson;
-import com.arangodb.util.ImportOptionsRaw;
-import com.arangodb.util.MapBuilder;
-import com.arangodb.util.ShortestPathOptions;
-import com.arangodb.util.TraversalQueryOptions;
-
-/**
- * ArangoDB driver. All of the functionality to use ArangoDB is provided via
- * this class.
- *
- * @author tamtam180 - kirscheless at gmail.com
- * @author gschwab
- * @author fbartels
- * @author a-brandt
- *
- * @version 2.2.
- *
- * @see ArangoDB
- * documentation
- */
-public class ArangoDriver extends BaseArangoDriver {
-
- private static final String DATABASE_SYSTEM = "_system";
- private static final String COLLECTION_USERS = "_users";
- private final ArangoConfigure configure;
- private final BatchHttpManager httpManager;
-
- private InternalCursorDriver cursorDriver;
- private InternalBatchDriverImpl batchDriver;
- private InternalCollectionDriver collectionDriver;
- private InternalDocumentDriver documentDriver;
- private InternalIndexDriver indexDriver;
- private InternalAdminDriver adminDriver;
- private InternalJobsDriver jobsDriver;
- private InternalAqlFunctionsDriver aqlFunctionsDriver;
- private InternalSimpleDriver simpleDriver;
- private InternalUsersDriver usersDriver;
- private InternalImportDriver importDriver;
- private InternalDatabaseDriver databaseDriver;
- private InternalEndpointDriver endpointDriver;
- private InternalReplicationDriver replicationDriver;
- private InternalGraphDriver graphDriver;
- private InternalTransactionDriver transactionDriver;
- private InternalTraversalDriver traversalDriver;
- private InternalQueryCacheDriver queryCacheDriver;
-
- private String database;
-
- /**
- * Constructor to create an instance of the driver that uses the default
- * database.
- *
- * @param configure
- * A configuration object.
- */
- public ArangoDriver(final ArangoConfigure configure) {
- this(configure, null);
- }
-
- /**
- * Constructor to create an instance of the driver that uses the provided
- * database.
- *
- * @param configure
- * A configuration object.
- * @param database
- * the name of the database that will be used.
- */
- public ArangoDriver(final ArangoConfigure configure, final String database) {
-
- this.database = configure.getDefaultDatabase();
- if (database != null) {
- this.database = database;
- }
-
- this.configure = configure;
- this.httpManager = configure.getHttpManager();
- this.createModuleDrivers(false);
- }
-
- /**
- * This method enables batch execution. Until 'cancelBatchMode' or
- * 'executeBatch' is called every other call is stacked and will be either
- * executed or discarded when the batch mode is canceled. Each call will
- * return a 'requestId' in the HTTP response, that can be used to select the
- * matching result from the batch execution.
- *
- * @see com.arangodb.ArangoDriver#cancelBatchMode()
- * @see ArangoDriver#executeBatch()
- * @see ArangoDriver#getBatchResponseByRequestId(String)
- * @throws com.arangodb.ArangoException
- */
- public void startBatchMode() throws ArangoException {
- if (this.httpManager.isBatchModeActive()) {
- throw new ArangoException("BatchMode is already active.");
- }
- this.httpManager.emptyCallStack();
- this.httpManager.setBatchModeActive(true);
- this.createModuleDrivers(true);
-
- }
-
- /**
- * This method sets the driver to asynchronous execution. If the parameter
- * 'fireAndforget' is set to true each call to ArangoDB will be send without
- * a return value. If set to false the return value will be the 'job id'.
- * Each job result can be received by the method 'getJobResult'.
- *
- * @param fireAndForget
- * if set to true the asynchronous mode is set to 'fire and
- * forget'.
- * @see ArangoDriver#stopAsyncMode()
- * @see com.arangodb.ArangoDriver#getJobResult(String)
- * @see com.arangodb.ArangoDriver#getJobs(com.arangodb.entity.JobsEntity.JobState,
- * int)
- * @see com.arangodb.ArangoDriver#deleteExpiredJobs(int)
- * @see ArangoDriver#getLastJobId()
- * @throws com.arangodb.ArangoException
- */
- public void startAsyncMode(final boolean fireAndForget) throws ArangoException {
- if (this.httpManager.getHttpMode().equals(HttpManager.HttpMode.ASYNC)
- || this.httpManager.getHttpMode().equals(HttpManager.HttpMode.FIREANDFORGET)) {
- throw new ArangoException("Arango driver already set to asynchronous mode.");
- }
- final HttpManager.HttpMode mode = fireAndForget ? HttpManager.HttpMode.FIREANDFORGET
- : HttpManager.HttpMode.ASYNC;
- this.httpManager.setHttpMode(mode);
- this.createModuleDrivers(true);
- this.httpManager.resetJobs();
- }
-
- /**
- * This method sets the driver back to synchronous execution.
- *
- * @see ArangoDriver#startAsyncMode(boolean)
- * @see com.arangodb.ArangoDriver#getJobResult(String)
- * @see com.arangodb.ArangoDriver#getJobs(com.arangodb.entity.JobsEntity.JobState,
- * int)
- * @see com.arangodb.ArangoDriver#deleteExpiredJobs(int)
- * @see ArangoDriver#getLastJobId()
- * @throws com.arangodb.ArangoException
- */
- public void stopAsyncMode() throws ArangoException {
- if (this.httpManager.getHttpMode().equals(HttpManager.HttpMode.SYNC)) {
- throw new ArangoException("Arango driver already set to synchronous mode.");
- }
- this.httpManager.setHttpMode(HttpManager.HttpMode.SYNC);
- this.createModuleDrivers(false);
- }
-
- /**
- * Returns the identifier of the last asynchronous executed job.
- *
- * @return String the identifier
- * @see ArangoDriver#startAsyncMode(boolean)
- * @see ArangoDriver#stopAsyncMode()
- * @see com.arangodb.ArangoDriver#getJobResult(String)
- * @see com.arangodb.ArangoDriver#getJobs(com.arangodb.entity.JobsEntity.JobState,
- * int)
- * @see com.arangodb.ArangoDriver#deleteExpiredJobs(int)
- * @see ArangoDriver#getLastJobId()
- */
- public String getLastJobId() {
- return this.httpManager.getLastJobId();
- }
-
- /**
- * Returns a list of all job identifiers of asynchronous executed jobs.
- *
- * @return List the list of all job identifiers
- * @see ArangoDriver#startAsyncMode(boolean)
- * @see ArangoDriver#stopAsyncMode()
- * @see com.arangodb.ArangoDriver#getJobResult(String)
- * @see com.arangodb.ArangoDriver#getJobs(com.arangodb.entity.JobsEntity.JobState,
- * int)
- * @see com.arangodb.ArangoDriver#deleteExpiredJobs(int)
- * @see ArangoDriver#getLastJobId()
- */
- public List getJobIds() {
- return this.httpManager.getJobIds();
- }
-
- /**
- * Returns a list of all job identifiers of asynchronous executed jobs,
- * filtered by job state.
- *
- * @param jobState
- * the job state as a filter.
- * @param count
- * a limit for the result set.
- * @return List list of all job identifiers
- * @see ArangoDriver#startAsyncMode(boolean)
- * @see ArangoDriver#stopAsyncMode()
- * @see com.arangodb.ArangoDriver#getJobResult(String)
- * @see com.arangodb.ArangoDriver#getJobIds()
- * @see com.arangodb.ArangoDriver#deleteExpiredJobs(int)
- * @see ArangoDriver#getLastJobId()
- */
- public List getJobs(final JobsEntity.JobState jobState, final int count) throws ArangoException {
- return this.jobsDriver.getJobs(getDefaultDatabase(), jobState, count);
- }
-
- /**
- * Returns a list of all job identifiers of asynchronous executed jobs,
- * filtered by job state.
- *
- *
- * @param jobState
- * the job state as a filter.
- * @return List list of all job identifiers
- * @see ArangoDriver#startAsyncMode(boolean)
- * @see ArangoDriver#stopAsyncMode()
- * @see com.arangodb.ArangoDriver#getJobResult(String)
- * @see com.arangodb.ArangoDriver#getJobIds()
- * @see com.arangodb.ArangoDriver#deleteExpiredJobs(int)
- * @see ArangoDriver#getLastJobId()
- */
- public List getJobs(final JobsEntity.JobState jobState) throws ArangoException {
- return this.jobsDriver.getJobs(getDefaultDatabase(), jobState);
- }
-
- /**
- * Deletes all job from ArangoDB.
- *
- * @see ArangoDriver#startAsyncMode(boolean)
- * @see ArangoDriver#stopAsyncMode()
- * @see com.arangodb.ArangoDriver#getJobResult(String)
- * @see com.arangodb.ArangoDriver#getJobIds()
- * @see com.arangodb.ArangoDriver#deleteExpiredJobs(int)
- * @see ArangoDriver#getLastJobId()
- */
- public void deleteAllJobs() throws ArangoException {
- this.jobsDriver.deleteAllJobs(getDefaultDatabase());
- this.httpManager.resetJobs();
- }
-
- /**
- * Deletes a job from ArangoDB.
- *
- * @param jobId
- * the identifier of the job
- * @see ArangoDriver#startAsyncMode(boolean)
- * @see ArangoDriver#stopAsyncMode()
- * @see com.arangodb.ArangoDriver#getJobResult(String)
- * @see com.arangodb.ArangoDriver#getJobIds()
- * @see com.arangodb.ArangoDriver#deleteExpiredJobs(int)
- * @see ArangoDriver#getLastJobId()
- */
- public void deleteJobById(final String jobId) throws ArangoException {
- this.jobsDriver.deleteJobById(getDefaultDatabase(), jobId);
- }
-
- /**
- * Deletes all jobs by a provided expiration date.
- *
- * @param timeStamp
- * a unix timestamp, every older job is deleted.
- * @see ArangoDriver#startAsyncMode(boolean)
- * @see ArangoDriver#stopAsyncMode()
- * @see com.arangodb.ArangoDriver#getJobResult(String)
- * @see com.arangodb.ArangoDriver#getJobIds()
- * @see com.arangodb.ArangoDriver#deleteExpiredJobs(int)
- * @see ArangoDriver#getLastJobId()
- */
- public void deleteExpiredJobs(final int timeStamp) throws ArangoException {
- this.jobsDriver.deleteExpiredJobs(getDefaultDatabase(), timeStamp);
- }
-
- /**
- * Returns the job result for a given job id.
- *
- * @param jobId
- * the job id.
- * @return - A generic return value, containing the job result
- * @see ArangoDriver#startAsyncMode(boolean)
- * @see ArangoDriver#stopAsyncMode()
- * @see com.arangodb.ArangoDriver#getJobResult(String)
- * @see com.arangodb.ArangoDriver#getJobIds()
- * @see com.arangodb.ArangoDriver#deleteExpiredJobs(int)
- * @see ArangoDriver#getLastJobId()
- */
- public T getJobResult(final String jobId) throws ArangoException {
- return this.jobsDriver.getJobResult(getDefaultDatabase(), jobId);
- }
-
- /**
- * This method sends all stacked requests as batch to ArangoDB.
- *
- * @see ArangoDriver#startBatchMode()
- * @see com.arangodb.ArangoDriver#cancelBatchMode()
- * @throws com.arangodb.ArangoException
- */
- public DefaultEntity executeBatch() throws ArangoException {
- if (!this.httpManager.isBatchModeActive()) {
- throw new ArangoException("BatchMode is not active.");
- }
- final List callStack = this.httpManager.getCallStack();
- this.cancelBatchMode();
- return this.batchDriver.executeBatch(callStack, this.getDefaultDatabase());
- }
-
- /**
- * This method returns the result of a call to ArangoDB executed within a
- * batch request.
- *
- * @param requestId
- * the id of a request.
- * @return - A generic return value, containing the result.
- * @see ArangoDriver#startBatchMode()
- * @see ArangoDriver#executeBatch()
- * @see com.arangodb.ArangoDriver#cancelBatchMode()
- * @throws com.arangodb.ArangoException
- */
- @SuppressWarnings("unchecked")
- public T getBatchResponseByRequestId(final String requestId) throws ArangoException {
- final BatchResponseEntity batchResponseEntity = this.batchDriver.getBatchResponseListEntity()
- .getResponseFromRequestId(requestId);
- try {
- this.httpManager.setPreDefinedResponse(batchResponseEntity.getHttpResponseEntity());
-
- final T result = (T) batchResponseEntity.getInvocationObject().getMethod().invoke(
- batchResponseEntity.getInvocationObject().getArangoDriver(),
- batchResponseEntity.getInvocationObject().getArgs());
- this.httpManager.setPreDefinedResponse(null);
- return result;
- } catch (final InvocationTargetException e) {
- this.httpManager.setPreDefinedResponse(null);
-
- HttpResponseEntity httpResponse = batchResponseEntity.getHttpResponseEntity();
- if (httpResponse.getStatusCode() >= 300) {
- DefaultEntity de = new DefaultEntity();
- de.setCode(httpResponse.getStatusCode());
- de.setError(true);
- if (httpResponse.getText() != null) {
- de.setErrorMessage(httpResponse.getText().trim());
- }
- de.setErrorNumber(httpResponse.getStatusCode());
- throw new ArangoException(de);
- }
-
- final T result = (T) createEntity(batchResponseEntity.getHttpResponseEntity(), DefaultEntity.class);
- return result;
- } catch (final Exception e) {
- this.httpManager.setPreDefinedResponse(null);
- throw new ArangoException(e);
- }
- }
-
- /**
- * This method cancels the batch execution mode. All stacked calls are
- * discarded.
- *
- * @see ArangoDriver#startBatchMode()
- * @see ArangoDriver#executeBatch()
- * @throws com.arangodb.ArangoException
- */
- public void cancelBatchMode() throws ArangoException {
- if (!this.httpManager.isBatchModeActive()) {
- throw new ArangoException("BatchMode is not active.");
- }
- this.httpManager.setBatchModeActive(false);
- this.createModuleDrivers(false);
- this.httpManager.emptyCallStack();
- this.httpManager.setPreDefinedResponse(null);
- }
-
- /**
- * Returns the default database.
- *
- * @return String
- */
- public String getDefaultDatabase() {
- return database;
- }
-
- /**
- * Sets the default database.
- *
- * @param database
- */
- public void setDefaultDatabase(final String database) {
- this.database = database;
- }
-
- /**
- * Creates a new collection.
- *
- * @param name
- * the name of the collection
- * @return CollectionEntity - the created collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity createCollection(final String name) throws ArangoException {
- return collectionDriver.createCollection(getDefaultDatabase(), name, new CollectionOptions());
- }
-
- /**
- * Creates a new collection.
- *
- * @param name
- * the name of the collection
- * @param collectionOptions
- * an object containing the various options.
- * @return CollectionEntity - the created collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity createCollection(final String name, final CollectionOptions collectionOptions)
- throws ArangoException {
- return collectionDriver.createCollection(getDefaultDatabase(), name, collectionOptions);
- }
-
- /**
- * Returns a collection from ArangoDB by name
- *
- * @param name
- * the name of the collection.
- * @return CollectionEntity - the requested collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity getCollection(final String name) throws ArangoException {
- return collectionDriver.getCollection(getDefaultDatabase(), name);
- }
-
- /**
- * Returns a collection from ArangoDB including all properties by name
- *
- * @param name
- * the name of the collection.
- * @return CollectionEntity - the requested collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity getCollectionProperties(final String name) throws ArangoException {
- return collectionDriver.getCollectionProperties(getDefaultDatabase(), name);
- }
-
- /**
- * Returns a collection from ArangoDB by name including the document count
- *
- * @param name
- * the name of the collection.
- * @return CollectionEntity - the requested collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity getCollectionCount(final String name) throws ArangoException {
- return collectionDriver.getCollectionCount(getDefaultDatabase(), name);
- }
-
- /**
- * Returns a collection from ArangoDB by name including the collection
- * figures
- *
- * @param name
- * the name of the collection.
- * @return CollectionEntity - the requested collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity getCollectionFigures(final String name) throws ArangoException {
- return collectionDriver.getCollectionFigures(getDefaultDatabase(), name);
- }
-
- /**
- * Returns a collection from ArangoDB by name including the collection
- * checksum
- *
- * @param name
- * the id of the collection.
- * @param withRevisions
- * includes the revision into the checksum calculation
- * @param withData
- * includes the collections data into the checksum calculation
- * @return CollectionEntity - the requested collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity getCollectionChecksum(
- final String name,
- final Boolean withRevisions,
- final Boolean withData) throws ArangoException {
- return collectionDriver.getCollectionChecksum(getDefaultDatabase(), name, withRevisions, withData);
- }
-
- /**
- * Returns all collections from ArangoDB
- *
- * @return CollectionsEntity - the CollectionsEntity.
- * @throws ArangoException
- */
- public CollectionsEntity getCollections() throws ArangoException {
- return collectionDriver.getCollections(getDefaultDatabase(), null);
- }
-
- /**
- * Returns all collections from ArangoDB
- *
- * @param excludeSystem
- * if set to true system collections will not be added to the
- * result
- * @return CollectionsEntity - the CollectionsEntity.
- * @throws ArangoException
- */
- public CollectionsEntity getCollections(final Boolean excludeSystem) throws ArangoException {
- return collectionDriver.getCollections(getDefaultDatabase(), excludeSystem);
- }
-
- /**
- * Returns the collection and loads it into memory.
- *
- * @param name
- * the name of the collection.
- * @return CollectionEntity - the collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity loadCollection(final String name) throws ArangoException {
- return collectionDriver.loadCollection(getDefaultDatabase(), name, null);
- }
-
- /**
- * Returns the collection and loads it into memory.
- *
- * @param name
- * the name of the collection.
- * @param count
- * if set to true the documents count is returned.
- * @return CollectionEntity - the collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity loadCollection(final String name, final Boolean count) throws ArangoException {
- return collectionDriver.loadCollection(getDefaultDatabase(), name, count);
- }
-
- /**
- * Returns the collection and deletes it from memory.
- *
- * @param name
- * the name of the collection.
- * @return CollectionEntity - the collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity unloadCollection(final String name) throws ArangoException {
- return collectionDriver.unloadCollection(getDefaultDatabase(), name);
- }
-
- /**
- * Returns the collection and deletes all documents.
- *
- * @param name
- * the name of the collection.
- * @return CollectionEntity - the collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity truncateCollection(final String name) throws ArangoException {
- return collectionDriver.truncateCollection(getDefaultDatabase(), name);
- }
-
- /**
- * Returns the collection and changes it's journalSize and waitForSync.
- *
- * @param name
- * the name of the collection.
- * @param newWaitForSync
- * a new value for the waitForSyncProperty
- * @param journalSize
- * a new value for the collections journalSize
- * @return CollectionEntity - the collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity setCollectionProperties(
- final String name,
- final Boolean newWaitForSync,
- final Long journalSize) throws ArangoException {
- return collectionDriver.setCollectionProperties(getDefaultDatabase(), name, newWaitForSync, journalSize);
- }
-
- /**
- * Returns the collection and changes it's name.
- *
- * @param name
- * the name of the collection.
- * @param newName
- * the new name for the collection
- * @return CollectionEntity - the collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity renameCollection(final String name, final String newName) throws ArangoException {
- return collectionDriver.renameCollection(getDefaultDatabase(), name, newName);
- }
-
- /**
- * Deletes a collection by name.
- *
- * @param name
- * the name of the collection.
- * @return CollectionEntity - the collectionEntity.
- * @throws ArangoException
- */
- public CollectionEntity deleteCollection(final String name) throws ArangoException {
- return collectionDriver.deleteCollection(getDefaultDatabase(), name);
- }
-
- /**
- * Creates a document in the collection defined by the collection's name
- *
- * @param collectionName
- * The name of the collection
- * @param value
- * An object containing the documents attributes
- * @return DocumentEntity>
- * @throws ArangoException
- */
- public DocumentEntity createDocument(final String collectionName, final T value) throws ArangoException {
- return documentDriver.createDocument(getDefaultDatabase(), collectionName, null, value, null);
- }
-
- /**
- * Creates a document in the collection defined by the collection's name.
- * This method allows to define to documents key. Note that the collection's
- * property CollectionKeyOption.allowUserKeys has to be set accordingly.
- *
- * @param collectionName
- * The name of the collection
- * @param documentKey
- * the desired document key
- * @param value
- * An object containing the documents attributes
- * @return DocumentEntity>
- * @throws ArangoException
- * @see CollectionKeyOption#allowUserKeys
- */
- public DocumentEntity createDocument(final String collectionName, final String documentKey, final T value)
- throws ArangoException {
- return documentDriver.createDocument(getDefaultDatabase(), collectionName, documentKey, value, null);
- }
-
- /**
- * Creates a document in the collection defined by the collection's name.
- *
- * @param collectionName
- * The name of the collection
- * @param value
- * An object containing the documents attributes
- * @param waitForSync
- * if set to true the response is returned when the server has
- * finished.
- * @return DocumentEntity>
- * @throws ArangoException
- * @see CollectionKeyOption#allowUserKeys
- */
- public DocumentEntity createDocument(final String collectionName, final T value, final Boolean waitForSync)
- throws ArangoException {
- return documentDriver.createDocument(getDefaultDatabase(), collectionName, null, value, waitForSync);
- }
-
- /**
- * Creates a document in the collection defined by the collection's name.
- * This method allows to define to documents key. Note that the collection's
- * property CollectionKeyOption.allowUserKeys has to be set accordingly.
- *
- * @param collectionName
- * The name of the collection
- * @param documentKey
- * the desired document key
- * @param value
- * An object containing the documents attributes
- * @param waitForSync
- * if set to true the response is returned when the server has
- * finished.
- * @return DocumentEntity>
- * @throws ArangoException
- * @see CollectionKeyOption#allowUserKeys
- */
- public DocumentEntity createDocument(
- final String collectionName,
- final String documentKey,
- final T value,
- final Boolean waitForSync) throws ArangoException {
- return documentDriver.createDocument(getDefaultDatabase(), collectionName, documentKey, value, waitForSync);
- }
-
- /**
- * This method replaces the content of the document defined by documentKey.
- *
- * @param collectionName
- * The collection's name.
- * @param documentKey
- * The document's key.
- * @param value
- * An object containing the documents attributes
- * @return DocumentEntity>
- * @throws ArangoException
- */
- public DocumentEntity replaceDocument(final String collectionName, final String documentKey, final T value)
- throws ArangoException {
- return replaceDocument(createDocumentHandle(collectionName, documentKey), value, null, null);
- }
-
- /**
- * This method replaces the content of the document defined by
- * documentHandle.
- *
- * @param documentHandle
- * The document handle.
- * @param value
- * An object containing the documents attributes
- * @return DocumentEntity>
- * @throws ArangoException
- */
- public DocumentEntity replaceDocument(final String documentHandle, final T value) throws ArangoException {
- return documentDriver.replaceDocument(getDefaultDatabase(), documentHandle, value, null, null);
- }
-
- /**
- * This method replaces the content of the document defined by documentKey.
- * This method offers a parameter rev (revision). If the revision of the
- * document on the server does not match the given revision an error is
- * thrown.
- *
- * @param collectionName
- * The collection's name.
- * @param documentKey
- * The document's key.
- * @param value
- * An object containing the new attributes of the document.
- * @param rev
- * the desired revision.
- * @param waitForSync
- * if set to true the response is returned when the server has
- * finished.
- * @return a DocumentEntity object
- * @throws ArangoException
- */
- public DocumentEntity> replaceDocument(
- final String collectionName,
- final String documentKey,
- final Object value,
- final String rev,
- final Boolean waitForSync) throws ArangoException {
- return replaceDocument(createDocumentHandle(collectionName, documentKey), value, rev, waitForSync);
- }
-
- /**
- * This method replaces the content of the document defined by
- * documentHandle. This method offers a parameter rev (revision). If the
- * revision of the document on the server does not match the given revision
- * an error is thrown.
- *
- * @param documentHandle
- * The document's handle.
- * @param value
- * An object containing the new attributes of the document.
- * @param rev
- * the desired revision.
- * @param waitForSync
- * if set to true the response is returned when the server has
- * finished.
- * @return a DocumentEntity object
- * @throws ArangoException
- */
- public DocumentEntity replaceDocument(
- final String documentHandle,
- final T value,
- final String rev,
- final Boolean waitForSync) throws ArangoException {
- return documentDriver.replaceDocument(getDefaultDatabase(), documentHandle, value, rev, waitForSync);
- }
-
- /**
- * This method updates a document defined by documentKey.
- *
- * @param collectionName
- * The collection's name.
- * @param documentKey
- * The document's key.
- * @param value
- * An object containing the documents attributes
- * @return DocumentEntity>
- * @throws ArangoException
- */
- public DocumentEntity> updateDocument(final String collectionName, final String documentKey, final Object value)
- throws ArangoException {
- return updateDocument(createDocumentHandle(collectionName, documentKey), value, null, null, null);
- }
-
- /**
- * This method updates a document defined by documentHandle.
- *
- * @param documentHandle
- * The document's handle.
- * @param value
- * An object containing the documents attributes
- * @return DocumentEntity>
- * @throws ArangoException
- */
- public DocumentEntity updateDocument(final String documentHandle, final T value) throws ArangoException {
- return documentDriver.updateDocument(getDefaultDatabase(), documentHandle, value, null, null, null);
- }
-
- /**
- * This method updates a document defined by documentKey.
- *
- * @param collectionName
- * The collection name.
- * @param documentKey
- * The document key.
- * @param value
- * An object containing the documents attributes
- * @param keepNull
- * If true null values are kept.
- * @return DocumentEntity>
- * @throws ArangoException
- */
- public DocumentEntity> updateDocument(
- final String collectionName,
- final String documentKey,
- final Object value,
- final Boolean keepNull) throws ArangoException {
- return updateDocument(createDocumentHandle(collectionName, documentKey), value, null, null, keepNull);
- }
-
- /**
- * This method updates a document defined by documentKey.
- *
- * @param documentHandle
- * The document handle.
- * @param value
- * An object containing the documents attributes
- * @param keepNull
- * If true null values are kept.
- * @return DocumentEntity>
- * @throws ArangoException
- */
- public DocumentEntity updateDocument(final String documentHandle, final T value, final Boolean keepNull)
- throws ArangoException {
- return documentDriver.updateDocument(getDefaultDatabase(), documentHandle, value, null, null, keepNull);
- }
-
- /**
- * This method updates a document defined by documentKey. This method offers
- * a parameter rev (revision). If the revision of the document on the server
- * does not match the given revision an error is thrown.
- *
- * @param collectionName
- * The collection name.
- * @param documentKey
- * The document key.
- * @param value
- * An object containing the documents attributes
- * @param rev
- * The desired revision
- * @param waitForSync
- * if set to true the response is returned when the server has
- * finished.
- * @param keepNull
- * If true null values are kept.
- * @return a DocumentEntity object
- * @throws ArangoException
- */
- public DocumentEntity> updateDocument(
- final String collectionName,
- final String documentKey,
- final Object value,
- final String rev,
- final Boolean waitForSync,
- final Boolean keepNull) throws ArangoException {
- return updateDocument(createDocumentHandle(collectionName, documentKey), value, rev, waitForSync, keepNull);
- }
-
- /**
- * This method updates a document defined by documentHandle. This method
- * offers a parameter rev (revision). If the revision of the document on the
- * server does not match the given revision an error is thrown.
- *
- * @param documentHandle
- * The document handle.
- * @param value
- * An object containing the documents attributes
- * @param rev
- * The desired revision
- * @param waitForSync
- * if set to true the response is returned when the server has
- * finished.
- * @param keepNull
- * If true null values are kept.
- * @return DocumentEntity>
- * @throws ArangoException
- */
- public DocumentEntity updateDocument(
- final String documentHandle,
- final T value,
- final String rev,
- final Boolean waitForSync,
- final Boolean keepNull) throws ArangoException {
- return documentDriver.updateDocument(getDefaultDatabase(), documentHandle, value, rev, waitForSync, keepNull);
- }
-
- /**
- * This method returns all document handles from a collection.
- *
- * @param collectionName
- * The collection name.
- * @return List - The list of document handles
- * @throws ArangoException
- */
- public List getDocuments(final String collectionName) throws ArangoException {
- return documentDriver.getDocuments(getDefaultDatabase(), collectionName);
- }
-
- /**
- * The exists method determines whether a document exists given its
- * identifier. Instead of returning the found document or an error, this
- * method will return either true or false. It can thus be used for easy
- * existence checks.
- *
- * @param collectionName
- * The collection name.
- * @param documentKey
- * The document key
- * @return true, if the document exists
- * @throws ArangoException
- */
- public boolean exists(final String collectionName, final String documentKey) throws ArangoException {
- return exists(createDocumentHandle(collectionName, documentKey));
- }
-
- /**
- * The exists method determines whether a document exists given its
- * identifier. Instead of returning the found document or an error, this
- * method will return either true or false. It can thus be used for easy
- * existence checks.
- *
- * @param documentHandle
- * The document handle
- * @return true, if the document exists
- * @throws ArangoException
- */
- public boolean exists(final String documentHandle) throws ArangoException {
- try {
- documentDriver.checkDocument(getDefaultDatabase(), documentHandle);
- } catch (final ArangoException e) {
- if (e.getCode() == ErrorNums.ERROR_HTTP_NOT_FOUND) {
- return false;
- }
- throw e;
- }
- return true;
- }
-
- /**
- * This method returns the current revision of a document.
- *
- * @param collectionName
- * The collection name.
- * @param documentKey
- * The document key
- * @return the document revision number
- * @throws ArangoException
- */
- public String checkDocument(final String collectionName, final String documentKey) throws ArangoException {
- return checkDocument(createDocumentHandle(collectionName, documentKey));
- }
-
- /**
- * This method returns the current revision of a document.
- *
- * @param documentHandle
- * The document handle
- * @return the document revision number
- * @throws ArangoException
- */
- public String checkDocument(final String documentHandle) throws ArangoException {
- return documentDriver.checkDocument(getDefaultDatabase(), documentHandle);
- }
-
- /**
- * Returns a document entity.
- *
- * @param collectionName
- * The collection name.
- * @param documentKey
- * The document key
- * @param clazz
- * The expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @return a DocumentEntity object
- * @throws ArangoException
- */
- public DocumentEntity getDocument(
- final String collectionName,
- final String documentKey,
- final Class clazz) throws ArangoException {
- return getDocument(createDocumentHandle(collectionName, documentKey), clazz);
- }
-
- /**
- * Returns a document entity.
- *
- * @param documentHandle
- * The document handle
- * @param clazz
- * The expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @return a DocumentEntity object
- * @throws ArangoException
- */
- public DocumentEntity getDocument(final String documentHandle, final Class clazz) throws ArangoException {
- return documentDriver.getDocument(getDefaultDatabase(), documentHandle, clazz, null, null);
- }
-
- /**
- * Returns a document entity. Note that the *ifNoneMatchRevision* and
- * *ifMatchRevision* can not be used at the same time, one of these two has
- * to be null.
- *
- * @param documentHandle
- * The document handle
- * @param clazz
- * The expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @param ifNoneMatchRevision
- * if set the document is only returned id it has a different
- * revision.
- * @param ifMatchRevision
- * if set the document is only returned id it has the same
- * revision.
- * @return a DocumentEntity object
- * @throws ArangoException
- */
- public DocumentEntity getDocument(
- final String documentHandle,
- final Class clazz,
- final String ifNoneMatchRevision,
- final String ifMatchRevision) throws ArangoException {
- return documentDriver.getDocument(getDefaultDatabase(), documentHandle, clazz, ifNoneMatchRevision,
- ifMatchRevision);
- }
-
- /**
- * Deletes a document from the database.
- *
- * @param collectionName
- * The collection name.
- * @param documentKey
- * The document key.
- * @return a DocumentEntity object
- * @throws ArangoException
- */
- public DocumentEntity> deleteDocument(final String collectionName, final String documentKey)
- throws ArangoException {
- return deleteDocument(createDocumentHandle(collectionName, documentKey));
- }
-
- /**
- * Deletes a document from the database.
- *
- * @param documentHandle
- * The document handle.
- * @return a DocumentEntity object
- * @throws ArangoException
- */
- public DocumentEntity> deleteDocument(final String documentHandle) throws ArangoException {
- return documentDriver.deleteDocument(getDefaultDatabase(), documentHandle, null);
- }
-
- /**
- * Deletes a document from the database. This method offers a parameter rev
- * (revision). If the revision of the document on the server does not match
- * the given revision an error is thrown.
- *
- * @param collectionName
- * The collection name.
- * @param documentKey
- * The document key.
- * @param rev
- * The desired revision
- * @return a DocumentEntity object
- * @throws ArangoException
- */
- public DocumentEntity> deleteDocument(final String collectionName, final String documentKey, final String rev)
- throws ArangoException {
- return deleteDocument(createDocumentHandle(collectionName, documentKey), rev);
- }
-
- /**
- * This method validates a given AQL query string and returns a CursorEntity
- *
- * @param query
- * an AQL query as string
- * @return a CursorEntity object
- * @throws ArangoException
- */
- public CursorEntity> validateQuery(final String query) throws ArangoException {
- return cursorDriver.validateQuery(getDefaultDatabase(), query);
- }
-
- /**
- * Continues data retrieval for an existing cursor
- *
- * @param cursorId
- * The id of a cursor.
- * @param clazz
- * the expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @return a CursorEntity object
- * @throws ArangoException
- */
- public CursorEntity continueQuery(final long cursorId, final Class>... clazz) throws ArangoException {
- return cursorDriver.continueQuery(getDefaultDatabase(), cursorId, clazz);
- }
-
- /**
- * Deletes a cursor from the database.
- *
- * @param cursorId
- * The id of a cursor.
- * @return a DefaultEntity object
- * @throws ArangoException
- */
- public DefaultEntity finishQuery(final long cursorId) throws ArangoException {
- return cursorDriver.finishQuery(getDefaultDatabase(), cursorId);
- }
-
- /**
- * This method executes an AQL query and returns a CursorEntity.
- *
- * @param query
- * an AQL query as string
- * @param bindVars
- * a map containing all bind variables,
- * @param clazz
- * the expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @param calcCount
- * if set to true the result count is returned
- * @param batchSize
- * the batch size of the result cursor (The batch size has to be
- * greater than 0)
- * @param fullCount
- * if set to true, then all results before the final LIMIT will
- * be counted
- * @return a CursorEntity object
- * @throws ArangoException
- */
- public CursorEntity executeCursorEntityQuery(
- final String query,
- final Map bindVars,
- final Boolean calcCount,
- final Integer batchSize,
- final Boolean fullCount,
- final Class>... clazz) throws ArangoException {
-
- final AqlQueryOptions aqlQueryOptions = new AqlQueryOptions().setCount(calcCount).setBatchSize(batchSize)
- .setFullCount(fullCount);
-
- return cursorDriver.executeCursorEntityQuery(getDefaultDatabase(), query, bindVars, aqlQueryOptions, clazz);
- }
-
- /**
- * Creates a default AqlQueryOptions object
- *
- * @return default AqlQueryOptions object
- */
- public AqlQueryOptions getDefaultAqlQueryOptions() {
- return new AqlQueryOptions().setBatchSize(configure.getBatchSize()).setCount(false).setFullCount(false);
- }
-
- /**
- * This method executes an AQL query and returns a DocumentCursor
- *
- * @param query
- * an AQL query as string
- * @param bindVars
- * a map containing all bind variables,
- * @param aqlQueryOptions
- * AQL query options (null for default values)
- * @param clazz
- * the expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @return DocumentCursor
- * @throws ArangoException
- */
- public DocumentCursor executeDocumentQuery(
- final String query,
- final Map bindVars,
- final AqlQueryOptions aqlQueryOptions,
- final Class clazz) throws ArangoException {
-
- @SuppressWarnings("unchecked")
- final DocumentCursorResult> baseCursor = cursorDriver.executeBaseCursorQuery(
- getDefaultDatabase(), query, bindVars, getAqlQueryOptions(aqlQueryOptions), DocumentEntity.class, clazz);
- return new DocumentCursor(baseCursor);
- }
-
- /**
- * This method executes an AQL query and returns a CursorResult
- *
- * @param query
- * an AQL query as string
- * @param bindVars
- * a map containing all bind variables,
- * @param aqlQueryOptions
- * AQL query options
- * @param clazz
- * the expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @return CursorResult
- * @throws ArangoException
- */
- public CursorResult executeAqlQuery(
- final String query,
- final Map bindVars,
- final AqlQueryOptions aqlQueryOptions,
- final Class clazz) throws ArangoException {
-
- return cursorDriver.executeAqlQuery(getDefaultDatabase(), query, bindVars, getAqlQueryOptions(aqlQueryOptions),
- clazz);
- }
-
- /**
- * Executes an AQL query and returns the raw JSON response
- *
- * @param query
- * an AQL query as string
- * @param bindVars
- * a map containing all bind variables,
- * @param aqlQueryOptions
- * AQL query options
- * @return A JSON string with the results from server
- * @throws ArangoException
- */
- public String executeAqlQueryJSON(
- final String query,
- final Map bindVars,
- final AqlQueryOptions aqlQueryOptions) throws ArangoException {
-
- return cursorDriver.executeAqlQueryJSON(getDefaultDatabase(), query, bindVars,
- getAqlQueryOptions(aqlQueryOptions));
- }
-
- /**
- * This method executes an AQL query and returns a DocumentCursorResult
- *
- * @param query
- * an AQL query as string
- * @param bindVars
- * a map containing all bind variables,
- * @param aqlQueryOptions
- * AQL query options
- * @param classDocumentEntity
- * the class the expected class is wrapped in (the class has to
- * extend DocumentEntity)
- * @param clazz
- * the expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @return DocumentCursorResult
- * @throws ArangoException
- */
- public > DocumentCursorResult executeAqlQueryWithDocumentCursorResult(
- final String query,
- final Map bindVars,
- final AqlQueryOptions aqlQueryOptions,
- final Class classDocumentEntity,
- final Class clazz) throws ArangoException {
-
- return cursorDriver.executeBaseCursorQuery(getDefaultDatabase(), query, bindVars,
- getAqlQueryOptions(aqlQueryOptions), classDocumentEntity, clazz);
- }
-
- /**
- * This method creates an index for a collection.
- *
- * @param collectionName
- * The collection name.
- * @param type
- * the index type.
- * @param unique
- * if set to true the index will be a unique index
- * @param fields
- * the fields (document attributes) the index is created on
- * @return IndexEntity
- * @throws ArangoException
- */
- public IndexEntity createIndex(
- final String collectionName,
- final IndexType type,
- final boolean unique,
- final String... fields) throws ArangoException {
- return indexDriver.createIndex(getDefaultDatabase(), collectionName, type, unique, fields);
- }
-
- /**
- * This method creates an index for a collection.
- *
- * @param collectionName
- * The collection name.
- * @param type
- * the index type.
- * @param unique
- * if set to true the index will be a unique index
- * @param sparse
- * if set to true the index will be sparse
- * @param fields
- * the fields (document attributes) the index is created on
- * @return IndexEntity
- * @throws ArangoException
- */
- public IndexEntity createIndex(
- final String collectionName,
- final IndexType type,
- final boolean unique,
- final boolean sparse,
- final String... fields) throws ArangoException {
- return indexDriver.createIndex(getDefaultDatabase(), collectionName, type, unique, sparse, fields);
- }
-
- /**
- * This method creates a hash index for a collection.
- *
- * @param collectionName
- * The collection name.
- * @param unique
- * if set to true the index will be a unique index
- * @param fields
- * the fields (document attributes) the index is created on
- * @return IndexEntity
- * @throws ArangoException
- */
- public IndexEntity createHashIndex(final String collectionName, final boolean unique, final String... fields)
- throws ArangoException {
- return indexDriver.createIndex(getDefaultDatabase(), collectionName, IndexType.HASH, unique, fields);
- }
-
- /**
- * This method creates a hash index for a collection.
- *
- * @param collectionName
- * The collection name.
- * @param unique
- * if set to true the index will be a unique index
- * @param sparse
- * if set to true the index will be sparse
- * @param fields
- * the fields (document attributes) the index is created on
- * @return IndexEntity
- * @throws ArangoException
- */
- public IndexEntity createHashIndex(
- final String collectionName,
- final boolean unique,
- final boolean sparse,
- final String... fields) throws ArangoException {
- return indexDriver.createIndex(getDefaultDatabase(), collectionName, IndexType.HASH, unique, sparse, fields);
- }
-
- /**
- * This method creates a geo index for a collection.
- *
- * @param collectionName
- * The collection name.
- * @param unique
- * if set to true the index will be a unique index
- * @param fields
- * the fields (document attributes) the index is created on
- * @return IndexEntity
- * @throws ArangoException
- */
- public IndexEntity createGeoIndex(final String collectionName, final boolean unique, final String... fields)
- throws ArangoException {
- return indexDriver.createIndex(getDefaultDatabase(), collectionName, IndexType.GEO, unique, fields);
- }
-
- /**
- * This method creates a skip list index for a collection.
- *
- * @param collectionName
- * The collection name.
- * @param unique
- * if set to true the index will be a unique index
- * @param fields
- * the fields (document attributes) the index is created on
- * @return IndexEntity
- * @throws ArangoException
- */
- public IndexEntity createSkipListIndex(final String collectionName, final boolean unique, final String... fields)
- throws ArangoException {
- return indexDriver.createIndex(getDefaultDatabase(), collectionName, IndexType.SKIPLIST, unique, fields);
- }
-
- /**
- * This method creates a skip list index for a collection.
- *
- * @param collectionName
- * The collection name.
- * @param unique
- * if set to true the index will be a unique index
- * @param sparse
- * if set to true the index will be sparse
- * @param fields
- * the fields (document attributes) the index is created on
- * @return IndexEntity
- * @throws ArangoException
- */
- public IndexEntity createSkipListIndex(
- final String collectionName,
- final boolean unique,
- final boolean sparse,
- final String... fields) throws ArangoException {
- return indexDriver.createIndex(getDefaultDatabase(), collectionName, IndexType.SKIPLIST, unique, sparse,
- fields);
- }
-
- /**
- * It is possible to define a persistent index on one or more attributes (or
- * paths) of documents. The index is then used in queries to locate
- * documents within a given range. If the index is declared unique, then no
- * two documents are allowed to have the same set of attribute values.
- *
- * @param collectionName
- * The collection name.
- * @param unique
- * if set to true the index will be a unique index
- * @param sparse
- * if set to true the index will be sparse
- * @param fields
- * the fields (document attributes) the index is created on
- * @return IndexEntity
- * @throws ArangoException
- */
- public IndexEntity createPersistentIndex(
- final String collectionName,
- final boolean unique,
- final boolean sparse,
- final String... fields) throws ArangoException {
- return indexDriver.createIndex(getDefaultDatabase(), collectionName, IndexType.PERSISTENT, unique, sparse,
- fields);
- }
-
- /**
- * This method creates a full text index for a collection.
- *
- * @param collectionName
- * The collection name.
- * @param fields
- * the fields (document attributes) the index is created on
- * @return IndexEntity
- * @throws ArangoException
- */
- public IndexEntity createFulltextIndex(final String collectionName, final String... fields) throws ArangoException {
- return createFulltextIndex(collectionName, null, fields);
- }
-
- /**
- * This method creates a full text index for a collection.
- *
- * @param collectionName
- * The collection name.
- * @param minLength
- * Minimum character length of words to index.
- * @param fields
- * the fields (document attributes) the index is created on
- * @return IndexEntity
- * @throws ArangoException
- */
- public IndexEntity createFulltextIndex(final String collectionName, final Integer minLength, final String... fields)
- throws ArangoException {
- return indexDriver.createFulltextIndex(getDefaultDatabase(), collectionName, minLength, fields);
- }
-
- /**
- * Deletes an index from a collection
- *
- * @param indexHandle
- * the index handle
- * @return IndexEntity
- * @throws ArangoException
- */
- public IndexEntity deleteIndex(final String indexHandle) throws ArangoException {
- return indexDriver.deleteIndex(getDefaultDatabase(), indexHandle);
- }
-
- /**
- * Returns an index from a collection.
- *
- * @param indexHandle
- * the index handle
- * @return IndexEntity
- * @throws ArangoException
- */
- public IndexEntity getIndex(final String indexHandle) throws ArangoException {
- return indexDriver.getIndex(getDefaultDatabase(), indexHandle);
- }
-
- /**
- * Returns all indices from a collection.
- *
- * @param collectionName
- * The collection name.
- * @return IndexesEntity
- * @throws ArangoException
- */
- public IndexesEntity getIndexes(final String collectionName) throws ArangoException {
- return indexDriver.getIndexes(getDefaultDatabase(), collectionName);
- }
-
- /**
- * Returns the server log, for the parameters *logLevel* and *logLevelUpTo*
- * please note the following: fatal or 0 error or 1 warning or 2 info or 3
- * debug or 4 The default value is info.
- *
- * @param logLevel
- * if set only logs with this *logLevel* are returned
- * @param logLevelUpTo
- * if set all logs up to the *logLevelUpTo* are returned
- * @param start
- * Returns all log entries such that their log entry identifier
- * (lid value) is greater or equal to start.
- * @param size
- * Restricts the result to at most size log entries.
- * @param offset
- * Starts to return log entries skipping the first offset log
- * entries.
- * @param sortAsc
- * if set to true the default sort order (descending) is reverted
- * to ascending
- * @param text
- * Only return the log entries containing the text specified in
- * text.
- * @return a AdminLogEntity object
- * @throws ArangoException
- */
- public AdminLogEntity getServerLog(
- final Integer logLevel,
- final Boolean logLevelUpTo,
- final Integer start,
- final Integer size,
- final Integer offset,
- final Boolean sortAsc,
- final String text) throws ArangoException {
- return adminDriver.getServerLog(logLevel, logLevelUpTo, start, size, offset, sortAsc, text);
- }
-
- /**
- * Returns the current statistics
- *
- * @return StatisticsEntity
- * @throws ArangoException
- */
- public StatisticsEntity getStatistics() throws ArangoException {
- return adminDriver.getStatistics();
- }
-
- /**
- * Returns the statistics description
- *
- * @return StatisticsDescriptionEntity
- * @throws ArangoException
- */
- public StatisticsDescriptionEntity getStatisticsDescription() throws ArangoException {
- return adminDriver.getStatisticsDescription();
- }
-
- /**
- * Returns the database version
- *
- * @return ArangoVersion
- * @throws ArangoException
- */
- public ArangoVersion getVersion() throws ArangoException {
- return adminDriver.getVersion();
- }
-
- /**
- * Returns the current server time
- *
- * @return ArangoUnixTime
- * @throws ArangoException
- */
- public ArangoUnixTime getTime() throws ArangoException {
- return adminDriver.getTime();
- }
-
- /**
- * Triggers the routes reloading in ArangoDB
- *
- * @return DefaultEntity
- * @throws ArangoException
- */
- public DefaultEntity reloadRouting() throws ArangoException {
- return adminDriver.reloadRouting();
- }
-
- /**
- * Executes a javascript code.
- *
- * @param jsCode
- * a javascript function as string
- * @return DefaultEntity
- * @throws ArangoException
- */
- public DefaultEntity executeScript(final String jsCode) throws ArangoException {
- return adminDriver.executeScript(getDefaultDatabase(), jsCode);
- }
-
- /**
- * This will find all documents matching a given example.
- *
- * @param collectionName
- * - The collection name.
- * @param example
- * The example as a map.
- * @param skip
- * The number of documents to skip in the query.
- * @param limit
- * The maximal amount of documents to return. The skip is applied
- * before the limit restriction.
- * @param clazz
- * the expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @return DocumentCursor
- * @throws ArangoException
- */
- public DocumentCursor executeSimpleByExampleDocuments(
- final String collectionName,
- final Map example,
- final int skip,
- final int limit,
- final Class clazz) throws ArangoException {
- return simpleDriver.executeSimpleByExampleDocuments(getDefaultDatabase(), collectionName, example, skip, limit,
- clazz);
- }
-
- /**
- * Returns all documents of a collections.
- *
- * @param collectionName
- * The collection name.
- * @param skip
- * The number of documents to skip in the query.
- * @param limit
- * The maximal amount of documents to return. The skip is applied
- * before the limit restriction.
- * @param clazz
- * the expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @return DocumentCursor
- * @throws ArangoException
- */
- public DocumentCursor executeSimpleAllDocuments(
- final String collectionName,
- final int skip,
- final int limit,
- final Class clazz) throws ArangoException {
- return simpleDriver.executeSimpleAllDocuments(getDefaultDatabase(), collectionName, skip, limit, clazz);
- }
-
- /**
- * Returns the first document matching the example
- *
- * @param collectionName
- * The collection name.
- * @param example
- * The example as a map.
- * @param clazz
- * the expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @return a ScalarExampleEntity object
- * @throws ArangoException
- */
- public ScalarExampleEntity executeSimpleFirstExample(
- final String collectionName,
- final Map example,
- final Class clazz) throws ArangoException {
- return simpleDriver.executeSimpleFirstExample(getDefaultDatabase(), collectionName, example, clazz);
- }
-
- /**
- * Returns a random document from the collection
- *
- * @param collectionName
- * The collection name.
- * @param clazz
- * the expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @return a ScalarExampleEntity object
- * @throws ArangoException
- */
- public ScalarExampleEntity executeSimpleAny(final String collectionName, final Class clazz)
- throws ArangoException {
- return simpleDriver.executeSimpleAny(getDefaultDatabase(), collectionName, clazz);
- }
-
- /**
- * This will find all documents within a given range.
- *
- * @param collectionName
- * The collection name.
- * @param attribute
- * The attribute path to check.
- * @param left
- * The lower bound
- * @param right
- * The upper bound
- * @param closed
- * If true, use interval including left and right, otherwise
- * exclude right, but include left.
- * @param skip
- * The number of documents to skip in the query.
- * @param limit
- * The maximal amount of documents to return. The skip is applied
- * before the limit restriction.
- * @param clazz
- * the expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @return DocumentCursor
- * @throws ArangoException
- */
- public DocumentCursor executeSimpleRangeWithDocuments(
- final String collectionName,
- final String attribute,
- final Object left,
- final Object right,
- final Boolean closed,
- final int skip,
- final int limit,
- final Class clazz) throws ArangoException {
- return simpleDriver.executeSimpleRangeWithDocuments(getDefaultDatabase(), collectionName, attribute, left,
- right, closed, skip, limit, clazz);
- }
-
- /**
- * This will find all documents from the collection that match the fulltext
- * query specified in query. In order to use the fulltext operator, a
- * fulltext index must be defined for the collection and the specified
- * attribute.
- *
- * @param collectionName
- * The collection name.
- * @param attribute
- * The attribute path to check.
- * @param query
- * The fulltext query as string.
- * @param skip
- * The number of documents to skip in the query.
- * @param limit
- * The maximal amount of documents to return. The skip is applied
- * before the limit restriction.
- * @param clazz
- * the expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @return DocumentCursor
- * @throws ArangoException
- */
- public DocumentCursor executeSimpleFulltextWithDocuments(
- final String collectionName,
- final String attribute,
- final String query,
- final int skip,
- final int limit,
- final String index,
- final Class clazz) throws ArangoException {
- return simpleDriver.executeSimpleFulltextWithDocuments(getDefaultDatabase(), collectionName, attribute, query,
- skip, limit, index, clazz);
- }
-
- /**
- * This will remove all documents in the collection that match the specified
- * example object.
- *
- * @param collectionName
- * The collection name.
- * @param example
- * The example as a map.
- * @param waitForSync
- * if set to true the response is returned when the server has
- * finished.
- * @param limit
- * limits the amount of documents which will be deleted.
- * @return SimpleByResultEntity
- * @throws ArangoException
- */
- public SimpleByResultEntity executeSimpleRemoveByExample(
- final String collectionName,
- final Map example,
- final Boolean waitForSync,
- final Integer limit) throws ArangoException {
- return simpleDriver.executeSimpleRemoveByExample(getDefaultDatabase(), collectionName, example, waitForSync,
- limit);
- }
-
- /**
- * This will replace all documents in the collection that match the
- * specified example object.
- *
- * @param collectionName
- * The collection name.
- * @param example
- * The example as a map.
- * @param newValue
- * The new values.
- * @param waitForSync
- * if set to true the response is returned when the server has
- * finished.
- * @param limit
- * limits the amount of documents which will be replaced.
- * @return SimpleByResultEntity
- * @throws ArangoException
- */
- public SimpleByResultEntity executeSimpleReplaceByExample(
- final String collectionName,
- final Map example,
- final Map newValue,
- final Boolean waitForSync,
- final Integer limit) throws ArangoException {
- return simpleDriver.executeSimpleReplaceByExample(getDefaultDatabase(), collectionName, example, newValue,
- waitForSync, limit);
- }
-
- /**
- * This will update all documents in the collection that match the specified
- * example object.
- *
- * @param collectionName
- * The collection name.
- * @param example
- * The example as a map.
- * @param newValue
- * The new values.
- * @param keepNull
- * - If true null values are kept.
- * @param waitForSync
- * if set to true the response is returned when the server has
- * finished.
- * @param limit
- * limits the amount of documents which will be updated.
- * @return SimpleByResultEntity
- * @throws ArangoException
- */
- public SimpleByResultEntity executeSimpleUpdateByExample(
- final String collectionName,
- final Map example,
- final Map newValue,
- final Boolean keepNull,
- final Boolean waitForSync,
- final Integer limit) throws ArangoException {
- return simpleDriver.executeSimpleUpdateByExample(getDefaultDatabase(), collectionName, example, newValue,
- keepNull, waitForSync, limit);
- }
-
- /**
- * Creates a database user.
- *
- * @param username
- * the username as string
- * @param passwd
- * the password as string
- * @param active
- * if true the user is active
- * @param extra
- * additional user data
- * @return DefaultEntity
- * @throws ArangoException
- */
- public DefaultEntity createUser(
- final String username,
- final String passwd,
- final Boolean active,
- final Map extra) throws ArangoException {
- return usersDriver.createUser(username, passwd, active, extra);
- }
-
- /**
- * Replaces the data of a database user.
- *
- * @param username
- * the username as string
- * @param passwd
- * the password as string
- * @param active
- * if true the user is active
- * @param extra
- * additional user data
- * @return DefaultEntity
- * @throws ArangoException
- */
- public DefaultEntity replaceUser(
- final String username,
- final String passwd,
- final Boolean active,
- final Map extra) throws ArangoException {
- return usersDriver.replaceUser(username, passwd, active, extra);
- }
-
- /**
- * Updates the data of a database user.
- *
- * @param username
- * the username as string
- * @param passwd
- * the password as string
- * @param active
- * if true the user is active
- * @param extra
- * additional user data
- * @return DefaultEntity
- * @throws ArangoException
- */
- public DefaultEntity updateUser(
- final String username,
- final String passwd,
- final Boolean active,
- final Map extra) throws ArangoException {
- return usersDriver.updateUser(username, passwd, active, extra);
- }
-
- /**
- * Deletes a database user.
- *
- * @param username
- * the username as string
- * @return DefaultEntity
- * @throws ArangoException
- */
- public DefaultEntity deleteUser(final String username) throws ArangoException {
- return usersDriver.deleteUser(username);
- }
-
- /**
- * Returns a database user.
- *
- * @param username
- * the username as string
- * @return UserEntity
- * @throws ArangoException
- */
- public UserEntity getUser(final String username) throws ArangoException {
- return usersDriver.getUser(username);
- }
-
- /**
- * Grants the User access to the given database.
- *
- * @param username
- * the username as string
- * @param database
- * @return a DefaultEntity object
- * @throws ArangoException
- */
- public DefaultEntity grantDatabaseAccess(final String username, final String database) throws ArangoException {
- return usersDriver.grantDatabaseAccess(username, database);
- }
-
- /**
- * Returns all database user as document.
- *
- * @return List>
- * @throws ArangoException
- */
- public List> getUsersDocument() throws ArangoException {
- final DocumentCursor documentCursor = simpleDriver.executeSimpleAllDocuments(DATABASE_SYSTEM,
- COLLECTION_USERS, 0, 0, UserEntity.class);
- return documentCursor.asList();
- }
-
- /**
- * Returns all database user.
- *
- * @return List
- * @throws ArangoException
- */
- public List getUsers() throws ArangoException {
- final DocumentCursor documentCursor = simpleDriver.executeSimpleAllDocuments(DATABASE_SYSTEM,
- COLLECTION_USERS, 0, 0, UserEntity.class);
- return documentCursor.asEntityList();
- }
-
- /**
- * Creates documents in a collection.
- *
- * @param collection
- * the collection as a string
- * @param values
- * a list of Objects that will be stored as documents
- * @return ImportResultEntity
- * @throws ArangoException
- */
- public ImportResultEntity importDocuments(final String collection, final Collection> values)
- throws ArangoException {
- return importDriver.importDocuments(getDefaultDatabase(), collection, values, new ImportOptionsJson());
- }
-
- /**
- * Creates documents in a collection.
- *
- * @param collection
- * the collection as a string
- * @param values
- * a list of Objects that will be stored as documents
- * @param importOptionsJson
- * options for importing documents
- * @return ImportResultEntity
- * @throws ArangoException
- */
- public ImportResultEntity importDocuments(
- final String collection,
- final Collection> values,
- final ImportOptionsJson importOptionsJson) throws ArangoException {
- return importDriver.importDocuments(getDefaultDatabase(), collection, values, importOptionsJson);
- }
-
- /**
- * Creates documents in a collection.
- *
- * @param collection
- * the collection as a string
- * @param values
- * a raw string containing JSON data
- * @param importOptions
- * options for importing documents
- * @return ImportResultEntity
- * @throws ArangoException
- */
- public ImportResultEntity importDocumentsRaw(
- final String collection,
- final String values,
- final ImportOptionsRaw importOptionsRaw) throws ArangoException {
- return importDriver.importDocumentsRaw(getDefaultDatabase(), collection, values, importOptionsRaw);
- }
-
- /**
- * Creates documents in a collection.
- *
- * @param collection
- * the collection as a string
- * @param headerValues
- * a list of lists that will be stored as documents
- * @return ImportResultEntity
- * @throws ArangoException
- */
- public ImportResultEntity importDocumentsByHeaderValues(
- final String collection,
- final Collection extends Collection>> headerValues) throws ArangoException {
- return importDriver.importDocumentsByHeaderValues(getDefaultDatabase(), collection, headerValues,
- new ImportOptions());
- }
-
- /**
- * Creates documents in a collection.
- *
- * @param collection
- * the collection as a string
- * @param headerValues
- * a list of lists that will be stored as documents
- * @param importOptions
- * options for importing documents
- * @return ImportResultEntity
- * @throws ArangoException
- */
- public ImportResultEntity importDocumentsByHeaderValues(
- final String collection,
- final Collection extends Collection>> headerValues,
- final ImportOptions importOptions) throws ArangoException {
- return importDriver.importDocumentsByHeaderValues(getDefaultDatabase(), collection, headerValues,
- importOptions);
- }
-
- /**
- * Creates documents in a collection.
- *
- * @param collection
- * the collection as a string
- * @param headerValues
- * raw JSON data that contains a list of lists that will be
- * stored as documents
- * @param importOptions
- * options for importing documents
- * @return ImportResultEntity
- * @throws ArangoException
- */
- public ImportResultEntity importDocumentsByHeaderValuesRaw(
- final String collection,
- final String headerValues,
- final ImportOptions importOptions) throws ArangoException {
- return importDriver.importDocumentsByHeaderValuesRaw(getDefaultDatabase(), collection, headerValues,
- importOptions);
- }
-
- /**
- * Returns the current database
- *
- * @return DatabaseEntity
- * @throws ArangoException
- */
- public DatabaseEntity getCurrentDatabase() throws ArangoException {
- return databaseDriver.getCurrentDatabase();
- }
-
- /**
- * Returns all databases
- *
- * @return StringsResultEntity
- * @throws ArangoException
- */
- public StringsResultEntity getDatabases() throws ArangoException {
- return getDatabases(false);
- }
-
- /**
- * Returns all databases
- *
- * @param currentUserAccessableOnly
- * If true only the databases are returned that the current user
- * can access
- * @return StringsResultEntity
- * @throws ArangoException
- */
- public StringsResultEntity getDatabases(final boolean currentUserAccessableOnly) throws ArangoException {
- return databaseDriver.getDatabases(currentUserAccessableOnly, null, null);
- }
-
- /**
- * Returns all databases the user identified by his credentials can access
- *
- * @param username
- * the username as string
- * @param password
- * the password as string
- * @return StringsResultEntity
- * @throws ArangoException
- */
- public StringsResultEntity getDatabases(final String username, final String password) throws ArangoException {
- return databaseDriver.getDatabases(true, username, password);
- }
-
- /**
- * This method creates a database
- *
- * @param database
- * the database name as a string
- * @param users
- * a list of users which are supposed to have access to the
- * database
- * @return BooleanResultEntity
- * @throws ArangoException
- */
- public BooleanResultEntity createDatabase(final String database, final UserEntity... users) throws ArangoException {
- return databaseDriver.createDatabase(database, users);
- }
-
- /**
- * This method deletes a database
- *
- * @param database
- * the database name as a string
- * @return BooleanResultEntity
- * @throws ArangoException
- */
- public BooleanResultEntity deleteDatabase(final String database) throws ArangoException {
- return databaseDriver.deleteDatabase(database);
- }
-
- /**
- * This method creates an endpoint.
- *
- * @param endpoint
- * the endpoint as string
- * @param databases
- * a list of databases that are allowed on this endpoint
- * @return BooleanResultEntity
- */
- public BooleanResultEntity createEndpoint(final String endpoint, final String... databases) throws ArangoException {
- return endpointDriver.createEndpoint(endpoint, databases);
- }
-
- /**
- * This method returns all endpoints.
- *
- * @return List
- */
- public List getEndpoints() throws ArangoException {
- return endpointDriver.getEndpoints();
- }
-
- /**
- * This method deletes an endpoint
- *
- * @param endpoint
- * the endpoint as string
- * @return BooleanResultEntity
- */
- public BooleanResultEntity deleteEndpoint(final String endpoint) throws ArangoException {
- return endpointDriver.deleteEndpoint(endpoint);
- }
-
- /**
- * Returns the list of collections and indexes available on the server. This
- * list can be used by replication clients to initiate an initial sync with
- * the server.
- *
- * @return ReplicationInventoryEntity
- * @throws ArangoException
- */
- public ReplicationInventoryEntity getReplicationInventory() throws ArangoException {
- return replicationDriver.getReplicationInventory(getDefaultDatabase(), null);
- }
-
- /**
- * Returns the list of collections and indexes available on the server. This
- * list can be used by replication clients to initiate an initial sync with
- * the server.
- *
- * @param includeSystem
- * if true the system collections are included into the result
- * @return ReplicationInventoryEntity
- * @throws ArangoException
- */
- public ReplicationInventoryEntity getReplicationInventory(final boolean includeSystem) throws ArangoException {
- return replicationDriver.getReplicationInventory(getDefaultDatabase(), includeSystem);
- }
-
- /**
- * Returns the data from the collection for the requested range.
- *
- * @param collectionName
- * the collection name
- * @param from
- * Lower bound tick value for results.
- * @param to
- * Upper bound tick value for results.
- * @param chunkSize
- * Approximate maximum size of the returned result.
- * @param ticks
- * Whether or not to include tick values in the dump. Default
- * value is true.
- * @param clazz
- * the expected class, the result from the server request is
- * deserialized to an instance of this class.
- * @param handler
- * a handler object that processes the dump
- * @throws ArangoException
- */
- public void getReplicationDump(
- final String collectionName,
- final Long from,
- final Long to,
- final Integer chunkSize,
- final Boolean ticks,
- final Class clazz,
- final DumpHandler