33
33
public class InternalCollectionDriverImpl extends BaseArangoDriverImpl
34
34
implements com .arangodb .InternalCollectionDriver {
35
35
36
+ private static final String API_COLLECTION = "/_api/collection" ;
37
+
36
38
InternalCollectionDriverImpl (ArangoConfigure configure , HttpManager httpManager ) {
37
39
super (configure , httpManager );
38
40
}
39
41
40
42
@ Override
41
43
public CollectionEntity createCollection (String database , String name , CollectionOptions collectionOptions )
42
44
throws ArangoException {
43
- if (collectionOptions == null ) {
44
- collectionOptions = new CollectionOptions ();
45
+ CollectionOptions tmpCollectionOptions = collectionOptions ;
46
+ if (tmpCollectionOptions == null ) {
47
+ tmpCollectionOptions = new CollectionOptions ();
45
48
}
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 ())
58
61
.get ()));
59
62
60
63
return createEntity (res , CollectionEntity .class );
@@ -65,7 +68,7 @@ public CollectionEntity createCollection(String database, String name, Collectio
65
68
public CollectionEntity getCollection (String database , String name ) throws ArangoException {
66
69
validateCollectionName (name );
67
70
68
- HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , "/_api/collection" , name ), null );
71
+ HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , API_COLLECTION , name ), null );
69
72
70
73
return createEntity (res , CollectionEntity .class );
71
74
}
@@ -75,7 +78,7 @@ public CollectionEntity getCollectionRevision(String database, String name) thro
75
78
76
79
validateCollectionName (name );
77
80
78
- HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , "/_api/collection" , name , "/revision" ),
81
+ HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , API_COLLECTION , name , "/revision" ),
79
82
null );
80
83
81
84
return createEntity (res , CollectionEntity .class );
@@ -86,7 +89,7 @@ public CollectionEntity getCollectionProperties(String database, String name) th
86
89
87
90
validateCollectionName (name );
88
91
89
- HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , "/_api/collection" , name , "/properties" ),
92
+ HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , API_COLLECTION , name , "/properties" ),
90
93
null );
91
94
92
95
return createEntity (res , CollectionEntity .class );
@@ -97,8 +100,7 @@ public CollectionEntity getCollectionCount(String database, String name) throws
97
100
98
101
validateCollectionName (name );
99
102
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 );
102
104
103
105
return createEntity (res , CollectionEntity .class );
104
106
}
@@ -108,8 +110,7 @@ public CollectionEntity getCollectionFigures(String database, String name) throw
108
110
109
111
validateCollectionName (name );
110
112
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 );
113
114
114
115
return createEntity (res , CollectionEntity .class );
115
116
}
@@ -119,7 +120,7 @@ public CollectionEntity getCollectionChecksum(String database, String name, Bool
119
120
throws ArangoException {
120
121
121
122
validateCollectionName (name );
122
- HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , "/_api/collection" , name , "/checksum" ),
123
+ HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , API_COLLECTION , name , "/checksum" ),
123
124
new MapBuilder ().put ("withRevisions" , withRevisions ).put ("withData" , withData ).get ());
124
125
125
126
return createEntity (res , CollectionEntity .class );
@@ -129,7 +130,7 @@ public CollectionEntity getCollectionChecksum(String database, String name, Bool
129
130
@ Override
130
131
public CollectionsEntity getCollections (String database , Boolean excludeSystem ) throws ArangoException {
131
132
132
- HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , "/_api/collection" ), null ,
133
+ HttpResponseEntity res = httpManager .doGet (createEndpointUrl (database , API_COLLECTION ), null ,
133
134
new MapBuilder ().put ("excludeSystem" , excludeSystem ).get ());
134
135
135
136
return createEntity (res , CollectionsEntity .class );
@@ -140,7 +141,7 @@ public CollectionsEntity getCollections(String database, Boolean excludeSystem)
140
141
public CollectionEntity loadCollection (String database , String name , Boolean count ) throws ArangoException {
141
142
142
143
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 ,
144
145
EntityFactory .toJsonString (new MapBuilder ("count" , count ).get ()));
145
146
146
147
return createEntity (res , CollectionEntity .class );
@@ -163,8 +164,8 @@ public CollectionEntity truncateCollection(String database, String name) throws
163
164
164
165
validateCollectionName (name );
165
166
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 );
168
169
169
170
return createEntity (res , CollectionEntity .class );
170
171
}
@@ -177,7 +178,7 @@ public CollectionEntity setCollectionProperties(
177
178
Long journalSize ) throws ArangoException {
178
179
179
180
validateCollectionName (name );
180
- HttpResponseEntity res = httpManager .doPut (createEndpointUrl (database , "/_api/collection" , name , "/properties" ),
181
+ HttpResponseEntity res = httpManager .doPut (createEndpointUrl (database , API_COLLECTION , name , "/properties" ),
181
182
null , EntityFactory .toJsonString (
182
183
new MapBuilder ().put ("waitForSync" , newWaitForSync ).put ("journalSize" , journalSize ).get ()));
183
184
@@ -189,8 +190,8 @@ public CollectionEntity renameCollection(String database, String name, String ne
189
190
190
191
validateCollectionName (newName );
191
192
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 ()));
194
195
195
196
return createEntity (res , CollectionEntity .class );
196
197
}
@@ -200,7 +201,7 @@ public CollectionEntity deleteCollection(String database, String name) throws Ar
200
201
201
202
validateCollectionName (name );
202
203
203
- HttpResponseEntity res = httpManager .doDelete (createEndpointUrl (database , "/_api/collection" , name ), null );
204
+ HttpResponseEntity res = httpManager .doDelete (createEndpointUrl (database , API_COLLECTION , name ), null );
204
205
205
206
return createEntity (res , CollectionEntity .class );
206
207
}
0 commit comments