use of io.lumeer.engine.api.exception.UnsuccessfulOperationException in project engine by Lumeer.
the class MongoDbStorage method createOldDocument.
@Override
public void createOldDocument(final String collectionName, final DataDocument dataDocument, final String documentId, final int version) throws UnsuccessfulOperationException {
Document doc = new Document(dataDocument);
doc.put(DOCUMENT_ID, new BasicDBObject(DOCUMENT_ID, new ObjectId(documentId)));
try {
database.getCollection(collectionName).insertOne(doc);
} catch (MongoWriteException e) {
if (e.getError().getCategory().equals(ErrorCategory.DUPLICATE_KEY)) {
throw new UnsuccessfulOperationException(e.getMessage(), e.getCause());
} else {
throw e;
}
}
}
Aggregations