Search in sources :

Example 1 with PermissionDto

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) PermissionDto(org.entando.entando.aps.system.services.role.model.PermissionDto) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PermissionDto

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;
}
Also used : FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) Filter(org.entando.entando.web.common.model.Filter) PermissionDto(org.entando.entando.aps.system.services.role.model.PermissionDto) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) Permission(com.agiletec.aps.system.services.role.Permission) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)

Aggregations

PermissionDto (org.entando.entando.aps.system.services.role.model.PermissionDto)2 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)1 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)1 Permission (com.agiletec.aps.system.services.role.Permission)1 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)1 Filter (org.entando.entando.web.common.model.Filter)1 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)1 RestResponse (org.entando.entando.web.common.model.RestResponse)1 ResponseEntity (org.springframework.http.ResponseEntity)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1