Search in sources :

Example 1 with UpdateRoleBean

use of io.apiman.manager.api.beans.idm.UpdateRoleBean in project apiman by apiman.

the class RoleResourceImpl method update.

/**
 * @see IRoleResource#update(java.lang.String, io.apiman.manager.api.beans.idm.UpdateRoleBean)
 */
@Override
public void update(String roleId, UpdateRoleBean bean) throws RoleNotFoundException, NotAuthorizedException {
    securityContext.checkAdminPermissions();
    try {
        RoleBean role = getRoleFromStorage(roleId);
        if (bean.getDescription() != null) {
            role.setDescription(bean.getDescription());
        }
        if (bean.getAutoGrant() != null) {
            role.setAutoGrant(bean.getAutoGrant());
        }
        if (bean.getName() != null) {
            role.setName(bean.getName());
        }
        if (bean.getPermissions() != null) {
            role.getPermissions().clear();
            role.getPermissions().addAll(bean.getPermissions());
        }
        storage.updateRole(role);
    } catch (StorageException e) {
        throw new SystemErrorException(e);
    }
}
Also used : SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) NewRoleBean(io.apiman.manager.api.beans.idm.NewRoleBean) UpdateRoleBean(io.apiman.manager.api.beans.idm.UpdateRoleBean) RoleBean(io.apiman.manager.api.beans.idm.RoleBean) StorageException(io.apiman.manager.api.core.exceptions.StorageException)

Aggregations

NewRoleBean (io.apiman.manager.api.beans.idm.NewRoleBean)1 RoleBean (io.apiman.manager.api.beans.idm.RoleBean)1 UpdateRoleBean (io.apiman.manager.api.beans.idm.UpdateRoleBean)1 StorageException (io.apiman.manager.api.core.exceptions.StorageException)1 SystemErrorException (io.apiman.manager.api.rest.exceptions.SystemErrorException)1