use of io.apiman.manager.api.beans.policies.UpdatePolicyDefinitionBean in project apiman by apiman.
the class PolicyDefinitionResourceImpl method update.
/**
* @see IPolicyDefinitionResource#update(java.lang.String, io.apiman.manager.api.beans.policies.UpdatePolicyDefinitionBean)
*/
@Override
public void update(String policyDefinitionId, UpdatePolicyDefinitionBean bean) throws PolicyDefinitionNotFoundException, NotAuthorizedException {
securityContext.checkAdminPermissions();
try {
PolicyDefinitionBean pdb = storage.getPolicyDefinition(policyDefinitionId);
if (pdb == null) {
throw ExceptionFactory.policyDefNotFoundException(policyDefinitionId);
}
if (pdb.getPluginId() != null) {
// $NON-NLS-1$
throw new SystemErrorException(Messages.i18n.format("CannotUpdatePluginPolicyDef"));
}
if (bean.getName() != null)
pdb.setName(bean.getName());
if (bean.getDescription() != null)
pdb.setDescription(bean.getDescription());
if (bean.getIcon() != null)
pdb.setIcon(bean.getIcon());
storage.updatePolicyDefinition(pdb);
} catch (AbstractRestException e) {
throw e;
} catch (Exception e) {
throw new SystemErrorException(e);
}
}
Aggregations