Search in sources :

Example 1 with KvAttributeDAO

use of com.intel.mtwilson.tag.dao.jdbi.KvAttributeDAO in project OpenAttestation by OpenAttestation.

the class KvAttributeRepository method create.

@Override
public //    @RequiresPermissions("tag_kv_attributes:create")     
void create(KvAttribute item) {
    log.debug("KvAttribute:Create - Got request to create a new KvAttribute {}.", item.getId().toString());
    CertificateLocator locator = new CertificateLocator();
    locator.id = item.getId();
    try (KvAttributeDAO dao = TagJdbi.kvAttributeDao()) {
        dao.insert(item.getId(), item.getName(), item.getValue());
        log.debug("KvAttribute:Create - Created the KvAttribute {} successfully.", item.getId().toString());
    } catch (RepositoryException re) {
        throw re;
    } catch (Exception ex) {
        log.error("KvAttribute:Create - Error during KvAttribute creation.", ex);
        throw new RepositoryCreateException(ex, locator);
    }
}
Also used : CertificateLocator(com.intel.mtwilson.datatypes.CertificateLocator) KvAttributeDAO(com.intel.mtwilson.tag.dao.jdbi.KvAttributeDAO) RepositoryException(com.intel.mtwilson.datatypes.RepositoryException) RepositoryCreateException(com.intel.mtwilson.datatypes.RepositoryCreateException) RepositoryDeleteException(com.intel.mtwilson.datatypes.RepositoryDeleteException) RepositoryRetrieveException(com.intel.mtwilson.datatypes.RepositoryRetrieveException) RepositoryException(com.intel.mtwilson.datatypes.RepositoryException) RepositorySearchException(com.intel.mtwilson.datatypes.RepositorySearchException) RepositoryStoreConflictException(com.intel.mtwilson.datatypes.RepositoryStoreConflictException) RepositoryStoreException(com.intel.mtwilson.datatypes.RepositoryStoreException) RepositoryCreateException(com.intel.mtwilson.datatypes.RepositoryCreateException)

Example 2 with KvAttributeDAO

use of com.intel.mtwilson.tag.dao.jdbi.KvAttributeDAO in project OpenAttestation by OpenAttestation.

the class KvAttributeRepository method store.

@Override
public //    @RequiresPermissions("tag_kv_attributes:store")     
void store(KvAttribute item) {
    log.debug("KvAttribute:Store - Got request to update KvAttribute with id {}.", item.getId().toString());
    KvAttributeLocator locator = new KvAttributeLocator();
    locator.id = item.getId();
    try (KvAttributeDAO dao = TagJdbi.kvAttributeDao()) {
        KvAttribute obj = dao.findById(item.getId());
        // Allowing the user to only edit the value.
        if (obj != null) {
            dao.update(item.getId(), obj.getName(), item.getValue());
            log.debug("KvAttribute:Store - Updated the KvAttribute {} successfully.", item.getId().toString());
        } else {
            log.error("KvAttribute:Store - KvAttribute will not be updated since it does not exist.");
            throw new RepositoryStoreConflictException(locator);
        }
    } catch (RepositoryException re) {
        throw re;
    } catch (Exception ex) {
        log.error("KvAttribute:Store - Error during KvAttribute update.", ex);
        throw new RepositoryStoreException(ex, locator);
    }
}
Also used : KvAttributeDAO(com.intel.mtwilson.tag.dao.jdbi.KvAttributeDAO) KvAttribute(com.intel.mtwilson.datatypes.KvAttribute) RepositoryException(com.intel.mtwilson.datatypes.RepositoryException) KvAttributeLocator(com.intel.mtwilson.datatypes.KvAttributeLocator) RepositoryStoreConflictException(com.intel.mtwilson.datatypes.RepositoryStoreConflictException) RepositoryCreateException(com.intel.mtwilson.datatypes.RepositoryCreateException) RepositoryDeleteException(com.intel.mtwilson.datatypes.RepositoryDeleteException) RepositoryRetrieveException(com.intel.mtwilson.datatypes.RepositoryRetrieveException) RepositoryException(com.intel.mtwilson.datatypes.RepositoryException) RepositorySearchException(com.intel.mtwilson.datatypes.RepositorySearchException) RepositoryStoreConflictException(com.intel.mtwilson.datatypes.RepositoryStoreConflictException) RepositoryStoreException(com.intel.mtwilson.datatypes.RepositoryStoreException) RepositoryStoreException(com.intel.mtwilson.datatypes.RepositoryStoreException)

Aggregations

RepositoryCreateException (com.intel.mtwilson.datatypes.RepositoryCreateException)2 RepositoryDeleteException (com.intel.mtwilson.datatypes.RepositoryDeleteException)2 RepositoryException (com.intel.mtwilson.datatypes.RepositoryException)2 RepositoryRetrieveException (com.intel.mtwilson.datatypes.RepositoryRetrieveException)2 RepositorySearchException (com.intel.mtwilson.datatypes.RepositorySearchException)2 RepositoryStoreConflictException (com.intel.mtwilson.datatypes.RepositoryStoreConflictException)2 RepositoryStoreException (com.intel.mtwilson.datatypes.RepositoryStoreException)2 KvAttributeDAO (com.intel.mtwilson.tag.dao.jdbi.KvAttributeDAO)2 CertificateLocator (com.intel.mtwilson.datatypes.CertificateLocator)1 KvAttribute (com.intel.mtwilson.datatypes.KvAttribute)1 KvAttributeLocator (com.intel.mtwilson.datatypes.KvAttributeLocator)1