|
26 | 26 | import com.arangodb.entity.*;
|
27 | 27 | import com.arangodb.model.*;
|
28 | 28 | import com.arangodb.util.RawData;
|
29 |
| -import org.slf4j.Logger; |
30 |
| -import org.slf4j.LoggerFactory; |
31 | 29 |
|
32 | 30 | import java.util.Collection;
|
33 | 31 |
|
| 32 | +import static com.arangodb.internal.ArangoErrors.*; |
34 | 33 | import static com.arangodb.internal.serde.SerdeUtils.constructParametricType;
|
35 | 34 |
|
36 | 35 | /**
|
|
39 | 38 | */
|
40 | 39 | public class ArangoCollectionImpl extends InternalArangoCollection implements ArangoCollection {
|
41 | 40 |
|
42 |
| - private static final Logger LOGGER = LoggerFactory.getLogger(ArangoCollectionImpl.class); |
43 |
| - |
44 | 41 | private final ArangoDatabase db;
|
45 | 42 |
|
46 | 43 | protected ArangoCollectionImpl(final ArangoDatabaseImpl db, final String name) {
|
@@ -139,17 +136,10 @@ public <T> T getDocument(final String key, final Class<T> type, final DocumentRe
|
139 | 136 | try {
|
140 | 137 | return executorSync().execute(getDocumentRequest(key, options), getDocumentResponseDeserializer(type));
|
141 | 138 | } catch (final ArangoDBException e) {
|
142 |
| - if (LOGGER.isDebugEnabled()) { |
143 |
| - LOGGER.debug(e.getMessage(), e); |
144 |
| - } |
145 |
| - |
146 |
| - // handle Response: 404, Error: 1655 - transaction not found |
147 |
| - if (e.getErrorNum() != null && e.getErrorNum() == 1655) { |
148 |
| - throw e; |
149 |
| - } |
150 |
| - |
151 |
| - if ((e.getResponseCode() != null && (e.getResponseCode() == 404 || e.getResponseCode() == 304 |
152 |
| - || e.getResponseCode() == 412))) { |
| 139 | + if (matches(e, 304) |
| 140 | + || matches(e, 404, ERROR_ARANGO_DOCUMENT_NOT_FOUND) |
| 141 | + || matches(e, 412, ERROR_ARANGO_CONFLICT) |
| 142 | + ) { |
153 | 143 | return null;
|
154 | 144 | }
|
155 | 145 | throw e;
|
@@ -332,14 +322,10 @@ public Boolean documentExists(final String key, final DocumentExistsOptions opti
|
332 | 322 | executorSync().execute(documentExistsRequest(key, options), Void.class);
|
333 | 323 | return true;
|
334 | 324 | } catch (final ArangoDBException e) {
|
335 |
| - |
336 |
| - // handle Response: 404, Error: 1655 - transaction not found |
337 |
| - if (e.getErrorNum() != null && e.getErrorNum() == 1655) { |
338 |
| - throw e; |
339 |
| - } |
340 |
| - |
341 |
| - if ((e.getResponseCode() != null && |
342 |
| - (e.getResponseCode() == 404 || e.getResponseCode() == 304 || e.getResponseCode() == 412))) { |
| 325 | + if (matches(e, 304) |
| 326 | + || matches(e, 404) |
| 327 | + || matches(e, 412) |
| 328 | + ) { |
343 | 329 | return false;
|
344 | 330 | }
|
345 | 331 | throw e;
|
@@ -408,10 +394,10 @@ public boolean exists() {
|
408 | 394 | getInfo();
|
409 | 395 | return true;
|
410 | 396 | } catch (final ArangoDBException e) {
|
411 |
| - if (ArangoErrors.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.equals(e.getErrorNum())) { |
412 |
| - return false; |
| 397 | + if (!matches(e, 404, ERROR_ARANGO_DATA_SOURCE_NOT_FOUND)) { |
| 398 | + throw e; |
413 | 399 | }
|
414 |
| - throw e; |
| 400 | + return false; |
415 | 401 | }
|
416 | 402 | }
|
417 | 403 |
|
|
0 commit comments