File tree Expand file tree Collapse file tree 5 files changed +38
-0
lines changed Expand file tree Collapse file tree 5 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 31
31
import javax .net .ssl .SSLContext ;
32
32
33
33
import com .arangodb .entity .ArangoDBVersion ;
34
+ import com .arangodb .entity .ArangoDBRole ;
34
35
import com .arangodb .entity .LogEntity ;
35
36
import com .arangodb .entity .LogLevelEntity ;
36
37
import com .arangodb .entity .UserEntity ;
@@ -453,6 +454,18 @@ public ArangoDBVersion getVersion() throws ArangoDBException {
453
454
return db ().getVersion ();
454
455
}
455
456
457
+ /**
458
+ * Returns the server role.
459
+ *
460
+ * @see <a href="https://docs.arangodb.com/current/HTTP/MiscellaneousFunctions/index.html#return-server-version">API
461
+ * Documentation</a>
462
+ * @return the server role
463
+ * @throws ArangoDBException
464
+ */
465
+ public ArangoDBRole getRole () throws ArangoDBException {
466
+ return db ().getRole ();
467
+ }
468
+
456
469
/**
457
470
* Create a new user. This user will not have access to any database. You need permission to the _system database in
458
471
* order to execute this call.
Original file line number Diff line number Diff line change 27
27
import com .arangodb .entity .AqlFunctionEntity ;
28
28
import com .arangodb .entity .AqlParseEntity ;
29
29
import com .arangodb .entity .ArangoDBVersion ;
30
+ import com .arangodb .entity .ArangoDBRole ;
30
31
import com .arangodb .entity .CollectionEntity ;
31
32
import com .arangodb .entity .CursorEntity ;
32
33
import com .arangodb .entity .DatabaseEntity ;
@@ -87,6 +88,18 @@ public ArangoDBVersion getVersion() throws ArangoDBException {
87
88
return executor .execute (getVersionRequest (), ArangoDBVersion .class );
88
89
}
89
90
91
+ /**
92
+ * Returns the server name and version number.
93
+ *
94
+ * @see <a href="https://docs.arangodb.com/current/HTTP/MiscellaneousFunctions/index.html#return-server-version">API
95
+ * Documentation</a>
96
+ * @return the server version, number
97
+ * @throws ArangoDBException
98
+ */
99
+ public ArangoDBRole getRole () throws ArangoDBException {
100
+ return executor .execute (getRoleRequest (), ArangoDBRole .class );
101
+ }
102
+
90
103
/**
91
104
* Retrieves a list of all databases the current user can access
92
105
*
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ public class ArangoDBConstants {
61
61
public static final String PATH_API_ADMIN_LOG_LEVEL = "/_admin/log/level" ;
62
62
public static final String PATH_API_ADMIN_ROUTING_RELOAD = "/_admin/routing/reload" ;
63
63
public static final String PATH_API_IMPORT = "/_api/import" ;
64
+ public static final String PATH_API_ROLE = "_admin/server/role" ;
64
65
65
66
public static final String ENCRYPTION_PLAIN = "plain" ;
66
67
Original file line number Diff line number Diff line change @@ -92,6 +92,10 @@ protected Request getVersionRequest() {
92
92
return new Request (name , RequestType .GET , ArangoDBConstants .PATH_API_VERSION );
93
93
}
94
94
95
+ protected Request getRoleRequest () {
96
+ return new Request (name , RequestType .GET , ArangoDBConstants .PATH_API_ROLE );
97
+ }
98
+
95
99
protected Request createCollectionRequest (final String name , final CollectionCreateOptions options ) {
96
100
return new Request (name (), RequestType .POST , ArangoDBConstants .PATH_API_COLLECTION ).setBody (
97
101
executor .serialize (OptionsBuilder .build (options != null ? options : new CollectionCreateOptions (), name )));
Original file line number Diff line number Diff line change 49
49
import com .arangodb .entity .AqlParseEntity ;
50
50
import com .arangodb .entity .AqlParseEntity .AstNode ;
51
51
import com .arangodb .entity .ArangoDBVersion ;
52
+ import com .arangodb .entity .ArangoDBRole ;
52
53
import com .arangodb .entity .BaseDocument ;
53
54
import com .arangodb .entity .BaseEdgeDocument ;
54
55
import com .arangodb .entity .CollectionEntity ;
@@ -124,6 +125,9 @@ public void deleteCollection() {
124
125
125
126
@ Test
126
127
public void deleteSystemCollection () {
128
+ if (db .getRole ().getRole () == "COORDINATOR" ) {
129
+ return ;
130
+ }
127
131
final String name = "_system_test" ;
128
132
db .createCollection (name , new CollectionCreateOptions ().isSystem (true ));
129
133
db .collection (name ).drop (true );
@@ -136,6 +140,9 @@ public void deleteSystemCollection() {
136
140
137
141
@ Test
138
142
public void deleteSystemCollectionFail () {
143
+ if (db .getRole ().getRole () == "COORDINATOR" ) {
144
+ return ;
145
+ }
139
146
final String name = "_system_test" ;
140
147
db .createCollection (name , new CollectionCreateOptions ().isSystem (true ));
141
148
try {
You can’t perform that action at this time.
0 commit comments