use of org.entando.entando.aps.system.services.entity.model.EntityTypeAttributeFullDto in project entando-core by entando.
the class DataTypeController method getDataTypeAttribute.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypes/{dataTypeCode}/attribute/{attributeCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse<EntityTypeAttributeFullDto, Map<String, String>>> getDataTypeAttribute(@PathVariable String dataTypeCode, @PathVariable String attributeCode) throws JsonProcessingException {
logger.debug("Requested data type {} - attribute {}", dataTypeCode, attributeCode);
EntityTypeAttributeFullDto dto = this.getDataObjectService().getDataTypeAttribute(dataTypeCode, attributeCode);
logger.debug("Main Response -> {}", dto);
Map<String, String> metadata = new HashMap<>();
metadata.put("dataTypeCode", dataTypeCode);
return new ResponseEntity<>(new RestResponse<>(dto, metadata), HttpStatus.OK);
}
use of org.entando.entando.aps.system.services.entity.model.EntityTypeAttributeFullDto in project entando-core by entando.
the class DataTypeController method updateDataTypeAttribute.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypes/{dataTypeCode}/attribute/{attributeCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse<EntityTypeAttributeFullDto, Map<String, String>>> updateDataTypeAttribute(@PathVariable String dataTypeCode, @PathVariable String attributeCode, @Valid @RequestBody EntityTypeAttributeFullDto bodyRequest, BindingResult bindingResult) throws JsonProcessingException {
logger.debug("Data type {} - Updating attribute {}", dataTypeCode, bodyRequest);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
} else if (!StringUtils.equals(attributeCode, bodyRequest.getCode())) {
bindingResult.rejectValue("code", DataTypeValidator.ERRCODE_URINAME_MISMATCH, new String[] { attributeCode, bodyRequest.getCode() }, "entityType.attribute.code.mismatch");
throw new ValidationConflictException(bindingResult);
}
EntityTypeAttributeFullDto result = this.getDataObjectService().updateDataTypeAttribute(dataTypeCode, bodyRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
logger.debug("Main Response -> {}", result);
Map<String, String> metadata = new HashMap<>();
metadata.put("dataTypeCode", dataTypeCode);
return new ResponseEntity<>(new RestResponse<>(result, metadata), HttpStatus.OK);
}
use of org.entando.entando.aps.system.services.entity.model.EntityTypeAttributeFullDto in project entando-core by entando.
the class DataTypeController method addDataTypeAttribute.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypes/{dataTypeCode}/attribute", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse<EntityTypeAttributeFullDto, Map<String, String>>> addDataTypeAttribute(@PathVariable String dataTypeCode, @Valid @RequestBody EntityTypeAttributeFullDto bodyRequest, BindingResult bindingResult) throws JsonProcessingException {
logger.debug("Data type {} - Adding attribute {}", dataTypeCode, bodyRequest);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
EntityTypeAttributeFullDto result = this.getDataObjectService().addDataTypeAttribute(dataTypeCode, bodyRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
logger.debug("Main Response -> {}", result);
Map<String, String> metadata = new HashMap<>();
metadata.put("dataTypeCode", dataTypeCode);
return new ResponseEntity<>(new RestResponse<>(result, metadata), HttpStatus.OK);
}
Aggregations