3333public class InternalCollectionDriverImpl extends BaseArangoDriverImpl
3434 implements com .arangodb .InternalCollectionDriver {
3535
36+ private static final String API_COLLECTION = "/_api/collection" ;
37+
3638 InternalCollectionDriverImpl (ArangoConfigure configure , HttpManager httpManager ) {
3739 super (configure , httpManager );
3840 }
3941
4042 @ Override
4143 public CollectionEntity createCollection (String database , String name , CollectionOptions collectionOptions )
4244 throws ArangoException {
43- if (collectionOptions == null ) {
44- collectionOptions = new CollectionOptions ();
45+ CollectionOptions tmpCollectionOptions = collectionOptions ;
46+ if (tmpCollectionOptions == null ) {
47+ tmpCollectionOptions = new CollectionOptions ();
4548 }
46- HttpResponseEntity res = httpManager
47- . doPost ( createEndpointUrl ( database , "/_api/collection" ), null , EntityFactory
48- . toJsonString (
49- new MapBuilder () .put ("name " , name ). put ( "waitForSync" , collectionOptions . getWaitForSync ())
50- .put ("doCompact " , collectionOptions . getDoCompact ())
51- .put ("journalSize " , collectionOptions . getJournalSize ())
52- .put ("isSystem " , collectionOptions . getIsSystem ())
53- .put ("isVolatile " , collectionOptions . getIsVolatile ())
54- .put ("keyOptions " , collectionOptions . getKeyOptions ())
55- .put ("numberOfShards " , collectionOptions . getNumberOfShards ()). put ( "shardKeys" ,
56- collectionOptions . getShardKeys ())
57- . put ( "type" , collectionOptions . getType () == null ? null : collectionOptions .getType ().getType ())
49+ HttpResponseEntity res = httpManager . doPost ( createEndpointUrl ( database , API_COLLECTION ), null ,
50+ EntityFactory . toJsonString (
51+ new MapBuilder (). put ( "name" , name ). put ( "waitForSync" , tmpCollectionOptions . getWaitForSync ())
52+ .put ("doCompact " , tmpCollectionOptions . getDoCompact ())
53+ .put ("journalSize " , tmpCollectionOptions . getJournalSize ())
54+ .put ("isSystem " , tmpCollectionOptions . getIsSystem ())
55+ .put ("isVolatile " , tmpCollectionOptions . getIsVolatile ())
56+ .put ("keyOptions " , tmpCollectionOptions . getKeyOptions ())
57+ .put ("numberOfShards " , tmpCollectionOptions . getNumberOfShards ())
58+ .put ("shardKeys " , tmpCollectionOptions . getShardKeys ())
59+ . put ( "type" , tmpCollectionOptions . getType () == null ? null
60+ : tmpCollectionOptions .getType ().getType ())
5861 .get ()));
5962
6063 return createEntity (res , CollectionEntity .class );
@@ -65,7 +68,7 @@ public CollectionEntity createCollection(String database, String name, Collectio
6568 public CollectionEntity getCollection (String database , String name ) throws ArangoException {
6669 validateCollectionName (name );
6770
68- HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , "/_api/collection" , name ), null );
71+ HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , API_COLLECTION , name ), null );
6972
7073 return createEntity (res , CollectionEntity .class );
7174 }
@@ -75,7 +78,7 @@ public CollectionEntity getCollectionRevision(String database, String name) thro
7578
7679 validateCollectionName (name );
7780
78- HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , "/_api/collection" , name , "/revision" ),
81+ HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , API_COLLECTION , name , "/revision" ),
7982 null );
8083
8184 return createEntity (res , CollectionEntity .class );
@@ -86,7 +89,7 @@ public CollectionEntity getCollectionProperties(String database, String name) th
8689
8790 validateCollectionName (name );
8891
89- HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , "/_api/collection" , name , "/properties" ),
92+ HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , API_COLLECTION , name , "/properties" ),
9093 null );
9194
9295 return createEntity (res , CollectionEntity .class );
@@ -97,8 +100,7 @@ public CollectionEntity getCollectionCount(String database, String name) throws
97100
98101 validateCollectionName (name );
99102
100- HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , "/_api/collection" , name , "/count" ),
101- null );
103+ HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , API_COLLECTION , name , "/count" ), null );
102104
103105 return createEntity (res , CollectionEntity .class );
104106 }
@@ -108,8 +110,7 @@ public CollectionEntity getCollectionFigures(String database, String name) throw
108110
109111 validateCollectionName (name );
110112
111- HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , "/_api/collection" , name , "/figures" ),
112- null );
113+ HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , API_COLLECTION , name , "/figures" ), null );
113114
114115 return createEntity (res , CollectionEntity .class );
115116 }
@@ -119,7 +120,7 @@ public CollectionEntity getCollectionChecksum(String database, String name, Bool
119120 throws ArangoException {
120121
121122 validateCollectionName (name );
122- HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , "/_api/collection" , name , "/checksum" ),
123+ HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , API_COLLECTION , name , "/checksum" ),
123124 new MapBuilder ().put ("withRevisions" , withRevisions ).put ("withData" , withData ).get ());
124125
125126 return createEntity (res , CollectionEntity .class );
@@ -129,7 +130,7 @@ public CollectionEntity getCollectionChecksum(String database, String name, Bool
129130 @ Override
130131 public CollectionsEntity getCollections (String database , Boolean excludeSystem ) throws ArangoException {
131132
132- HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , "/_api/collection" ), null ,
133+ HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , API_COLLECTION ), null ,
133134 new MapBuilder ().put ("excludeSystem" , excludeSystem ).get ());
134135
135136 return createEntity (res , CollectionsEntity .class );
@@ -140,7 +141,7 @@ public CollectionsEntity getCollections(String database, Boolean excludeSystem)
140141 public CollectionEntity loadCollection (String database , String name , Boolean count ) throws ArangoException {
141142
142143 validateCollectionName (name );
143- HttpResponseEntity res = httpManager .doPut (createEndpointUrl (database , "/_api/collection" , name , "/load" ), null ,
144+ HttpResponseEntity res = httpManager .doPut (createEndpointUrl (database , API_COLLECTION , name , "/load" ), null ,
144145 EntityFactory .toJsonString (new MapBuilder ("count" , count ).get ()));
145146
146147 return createEntity (res , CollectionEntity .class );
@@ -163,8 +164,8 @@ public CollectionEntity truncateCollection(String database, String name) throws
163164
164165 validateCollectionName (name );
165166
166- HttpResponseEntity res = httpManager .doPut (createEndpointUrl (database , "/_api/collection" , name , "/truncate" ),
167- null , null );
167+ HttpResponseEntity res = httpManager .doPut (createEndpointUrl (database , API_COLLECTION , name , "/truncate" ), null ,
168+ null );
168169
169170 return createEntity (res , CollectionEntity .class );
170171 }
@@ -177,7 +178,7 @@ public CollectionEntity setCollectionProperties(
177178 Long journalSize ) throws ArangoException {
178179
179180 validateCollectionName (name );
180- HttpResponseEntity res = httpManager .doPut (createEndpointUrl (database , "/_api/collection" , name , "/properties" ),
181+ HttpResponseEntity res = httpManager .doPut (createEndpointUrl (database , API_COLLECTION , name , "/properties" ),
181182 null , EntityFactory .toJsonString (
182183 new MapBuilder ().put ("waitForSync" , newWaitForSync ).put ("journalSize" , journalSize ).get ()));
183184
@@ -189,8 +190,8 @@ public CollectionEntity renameCollection(String database, String name, String ne
189190
190191 validateCollectionName (newName );
191192
192- HttpResponseEntity res = httpManager .doPut (createEndpointUrl (database , "/_api/collection" , name , "/rename" ),
193- null , EntityFactory .toJsonString (new MapBuilder ("name" , newName ).get ()));
193+ HttpResponseEntity res = httpManager .doPut (createEndpointUrl (database , API_COLLECTION , name , "/rename" ), null ,
194+ EntityFactory .toJsonString (new MapBuilder ("name" , newName ).get ()));
194195
195196 return createEntity (res , CollectionEntity .class );
196197 }
@@ -200,7 +201,7 @@ public CollectionEntity deleteCollection(String database, String name) throws Ar
200201
201202 validateCollectionName (name );
202203
203- HttpResponseEntity res = httpManager .doDelete (createEndpointUrl (database , "/_api/collection" , name ), null );
204+ HttpResponseEntity res = httpManager .doDelete (createEndpointUrl (database , API_COLLECTION , name ), null );
204205
205206 return createEntity (res , CollectionEntity .class );
206207 }
0 commit comments