@@ -50,26 +50,25 @@ public class InternalDocumentDriverImpl extends BaseArangoDriverImpl implements
5050
5151 private static final Pattern pattern = Pattern .compile ("^/_db/.*/_api/document/(.*)$" );
5252
53- InternalDocumentDriverImpl (ArangoConfigure configure , HttpManager httpManager ) {
53+ InternalDocumentDriverImpl (final ArangoConfigure configure , final HttpManager httpManager ) {
5454 super (configure , httpManager );
5555 }
5656
5757 private <T > DocumentEntity <T > internalCreateDocument (
58- String database ,
59- String collectionName ,
60- String documentKey ,
61- T value ,
62- Boolean createCollection ,
63- Boolean waitForSync ,
64- boolean raw ) throws ArangoException {
58+ final String database ,
59+ final String collectionName ,
60+ final String documentKey ,
61+ final T value ,
62+ final Boolean waitForSync ,
63+ final boolean raw ) throws ArangoException {
6564
6665 validateCollectionName (collectionName );
6766
6867 String body ;
6968 if (raw ) {
7069 body = value .toString ();
7170 } else if (documentKey != null ) {
72- JsonElement elem = EntityFactory .toJsonElement (value , false );
71+ final JsonElement elem = EntityFactory .toJsonElement (value , false );
7372 if (elem .isJsonObject ()) {
7473 elem .getAsJsonObject ().addProperty (BaseDocument .KEY , documentKey );
7574 }
@@ -78,13 +77,11 @@ private <T> DocumentEntity<T> internalCreateDocument(
7877 body = EntityFactory .toJsonString (value );
7978 }
8079
81- HttpResponseEntity res = httpManager .doPost (createDocumentEndpointUrl (database ),
82- new MapBuilder ().put ("collection" , collectionName ).put ("createCollection" , createCollection )
83- .put (WAIT_FOR_SYNC , waitForSync ).get (),
84- body );
80+ final HttpResponseEntity res = httpManager .doPost (createDocumentEndpointUrl (database ),
81+ new MapBuilder ().put ("collection" , collectionName ).put (WAIT_FOR_SYNC , waitForSync ).get (), body );
8582
8683 @ SuppressWarnings ("unchecked" )
87- DocumentEntity <T > result = createEntity (res , DocumentEntity .class );
84+ final DocumentEntity <T > result = createEntity (res , DocumentEntity .class );
8885
8986 annotationHandler .updateDocumentAttributes (value , result .getDocumentRevision (), result .getDocumentHandle (),
9087 result .getDocumentKey ());
@@ -95,93 +92,89 @@ private <T> DocumentEntity<T> internalCreateDocument(
9592
9693 @ Override
9794 public <T > DocumentEntity <T > createDocument (
98- String database ,
99- String collectionName ,
100- String documentKey ,
101- T value ,
102- Boolean createCollection ,
103- Boolean waitForSync ) throws ArangoException {
104- return internalCreateDocument (database , collectionName , documentKey , value , createCollection , waitForSync ,
105- false );
95+ final String database ,
96+ final String collectionName ,
97+ final String documentKey ,
98+ final T value ,
99+ final Boolean waitForSync ) throws ArangoException {
100+ return internalCreateDocument (database , collectionName , documentKey , value , waitForSync , false );
106101 }
107102
108103 @ Override
109104 public DocumentEntity <String > createDocumentRaw (
110- String database ,
111- String collectionName ,
112- String rawJsonObjectString ,
113- Boolean createCollection ,
114- Boolean waitForSync ) throws ArangoException {
115- return internalCreateDocument (database , collectionName , null , rawJsonObjectString , createCollection ,
116- waitForSync , true );
105+ final String database ,
106+ final String collectionName ,
107+ final String rawJsonObjectString ,
108+ final Boolean waitForSync ) throws ArangoException {
109+ return internalCreateDocument (database , collectionName , null , rawJsonObjectString , waitForSync , true );
117110 }
118111
119112 @ SuppressWarnings ("unchecked" )
120113 @ Override
121114 public <T > DocumentEntity <T > replaceDocument (
122- String database ,
123- String documentHandle ,
124- T value ,
125- Long rev ,
126- Policy policy ,
127- Boolean waitForSync ) throws ArangoException {
115+ final String database ,
116+ final String documentHandle ,
117+ final T value ,
118+ final Long rev ,
119+ final Policy policy ,
120+ final Boolean waitForSync ) throws ArangoException {
128121
129122 validateDocumentHandle (documentHandle );
130123
131124 Map <String , Object > header = null ;
132125 if (rev != null ) {
133- MapBuilder mapBuilder = new MapBuilder ().put ("If-Match" , rev );
126+ final MapBuilder mapBuilder = new MapBuilder ().put ("If-Match" , rev );
134127 header = mapBuilder .get ();
135128 }
136129
137- HttpResponseEntity res = httpManager .doPut (createDocumentEndpointUrl (database , documentHandle ), header ,
130+ final HttpResponseEntity res = httpManager .doPut (createDocumentEndpointUrl (database , documentHandle ), header ,
138131 new MapBuilder ().put (WAIT_FOR_SYNC , waitForSync ).get (), EntityFactory .toJsonString (value ));
139132
140- DocumentEntity <T > result = createEntity (res , DocumentEntity .class );
133+ final DocumentEntity <T > result = createEntity (res , DocumentEntity .class );
141134 annotationHandler .updateDocumentRev (value , result .getDocumentRevision ());
142135 result .setEntity (value );
143136 return result ;
144137 }
145138
146139 @ Override
147140 public DocumentEntity <String > replaceDocumentRaw (
148- String database ,
149- String documentHandle ,
150- String rawJsonString ,
151- Long rev ,
152- Policy policy ,
153- Boolean waitForSync ) throws ArangoException {
141+ final String database ,
142+ final String documentHandle ,
143+ final String rawJsonString ,
144+ final Long rev ,
145+ final Policy policy ,
146+ final Boolean waitForSync ) throws ArangoException {
154147
155148 validateDocumentHandle (documentHandle );
156- HttpResponseEntity res = httpManager .doPut (
149+ final HttpResponseEntity res = httpManager .doPut (
157150 createDocumentEndpointUrl (database , documentHandle ), new MapBuilder ().put ("rev" , rev )
158151 .put (POLICY , policy == null ? null : policy .name ()).put (WAIT_FOR_SYNC , waitForSync ).get (),
159152 rawJsonString );
160153
161154 @ SuppressWarnings ("unchecked" )
162- DocumentEntity <String > result = createEntity (res , DocumentEntity .class );
155+ final DocumentEntity <String > result = createEntity (res , DocumentEntity .class );
163156 result .setEntity (rawJsonString );
164157 return result ;
165158 }
166159
167160 @ Override
168161 public <T > DocumentEntity <T > updateDocument (
169- String database ,
170- String documentHandle ,
171- T value ,
172- Long rev ,
173- Policy policy ,
174- Boolean waitForSync ,
175- Boolean keepNull ) throws ArangoException {
162+ final String database ,
163+ final String documentHandle ,
164+ final T value ,
165+ final Long rev ,
166+ final Policy policy ,
167+ final Boolean waitForSync ,
168+ final Boolean keepNull ) throws ArangoException {
176169
177170 validateDocumentHandle (documentHandle );
178- HttpResponseEntity res = httpManager .doPatch (createDocumentEndpointUrl (database , documentHandle ),
171+ final HttpResponseEntity res = httpManager .doPatch (createDocumentEndpointUrl (database , documentHandle ),
179172 new MapBuilder ().put ("rev" , rev ).put (POLICY , policy == null ? null : policy .name ())
180173 .put (WAIT_FOR_SYNC , waitForSync ).put ("keepNull" , keepNull ).get (),
181174 EntityFactory .toJsonString (value , keepNull != null && !keepNull ));
182175
183176 @ SuppressWarnings ("unchecked" )
184- DocumentEntity <T > result = createEntity (res , DocumentEntity .class );
177+ final DocumentEntity <T > result = createEntity (res , DocumentEntity .class );
185178 annotationHandler .updateDocumentAttributes (value , result .getDocumentRevision (), result .getDocumentHandle (),
186179 result .getDocumentKey ());
187180 result .setEntity (value );
@@ -190,45 +183,45 @@ public <T> DocumentEntity<T> updateDocument(
190183
191184 @ Override
192185 public DocumentEntity <String > updateDocumentRaw (
193- String database ,
194- String documentHandle ,
195- String rawJsonString ,
196- Long rev ,
197- Policy policy ,
198- Boolean waitForSync ,
199- Boolean keepNull ) throws ArangoException {
186+ final String database ,
187+ final String documentHandle ,
188+ final String rawJsonString ,
189+ final Long rev ,
190+ final Policy policy ,
191+ final Boolean waitForSync ,
192+ final Boolean keepNull ) throws ArangoException {
200193
201194 validateDocumentHandle (documentHandle );
202- HttpResponseEntity res = httpManager .doPatch (createDocumentEndpointUrl (database , documentHandle ),
195+ final HttpResponseEntity res = httpManager .doPatch (createDocumentEndpointUrl (database , documentHandle ),
203196 new MapBuilder ().put ("rev" , rev ).put (POLICY , policy == null ? null : policy .name ())
204197 .put (WAIT_FOR_SYNC , waitForSync ).put ("keepNull" , keepNull ).get (),
205198 rawJsonString );
206199
207200 @ SuppressWarnings ("unchecked" )
208- DocumentEntity <String > result = createEntity (res , DocumentEntity .class );
201+ final DocumentEntity <String > result = createEntity (res , DocumentEntity .class );
209202 result .setEntity (rawJsonString );
210203 return result ;
211204 }
212205
213206 @ Override
214- public List <String > getDocuments (String database , String collectionName ) throws ArangoException {
215- HttpResponseEntity res = httpManager .doPut (createEndpointUrl (database , "/_api/simple/all-keys" ), null ,
207+ public List <String > getDocuments (final String database , final String collectionName ) throws ArangoException {
208+ final HttpResponseEntity res = httpManager .doPut (createEndpointUrl (database , "/_api/simple/all-keys" ), null ,
216209 EntityFactory .toJsonString (new MapBuilder ().put ("collection" , collectionName ).put ("type" , "id" ).get ()));
217210
218211 @ SuppressWarnings ("unchecked" )
219- CursorEntity <String > tmp = createEntity (res , CursorEntity .class , String .class );
212+ final CursorEntity <String > tmp = createEntity (res , CursorEntity .class , String .class );
220213
221214 return tmp .getResults ();
222215 }
223216
224- private void updateDocumentHandles (List <String > documents ) {
225- ListIterator <String > lit = documents .listIterator ();
217+ private void updateDocumentHandles (final List <String > documents ) {
218+ final ListIterator <String > lit = documents .listIterator ();
226219 while (lit .hasNext ()) {
227- String d = lit .next ();
220+ final String d = lit .next ();
228221 if (d .startsWith (API_DOCUMENT_PREFIX )) {
229222 lit .set (d .substring (API_DOCUMENT_PREFIX .length ()));
230223 } else {
231- Matcher matcher = pattern .matcher (d );
224+ final Matcher matcher = pattern .matcher (d );
232225 if (matcher .find ()) {
233226 lit .set (matcher .group (1 ));
234227 }
@@ -237,25 +230,25 @@ private void updateDocumentHandles(List<String> documents) {
237230 }
238231
239232 @ Override
240- public long checkDocument (String database , String documentHandle ) throws ArangoException {
233+ public long checkDocument (final String database , final String documentHandle ) throws ArangoException {
241234 validateDocumentHandle (documentHandle );
242- HttpResponseEntity res = httpManager .doHead (createDocumentEndpointUrl (database , documentHandle ), null );
235+ final HttpResponseEntity res = httpManager .doHead (createDocumentEndpointUrl (database , documentHandle ), null );
243236
244- DefaultEntity entity = createEntity (res , DefaultEntity .class );
237+ final DefaultEntity entity = createEntity (res , DefaultEntity .class );
245238 return entity .getEtag ();
246239
247240 }
248241
249242 @ Override
250243 public <T > DocumentEntity <T > getDocument (
251- String database ,
252- String documentHandle ,
253- Class <T > clazz ,
254- Long ifNoneMatchRevision ,
255- Long ifMatchRevision ) throws ArangoException {
244+ final String database ,
245+ final String documentHandle ,
246+ final Class <T > clazz ,
247+ final Long ifNoneMatchRevision ,
248+ final Long ifMatchRevision ) throws ArangoException {
256249
257250 validateDocumentHandle (documentHandle );
258- HttpResponseEntity res = httpManager .doGet (createDocumentEndpointUrl (database , documentHandle ),
251+ final HttpResponseEntity res = httpManager .doGet (createDocumentEndpointUrl (database , documentHandle ),
259252 new MapBuilder ().put ("If-None-Match" , ifNoneMatchRevision , true ).put ("If-Match" , ifMatchRevision ).get (),
260253 null );
261254 @ SuppressWarnings ("unchecked" )
@@ -267,16 +260,19 @@ public <T> DocumentEntity<T> getDocument(
267260 }
268261
269262 @ Override
270- public String getDocumentRaw (String database , String documentHandle , Long ifNoneMatchRevision , Long ifMatchRevision )
271- throws ArangoException {
263+ public String getDocumentRaw (
264+ final String database ,
265+ final String documentHandle ,
266+ final Long ifNoneMatchRevision ,
267+ final Long ifMatchRevision ) throws ArangoException {
272268
273269 validateDocumentHandle (documentHandle );
274- HttpResponseEntity res = httpManager .doGet (createDocumentEndpointUrl (database , documentHandle ),
270+ final HttpResponseEntity res = httpManager .doGet (createDocumentEndpointUrl (database , documentHandle ),
275271 new MapBuilder ().put ("If-None-Match" , ifNoneMatchRevision , true ).put ("If-Match" , ifMatchRevision ).get (),
276272 null );
277273
278274 if (res .getStatusCode () >= 400 ) {
279- BaseDocument entity = new BaseDocument ();
275+ final BaseDocument entity = new BaseDocument ();
280276 entity .setError (true );
281277 entity .setCode (res .getStatusCode ());
282278 entity .setStatusCode (res .getStatusCode ());
@@ -289,11 +285,14 @@ public String getDocumentRaw(String database, String documentHandle, Long ifNone
289285 }
290286
291287 @ Override
292- public DocumentEntity <?> deleteDocument (String database , String documentHandle , Long rev , Policy policy )
293- throws ArangoException {
288+ public DocumentEntity <?> deleteDocument (
289+ final String database ,
290+ final String documentHandle ,
291+ final Long rev ,
292+ final Policy policy ) throws ArangoException {
294293
295294 validateDocumentHandle (documentHandle );
296- HttpResponseEntity res = httpManager .doDelete (createDocumentEndpointUrl (database , documentHandle ),
295+ final HttpResponseEntity res = httpManager .doDelete (createDocumentEndpointUrl (database , documentHandle ),
297296 new MapBuilder ().put ("rev" , rev ).put (POLICY , policy == null ? null : policy .name ().toLowerCase (Locale .US ))
298297 .get ());
299298
0 commit comments