diff --git a/ChangeLog.md b/ChangeLog.md
index a160ae4..1d86fa9 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -6,6 +6,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
## [Unreleased]
+### Fixed
+
+- custom serde not always used
+
+### Added
+
+- split `GraphDocumentReadOptions` from `DocumentReadOptions` (breaking change)
+- added `ArangoCollection#getResponsibleShard(Object)`
+- added support for Analyzers
+- added support for Stream Transactions
+- added support for named indices
+- added support for TTL indices
+- added minReplicationAttribute for collections and graphs
+
## [5.1.0] - 2019-28-08
### Fixed
diff --git a/pom.xml b/pom.xml
index c0e2cc1..9644803 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.arangodbarangodb-java-driver-async
- 5.1.0
+ 6.0.0-SNAPSHOT2016jar
@@ -22,11 +22,14 @@
UTF-8
- 1.1.3
+ 1.2.31.34.12
- 5.0.7
+ 6.1.01.1.0
+
+
+
@@ -76,7 +79,7 @@
org.sonatype.pluginsnexus-staging-maven-plugin
- 1.6.5
+ 1.6.8trueossrh
@@ -85,56 +88,27 @@
false
-
-
- org.apache.maven.plugins
- maven-assembly-plugin
- 2.4.1
-
-
- assembly
- package
-
- single
-
-
-
-
-
- ${project.artifactId}-${project.version}-standalone
-
- false
- false
-
- jar-with-dependencies
-
-
-
-
org.apache.maven.pluginsmaven-compiler-plugin
- 3.2
+ 3.8.11.81.8
-
-
org.apache.maven.pluginsmaven-resources-plugin
- 2.7
+ 3.1.0UTF-8
-
org.apache.maven.pluginsmaven-source-plugin
- 2.4
+ 3.1.0
@@ -147,7 +121,7 @@
org.apache.maven.pluginsmaven-javadoc-plugin
- 2.9.1
+ 3.1.1attach-javadocs
@@ -155,7 +129,7 @@
jar
- ${javadoc.opts}
+ ${javadoc.opts}com.arangodb.internal
@@ -164,7 +138,7 @@
maven-surefire-plugin
- 2.19.1
+ 2.22.2**/*Test.java
@@ -185,7 +159,7 @@
org.apache.maven.pluginsmaven-gpg-plugin
- 1.5
+ 1.6sign-artifacts
@@ -225,6 +199,12 @@
hamcrest-alltest
+
+ com.arangodb
+ jackson-dataformat-velocypack
+ 0.1.4
+ test
+
diff --git a/src/main/java/com/arangodb/ArangoCollectionAsync.java b/src/main/java/com/arangodb/ArangoCollectionAsync.java
index 136ee92..826f86e 100644
--- a/src/main/java/com/arangodb/ArangoCollectionAsync.java
+++ b/src/main/java/com/arangodb/ArangoCollectionAsync.java
@@ -23,30 +23,8 @@
import java.util.Collection;
import java.util.concurrent.CompletableFuture;
-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.DocumentImportEntity;
-import com.arangodb.entity.DocumentUpdateEntity;
-import com.arangodb.entity.IndexEntity;
-import com.arangodb.entity.MultiDocumentEntity;
-import com.arangodb.entity.Permissions;
-import com.arangodb.model.CollectionCreateOptions;
-import com.arangodb.model.CollectionPropertiesOptions;
-import com.arangodb.model.DocumentCreateOptions;
-import com.arangodb.model.DocumentDeleteOptions;
-import com.arangodb.model.DocumentExistsOptions;
-import com.arangodb.model.DocumentImportOptions;
-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.entity.*;
+import com.arangodb.model.*;
/**
* Interface for operations on ArangoDB collection level.
@@ -535,6 +513,17 @@ CompletableFuture ensureFulltextIndex(
final Iterable fields,
final FulltextIndexOptions options);
+ /**
+ * Creates a ttl index for the collection, if it does not already exist.
+ *
+ * @param fields A list of attribute paths
+ * @param options Additional options, can be null
+ * @return information about the index
+ * @see API
+ * Documentation
+ */
+ CompletableFuture ensureTtlIndex(Iterable fields, TtlIndexOptions options);
+
/**
* Returns all indexes of the collection
*
@@ -554,16 +543,25 @@ CompletableFuture ensureFulltextIndex(
/**
* Removes all documents from the collection, but leaves the indexes intact
- *
+ *
* @see API
* Documentation
* @return information about the collection
*/
CompletableFuture truncate();
+ /**
+ * Removes all documents from the collection, but leaves the indexes intact
+ *
+ * @see API
+ * Documentation
+ * @return information about the collection
+ */
+ CompletableFuture truncate(CollectionTruncateOptions options);
+
/**
* Counts the documents in a collection
- *
+ *
* @see API
* Documentation
@@ -571,6 +569,16 @@ CompletableFuture ensureFulltextIndex(
*/
CompletableFuture count();
+ /**
+ * Counts the documents in a collection
+ *
+ * @see API
+ * Documentation
+ * @return information about the collection, including the number of documents
+ */
+ CompletableFuture count(CollectionCountOptions options);
+
/**
* Creates the collection
*
@@ -676,6 +684,19 @@ CompletableFuture ensureFulltextIndex(
*/
CompletableFuture rename(final String newName);
+ /**
+ * Returns the responsible shard for the document.
+ * Please note that this API is only meaningful and available on a cluster coordinator.
+ *
+ * @param value A projection of the document containing at least the shard key (_key or a custom attribute) for
+ * which the responsible shard should be determined
+ * @return information about the responsible shard
+ * @see
+ * API Documentation
+ * @since ArangoDB 3.5.0
+ */
+ CompletableFuture getResponsibleShard(final Object value);
+
/**
* Retrieve the collections revision
*
diff --git a/src/main/java/com/arangodb/ArangoDatabaseAsync.java b/src/main/java/com/arangodb/ArangoDatabaseAsync.java
index 01a06b3..ab3a65a 100644
--- a/src/main/java/com/arangodb/ArangoDatabaseAsync.java
+++ b/src/main/java/com/arangodb/ArangoDatabaseAsync.java
@@ -24,706 +24,723 @@
import java.util.Map;
import java.util.concurrent.CompletableFuture;
-import com.arangodb.entity.AqlExecutionExplainEntity;
-import com.arangodb.entity.AqlFunctionEntity;
-import com.arangodb.entity.AqlParseEntity;
-import com.arangodb.entity.ArangoDBVersion;
-import com.arangodb.entity.CollectionEntity;
-import com.arangodb.entity.DatabaseEntity;
-import com.arangodb.entity.EdgeDefinition;
-import com.arangodb.entity.GraphEntity;
-import com.arangodb.entity.IndexEntity;
-import com.arangodb.entity.Permissions;
-import com.arangodb.entity.QueryCachePropertiesEntity;
-import com.arangodb.entity.QueryEntity;
-import com.arangodb.entity.QueryTrackingPropertiesEntity;
-import com.arangodb.entity.TraversalEntity;
-import com.arangodb.entity.ViewEntity;
-import com.arangodb.entity.ViewType;
-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.entity.*;
+import com.arangodb.entity.arangosearch.AnalyzerEntity;
+import com.arangodb.model.*;
+import com.arangodb.model.arangosearch.AnalyzerDeleteOptions;
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
/**
* Interface for operations on ArangoDB database level.
- *
+ *
+ * @author Mark Vollmary
* @see Databases API Documentation
* @see Query API Documentation
- * @author Mark Vollmary
*/
public interface ArangoDatabaseAsync extends ArangoSerializationAccessor {
- /**
- * Return the main entry point for the ArangoDB driver
- *
- * @return main entry point
- */
- ArangoDBAsync arango();
-
- /**
- * Returns the name of the database
- *
- * @return database name
- */
- String name();
-
- /**
- * Returns the server name and version number.
- *
- * @see API
- * Documentation
- * @return the server version, number
- */
- CompletableFuture getVersion();
-
- /**
- * Checks whether the database exists
- *
- * @return true if the database exists, otherwise false
- */
- CompletableFuture exists();
-
- /**
- * Retrieves a list of all databases the current user can access
- *
- * @see API
- * Documentation
- * @return a list of all databases the current user can access
- */
- CompletableFuture> getAccessibleDatabases();
-
- /**
- * Returns a handler of the collection by the given name
- *
- * @param name
- * Name of the collection
- * @return collection handler
- */
- ArangoCollectionAsync collection(final String name);
-
- /**
- * 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
- */
- CompletableFuture createCollection(final String name);
-
- /**
- * 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
- */
- CompletableFuture createCollection(final String name, final CollectionCreateOptions options);
-
- /**
- * Returns all collections
- *
- * @see API
- * Documentation
- * @return list of information about all collections
- */
- CompletableFuture> getCollections();
-
- /**
- * Returns all collections
- *
- * @see API
- * Documentation
- * @param options
- * Additional options, can be null
- * @return list of information about all collections
- */
- CompletableFuture> getCollections(final CollectionsReadOptions options);
-
- /**
- * Returns an index
- *
- * @see API Documentation
- * @param id
- * The index-handle
- * @return information about the index
- */
- CompletableFuture getIndex(final String id);
-
- /**
- * Deletes an index
- *
- * @see API Documentation
- * @param id
- * The index handle
- * @return the id of the index
- */
- CompletableFuture deleteIndex(final String id);
-
- /**
- * Creates the database
- *
- * @see API
- * Documentation
- * @return true if the database was created successfully.
- */
- CompletableFuture create();
-
- /**
- * Drop an existing database
- *
- * @see API
- * Documentation
- * @return true if the database was dropped successfully
- */
- CompletableFuture drop();
-
- /**
- * 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
- * @param permissions
- * The permissions the user grant
- * @return void
- */
- CompletableFuture grantAccess(final String user, final Permissions permissions);
-
- /**
- * 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
- * @return void
- */
- CompletableFuture grantAccess(final String user);
-
- /**
- * 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
- * @return void
- */
- CompletableFuture revokeAccess(final String user);
-
- /**
- * Clear the database access level, revert back to the default access level.
- *
- * @see
- * API Documentation
- * @param user
- * The name of the user
- * @since ArangoDB 3.2.0
- * @return void
- */
- CompletableFuture resetAccess(final String user);
-
- /**
- * Sets the default access level for collections within this database for the user user. You need
- * permission to the _system database in order to execute this call.
- *
- * @param user
- * The name of the user
- * @param permissions
- * The permissions the user grant
- * @since ArangoDB 3.2.0
- */
- CompletableFuture grantDefaultCollectionAccess(final String user, final Permissions permissions);
-
- /**
- * Get specific database access level
- *
- * @see API
- * Documentation
- * @param user
- * The name of the user
- * @return permissions of the user
- * @since ArangoDB 3.2.0
- */
- CompletableFuture getPermissions(final String user);
-
- /**
- * Performs a database query using the given {@code query} and {@code bindVars}, then returns a new
- * {@code ArangoCursor} instance for the result list.
- *
- * @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
- */
- CompletableFuture> query(
- final String query,
- final Map bindVars,
- final AqlQueryOptions options,
- final Class type);
-
- /**
- * Performs a database query using the given {@code query}, then returns a new {@code ArangoCursor} instance for the
- * result list.
- *
- * @see API
- * Documentation
- * @param query
- * contains the query string to be executed
- * @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
- */
- CompletableFuture> query(
- final String query,
- final AqlQueryOptions options,
- final Class type);
-
- /**
- * Performs a database query using the given {@code query} and {@code bindVars}, then returns a new
- * {@code ArangoCursor} instance for the result list.
- *
- * @see API
- * Documentation
- * @param query
- * contains the query string to be executed
- * @param bindVars
- * key/value pairs representing the bind parameters
- * @param type
- * The type of the result (POJO class, VPackSlice, String for Json, or Collection/List/Map)
- * @return cursor of the results
- */
- CompletableFuture> query(
- final String query,
- final Map bindVars,
- final Class type);
-
- /**
- * Performs a database query using the given {@code query}, then returns a new {@code ArangoCursor} instance for the
- * result list.
- *
- * @see API
- * Documentation
- * @param query
- * contains the query string to be executed
- * @param type
- * The type of the result (POJO class, VPackSlice, String for Json, or Collection/List/Map)
- * @return cursor of the results
- */
- CompletableFuture> query(final String query, final Class type);
-
- /**
- * Return an cursor from the given cursor-ID if still existing
- *
- * @see API
- * Documentation
- * @param cursorId
- * The ID of the cursor
- * @param type
- * The type of the result (POJO class, VPackSlice, String for Json, or Collection/List/Map)
- * @return cursor of the results
- */
- CompletableFuture> cursor(final String cursorId, final Class type);
-
- /**
- * 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
- */
- CompletableFuture explainQuery(
- final String query,
- final Map bindVars,
- final AqlQueryExplainOptions options);
-
- /**
- * Parse an AQL query and return information about it This method is for query validation only. To actually query
- * the database, see {@link ArangoDatabaseAsync#query(String, Map, AqlQueryOptions, Class)}
- *
- * @see API
- * Documentation
- * @param query
- * the query which you want parse
- * @return imformation about the query
- */
- CompletableFuture parseQuery(final String query);
-
- /**
- * Clears the AQL query cache
- *
- * @see API
- * Documentation
- * @return void
- */
- CompletableFuture clearQueryCache();
-
- /**
- * Returns the global configuration for the AQL query cache
- *
- * @see API
- * Documentation
- * @return configuration for the AQL query cache
- */
- CompletableFuture getQueryCacheProperties();
-
- /**
- * 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
- */
- CompletableFuture setQueryCacheProperties(final QueryCachePropertiesEntity properties);
-
- /**
- * Returns the configuration for the AQL query tracking
- *
- * @see API
- * Documentation
- * @return configuration for the AQL query tracking
- */
- CompletableFuture getQueryTrackingProperties();
-
- /**
- * Changes the configuration for the AQL query tracking
- *
- * @see API
- * Documentation
- * @param properties
- * properties to be set
- * @return current set of properties
- */
- CompletableFuture setQueryTrackingProperties(
- final QueryTrackingPropertiesEntity properties);
-
- /**
- * Returns a list of currently running AQL queries
- *
- * @see API
- * Documentation
- * @return a list of currently running AQL queries
- */
- CompletableFuture> getCurrentlyRunningQueries();
-
- /**
- * Returns a list of slow running AQL queries
- *
- * @see API
- * Documentation
- * @return a list of slow running AQL queries
- */
- CompletableFuture> getSlowQueries();
-
- /**
- * Clears the list of slow AQL queries
- *
- * @see API
- * Documentation
- * @return void
- */
- CompletableFuture clearSlowQueries();
-
- /**
- * Kills a running query. The query will be terminated at the next cancelation point.
- *
- * @see API
- * Documentation
- * @param id
- * The id of the query
- * @return void
- */
- CompletableFuture killQuery(final String id);
-
- /**
- * 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
- * @return void
- */
- CompletableFuture createAqlFunction(
- final String name,
- final String code,
- final AqlFunctionCreateOptions options);
-
- /**
- * 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
- * @return number of deleted functions (since ArangoDB 3.4.0)
- */
- CompletableFuture deleteAqlFunction(final String name, final AqlFunctionDeleteOptions options);
-
- /**
- * Gets all reqistered AQL user functions
- *
- * @see API
- * Documentation
- * @param options
- * Additional options, can be null
- * @return all reqistered AQL user functions
- */
- CompletableFuture> getAqlFunctions(final AqlFunctionGetOptions options);
-
- /**
- * Returns a handler of the graph by the given name
- *
- * @param name
- * Name of the graph
- * @return graph handler
- */
- ArangoGraphAsync graph(final String 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
- */
- CompletableFuture createGraph(final String name, final Collection edgeDefinitions);
-
- /**
- * 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
- */
- CompletableFuture createGraph(
- final String name,
- final Collection edgeDefinitions,
- final GraphCreateOptions options);
-
- /**
- * Lists all graphs known to the graph module
- *
- * @see API
- * Documentation
- * @return graphs stored in this database
- */
- CompletableFuture> getGraphs();
-
- /**
- * 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
- */
- CompletableFuture transaction(final String action, final Class type, final TransactionOptions options);
-
- /**
- * Retrieves information about the current database
- *
- * @see API
- * Documentation
- * @return information about the current database
- */
- CompletableFuture getInfo();
-
- /**
- * 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
- */
- CompletableFuture> executeTraversal(
- final Class vertexClass,
- final Class edgeClass,
- final TraversalOptions options);
-
- /**
- * 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
- */
- CompletableFuture getDocument(final String id, final Class type) throws ArangoDBException;
-
- /**
- * 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
- */
- CompletableFuture getDocument(final String id, final Class type, final DocumentReadOptions options)
- throws ArangoDBException;
-
- /**
- * Reload the routing table.
- *
- * @see API
- * Documentation
- * @return void
- */
- CompletableFuture reloadRouting();
-
- /**
- * Returns a new {@link ArangoRouteAsync} instance for the given path (relative to the database) that can be used to
- * perform arbitrary requests.
- *
- * @param path
- * The database-relative URL of the route
- * @return {@link ArangoRouteAsync}
- */
- ArangoRouteAsync route(String... path);
-
- /**
- * Fetches all views from the database and returns an list of view descriptions.
- *
- * @see API Documentation
- * @return list of information about all views
- * @since ArangoDB 3.4.0
- */
- CompletableFuture> getViews();
-
- /**
- * Returns a {@code ArangoViewAsync} instance for the given view name.
- *
- * @param name
- * Name of the view
- * @return view handler
- * @since ArangoDB 3.4.0
- */
- ArangoViewAsync view(String name);
-
- /**
- * Returns a {@code ArangoSearchAsync} instance for the given ArangoSearch view name.
- *
- * @param name
- * Name of the view
- * @return ArangoSearch view handler
- * @since ArangoDB 3.4.0
- */
- ArangoSearchAsync arangoSearch(String name);
-
- /**
- * Creates a view of the given {@code type}, then returns view information from the server.
- *
- * @param name
- * The name of the view
- * @param type
- * The type of the view
- * @return information about the view
- * @since ArangoDB 3.4.0
- */
- CompletableFuture createView(String name, ViewType type);
-
- /**
- * Creates a ArangoSearch view with the given {@code options}, then returns view information from the server.
- *
- * @see API
- * Documentation
- * @param name
- * The name of the view
- * @param options
- * Additional options, can be null
- * @return information about the view
- * @since ArangoDB 3.4.0
- */
- CompletableFuture createArangoSearch(String name, ArangoSearchCreateOptions options);
+ /**
+ * Return the main entry point for the ArangoDB driver
+ *
+ * @return main entry point
+ */
+ ArangoDBAsync arango();
+
+ /**
+ * Returns the name of the database
+ *
+ * @return database name
+ */
+ String name();
+
+ /**
+ * Returns the server name and version number.
+ *
+ * @return the server version, number
+ * @see API
+ * Documentation
+ */
+ CompletableFuture getVersion();
+
+ /**
+ * Returns the name of the used storage engine.
+ *
+ * @return the storage engine name
+ * @see API
+ * Documentation
+ */
+ CompletableFuture getEngine();
+
+ /**
+ * Checks whether the database exists
+ *
+ * @return true if the database exists, otherwise false
+ */
+ CompletableFuture exists();
+
+ /**
+ * Retrieves a list of all databases the current user can access
+ *
+ * @return a list of all databases the current user can access
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> getAccessibleDatabases();
+
+ /**
+ * Returns a handler of the collection by the given name
+ *
+ * @param name Name of the collection
+ * @return collection handler
+ */
+ ArangoCollectionAsync collection(final String name);
+
+ /**
+ * Creates a collection
+ *
+ * @param name The name of the collection
+ * @param options Additional options, can be null
+ * @return information about the collection
+ * @see API
+ * Documentation
+ */
+ CompletableFuture createCollection(final String name);
+
+ /**
+ * Creates a collection
+ *
+ * @param name The name of the collection
+ * @param options Additional options, can be null
+ * @return information about the collection
+ * @see API
+ * Documentation
+ */
+ CompletableFuture createCollection(final String name, final CollectionCreateOptions options);
+
+ /**
+ * Returns all collections
+ *
+ * @return list of information about all collections
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> getCollections();
+
+ /**
+ * Returns all collections
+ *
+ * @param options Additional options, can be null
+ * @return list of information about all collections
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> getCollections(final CollectionsReadOptions options);
+
+ /**
+ * Returns an index
+ *
+ * @param id The index-handle
+ * @return information about the index
+ * @see API Documentation
+ */
+ CompletableFuture getIndex(final String id);
+
+ /**
+ * Deletes an index
+ *
+ * @param id The index handle
+ * @return the id of the index
+ * @see API Documentation
+ */
+ CompletableFuture deleteIndex(final String id);
+
+ /**
+ * Creates the database
+ *
+ * @return true if the database was created successfully.
+ * @see API
+ * Documentation
+ */
+ CompletableFuture create();
+
+ /**
+ * Drop an existing database
+ *
+ * @return true if the database was dropped successfully
+ * @see API
+ * Documentation
+ */
+ CompletableFuture drop();
+
+ /**
+ * Grants access to the database dbname for user user. You need permission to the _system database in order to
+ * execute this call.
+ *
+ * @param user The name of the user
+ * @param permissions The permissions the user grant
+ * @return void
+ * @see
+ * API Documentation
+ */
+ CompletableFuture grantAccess(final String user, final Permissions permissions);
+
+ /**
+ * Grants access to the database dbname for user user. You need permission to the _system database in order to
+ * execute this call.
+ *
+ * @param user The name of the user
+ * @return void
+ * @see
+ * API Documentation
+ */
+ CompletableFuture grantAccess(final String user);
+
+ /**
+ * Revokes access to the database dbname for user user. You need permission to the _system database in order to
+ * execute this call.
+ *
+ * @param user The name of the user
+ * @return void
+ * @see
+ * API Documentation
+ */
+ CompletableFuture revokeAccess(final String user);
+
+ /**
+ * Clear the database access level, revert back to the default access level.
+ *
+ * @param user The name of the user
+ * @return void
+ * @see
+ * API Documentation
+ * @since ArangoDB 3.2.0
+ */
+ CompletableFuture resetAccess(final String user);
+
+ /**
+ * Sets the default access level for collections within this database for the user user. You need
+ * permission to the _system database in order to execute this call.
+ *
+ * @param user The name of the user
+ * @param permissions The permissions the user grant
+ * @since ArangoDB 3.2.0
+ */
+ CompletableFuture grantDefaultCollectionAccess(final String user, final Permissions permissions);
+
+ /**
+ * Get specific database access level
+ *
+ * @param user The name of the user
+ * @return permissions of the user
+ * @see API
+ * Documentation
+ * @since ArangoDB 3.2.0
+ */
+ CompletableFuture getPermissions(final String user);
+
+ /**
+ * Performs a database query using the given {@code query} and {@code bindVars}, then returns a new
+ * {@code ArangoCursor} instance for the result list.
+ *
+ * @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
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> query(
+ final String query,
+ final Map bindVars,
+ final AqlQueryOptions options,
+ final Class type);
+
+ /**
+ * Performs a database query using the given {@code query}, then returns a new {@code ArangoCursor} instance for the
+ * result list.
+ *
+ * @param query contains the query string to be executed
+ * @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
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> query(
+ final String query,
+ final AqlQueryOptions options,
+ final Class type);
+
+ /**
+ * Performs a database query using the given {@code query} and {@code bindVars}, then returns a new
+ * {@code ArangoCursor} instance for the result list.
+ *
+ * @param query contains the query string to be executed
+ * @param bindVars key/value pairs representing the bind parameters
+ * @param type The type of the result (POJO class, VPackSlice, String for Json, or Collection/List/Map)
+ * @return cursor of the results
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> query(
+ final String query,
+ final Map bindVars,
+ final Class type);
+
+ /**
+ * Performs a database query using the given {@code query}, then returns a new {@code ArangoCursor} instance for the
+ * result list.
+ *
+ * @param query contains the query string to be executed
+ * @param type The type of the result (POJO class, VPackSlice, String for Json, or Collection/List/Map)
+ * @return cursor of the results
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> query(final String query, final Class type);
+
+ /**
+ * Return an cursor from the given cursor-ID if still existing
+ *
+ * @param cursorId The ID of the cursor
+ * @param type The type of the result (POJO class, VPackSlice, String for Json, or Collection/List/Map)
+ * @return cursor of the results
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> cursor(final String cursorId, final Class type);
+
+ /**
+ * Explain an AQL query and return information about it
+ *
+ * @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
+ * @see API
+ * Documentation
+ */
+ CompletableFuture explainQuery(
+ final String query,
+ final Map bindVars,
+ final AqlQueryExplainOptions options);
+
+ /**
+ * Parse an AQL query and return information about it This method is for query validation only. To actually query
+ * the database, see {@link ArangoDatabaseAsync#query(String, Map, AqlQueryOptions, Class)}
+ *
+ * @param query the query which you want parse
+ * @return imformation about the query
+ * @see API
+ * Documentation
+ */
+ CompletableFuture parseQuery(final String query);
+
+ /**
+ * Clears the AQL query cache
+ *
+ * @return void
+ * @see API
+ * Documentation
+ */
+ CompletableFuture clearQueryCache();
+
+ /**
+ * Returns the global configuration for the AQL query cache
+ *
+ * @return configuration for the AQL query cache
+ * @see API
+ * Documentation
+ */
+ CompletableFuture getQueryCacheProperties();
+
+ /**
+ * Changes the configuration for the AQL query cache. Note: changing the properties may invalidate all results in
+ * the cache.
+ *
+ * @param properties properties to be set
+ * @return current set of properties
+ * @see API
+ * Documentation
+ */
+ CompletableFuture setQueryCacheProperties(final QueryCachePropertiesEntity properties);
+
+ /**
+ * Returns the configuration for the AQL query tracking
+ *
+ * @return configuration for the AQL query tracking
+ * @see API
+ * Documentation
+ */
+ CompletableFuture getQueryTrackingProperties();
+
+ /**
+ * Changes the configuration for the AQL query tracking
+ *
+ * @param properties properties to be set
+ * @return current set of properties
+ * @see API
+ * Documentation
+ */
+ CompletableFuture setQueryTrackingProperties(
+ final QueryTrackingPropertiesEntity properties);
+
+ /**
+ * Returns a list of currently running AQL queries
+ *
+ * @return a list of currently running AQL queries
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> getCurrentlyRunningQueries();
+
+ /**
+ * Returns a list of slow running AQL queries
+ *
+ * @return a list of slow running AQL queries
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> getSlowQueries();
+
+ /**
+ * Clears the list of slow AQL queries
+ *
+ * @return void
+ * @see API
+ * Documentation
+ */
+ CompletableFuture clearSlowQueries();
+
+ /**
+ * Kills a running query. The query will be terminated at the next cancelation point.
+ *
+ * @param id The id of the query
+ * @return void
+ * @see API
+ * Documentation
+ */
+ CompletableFuture killQuery(final String id);
+
+ /**
+ * Create a new AQL user function
+ *
+ * @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
+ * @return void
+ * @see API
+ * Documentation
+ */
+ CompletableFuture createAqlFunction(
+ final String name,
+ final String code,
+ final AqlFunctionCreateOptions options);
+
+ /**
+ * Remove an existing AQL user function
+ *
+ * @param name the name of the AQL user function
+ * @param options Additional options, can be null
+ * @return number of deleted functions (since ArangoDB 3.4.0)
+ * @see API
+ * Documentation
+ */
+ CompletableFuture deleteAqlFunction(final String name, final AqlFunctionDeleteOptions options);
+
+ /**
+ * Gets all reqistered AQL user functions
+ *
+ * @param options Additional options, can be null
+ * @return all reqistered AQL user functions
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> getAqlFunctions(final AqlFunctionGetOptions options);
+
+ /**
+ * Returns a handler of the graph by the given name
+ *
+ * @param name Name of the graph
+ * @return graph handler
+ */
+ ArangoGraphAsync graph(final String 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.
+ *
+ * @param name Name of the graph
+ * @param edgeDefinitions An array of definitions for the edge
+ * @return information about the graph
+ * @see API
+ * Documentation
+ */
+ CompletableFuture createGraph(final String name, final Collection edgeDefinitions);
+
+ /**
+ * 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.
+ *
+ * @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
+ * @see API
+ * Documentation
+ */
+ CompletableFuture createGraph(
+ final String name,
+ final Collection edgeDefinitions,
+ final GraphCreateOptions options);
+
+ /**
+ * Lists all graphs known to the graph module
+ *
+ * @return graphs stored in this database
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> getGraphs();
+
+ /**
+ * Execute a server-side transaction
+ *
+ * @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
+ * @see API
+ * Documentation
+ */
+ CompletableFuture transaction(final String action, final Class type, final TransactionOptions options);
+
+ /**
+ * Begins a Stream Transaction.
+ *
+ * @param options Additional options, can be null
+ * @return information about the transaction
+ * @see API
+ * Documentation
+ * @since ArangoDB 3.5.0
+ */
+ CompletableFuture beginStreamTransaction(StreamTransactionOptions options);
+
+ /**
+ * Aborts a Stream Transaction.
+ *
+ * @return information about the transaction
+ * @see API
+ * Documentation
+ */
+ CompletableFuture abortStreamTransaction(String id);
+
+ /**
+ * Gets information about a Stream Transaction.
+ *
+ * @return information about the transaction
+ * @see
+ * API Documentation
+ * @since ArangoDB 3.5.0
+ */
+ CompletableFuture getStreamTransaction(String id);
+
+ /**
+ * Gets all the currently running Stream Transactions.
+ *
+ * @return all the currently running Stream Transactions
+ * @see
+ * API Documentation
+ * @since ArangoDB 3.5.0
+ */
+ CompletableFuture> getStreamTransactions();
+
+ /**
+ * Commits a Stream Transaction.
+ *
+ * @return information about the transaction
+ * @see
+ * API Documentation
+ * @since ArangoDB 3.5.0
+ */
+ CompletableFuture commitStreamTransaction(String id);
+
+ /**
+ * Retrieves information about the current database
+ *
+ * @return information about the current database
+ * @see API
+ * Documentation
+ */
+ CompletableFuture getInfo();
+
+ /**
+ * Execute a server-side traversal
+ *
+ * @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
+ * @see API
+ * Documentation
+ */
+ CompletableFuture> executeTraversal(
+ final Class vertexClass,
+ final Class edgeClass,
+ final TraversalOptions options);
+
+ /**
+ * Reads a single document
+ *
+ * @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
+ * @see API
+ * Documentation
+ */
+ CompletableFuture getDocument(final String id, final Class type) throws ArangoDBException;
+
+ /**
+ * Reads a single document
+ *
+ * @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
+ * @see API
+ * Documentation
+ */
+ CompletableFuture getDocument(final String id, final Class type, final DocumentReadOptions options)
+ throws ArangoDBException;
+
+ /**
+ * Reload the routing table.
+ *
+ * @return void
+ * @see API
+ * Documentation
+ */
+ CompletableFuture reloadRouting();
+
+ /**
+ * Returns a new {@link ArangoRouteAsync} instance for the given path (relative to the database) that can be used to
+ * perform arbitrary requests.
+ *
+ * @param path The database-relative URL of the route
+ * @return {@link ArangoRouteAsync}
+ */
+ ArangoRouteAsync route(String... path);
+
+ /**
+ * Fetches all views from the database and returns an list of view descriptions.
+ *
+ * @return list of information about all views
+ * @see API Documentation
+ * @since ArangoDB 3.4.0
+ */
+ CompletableFuture> getViews();
+
+ /**
+ * Returns a {@code ArangoViewAsync} instance for the given view name.
+ *
+ * @param name Name of the view
+ * @return view handler
+ * @since ArangoDB 3.4.0
+ */
+ ArangoViewAsync view(String name);
+
+ /**
+ * Returns a {@code ArangoSearchAsync} instance for the given ArangoSearch view name.
+ *
+ * @param name Name of the view
+ * @return ArangoSearch view handler
+ * @since ArangoDB 3.4.0
+ */
+ ArangoSearchAsync arangoSearch(String name);
+
+ /**
+ * Creates a view of the given {@code type}, then returns view information from the server.
+ *
+ * @param name The name of the view
+ * @param type The type of the view
+ * @return information about the view
+ * @since ArangoDB 3.4.0
+ */
+ CompletableFuture createView(String name, ViewType type);
+
+ /**
+ * Creates a ArangoSearch view with the given {@code options}, then returns view information from the server.
+ *
+ * @param name The name of the view
+ * @param options Additional options, can be null
+ * @return information about the view
+ * @see API
+ * Documentation
+ * @since ArangoDB 3.4.0
+ */
+ CompletableFuture createArangoSearch(String name, ArangoSearchCreateOptions options);
+
+ /**
+ * Creates an Analyzer
+ *
+ * @param options AnalyzerEntity
+ * @return the created Analyzer
+ * @see API Documentation
+ * @since ArangoDB 3.5.0
+ */
+ CompletableFuture createAnalyzer(AnalyzerEntity options);
+
+ /**
+ * Gets information about an Analyzer
+ *
+ * @param name of the Analyzer without database prefix
+ * @return information about an Analyzer
+ * @see API Documentation
+ * @since ArangoDB 3.5.0
+ */
+ CompletableFuture getAnalyzer(String name);
+
+ /**
+ * Retrieves all analyzers definitions.
+ *
+ * @return collection of all analyzers definitions
+ * @see API Documentation
+ * @since ArangoDB 3.5.0
+ */
+ CompletableFuture> getAnalyzers();
+
+ /**
+ * Deletes an Analyzer
+ *
+ * @param name of the Analyzer without database prefix
+ * @see API Documentation
+ * @since ArangoDB 3.5.0
+ */
+ CompletableFuture deleteAnalyzer(String name);
+
+ /**
+ * Deletes an Analyzer
+ *
+ * @param name of the Analyzer without database prefix
+ * @param options AnalyzerDeleteOptions
+ * @see API Documentation
+ * @since ArangoDB 3.5.0
+ */
+ CompletableFuture deleteAnalyzer(String name, AnalyzerDeleteOptions options);
}
diff --git a/src/main/java/com/arangodb/ArangoEdgeCollectionAsync.java b/src/main/java/com/arangodb/ArangoEdgeCollectionAsync.java
index 5b6b458..395286a 100644
--- a/src/main/java/com/arangodb/ArangoEdgeCollectionAsync.java
+++ b/src/main/java/com/arangodb/ArangoEdgeCollectionAsync.java
@@ -24,11 +24,7 @@
import com.arangodb.entity.EdgeEntity;
import com.arangodb.entity.EdgeUpdateEntity;
-import com.arangodb.model.DocumentReadOptions;
-import com.arangodb.model.EdgeCreateOptions;
-import com.arangodb.model.EdgeDeleteOptions;
-import com.arangodb.model.EdgeReplaceOptions;
-import com.arangodb.model.EdgeUpdateOptions;
+import com.arangodb.model.*;
/**
* Interface for operations on ArangoDB edge collection level.
@@ -98,7 +94,7 @@ public interface ArangoEdgeCollectionAsync extends ArangoSerializationAccessor {
* Additional options, can be null
* @return the edge identified by the key
*/
- CompletableFuture getEdge(final String key, final Class type, final DocumentReadOptions options);
+ CompletableFuture getEdge(final String key, final Class type, final GraphDocumentReadOptions options);
/**
* Replaces the edge with key with the one in the body, provided there is such a edge and no precondition is
diff --git a/src/main/java/com/arangodb/ArangoVertexCollectionAsync.java b/src/main/java/com/arangodb/ArangoVertexCollectionAsync.java
index 56a26ef..7167515 100644
--- a/src/main/java/com/arangodb/ArangoVertexCollectionAsync.java
+++ b/src/main/java/com/arangodb/ArangoVertexCollectionAsync.java
@@ -24,11 +24,7 @@
import com.arangodb.entity.VertexEntity;
import com.arangodb.entity.VertexUpdateEntity;
-import com.arangodb.model.DocumentReadOptions;
-import com.arangodb.model.VertexCreateOptions;
-import com.arangodb.model.VertexDeleteOptions;
-import com.arangodb.model.VertexReplaceOptions;
-import com.arangodb.model.VertexUpdateOptions;
+import com.arangodb.model.*;
/**
* Interface for operations on ArangoDB vertex collection level.
@@ -108,7 +104,7 @@ public interface ArangoVertexCollectionAsync extends ArangoSerializationAccessor
* Additional options, can be null
* @return the vertex identified by the key
*/
- CompletableFuture getVertex(final String key, final Class type, final DocumentReadOptions options);
+ CompletableFuture getVertex(final String key, final Class type, final GraphDocumentReadOptions options);
/**
* Replaces the vertex with key with the one in the body, provided there is such a vertex and no precondition is
diff --git a/src/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java b/src/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java
index 7d93e5e..695d9bc 100644
--- a/src/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java
+++ b/src/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java
@@ -113,18 +113,22 @@ public CompletableFuture getDocument(
final Class type,
final DocumentReadOptions options) throws ArangoDBException {
DocumentUtil.validateDocumentKey(key);
+ boolean isCatchException = options != null ? options.isCatchException() : new DocumentReadOptions().isCatchException();
return (CompletableFuture) executor.execute(getDocumentRequest(key, options), type)
- .exceptionally(handleGetDocumentExceptions(options != null ? options.isCatchException() : new DocumentReadOptions().isCatchException()));
+ .exceptionally(handleGetDocumentExceptions(isCatchException));
}
private Function handleGetDocumentExceptions(Boolean isCatchException) {
return throwable -> {
- if (throwable instanceof CompletionException && throwable.getCause() instanceof ArangoDBException) {
- ArangoDBException arangoDBException = (ArangoDBException) throwable.getCause();
- if ((arangoDBException.getResponseCode() != null && (arangoDBException.getResponseCode() == 404 || arangoDBException.getResponseCode() == 304
- || arangoDBException.getResponseCode() == 412)) && isCatchException) {
- return null;
+ if (throwable instanceof CompletionException) {
+ if (throwable.getCause() instanceof ArangoDBException) {
+ ArangoDBException arangoDBException = (ArangoDBException) throwable.getCause();
+ if ((arangoDBException.getResponseCode() != null && (arangoDBException.getResponseCode() == 404 || arangoDBException.getResponseCode() == 304
+ || arangoDBException.getResponseCode() == 412)) && isCatchException) {
+ return null;
+ }
}
+ throw (CompletionException) throwable;
}
throw new CompletionException(throwable);
};
@@ -247,8 +251,9 @@ public CompletableFuture documentExists(final String key) {
@Override
public CompletableFuture documentExists(final String key, final DocumentExistsOptions options) {
+ boolean isCatchException = options != null ? options.isCatchException() : new DocumentExistsOptions().isCatchException();
return executor.execute(documentExistsRequest(key, options), response -> response)
- .exceptionally(handleGetDocumentExceptions(options != null ? options.isCatchException() : new DocumentExistsOptions().isCatchException()))
+ .exceptionally(handleGetDocumentExceptions(isCatchException))
.thenApply(Objects::nonNull);
}
@@ -295,6 +300,11 @@ public CompletableFuture ensureFulltextIndex(
return executor.execute(createFulltextIndexRequest(fields, options), IndexEntity.class);
}
+ @Override
+ public CompletableFuture ensureTtlIndex(Iterable fields, TtlIndexOptions options) {
+ return executor.execute(createTtlIndexRequest(fields, options), IndexEntity.class);
+ }
+
@Override
public CompletableFuture> getIndexes() {
return executor.execute(getIndexesRequest(), getIndexesResponseDeserializer());
@@ -307,12 +317,22 @@ public CompletableFuture exists() {
@Override
public CompletableFuture truncate() {
- return executor.execute(truncateRequest(), CollectionEntity.class);
+ return truncate(null);
+ }
+
+ @Override
+ public CompletableFuture truncate(CollectionTruncateOptions options) {
+ return executor.execute(truncateRequest(options), CollectionEntity.class);
}
@Override
public CompletableFuture count() {
- return executor.execute(countRequest(), CollectionPropertiesEntity.class);
+ return count(null);
+ }
+
+ @Override
+ public CompletableFuture count(CollectionCountOptions options) {
+ return executor.execute(countRequest(options), CollectionPropertiesEntity.class);
}
@Override
@@ -365,6 +385,11 @@ public CompletableFuture rename(final String newName) {
return executor.execute(renameRequest(newName), CollectionEntity.class);
}
+ @Override
+ public CompletableFuture getResponsibleShard(Object value) {
+ return executor.execute(responsibleShardRequest(value), ShardEntity.class);
+ }
+
@Override
public CompletableFuture getRevision() {
return executor.execute(getRevisionRequest(), CollectionRevisionEntity.class);
diff --git a/src/main/java/com/arangodb/internal/ArangoDatabaseAsyncImpl.java b/src/main/java/com/arangodb/internal/ArangoDatabaseAsyncImpl.java
index 05a61af..29fceee 100644
--- a/src/main/java/com/arangodb/internal/ArangoDatabaseAsyncImpl.java
+++ b/src/main/java/com/arangodb/internal/ArangoDatabaseAsyncImpl.java
@@ -34,393 +34,425 @@
import com.arangodb.ArangoRouteAsync;
import com.arangodb.ArangoSearchAsync;
import com.arangodb.ArangoViewAsync;
-import com.arangodb.entity.AqlExecutionExplainEntity;
-import com.arangodb.entity.AqlFunctionEntity;
-import com.arangodb.entity.AqlParseEntity;
-import com.arangodb.entity.ArangoDBVersion;
-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.Permissions;
-import com.arangodb.entity.QueryCachePropertiesEntity;
-import com.arangodb.entity.QueryEntity;
-import com.arangodb.entity.QueryTrackingPropertiesEntity;
-import com.arangodb.entity.TraversalEntity;
-import com.arangodb.entity.ViewEntity;
-import com.arangodb.entity.ViewType;
+import com.arangodb.entity.*;
+import com.arangodb.entity.arangosearch.AnalyzerEntity;
import com.arangodb.internal.net.HostHandle;
import com.arangodb.internal.util.DocumentUtil;
-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.model.*;
+import com.arangodb.model.arangosearch.AnalyzerDeleteOptions;
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
import com.arangodb.velocypack.Type;
import com.arangodb.velocystream.Request;
/**
* @author Mark Vollmary
- *
+ * @author Michele Rastelli
*/
public class ArangoDatabaseAsyncImpl extends InternalArangoDatabase
- implements ArangoDatabaseAsync {
-
- protected ArangoDatabaseAsyncImpl(final ArangoDBAsyncImpl arangoDB, final String name) {
- super(arangoDB, name);
- }
-
- @Override
- public CompletableFuture getVersion() {
- return executor.execute(getVersionRequest(), ArangoDBVersion.class);
- }
-
- @Override
- public CompletableFuture exists() {
- return getInfo().thenApply(info -> info != null).exceptionally(e -> e == null);
- }
-
- @Override
- public CompletableFuture> getAccessibleDatabases() {
- return executor.execute(getAccessibleDatabasesRequest(), getDatabaseResponseDeserializer());
- }
-
- @Override
- public ArangoCollectionAsync collection(final String name) {
- return new ArangoCollectionAsyncImpl(this, name);
- }
-
- @Override
- public CompletableFuture createCollection(final String name) {
- return executor.execute(createCollectionRequest(name, new CollectionCreateOptions()), CollectionEntity.class);
- }
-
- @Override
- public CompletableFuture createCollection(
- final String name,
- final CollectionCreateOptions options) {
- return executor.execute(createCollectionRequest(name, options), CollectionEntity.class);
- }
-
- @Override
- public CompletableFuture> getCollections() {
- return executor.execute(getCollectionsRequest(new CollectionsReadOptions()),
- getCollectionsResponseDeserializer());
- }
-
- @Override
- public CompletableFuture> getCollections(final CollectionsReadOptions options) {
- return executor.execute(getCollectionsRequest(options), getCollectionsResponseDeserializer());
- }
-
- @Override
- public CompletableFuture getIndex(final String id) {
- DocumentUtil.validateIndexId(id);
- final String[] split = id.split("/");
- return collection(split[0]).getIndex(split[1]);
- }
-
- @Override
- public CompletableFuture deleteIndex(final String id) {
- DocumentUtil.validateIndexId(id);
- final String[] split = id.split("/");
- return collection(split[0]).deleteIndex(split[1]);
- }
-
- @Override
- public CompletableFuture create() {
- return arango().createDatabase(name());
- }
-
- @Override
- public CompletableFuture drop() {
- return executor.execute(dropRequest(), createDropResponseDeserializer());
- }
-
- @Override
- public CompletableFuture grantAccess(final String user, final Permissions permissions) {
- return executor.execute(grantAccessRequest(user, permissions), Void.class);
- }
-
- @Override
- public CompletableFuture grantAccess(final String user) {
- return executor.execute(grantAccessRequest(user, Permissions.RW), Void.class);
- }
-
- @Override
- public CompletableFuture revokeAccess(final String user) {
- return executor.execute(grantAccessRequest(user, Permissions.NONE), Void.class);
- }
-
- @Override
- public CompletableFuture resetAccess(final String user) {
- return executor.execute(resetAccessRequest(user), Void.class);
- }
-
- @Override
- public CompletableFuture grantDefaultCollectionAccess(final String user, final Permissions permissions) {
- return executor.execute(updateUserDefaultCollectionAccessRequest(user, permissions), Void.class);
- }
-
- @Override
- public CompletableFuture getPermissions(final String user) {
- return executor.execute(getPermissionsRequest(user), getPermissionsResponseDeserialzer());
- }
-
- @Override
- public CompletableFuture> query(
- final String query,
- final Map bindVars,
- final AqlQueryOptions options,
- final Class type) {
- final Request request = queryRequest(query, bindVars, options);
- final HostHandle hostHandle = new HostHandle();
- final CompletableFuture execution = executor.execute(request, CursorEntity.class, hostHandle);
- return execution.thenApply(result -> createCursor(result, type, options, hostHandle));
- }
-
- @Override
- public CompletableFuture> query(
- final String query,
- final AqlQueryOptions options,
- final Class type) {
- return query(query, null, options, type);
- }
-
- @Override
- public CompletableFuture> query(
- final String query,
- final Map bindVars,
- final Class type) {
- return query(query, bindVars, null, type);
- }
-
- @Override
- public CompletableFuture> query(final String query, final Class type) {
- return query(query, null, null, type);
- }
-
- @Override
- public CompletableFuture> cursor(final String cursorId, final Class type) {
- final HostHandle hostHandle = new HostHandle();
- final CompletableFuture execution = executor.execute(queryNextRequest(cursorId, null, null), CursorEntity.class, hostHandle);
- return execution.thenApply(result -> createCursor(result, type, null, hostHandle));
- }
-
- private ArangoCursorAsync createCursor(
- final CursorEntity result,
- final Class type,
- final AqlQueryOptions options,
- final HostHandle hostHandle) {
- return new ArangoCursorAsyncImpl<>(this, new ArangoCursorExecute() {
- @Override
- public CursorEntity next(final String id, Map meta) {
- final CompletableFuture result = executor.execute(queryNextRequest(id, options, meta),
- CursorEntity.class, hostHandle);
- try {
- return result.get();
- } catch (InterruptedException | ExecutionException e) {
- throw new ArangoDBException(e);
- }
- }
-
- @Override
- public void close(final String id, Map meta) {
- try {
- executor.execute(queryCloseRequest(id, options, meta), Void.class, hostHandle).get();
- } catch (InterruptedException | ExecutionException e) {
- throw new ArangoDBException(e);
- }
- }
- }, type, result);
- }
-
- @Override
- public CompletableFuture explainQuery(
- final String query,
- final Map