Skip to content

Commit 8ecd3a4

Browse files
committed
added getLicense method, fixed enterprise only test
1 parent 17035b2 commit 8ecd3a4

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

src/main/java/com/arangodb/ArangoDB.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.arangodb.entity.LogEntity;
3333
import com.arangodb.entity.LogLevelEntity;
3434
import com.arangodb.entity.Permissions;
35+
import com.arangodb.entity.ServerLicense;
3536
import com.arangodb.entity.ServerRole;
3637
import com.arangodb.entity.UserEntity;
3738
import com.arangodb.internal.ArangoContext;
@@ -710,6 +711,14 @@ public synchronized ArangoDB build() {
710711
* @throws ArangoDBException
711712
*/
712713
ServerRole getRole() throws ArangoDBException;
714+
715+
/**
716+
* Returns the server license.
717+
*
718+
* @return the server license
719+
* @throws ArangoDBException
720+
*/
721+
ServerLicense getLicense() throws ArangoDBException;
713722

714723
/**
715724
* Create a new user. This user will not have access to any database. You need permission to the _system database in

src/main/java/com/arangodb/internal/ArangoDBImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.arangodb.entity.LogEntity;
3535
import com.arangodb.entity.LogLevelEntity;
3636
import com.arangodb.entity.Permissions;
37+
import com.arangodb.entity.ServerLicense;
3738
import com.arangodb.entity.ServerRole;
3839
import com.arangodb.entity.UserEntity;
3940
import com.arangodb.internal.ArangoExecutor.ResponseDeserializer;
@@ -60,6 +61,7 @@
6061

6162
/**
6263
* @author Mark Vollmary
64+
* @author Heiko Kernbach
6365
*
6466
*/
6567
public class ArangoDBImpl extends InternalArangoDB<ArangoExecutorSync> implements ArangoDB {
@@ -193,6 +195,11 @@ public ArangoDBVersion getVersion() throws ArangoDBException {
193195
public ServerRole getRole() throws ArangoDBException {
194196
return executor.execute(getRoleRequest(), getRoleResponseDeserializer());
195197
}
198+
199+
@Override
200+
public ServerLicense getLicense() throws ArangoDBException {
201+
return executor.execute(getLicenseRequest(), getLicenseResponseDeserializer());
202+
}
196203

197204
@Override
198205
public UserEntity createUser(final String user, final String passwd) throws ArangoDBException {

src/main/java/com/arangodb/internal/InternalArangoDB.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import com.arangodb.entity.LogLevelEntity;
2929
import com.arangodb.entity.Permissions;
30+
import com.arangodb.entity.ServerLicense;
3031
import com.arangodb.entity.ServerRole;
3132
import com.arangodb.entity.UserEntity;
3233
import com.arangodb.internal.ArangoExecutor.ResponseDeserializer;
@@ -46,13 +47,15 @@
4647

4748
/**
4849
* @author Mark Vollmary
50+
* @author Heiko Kernbach
4951
*
5052
*/
5153
public abstract class InternalArangoDB<E extends ArangoExecutor> extends ArangoExecuteable<E> {
5254

5355
private static final String PATH_API_ADMIN_LOG = "/_admin/log";
5456
private static final String PATH_API_ADMIN_LOG_LEVEL = "/_admin/log/level";
5557
private static final String PATH_API_ROLE = "/_admin/server/role";
58+
private static final String PATH_API_VERSION = "/_api/version";
5659
protected static final String PATH_ENDPOINTS = "/_api/cluster/endpoints";
5760
private static final String PATH_API_USER = "/_api/user";
5861

@@ -72,6 +75,20 @@ public ServerRole deserialize(final Response response) throws VPackException {
7275
}
7376
};
7477
}
78+
79+
protected Request getLicenseRequest() {
80+
return request(ArangoRequestParam.SYSTEM, RequestType.GET, PATH_API_VERSION);
81+
}
82+
83+
protected ResponseDeserializer<ServerLicense> getLicenseResponseDeserializer() {
84+
return new ResponseDeserializer<ServerLicense>() {
85+
@Override
86+
public ServerLicense deserialize(final Response response) throws VPackException {
87+
System.out.println(response.getBody().toString());
88+
return util().deserialize(response.getBody().get("license"), ServerLicense.class);
89+
}
90+
};
91+
}
7592

7693
protected Request createDatabaseRequest(final String name) {
7794
final Request request = request(ArangoRequestParam.SYSTEM, RequestType.POST,

src/test/java/com/arangodb/ArangoDatabaseTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import com.arangodb.entity.QueryEntity;
7070
import com.arangodb.entity.QueryExecutionState;
7171
import com.arangodb.entity.QueryTrackingPropertiesEntity;
72+
import com.arangodb.entity.ServerLicense;
7273
import com.arangodb.entity.ServerRole;
7374
import com.arangodb.entity.TraversalEntity;
7475
import com.arangodb.model.AqlFunctionDeleteOptions;
@@ -170,6 +171,11 @@ public void createSatelliteCollection() {
170171
if (arangoDB.getRole() == ServerRole.SINGLE) {
171172
return;
172173
}
174+
175+
if (arangoDB.getLicense() == ServerLicense.community) {
176+
return;
177+
}
178+
173179
try {
174180
final CollectionEntity result = db.createCollection(COLLECTION_NAME,
175181
new CollectionCreateOptions().satellite(true));

0 commit comments

Comments
 (0)