use of org.entando.entando.web.common.exceptions.ValidationGenericException in project entando-core by entando.
the class DataObjectModelController method deleteGroup.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataModelId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deleteGroup(@PathVariable String dataModelId) throws ApsSystemException {
logger.info("deleting data object model -> {}", dataModelId);
MapBindingResult bindingResult = new MapBindingResult(new HashMap<>(), "dataModels");
Long dataId = this.getDataObjectModelValidator().checkValidModelId(dataModelId, bindingResult);
if (null == dataId) {
throw new ValidationGenericException(bindingResult);
}
this.getDataObjectModelService().removeDataObjectModel(Long.parseLong(dataModelId));
Map<String, String> payload = new HashMap<>();
payload.put("modelId", dataModelId);
return new ResponseEntity<>(new RestResponse(payload), HttpStatus.OK);
}
use of org.entando.entando.web.common.exceptions.ValidationGenericException in project entando-core by entando.
the class GroupController method addGroup.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> addGroup(@Valid @RequestBody GroupRequest groupRequest, BindingResult bindingResult) throws ApsSystemException {
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
// business validations
getGroupValidator().validate(groupRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationConflictException(bindingResult);
}
GroupDto dto = this.getGroupService().addGroup(groupRequest);
return new ResponseEntity<>(new RestResponse(dto), HttpStatus.OK);
}
use of org.entando.entando.web.common.exceptions.ValidationGenericException in project entando-core by entando.
the class GuiFragmentController method updateGuiFragment.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{fragmentCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateGuiFragment(@PathVariable String fragmentCode, @Valid @RequestBody GuiFragmentRequestBody guiFragmentRequest, BindingResult bindingResult) {
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
int result = this.getGuiFragmentValidator().validateBody(fragmentCode, guiFragmentRequest, bindingResult);
if (bindingResult.hasErrors()) {
if (404 == result) {
throw new RestRourceNotFoundException(GuiFragmentValidator.ERRCODE_FRAGMENT_DOES_NOT_EXISTS, "fragment", fragmentCode);
} else {
throw new ValidationGenericException(bindingResult);
}
}
GuiFragmentDto fragment = this.getGuiFragmentService().updateGuiFragment(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 LanguageController method updateLanguage.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{code}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateLanguage(@PathVariable String code, @Valid @RequestBody LanguageRequest languageRequest, BindingResult bindingResult) {
logger.trace("loading language {}", code);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
LanguageDto result = this.getLanguageService().updateLanguage(code, languageRequest.getStatus());
return new ResponseEntity<>(new RestResponse(result), HttpStatus.OK);
}
use of org.entando.entando.web.common.exceptions.ValidationGenericException in project entando-core by entando.
the class PageController method movePage.
@RestAccessControl(permission = Permission.MANAGE_PAGES)
@RequestMapping(value = "/pages/{pageCode}/position", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> movePage(@ModelAttribute("user") UserDetails user, @PathVariable String pageCode, @Valid @RequestBody PagePositionRequest pageRequest, BindingResult bindingResult) {
logger.debug("changing position for 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().validateChangePositionRequest(pageCode, pageRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
this.getPageValidator().validateGroups(pageCode, pageRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
this.getPageValidator().validatePagesStatus(pageCode, pageRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
PageDto page = this.getPageService().movePage(pageCode, pageRequest);
Map<String, String> metadata = new HashMap<>();
return new ResponseEntity<>(new RestResponse(page, new ArrayList<>(), metadata), HttpStatus.OK);
}
Aggregations