use of com.intel.mtwilson.tag.repository.RepositoryStoreConflictException in project OpenAttestation by OpenAttestation.
the class CertificateRepository method store.
@Override
public // @RequiresPermissions("tag_certificates:store")
void store(Certificate item) {
log.debug("Certificate:Store - Got request to update Certificate with id {}.", item.getId().toString());
// will be used if we need to throw an exception
CertificateLocator locator = new CertificateLocator();
locator.id = item.getId();
try (CertificateDAO dao = TagJdbi.certificateDao()) {
Certificate obj = dao.findById(item.getId());
// Allowing the user to only edit the revoked field.
if (obj != null) {
dao.updateRevoked(item.getId(), item.isRevoked());
log.debug("Certificate:Store - Updated the Certificate {} successfully.", item.getId().toString());
} else {
log.error("Certificate:Store - Certificate will not be updated since it does not exist.");
throw new RepositoryStoreConflictException(locator);
}
} catch (RepositoryException re) {
throw re;
} catch (Exception ex) {
log.error("Certificate:Store - Error during Certificate update.", ex);
throw new RepositoryStoreException(ex, locator);
}
}
Aggregations