From 8ecd3a4b8d3eeb14e14d26dbeb019b4358acd76d Mon Sep 17 00:00:00 2001 From: hkernbach Date: Thu, 2 May 2019 12:59:25 +0200 Subject: [PATCH 1/5] added getLicense method, fixed enterprise only test --- src/main/java/com/arangodb/ArangoDB.java | 9 +++++++++ .../com/arangodb/internal/ArangoDBImpl.java | 7 +++++++ .../com/arangodb/internal/InternalArangoDB.java | 17 +++++++++++++++++ .../java/com/arangodb/ArangoDatabaseTest.java | 6 ++++++ 4 files changed, 39 insertions(+) diff --git a/src/main/java/com/arangodb/ArangoDB.java b/src/main/java/com/arangodb/ArangoDB.java index 6bf3897c1..b63f667ec 100644 --- a/src/main/java/com/arangodb/ArangoDB.java +++ b/src/main/java/com/arangodb/ArangoDB.java @@ -32,6 +32,7 @@ import com.arangodb.entity.LogEntity; import com.arangodb.entity.LogLevelEntity; import com.arangodb.entity.Permissions; +import com.arangodb.entity.ServerLicense; import com.arangodb.entity.ServerRole; import com.arangodb.entity.UserEntity; import com.arangodb.internal.ArangoContext; @@ -710,6 +711,14 @@ public synchronized ArangoDB build() { * @throws ArangoDBException */ ServerRole getRole() throws ArangoDBException; + + /** + * Returns the server license. + * + * @return the server license + * @throws ArangoDBException + */ + ServerLicense getLicense() throws ArangoDBException; /** * Create a new user. This user will not have access to any database. You need permission to the _system database in diff --git a/src/main/java/com/arangodb/internal/ArangoDBImpl.java b/src/main/java/com/arangodb/internal/ArangoDBImpl.java index f0b935624..086194503 100644 --- a/src/main/java/com/arangodb/internal/ArangoDBImpl.java +++ b/src/main/java/com/arangodb/internal/ArangoDBImpl.java @@ -34,6 +34,7 @@ import com.arangodb.entity.LogEntity; import com.arangodb.entity.LogLevelEntity; import com.arangodb.entity.Permissions; +import com.arangodb.entity.ServerLicense; import com.arangodb.entity.ServerRole; import com.arangodb.entity.UserEntity; import com.arangodb.internal.ArangoExecutor.ResponseDeserializer; @@ -60,6 +61,7 @@ /** * @author Mark Vollmary + * @author Heiko Kernbach * */ public class ArangoDBImpl extends InternalArangoDB implements ArangoDB { @@ -193,6 +195,11 @@ public ArangoDBVersion getVersion() throws ArangoDBException { public ServerRole getRole() throws ArangoDBException { return executor.execute(getRoleRequest(), getRoleResponseDeserializer()); } + + @Override + public ServerLicense getLicense() throws ArangoDBException { + return executor.execute(getLicenseRequest(), getLicenseResponseDeserializer()); + } @Override public UserEntity createUser(final String user, final String passwd) throws ArangoDBException { diff --git a/src/main/java/com/arangodb/internal/InternalArangoDB.java b/src/main/java/com/arangodb/internal/InternalArangoDB.java index 0c2235987..aad2e0bfd 100644 --- a/src/main/java/com/arangodb/internal/InternalArangoDB.java +++ b/src/main/java/com/arangodb/internal/InternalArangoDB.java @@ -27,6 +27,7 @@ import com.arangodb.entity.LogLevelEntity; import com.arangodb.entity.Permissions; +import com.arangodb.entity.ServerLicense; import com.arangodb.entity.ServerRole; import com.arangodb.entity.UserEntity; import com.arangodb.internal.ArangoExecutor.ResponseDeserializer; @@ -46,6 +47,7 @@ /** * @author Mark Vollmary + * @author Heiko Kernbach * */ public abstract class InternalArangoDB extends ArangoExecuteable { @@ -53,6 +55,7 @@ public abstract class InternalArangoDB extends ArangoE private static final String PATH_API_ADMIN_LOG = "/_admin/log"; private static final String PATH_API_ADMIN_LOG_LEVEL = "/_admin/log/level"; private static final String PATH_API_ROLE = "/_admin/server/role"; + private static final String PATH_API_VERSION = "/_api/version"; protected static final String PATH_ENDPOINTS = "/_api/cluster/endpoints"; private static final String PATH_API_USER = "/_api/user"; @@ -72,6 +75,20 @@ public ServerRole deserialize(final Response response) throws VPackException { } }; } + + protected Request getLicenseRequest() { + return request(ArangoRequestParam.SYSTEM, RequestType.GET, PATH_API_VERSION); + } + + protected ResponseDeserializer getLicenseResponseDeserializer() { + return new ResponseDeserializer() { + @Override + public ServerLicense deserialize(final Response response) throws VPackException { + System.out.println(response.getBody().toString()); + return util().deserialize(response.getBody().get("license"), ServerLicense.class); + } + }; + } protected Request createDatabaseRequest(final String name) { final Request request = request(ArangoRequestParam.SYSTEM, RequestType.POST, diff --git a/src/test/java/com/arangodb/ArangoDatabaseTest.java b/src/test/java/com/arangodb/ArangoDatabaseTest.java index e7c76450e..db461a683 100644 --- a/src/test/java/com/arangodb/ArangoDatabaseTest.java +++ b/src/test/java/com/arangodb/ArangoDatabaseTest.java @@ -69,6 +69,7 @@ import com.arangodb.entity.QueryEntity; import com.arangodb.entity.QueryExecutionState; import com.arangodb.entity.QueryTrackingPropertiesEntity; +import com.arangodb.entity.ServerLicense; import com.arangodb.entity.ServerRole; import com.arangodb.entity.TraversalEntity; import com.arangodb.model.AqlFunctionDeleteOptions; @@ -170,6 +171,11 @@ public void createSatelliteCollection() { if (arangoDB.getRole() == ServerRole.SINGLE) { return; } + + if (arangoDB.getLicense() == ServerLicense.community) { + return; + } + try { final CollectionEntity result = db.createCollection(COLLECTION_NAME, new CollectionCreateOptions().satellite(true)); From 319f66b6311365c94aeb7af49dc888786148a217 Mon Sep 17 00:00:00 2001 From: hkernbach Date: Thu, 2 May 2019 13:09:56 +0200 Subject: [PATCH 2/5] added ServerLicense enum --- .../com/arangodb/entity/ServerLicense.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/arangodb/entity/ServerLicense.java diff --git a/src/main/java/com/arangodb/entity/ServerLicense.java b/src/main/java/com/arangodb/entity/ServerLicense.java new file mode 100644 index 000000000..00c49415e --- /dev/null +++ b/src/main/java/com/arangodb/entity/ServerLicense.java @@ -0,0 +1,29 @@ +/* + * 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.entity; + +/** + * @author Heiko Kernbach + * + */ +public enum ServerLicense { + community, enterprise, undefined +} From aabe64ac181d0575fcf667cbe87929bae493a81e Mon Sep 17 00:00:00 2001 From: "axel.becker" Date: Fri, 3 May 2019 09:47:38 +0200 Subject: [PATCH 3/5] use existing arangoDB.getVersion().getLicense() --- src/main/java/com/arangodb/ArangoDB.java | 9 ------ .../com/arangodb/entity/ServerLicense.java | 29 ------------------- .../com/arangodb/internal/ArangoDBImpl.java | 6 ---- .../arangodb/internal/InternalArangoDB.java | 15 ---------- .../java/com/arangodb/ArangoDatabaseTest.java | 18 ++++++++---- 5 files changed, 13 insertions(+), 64 deletions(-) delete mode 100644 src/main/java/com/arangodb/entity/ServerLicense.java diff --git a/src/main/java/com/arangodb/ArangoDB.java b/src/main/java/com/arangodb/ArangoDB.java index b63f667ec..4ba81375f 100644 --- a/src/main/java/com/arangodb/ArangoDB.java +++ b/src/main/java/com/arangodb/ArangoDB.java @@ -32,7 +32,6 @@ import com.arangodb.entity.LogEntity; import com.arangodb.entity.LogLevelEntity; import com.arangodb.entity.Permissions; -import com.arangodb.entity.ServerLicense; import com.arangodb.entity.ServerRole; import com.arangodb.entity.UserEntity; import com.arangodb.internal.ArangoContext; @@ -712,14 +711,6 @@ public synchronized ArangoDB build() { */ ServerRole getRole() throws ArangoDBException; - /** - * Returns the server license. - * - * @return the server license - * @throws ArangoDBException - */ - ServerLicense getLicense() throws ArangoDBException; - /** * 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. diff --git a/src/main/java/com/arangodb/entity/ServerLicense.java b/src/main/java/com/arangodb/entity/ServerLicense.java deleted file mode 100644 index 00c49415e..000000000 --- a/src/main/java/com/arangodb/entity/ServerLicense.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.entity; - -/** - * @author Heiko Kernbach - * - */ -public enum ServerLicense { - community, enterprise, undefined -} diff --git a/src/main/java/com/arangodb/internal/ArangoDBImpl.java b/src/main/java/com/arangodb/internal/ArangoDBImpl.java index 086194503..cf10e9e75 100644 --- a/src/main/java/com/arangodb/internal/ArangoDBImpl.java +++ b/src/main/java/com/arangodb/internal/ArangoDBImpl.java @@ -34,7 +34,6 @@ import com.arangodb.entity.LogEntity; import com.arangodb.entity.LogLevelEntity; import com.arangodb.entity.Permissions; -import com.arangodb.entity.ServerLicense; import com.arangodb.entity.ServerRole; import com.arangodb.entity.UserEntity; import com.arangodb.internal.ArangoExecutor.ResponseDeserializer; @@ -196,11 +195,6 @@ public ServerRole getRole() throws ArangoDBException { return executor.execute(getRoleRequest(), getRoleResponseDeserializer()); } - @Override - public ServerLicense getLicense() throws ArangoDBException { - return executor.execute(getLicenseRequest(), getLicenseResponseDeserializer()); - } - @Override public UserEntity createUser(final String user, final String passwd) throws ArangoDBException { return executor.execute(createUserRequest(db().name(), user, passwd, new UserCreateOptions()), diff --git a/src/main/java/com/arangodb/internal/InternalArangoDB.java b/src/main/java/com/arangodb/internal/InternalArangoDB.java index aad2e0bfd..f0419aa2b 100644 --- a/src/main/java/com/arangodb/internal/InternalArangoDB.java +++ b/src/main/java/com/arangodb/internal/InternalArangoDB.java @@ -27,7 +27,6 @@ import com.arangodb.entity.LogLevelEntity; import com.arangodb.entity.Permissions; -import com.arangodb.entity.ServerLicense; import com.arangodb.entity.ServerRole; import com.arangodb.entity.UserEntity; import com.arangodb.internal.ArangoExecutor.ResponseDeserializer; @@ -76,20 +75,6 @@ public ServerRole deserialize(final Response response) throws VPackException { }; } - protected Request getLicenseRequest() { - return request(ArangoRequestParam.SYSTEM, RequestType.GET, PATH_API_VERSION); - } - - protected ResponseDeserializer getLicenseResponseDeserializer() { - return new ResponseDeserializer() { - @Override - public ServerLicense deserialize(final Response response) throws VPackException { - System.out.println(response.getBody().toString()); - return util().deserialize(response.getBody().get("license"), ServerLicense.class); - } - }; - } - protected Request createDatabaseRequest(final String name) { final Request request = request(ArangoRequestParam.SYSTEM, RequestType.POST, InternalArangoDatabase.PATH_API_DATABASE); diff --git a/src/test/java/com/arangodb/ArangoDatabaseTest.java b/src/test/java/com/arangodb/ArangoDatabaseTest.java index db461a683..817bc048c 100644 --- a/src/test/java/com/arangodb/ArangoDatabaseTest.java +++ b/src/test/java/com/arangodb/ArangoDatabaseTest.java @@ -44,6 +44,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.arangodb.ArangoDB.Builder; import com.arangodb.entity.AqlExecutionExplainEntity; @@ -69,7 +71,6 @@ import com.arangodb.entity.QueryEntity; import com.arangodb.entity.QueryExecutionState; import com.arangodb.entity.QueryTrackingPropertiesEntity; -import com.arangodb.entity.ServerLicense; import com.arangodb.entity.ServerRole; import com.arangodb.entity.TraversalEntity; import com.arangodb.model.AqlFunctionDeleteOptions; @@ -92,6 +93,8 @@ */ @RunWith(Parameterized.class) public class ArangoDatabaseTest extends BaseTest { + + Logger LOG = LoggerFactory.getLogger(ArangoDatabaseTest.class); private static final String COLLECTION_NAME = "db_test"; private static final String GRAPH_NAME = "graph_test"; @@ -168,21 +171,26 @@ public void createCollectionWithReplicationFactor() { @Test public void createSatelliteCollection() { - if (arangoDB.getRole() == ServerRole.SINGLE) { + + if (arangoDB.getVersion().getLicense() == ArangoDBVersion.License.COMMUNITY) { + LOG.info("Skip Test on COMMUNITY VERSION"); return; } - if (arangoDB.getLicense() == ServerLicense.community) { + if (arangoDB.getRole() == ServerRole.SINGLE) { + LOG.info("Skip Test on SINGLE SERVER"); return; } try { - final CollectionEntity result = db.createCollection(COLLECTION_NAME, - new CollectionCreateOptions().satellite(true)); + + final CollectionEntity result = db.createCollection(COLLECTION_NAME, new CollectionCreateOptions().satellite(true)); + assertThat(result, is(notNullValue())); assertThat(result.getId(), is(notNullValue())); assertThat(db.collection(COLLECTION_NAME).getProperties().getReplicationFactor(), is(nullValue())); assertThat(db.collection(COLLECTION_NAME).getProperties().getSatellite(), is(true)); + } finally { db.collection(COLLECTION_NAME).drop(); } From 37300ef810d6cc6269191e9d5cdaf6346fbe804e Mon Sep 17 00:00:00 2001 From: hkernbach Date: Mon, 6 May 2019 13:28:49 +0200 Subject: [PATCH 4/5] changelog --- ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 358093e35..a2d3182b2 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] +- added smartJoinAttribute and shardingStrategy collection attributes + ## [5.0.4] - 2019-18-01 ### Fixed From dafae6a4edb510d26de1ddb9edd5dfe07be7958b Mon Sep 17 00:00:00 2001 From: "axel.becker" Date: Fri, 10 May 2019 10:13:12 +0200 Subject: [PATCH 5/5] remove unused --- .../java/com/arangodb/internal/InternalArangoDB.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/arangodb/internal/InternalArangoDB.java b/src/main/java/com/arangodb/internal/InternalArangoDB.java index f0419aa2b..49939a365 100644 --- a/src/main/java/com/arangodb/internal/InternalArangoDB.java +++ b/src/main/java/com/arangodb/internal/InternalArangoDB.java @@ -51,12 +51,11 @@ */ public abstract class InternalArangoDB extends ArangoExecuteable { - private static final String PATH_API_ADMIN_LOG = "/_admin/log"; - private static final String PATH_API_ADMIN_LOG_LEVEL = "/_admin/log/level"; - private static final String PATH_API_ROLE = "/_admin/server/role"; - private static final String PATH_API_VERSION = "/_api/version"; - protected static final String PATH_ENDPOINTS = "/_api/cluster/endpoints"; - private static final String PATH_API_USER = "/_api/user"; + private static final String PATH_API_ADMIN_LOG = "/_admin/log"; + private static final String PATH_API_ADMIN_LOG_LEVEL = "/_admin/log/level"; + private static final String PATH_API_ROLE = "/_admin/server/role"; + protected static final String PATH_ENDPOINTS = "/_api/cluster/endpoints"; + private static final String PATH_API_USER = "/_api/user"; protected InternalArangoDB(final E executor, final ArangoSerializationFactory util, final ArangoContext context) { super(executor, util, context);