Search in sources :

Example 1 with KvAttributeLocator

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

Example 2 with KvAttributeLocator

use of com.intel.mtwilson.datatypes.KvAttributeLocator in project OpenAttestation by OpenAttestation.

the class KvAttributeRepository method delete.

@Override
public //    @RequiresPermissions("tag_kv_attributes:delete,search")     
void delete(KvAttributeFilterCriteria criteria) {
    log.debug("KvAttribute:Delete - Got request to delete KvAttribute by search criteria.");
    KvAttributeCollection objCollection = search(criteria);
    try {
        for (KvAttribute obj : objCollection.getKvAttributes()) {
            KvAttributeLocator locator = new KvAttributeLocator();
            locator.id = obj.getId();
            delete(locator);
        }
    } catch (RepositoryException re) {
        throw re;
    } catch (Exception ex) {
        log.error("KvAttribute:Delete - Error during KvAttribute deletion.", ex);
        throw new RepositoryDeleteException(ex);
    }
}
Also used : RepositoryDeleteException(com.intel.mtwilson.datatypes.RepositoryDeleteException) KvAttributeCollection(com.intel.mtwilson.datatypes.KvAttributeCollection) KvAttribute(com.intel.mtwilson.datatypes.KvAttribute) RepositoryException(com.intel.mtwilson.datatypes.RepositoryException) KvAttributeLocator(com.intel.mtwilson.datatypes.KvAttributeLocator) 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)

Aggregations

KvAttribute (com.intel.mtwilson.datatypes.KvAttribute)2 KvAttributeLocator (com.intel.mtwilson.datatypes.KvAttributeLocator)2 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 KvAttributeCollection (com.intel.mtwilson.datatypes.KvAttributeCollection)1 KvAttributeDAO (com.intel.mtwilson.tag.dao.jdbi.KvAttributeDAO)1