use of org.entando.entando.aps.system.services.role.model.PermissionDto in project entando-core by entando.
the class PermissionController method getPermissions.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getPermissions(RestListRequest requestList) throws JsonProcessingException {
this.getPermissionValidator().validateRestListRequest(requestList);
PagedMetadata<PermissionDto> result = this.getRoleService().getPermissions(requestList);
this.getPermissionValidator().validateRestListResult(requestList, result);
logger.debug("Main Response -> {}", result);
return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
use of org.entando.entando.aps.system.services.role.model.PermissionDto in project entando-core by entando.
the class RoleService method getPermissions.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public PagedMetadata<PermissionDto> getPermissions(RestListRequest requestList) {
List<Permission> permissions = this.getRoleManager().getPermissions();
permissions = sortPermissionList(requestList, permissions);
if (null != requestList.getFilters()) {
for (Filter f : requestList.getFilters()) {
if (f.getAttributeName().equals(KEY_FILTER_PERMISSION_CODE)) {
permissions = permissions.stream().filter(i -> i.getName().toLowerCase().contains(f.getValue().toLowerCase())).collect(Collectors.toList());
}
if (f.getAttributeName().equals(KEY_FILTER_PERMISSION_DESCR)) {
permissions = permissions.stream().filter(i -> i.getDescription().toLowerCase().contains(f.getValue().toLowerCase())).collect(Collectors.toList());
}
}
}
List<Permission> subList = requestList.getSublist(permissions);
List<PermissionDto> dtoSlice = this.getPermissionDtoBuilder().convert(subList);
SearcherDaoPaginatedResult<PermissionDto> paginatedResult = new SearcherDaoPaginatedResult(permissions.size(), dtoSlice);
PagedMetadata<PermissionDto> pagedMetadata = new PagedMetadata<>(requestList, paginatedResult);
pagedMetadata.setBody(dtoSlice);
return pagedMetadata;
}
Aggregations