Search in sources :

Example 1 with RepositoryStoreConflictException

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

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