private static long resolveFileIdByName(String fileName) {
final OAbstractPaginatedStorage storage = (OAbstractPaginatedStorage) ODatabaseRecordThreadLocal.instance().get().getStorage()
.getUnderlying();
boolean rollback = false;
final OAtomicOperation atomicOperation;
try {
atomicOperation = storage.getAtomicOperationsManager().startAtomicOperation(fileName, true);
} catch (IOException e) {
throw OException.wrapException(new OIndexEngineException("Error creation of sbtree with name " + fileName, fileName), e);
}
try {
long fileId;
if (atomicOperation.isFileExists(fileName)) {
fileId = atomicOperation.loadFile(fileName);
} else {
fileId = atomicOperation.addFile(fileName);
}
return fileId;
} catch (IOException e) {
rollback = true;
throw OException.wrapException(new OIndexEngineException("Error creation of sbtree with name " + fileName, fileName), e);
} finally {
try {
storage.getAtomicOperationsManager().endAtomicOperation(rollback);
} catch (IOException ioe) {
OLogManager.instance().error(OMixedIndexRIDContainer.class, "Error of rollback of atomic operation", ioe);
}
}
}