Search in sources :

Example 1 with UpdatePolicyDefinitionBean

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);
    }
}
Also used : SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) PolicyDefinitionBean(io.apiman.manager.api.beans.policies.PolicyDefinitionBean) UpdatePolicyDefinitionBean(io.apiman.manager.api.beans.policies.UpdatePolicyDefinitionBean) AbstractRestException(io.apiman.manager.api.rest.exceptions.AbstractRestException) PolicyDefinitionAlreadyExistsException(io.apiman.manager.api.rest.exceptions.PolicyDefinitionAlreadyExistsException) SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) AbstractRestException(io.apiman.manager.api.rest.exceptions.AbstractRestException) StorageException(io.apiman.manager.api.core.exceptions.StorageException) NotAuthorizedException(io.apiman.manager.api.rest.exceptions.NotAuthorizedException) PolicyDefinitionNotFoundException(io.apiman.manager.api.rest.exceptions.PolicyDefinitionNotFoundException)

Aggregations

PolicyDefinitionBean (io.apiman.manager.api.beans.policies.PolicyDefinitionBean)1 UpdatePolicyDefinitionBean (io.apiman.manager.api.beans.policies.UpdatePolicyDefinitionBean)1 StorageException (io.apiman.manager.api.core.exceptions.StorageException)1 AbstractRestException (io.apiman.manager.api.rest.exceptions.AbstractRestException)1 NotAuthorizedException (io.apiman.manager.api.rest.exceptions.NotAuthorizedException)1 PolicyDefinitionAlreadyExistsException (io.apiman.manager.api.rest.exceptions.PolicyDefinitionAlreadyExistsException)1 PolicyDefinitionNotFoundException (io.apiman.manager.api.rest.exceptions.PolicyDefinitionNotFoundException)1 SystemErrorException (io.apiman.manager.api.rest.exceptions.SystemErrorException)1