Search in sources :

Example 1 with RepositoryDeleteException

use of com.intel.mtwilson.tag.repository.RepositoryDeleteException in project OpenAttestation by OpenAttestation.

the class CertificateRepository method delete.

@Override
public //    @RequiresPermissions("tag_certificates:delete,search") 
void delete(CertificateFilterCriteria criteria) {
    log.debug("Certificate:Delete - Got request to delete certificate by search criteria.");
    CertificateCollection objCollection = search(criteria);
    try {
        for (Certificate obj : objCollection.getCertificates()) {
            CertificateLocator locator = new CertificateLocator();
            locator.id = obj.getId();
            delete(locator);
        }
    } catch (RepositoryException re) {
        throw re;
    } catch (Exception ex) {
        log.error("Certificate:Delete - Error during Certificate deletion.", ex);
        throw new RepositoryDeleteException(ex);
    }
}
Also used : CertificateLocator(com.intel.mtwilson.datatypes.CertificateLocator) RepositoryDeleteException(com.intel.mtwilson.tag.repository.RepositoryDeleteException) CertificateCollection(com.intel.mtwilson.datatypes.CertificateCollection) RepositoryException(com.intel.mtwilson.tag.repository.RepositoryException) 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)

Example 2 with RepositoryDeleteException

use of com.intel.mtwilson.tag.repository.RepositoryDeleteException in project OpenAttestation by OpenAttestation.

the class CertificateRepository method delete.

@Override
public //    @RequiresPermissions("tag_certificates:delete") 
void delete(CertificateLocator locator) {
    if (locator == null || locator.id == null) {
        return;
    }
    log.debug("Certificate:Delete - Got request to delete Certificate with id {}.", locator.id.toString());
    try (CertificateDAO dao = TagJdbi.certificateDao()) {
        Certificate obj = dao.findById(locator.id);
        if (obj != null) {
            dao.delete(locator.id);
            log.debug("Certificate:Delete - Deleted the Certificate {} successfully.", locator.id.toString());
        } else {
            log.info("Certificate:Delete - Certificate does not exist in the system.");
        }
    } catch (Exception ex) {
        log.error("Certificate:Delete - Error during certificate deletion.", ex);
        throw new RepositoryDeleteException(ex, locator);
    }
}
Also used : RepositoryDeleteException(com.intel.mtwilson.tag.repository.RepositoryDeleteException) CertificateDAO(com.intel.mtwilson.tag.dao.jdbi.CertificateDAO) 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)

Aggregations

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