use of io.apiman.manager.api.beans.orgs.UpdateOrganizationBean in project apiman by apiman.
the class OrganizationResourceImpl method update.
/**
* @see IOrganizationResource#update(java.lang.String, io.apiman.manager.api.beans.orgs.UpdateOrganizationBean)
*/
@Override
public void update(String organizationId, UpdateOrganizationBean bean) throws OrganizationNotFoundException, NotAuthorizedException {
securityContext.checkPermissions(PermissionType.orgEdit, organizationId);
try {
storage.beginTx();
OrganizationBean orgForUpdate = getOrganizationFromStorage(organizationId);
EntityUpdatedData auditData = new EntityUpdatedData();
if (AuditUtils.valueChanged(orgForUpdate.getDescription(), bean.getDescription())) {
// $NON-NLS-1$
auditData.addChange("description", orgForUpdate.getDescription(), bean.getDescription());
orgForUpdate.setDescription(bean.getDescription());
}
storage.updateOrganization(orgForUpdate);
storage.createAuditEntry(AuditUtils.organizationUpdated(orgForUpdate, auditData, securityContext));
storage.commitTx();
// $NON-NLS-1$
log.debug(String.format("Updated organization %s: %s", orgForUpdate.getName(), orgForUpdate));
} catch (AbstractRestException e) {
storage.rollbackTx();
throw e;
} catch (Exception e) {
storage.rollbackTx();
throw new SystemErrorException(e);
}
}
use of io.apiman.manager.api.beans.orgs.UpdateOrganizationBean in project apiman by apiman.
the class OrganizationService method updateOrg.
public void updateOrg(String organizationId, UpdateOrganizationBean bean) throws OrganizationNotFoundException, NotAuthorizedException {
OrganizationBean orgForUpdate = tryAction(() -> getOrganizationFromStorage(organizationId));
EntityUpdatedData auditData = new EntityUpdatedData();
if (AuditUtils.valueChanged(orgForUpdate.getDescription(), bean.getDescription())) {
// $NON-NLS-1$
auditData.addChange("description", orgForUpdate.getDescription(), bean.getDescription());
orgForUpdate.setDescription(bean.getDescription());
}
tryAction(() -> {
storage.updateOrganization(orgForUpdate);
storage.createAuditEntry(AuditUtils.organizationUpdated(orgForUpdate, auditData, securityContext));
});
// $NON-NLS-1$
LOGGER.debug(String.format("Updated organization %s: %s", orgForUpdate.getName(), orgForUpdate));
}
Aggregations