Search in sources :

Example 6 with CertificateLocator

use of com.intel.mtwilson.datatypes.CertificateLocator 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

CertificateLocator (com.intel.mtwilson.datatypes.CertificateLocator)6 Certificate (com.intel.mtwilson.datatypes.Certificate)5 RepositoryException (com.intel.mtwilson.tag.repository.RepositoryException)5 CertificateDAO (com.intel.mtwilson.tag.dao.jdbi.CertificateDAO)4 X509AttributeCertificate (com.intel.mtwilson.datatypes.X509AttributeCertificate)3 RepositoryCreateConflictException (com.intel.mtwilson.tag.repository.RepositoryCreateConflictException)3 RepositoryCreateException (com.intel.mtwilson.tag.repository.RepositoryCreateException)3 RepositoryDeleteException (com.intel.mtwilson.tag.repository.RepositoryDeleteException)3 RepositoryRetrieveException (com.intel.mtwilson.tag.repository.RepositoryRetrieveException)3 RepositorySearchException (com.intel.mtwilson.tag.repository.RepositorySearchException)3 RepositoryStoreConflictException (com.intel.mtwilson.tag.repository.RepositoryStoreConflictException)3 RepositoryStoreException (com.intel.mtwilson.tag.repository.RepositoryStoreException)3 RepositoryInvalidInputException (com.intel.mtwilson.tag.repository.RepositoryInvalidInputException)2 ApiClient (com.intel.mtwilson.ApiClient)1 AssetTagCertCreateRequest (com.intel.mtwilson.datatypes.AssetTagCertCreateRequest)1 AssetTagCertRevokeRequest (com.intel.mtwilson.datatypes.AssetTagCertRevokeRequest)1 CertificateCollection (com.intel.mtwilson.datatypes.CertificateCollection)1 KvAttribute (com.intel.mtwilson.datatypes.KvAttribute)1 KvAttributeCollection (com.intel.mtwilson.datatypes.KvAttributeCollection)1 KvAttributeFilterCriteria (com.intel.mtwilson.datatypes.KvAttributeFilterCriteria)1