use of nl.knaw.huygens.persistence.PersistenceException in project timbuctoo by HuygensING.
the class HandleAdder method actualExecution.
private void actualExecution(HandleAdderParameters params) {
try {
URI uri = params.getUrlToRedirectTo();
LOG.info(String.format("Retrieving persistent url for '%s'", uri));
String persistentId = (manager.persistURL(uri.toString()));
URI persistentUrl = new URI(manager.getPersistentURL(persistentId));
transactionEnforcer.execute(timbuctooActions -> {
try {
timbuctooActions.addPid(persistentUrl, params.getEntityLookup());
LOG.info("committed pid");
return TransactionState.commit();
} catch (NotFoundException e) {
LOG.warn("Entity for entityLookup '{}' cannot be found", params.getEntityLookup());
try {
manager.deletePersistentId(persistentId);
} catch (PersistenceException e1) {
LOG.error("Cannot remove handle with id '{}'", persistentId);
}
return TransactionState.rollback();
}
});
} catch (PersistenceException | URISyntaxException e) {
LOG.error(Logmarkers.serviceUnavailable, "Could not create handle", e);
if (params.getRetries() < 5) {
LOG.warn(String.format("Re-adding %s%s job to the queue for '%s' '%s'", params.getRetries() + 1, getOrdinalSuffix(params.getRetries() + 1), params.getEntityLookup(), params.getUrlToRedirectTo()));
this.sender.send(params.nextTry());
}
}
}
Aggregations