use of com.agiletec.aps.system.services.role.Role in project entando-core by entando.
the class RoleService method updateRole.
@Override
public RoleDto updateRole(RoleRequest roleRequest) {
try {
Role role = this.getRoleManager().getRole(roleRequest.getCode());
if (null == role) {
logger.warn("no role found with code {}", roleRequest.getCode());
throw new RestRourceNotFoundException(RoleValidator.ERRCODE_ROLE_NOT_FOUND, "role", roleRequest.getCode());
}
role.setDescription(roleRequest.getName());
role.getPermissions().clear();
if (null != roleRequest.getPermissions()) {
roleRequest.getPermissions().entrySet().stream().filter(entry -> null != entry.getValue() && entry.getValue().booleanValue()).forEach(i -> role.addPermission(i.getKey()));
}
BeanPropertyBindingResult validationResult = this.validateRoleForUpdate(role);
if (validationResult.hasErrors()) {
throw new ValidationConflictException(validationResult);
}
this.getRoleManager().updateRole(role);
RoleDto dto = this.getDtoBuilder().toDto(role, this.getRoleManager().getPermissionsCodes());
return dto;
} catch (ApsSystemException e) {
logger.error("Error updating a role", e);
throw new RestServerError("error in update role", e);
}
}
use of com.agiletec.aps.system.services.role.Role in project entando-core by entando.
the class UserAuthorizationAction method getRoles.
public List<Role> getRoles() {
List<Role> roles = this.getRoleManager().getRoles();
Collections.sort(roles, new BeanComparator("description"));
return roles;
}
use of com.agiletec.aps.system.services.role.Role in project entando-core by entando.
the class TestRoleAction method checkRole.
private void checkRole(String roleName, String descr, String[] permissions) {
Role role = this._roleManager.getRole(roleName);
assertEquals(role.getName(), roleName);
assertEquals(role.getDescription(), descr);
Set<String> rolePerms = role.getPermissions();
assertEquals(rolePerms.size(), permissions.length);
for (int i = 0; i < permissions.length; i++) {
assertTrue(rolePerms.contains(permissions[i]));
}
}
use of com.agiletec.aps.system.services.role.Role in project entando-core by entando.
the class TestRoleAction method addRole.
private void addRole(String roleName, String descr, String[] permissions) throws ApsSystemException {
Role role = new Role();
role.setName(roleName);
role.setDescription(descr);
for (int i = 0; i < permissions.length; i++) {
role.addPermission(permissions[i]);
}
this._roleManager.addRole(role);
}
use of com.agiletec.aps.system.services.role.Role in project entando-core by entando.
the class RoleFinderAction method getRoles.
public List<Role> getRoles() {
List<Role> roles = this.getRoleManager().getRoles();
BeanComparator comparator = new BeanComparator("description");
Collections.sort(roles, comparator);
return roles;
}
Aggregations