use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class ActivityStreamController method removeLike.
@RestAccessControl(permission = Permission.ENTER_BACKEND)
@RequestMapping(value = "/{recordId}/like", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<ActionLogRecordDto>> removeLike(@PathVariable int recordId, HttpServletRequest request) throws JsonProcessingException {
ActionLogRecordDto result = this.getActivityStreamService().removeLike(recordId, (UserDetails) request.getSession().getAttribute("user"));
logger.debug("remove like to activity stream record", result);
return new ResponseEntity<>(new SimpleRestResponse<>(result), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class ActivityStreamController method removeComment.
@RestAccessControl(permission = Permission.ENTER_BACKEND)
@RequestMapping(value = "/{recordId}/comments/{commentId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<ActionLogRecordDto>> removeComment(@PathVariable int recordId, @PathVariable int commentId, HttpServletRequest request) throws JsonProcessingException {
ActionLogRecordDto result = this.getActivityStreamService().removeComment(recordId, commentId, (UserDetails) request.getSession().getAttribute("user"));
logger.debug("remove comment to activity stream record", result);
return new ResponseEntity<>(new SimpleRestResponse<>(result), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class ActivityStreamController method addComment.
@RestAccessControl(permission = Permission.ENTER_BACKEND)
@RequestMapping(value = "/{recordId}/comments", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<ActionLogRecordDto>> addComment(@PathVariable int recordId, @Valid @RequestBody ActivityStreamCommentRequest commentRequest, BindingResult bindingResult, HttpServletRequest request) throws JsonProcessingException {
this.getActivityStreamValidator().validateBodyName(recordId, commentRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
ActionLogRecordDto result = this.getActivityStreamService().addComment(commentRequest, (UserDetails) request.getSession().getAttribute("user"));
logger.debug("adding comment to activity stream record", result);
return new ResponseEntity<>(new SimpleRestResponse<>(result), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class CategoryController method updateCategory.
@RestAccessControl(permission = Permission.MANAGE_CATEGORIES)
@RequestMapping(value = "/{categoryCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse<CategoryDto, Map<String, String>>> updateCategory(@PathVariable String categoryCode, @Valid @RequestBody CategoryDto categoryRequest, BindingResult bindingResult) {
logger.debug("updating category {} with request {}", categoryCode, categoryRequest);
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
this.getCategoryValidator().validatePutReferences(categoryCode, categoryRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
CategoryDto category = this.getCategoryService().updateCategory(categoryRequest);
Map<String, String> metadata = new HashMap<>();
return new ResponseEntity<>(new RestResponse<>(category, metadata), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class UserSettingsController method updateUserSettings.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<UserSettingsDto>> updateUserSettings(@Valid @RequestBody UserSettingsRequest request, BindingResult bindingResult) {
logger.debug("updatinug user settings");
// params validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
UserSettingsDto settings = this.getUserSettingsService().updateUserSettings(request);
return new ResponseEntity<>(new SimpleRestResponse<>(settings), HttpStatus.OK);
}
Aggregations