use of org.entando.entando.web.common.exceptions.ValidationConflictException 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);
}
use of org.entando.entando.web.common.exceptions.ValidationConflictException in project entando-core by entando.
the class PageModelService method removePageModel.
@Override
public void removePageModel(String code) {
try {
PageModel pageModel = this.getPageModelManager().getPageModel(code);
if (null == pageModel) {
return;
}
BeanPropertyBindingResult validationResult = this.validateDelete(pageModel);
if (validationResult.hasErrors()) {
throw new ValidationConflictException(validationResult);
}
this.getPageModelManager().deletePageModel(code);
} catch (ApsSystemException e) {
logger.error("Error in delete pagemodel {}", code, e);
throw new RestServerError("error in delete pagemodel", e);
}
}
use of org.entando.entando.web.common.exceptions.ValidationConflictException in project entando-core by entando.
the class RoleService method addRole.
@Override
public RoleDto addRole(RoleRequest roleRequest) {
try {
Role role = this.createRole(roleRequest);
BeanPropertyBindingResult validationResult = this.validateRoleForAdd(role);
if (validationResult.hasErrors()) {
throw new ValidationConflictException(validationResult);
}
this.getRoleManager().addRole(role);
RoleDto dto = this.getDtoBuilder().toDto(role, this.getRoleManager().getPermissionsCodes());
return dto;
} catch (ApsSystemException e) {
logger.error("Error adding a role", e);
throw new RestServerError("error in add role", e);
}
}
use of org.entando.entando.web.common.exceptions.ValidationConflictException in project entando-core by entando.
the class RoleService method removeRole.
@Override
public void removeRole(String roleCode) {
try {
Role role = this.getRoleManager().getRole(roleCode);
if (null == role) {
logger.info("role {} does not exists", roleCode);
return;
}
BeanPropertyBindingResult validationResult = this.validateRoleForDelete(role);
if (validationResult.hasErrors()) {
throw new ValidationConflictException(validationResult);
}
this.getRoleManager().removeRole(role);
} catch (ApsSystemException e) {
logger.error("Error in delete role {}", roleCode, e);
throw new RestServerError("error in delete role", e);
}
}
use of org.entando.entando.web.common.exceptions.ValidationConflictException in project entando-core by entando.
the class DataObjectModelService method removeDataObjectModel.
@Override
public void removeDataObjectModel(Long dataModelId) {
try {
DataObjectModel dataObjectModel = this.getDataObjectModelManager().getDataObjectModel(dataModelId);
if (null == dataObjectModel) {
return;
}
DataModelDto dto = this.getDtoBuilder().convert(dataObjectModel);
BeanPropertyBindingResult validationResult = this.checkDataObjectModelForDelete(dataObjectModel, dto);
if (validationResult.hasErrors()) {
throw new ValidationConflictException(validationResult);
}
this.getDataObjectModelManager().removeDataObjectModel(dataObjectModel);
} catch (ApsSystemException e) {
logger.error("Error in delete DataObjectModel {}", dataModelId, e);
throw new RestServerError("error in delete DataObjectModel", e);
}
}
Aggregations