use of io.apiman.manager.api.beans.plans.UpdatePlanBean in project apiman by apiman.
the class PlanService method updatePlan.
public void updatePlan(String organizationId, String planId, UpdatePlanBean bean) throws PlanNotFoundException, NotAuthorizedException {
EntityUpdatedData auditData = new EntityUpdatedData();
tryAction(() -> {
PlanBean planForUpdate = storage.getPlan(organizationId, planId);
if (planForUpdate == null) {
throw ExceptionFactory.planNotFoundException(planId);
}
if (AuditUtils.valueChanged(planForUpdate.getDescription(), bean.getDescription())) {
// $NON-NLS-1$
auditData.addChange("description", planForUpdate.getDescription(), bean.getDescription());
planForUpdate.setDescription(bean.getDescription());
}
storage.updatePlan(planForUpdate);
storage.createAuditEntry(AuditUtils.planUpdated(planForUpdate, auditData, securityContext));
// $NON-NLS-1$
LOGGER.debug(String.format("Updated plan: %s", planForUpdate));
});
}
use of io.apiman.manager.api.beans.plans.UpdatePlanBean in project apiman by apiman.
the class OrganizationResourceImpl method updatePlan.
/**
* @see IOrganizationResource#updatePlan(java.lang.String,
* java.lang.String, io.apiman.manager.api.beans.plans.UpdatePlanBean)
*/
@Override
public void updatePlan(String organizationId, String planId, UpdatePlanBean bean) throws PlanNotFoundException, NotAuthorizedException {
securityContext.checkPermissions(PermissionType.planEdit, organizationId);
EntityUpdatedData auditData = new EntityUpdatedData();
try {
storage.beginTx();
PlanBean planForUpdate = storage.getPlan(organizationId, planId);
if (planForUpdate == null) {
throw ExceptionFactory.planNotFoundException(planId);
}
if (AuditUtils.valueChanged(planForUpdate.getDescription(), bean.getDescription())) {
// $NON-NLS-1$
auditData.addChange("description", planForUpdate.getDescription(), bean.getDescription());
planForUpdate.setDescription(bean.getDescription());
}
storage.updatePlan(planForUpdate);
storage.createAuditEntry(AuditUtils.planUpdated(planForUpdate, auditData, securityContext));
storage.commitTx();
// $NON-NLS-1$
log.debug(String.format("Updated plan: %s", planForUpdate));
} catch (AbstractRestException e) {
storage.rollbackTx();
throw e;
} catch (Exception e) {
storage.rollbackTx();
throw new SystemErrorException(e);
}
}
Aggregations