Search in sources :

Example 66 with RestAccessControl

use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.

the class PageModelController method deletePageModel.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{code}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deletePageModel(@PathVariable String code) throws ApsSystemException {
    logger.debug("deleting {}", code);
    this.getPageModelService().removePageModel(code);
    Map<String, String> result = new HashMap<>();
    result.put("code", code);
    return new ResponseEntity<>(new RestResponse(result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 67 with RestAccessControl

use of org.entando.entando.web.common.annotation.RestAccessControl 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 68 with RestAccessControl

use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.

the class RoleController method deleteRole.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{roleCode}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deleteRole(@PathVariable String roleCode) throws ApsSystemException {
    logger.info("deleting {}", roleCode);
    this.getRoleService().removeRole(roleCode);
    Map<String, String> result = new HashMap<>();
    result.put("code", roleCode);
    return new ResponseEntity<>(new RestResponse(result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 69 with RestAccessControl

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

Example 70 with RestAccessControl

use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.

the class UserController method deleteUser.

@RestAccessControl(permission = Permission.MANAGE_USERS)
@RequestMapping(value = "/{username}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> deleteUser(@PathVariable String username) throws ApsSystemException {
    logger.debug("deleting {}", username);
    this.getUserService().removeUser(username);
    Map<String, String> result = new HashMap<>();
    result.put("code", username);
    return new ResponseEntity<>(new RestResponse(result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)118 ResponseEntity (org.springframework.http.ResponseEntity)108 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)84 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)45 RestResponse (org.entando.entando.web.common.model.RestResponse)42 HashMap (java.util.HashMap)36 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)9 ActivityStreamAuditable (org.entando.entando.web.common.annotation.ActivityStreamAuditable)9 PageDto (org.entando.entando.aps.system.services.page.model.PageDto)8 UserDto (org.entando.entando.aps.system.services.user.model.UserDto)7 ArrayList (java.util.ArrayList)6 DataModelDto (org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto)6 WidgetConfigurationDto (org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto)5 RoleDto (org.entando.entando.aps.system.services.role.model.RoleDto)5 ActionLogRecordDto (org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto)4 CategoryDto (org.entando.entando.aps.system.services.category.model.CategoryDto)4 LabelDto (org.entando.entando.aps.system.services.label.model.LabelDto)4 PageConfigurationDto (org.entando.entando.aps.system.services.page.model.PageConfigurationDto)4 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)4 DataTypeDto (org.entando.entando.aps.system.services.dataobject.model.DataTypeDto)3