use of org.entando.entando.web.common.exceptions.ValidationGenericException in project entando-core by entando.
the class GuiFragmentController method addGuiFragment.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> addGuiFragment(@Valid @RequestBody GuiFragmentRequestBody guiFragmentRequest, BindingResult bindingResult) throws ApsSystemException {
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
// business validations
this.getGuiFragmentValidator().validate(guiFragmentRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
GuiFragmentDto fragment = this.getGuiFragmentService().addGuiFragment(guiFragmentRequest);
return new ResponseEntity<>(new RestResponse(fragment), HttpStatus.OK);
}
use of org.entando.entando.web.common.exceptions.ValidationGenericException in project entando-core by entando.
the class LabelController method updateLabelGroup.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{labelCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateLabelGroup(@PathVariable String labelCode, @Valid @RequestBody LabelRequest labelRequest, BindingResult bindingResult) {
logger.debug("updating label {}", labelRequest.getKey());
this.getLabelValidator().validateBodyName(labelCode, labelRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
LabelDto group = this.getLabelService().updateLabelGroup(labelRequest);
return new ResponseEntity<>(new RestResponse(group), HttpStatus.OK);
}
use of org.entando.entando.web.common.exceptions.ValidationGenericException in project entando-core by entando.
the class PageController method updatePage.
@RestAccessControl(permission = Permission.MANAGE_PAGES)
@RequestMapping(value = "/pages/{pageCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updatePage(@ModelAttribute("user") UserDetails user, @PathVariable String pageCode, @Valid @RequestBody PageRequest pageRequest, BindingResult bindingResult) {
logger.debug("updating page {} with request {}", pageCode, pageRequest);
if (!this.getAuthorizationService().isAuth(user, pageCode)) {
return new ResponseEntity<>(new RestResponse(new PageDto()), HttpStatus.UNAUTHORIZED);
}
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
this.getPageValidator().validateBodyCode(pageCode, pageRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
PageDto page = this.getPageService().updatePage(pageCode, pageRequest);
Map<String, String> metadata = new HashMap<>();
return new ResponseEntity<>(new RestResponse(page, new ArrayList<>(), metadata), HttpStatus.OK);
}
use of org.entando.entando.web.common.exceptions.ValidationGenericException in project entando-core by entando.
the class RoleController method updateRole.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{roleCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateRole(@PathVariable String roleCode, @Valid @RequestBody RoleRequest roleRequest, BindingResult bindingResult) {
logger.debug("updating role {}", roleCode);
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
this.getRoleValidator().validateBodyName(roleCode, roleRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
RoleDto role = this.getRoleService().updateRole(roleRequest);
return new ResponseEntity<>(new RestResponse(role), HttpStatus.OK);
}
use of org.entando.entando.web.common.exceptions.ValidationGenericException in project entando-core by entando.
the class RoleController method addRole.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> addRole(@Valid @RequestBody RoleRequest roleRequest, BindingResult bindingResult) throws ApsSystemException {
logger.debug("adding role");
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
// business validations
getRoleValidator().validate(roleRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationConflictException(bindingResult);
}
RoleDto dto = this.getRoleService().addRole(roleRequest);
return new ResponseEntity<>(new RestResponse(dto), HttpStatus.OK);
}
Aggregations