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);
}
}
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);
}
}
Aggregations