Search in sources :

Example 1 with RepositoryStoreException

use of com.intel.mtwilson.tag.repository.RepositoryStoreException 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);
    }
}
Also used : CertificateLocator(com.intel.mtwilson.datatypes.CertificateLocator) CertificateDAO(com.intel.mtwilson.tag.dao.jdbi.CertificateDAO) RepositoryException(com.intel.mtwilson.tag.repository.RepositoryException) RepositoryStoreConflictException(com.intel.mtwilson.tag.repository.RepositoryStoreConflictException) RepositoryCreateException(com.intel.mtwilson.tag.repository.RepositoryCreateException) RepositoryDeleteException(com.intel.mtwilson.tag.repository.RepositoryDeleteException) RepositoryStoreException(com.intel.mtwilson.tag.repository.RepositoryStoreException) RepositoryStoreConflictException(com.intel.mtwilson.tag.repository.RepositoryStoreConflictException) RepositoryRetrieveException(com.intel.mtwilson.tag.repository.RepositoryRetrieveException) RepositoryException(com.intel.mtwilson.tag.repository.RepositoryException) RepositorySearchException(com.intel.mtwilson.tag.repository.RepositorySearchException) RepositoryCreateConflictException(com.intel.mtwilson.tag.repository.RepositoryCreateConflictException) Certificate(com.intel.mtwilson.datatypes.Certificate) X509AttributeCertificate(com.intel.mtwilson.datatypes.X509AttributeCertificate) RepositoryStoreException(com.intel.mtwilson.tag.repository.RepositoryStoreException)

Aggregations

Certificate (com.intel.mtwilson.datatypes.Certificate)1 CertificateLocator (com.intel.mtwilson.datatypes.CertificateLocator)1 X509AttributeCertificate (com.intel.mtwilson.datatypes.X509AttributeCertificate)1 CertificateDAO (com.intel.mtwilson.tag.dao.jdbi.CertificateDAO)1 RepositoryCreateConflictException (com.intel.mtwilson.tag.repository.RepositoryCreateConflictException)1 RepositoryCreateException (com.intel.mtwilson.tag.repository.RepositoryCreateException)1 RepositoryDeleteException (com.intel.mtwilson.tag.repository.RepositoryDeleteException)1 RepositoryException (com.intel.mtwilson.tag.repository.RepositoryException)1 RepositoryRetrieveException (com.intel.mtwilson.tag.repository.RepositoryRetrieveException)1 RepositorySearchException (com.intel.mtwilson.tag.repository.RepositorySearchException)1 RepositoryStoreConflictException (com.intel.mtwilson.tag.repository.RepositoryStoreConflictException)1 RepositoryStoreException (com.intel.mtwilson.tag.repository.RepositoryStoreException)1