use of org.entando.entando.aps.system.exception.RestRourceNotFoundException in project entando-core by entando.
the class DataObjectModelController method updateGroup.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataModelId}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateGroup(@PathVariable String dataModelId, @Valid @RequestBody DataObjectModelRequest dataObjectModelRequest, BindingResult bindingResult) throws JsonProcessingException {
logger.debug("Updating data object model -> {}", dataObjectModelRequest.getModelId());
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
this.getDataObjectModelValidator().validateBodyName(dataModelId, dataObjectModelRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
int result = this.getDataObjectModelValidator().validateBody(dataObjectModelRequest, true, bindingResult);
if (bindingResult.hasErrors()) {
if (404 == result) {
if (1 == bindingResult.getFieldErrorCount("type")) {
throw new RestRourceNotFoundException(DataObjectModelValidator.ERRCODE_PUT_DATAOBJECTTYPE_DOES_NOT_EXIST, "type", dataObjectModelRequest.getType());
} else {
throw new RestRourceNotFoundException(DataObjectModelValidator.ERRCODE_DATAOBJECTMODEL_ALREADY_EXISTS, "modelId", dataObjectModelRequest.getModelId());
}
} else {
throw new ValidationGenericException(bindingResult);
}
}
DataModelDto dataModelDto = this.getDataObjectModelService().updateDataObjectModel(dataObjectModelRequest);
logger.debug("Main Response -> {}", dataModelDto);
return new ResponseEntity<>(new RestResponse(dataModelDto), HttpStatus.OK);
}
use of org.entando.entando.aps.system.exception.RestRourceNotFoundException in project entando-core by entando.
the class AbstractEntityService method getFullEntityType.
protected O getFullEntityType(String entityManagerCode, String entityTypeCode) {
IEntityManager entityManager = this.extractEntityManager(entityManagerCode);
I entityType = (I) entityManager.getEntityPrototype(entityTypeCode);
if (null == entityManager) {
logger.warn("no entity type found with code {}", entityTypeCode);
throw new RestRourceNotFoundException("entityTypeCode", entityTypeCode);
}
O type = this.convertEntityType(entityManager, entityType);
type.setStatus(String.valueOf(entityManager.getStatus(entityTypeCode)));
return type;
}
Aggregations