use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class UserController method getUsers.
@RestAccessControl(permission = Permission.MANAGE_USERS)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getUsers(RestListRequest requestList) {
logger.debug("getting users details with request {}", requestList);
PagedMetadata<UserDto> result = this.getUserService().getUsers(requestList);
return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class UserController method addUserAuthorities.
@RestAccessControl(permission = Permission.MANAGE_USERS)
@RequestMapping(value = "/{target}/authorities", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> addUserAuthorities(@ModelAttribute("user") UserDetails user, @PathVariable String target, @Valid @RequestBody UserAuthoritiesRequest authRequest, BindingResult bindingResult) throws ApsSystemException {
logger.debug("user {} requesting add authorities for username {} with req {}", user.getUsername(), target, authRequest);
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
// business validations
getUserValidator().validate(authRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
getUserValidator().validateUpdateSelf(target, user.getUsername(), bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
List<UserAuthorityDto> authorities = this.getUserService().addUserAuthorities(target, authRequest);
return new ResponseEntity<>(new RestResponse(authorities), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class UserController method updateUserAuthorities.
@RestAccessControl(permission = Permission.MANAGE_USERS)
@RequestMapping(value = "/{target}/authorities", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateUserAuthorities(@ModelAttribute("user") UserDetails user, @PathVariable String target, @Valid @RequestBody UserAuthoritiesRequest authRequest, BindingResult bindingResult) {
logger.debug("user {} requesting update authorities for username {} with req {}", user.getUsername(), target, authRequest);
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
// business validations
getUserValidator().validate(authRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
getUserValidator().validateUpdateSelf(target, user.getUsername(), bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
List<UserAuthorityDto> authorities = this.getUserService().addUserAuthorities(target, authRequest);
return new ResponseEntity<>(new RestResponse(authorities), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class ProfileTypeController method deleteDataType.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{profileTypeCode}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deleteDataType(@PathVariable String profileTypeCode) throws ApsSystemException {
logger.debug("Deleting profile type -> {}", profileTypeCode);
this.getUserProfileTypeService().deleteUserProfileType(profileTypeCode);
Map<String, String> result = new HashMap<>();
result.put("code", profileTypeCode);
return new ResponseEntity<>(new RestResponse(result), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class ProfileTypeController method getUserProfileTypes.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getUserProfileTypes(RestListRequest requestList) throws JsonProcessingException {
this.getProfileTypeValidator().validateRestListRequest(requestList);
PagedMetadata<EntityTypeShortDto> result = this.getUserProfileTypeService().getShortUserProfileTypes(requestList);
logger.debug("Main Response -> {}", result);
this.getProfileTypeValidator().validateRestListResult(requestList, result);
return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
Aggregations