use of org.entando.entando.aps.system.services.role.model.RoleDto in project entando-core by entando.
the class RoleMockHelper method mockRoleDto.
/**
* @return a mocked RoleDto instance
*/
public static RoleDto mockRoleDto(String suffix) {
RoleDto role = new RoleDto();
role.setName(ROLE_NAME + suffix);
// role.setPermissions(PERMISSION + suffix);
return role;
}
use of org.entando.entando.aps.system.services.role.model.RoleDto in project entando-core by entando.
the class RoleController method getRoles.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getRoles(RestListRequest requestList) throws JsonProcessingException {
this.getRoleValidator().validateRestListRequest(requestList);
PagedMetadata<RoleDto> result = this.getRoleService().getRoles(requestList);
this.getRoleValidator().validateRestListResult(requestList, result);
logger.debug("loading role list -> {}", result);
return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
use of org.entando.entando.aps.system.services.role.model.RoleDto 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 ResourceNotFoundException(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 ValidationGenericException(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 org.entando.entando.aps.system.services.role.model.RoleDto in project entando-core by entando.
the class RoleService method getRole.
@Override
public RoleDto getRole(String roleCode) {
Role role = this.getRoleManager().getRole(roleCode);
if (null == role) {
logger.warn("no role found with code {}", roleCode);
throw new ResourceNotFoundException(RoleValidator.ERRCODE_ROLE_NOT_FOUND, "role", roleCode);
}
RoleDto dto = this.getDtoBuilder().toDto(role, this.getRoleManager().getPermissionsCodes());
return dto;
}
use of org.entando.entando.aps.system.services.role.model.RoleDto in project entando-core by entando.
the class RoleController method getRole.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{roleCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<RoleDto>> getRole(@PathVariable String roleCode) {
logger.debug("loading role {}", roleCode);
RoleDto role = this.getRoleService().getRole(roleCode);
return new ResponseEntity<>(new SimpleRestResponse<>(role), HttpStatus.OK);
}
Aggregations