Skip to content

Commit

Permalink
Fix db, collection creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mpv1989 committed Jul 24, 2018
1 parent 9d0c9f2 commit 3429a50
Showing 1 changed file with 4 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,8 @@ private ArangoDatabase db() {
return db;
}
db = arango.db(databaseName);
try {
db.getInfo();
} catch (final ArangoDBException e) {
if (new Integer(404).equals(e.getResponseCode())) {
try {
arango.createDatabase(databaseName);
} catch (final ArangoDBException e1) {
throw translateExceptionIfPossible(e1);
}
} else {
throw translateExceptionIfPossible(e);
}
if (!db.exists()) {
db.create();
}
database = db;
return db;
Expand Down Expand Up @@ -169,18 +159,8 @@ private ArangoCollection _collection(

return collectionCache.computeIfAbsent(name, collName -> {
final ArangoCollection collection = db().collection(collName);
try {
collection.getInfo();
} catch (final ArangoDBException e) {
if (new Integer(404).equals(e.getResponseCode())) {
try {
db().createCollection(collName, options);
} catch (final ArangoDBException e1) {
throw translateExceptionIfPossible(e1);
}
} else {
throw translateExceptionIfPossible(e);
}
if (!collection.exists()) {
collection.create(options);
}
if (persistentEntity != null) {
ensureCollectionIndexes(collection(collection), persistentEntity);
Expand Down

0 comments on commit 3429a50

Please sign in to comment.