use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataTypeController method getDataType.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypes/{dataTypeCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<DataTypeDto>> getDataType(@PathVariable String dataTypeCode) throws JsonProcessingException {
logger.debug("Requested data type -> {}", dataTypeCode);
if (!this.getDataTypeValidator().existType(dataTypeCode)) {
throw new ResourceNotFoundException(DataTypeValidator.ERRCODE_ENTITY_TYPE_DOES_NOT_EXIST, "Data Type", dataTypeCode);
}
DataTypeDto dto = this.getDataObjectService().getDataType(dataTypeCode);
logger.debug("Main Response -> {}", dto);
return new ResponseEntity<>(new SimpleRestResponse<>(dto), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataTypeController method extractStatus.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypesStatus", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<EntityTypesStatusDto>> extractStatus() throws Throwable {
logger.debug("Extract data types status");
EntityTypesStatusDto status = this.getDataObjectService().getDataTypesRefreshStatus();
logger.debug("Extracted data types status {}", status);
return new ResponseEntity<>(new SimpleRestResponse<>(status), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataTypeController method addDataTypes.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypes", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<DataTypeDto>> addDataTypes(@Valid @RequestBody DataTypeDtoRequest bodyRequest, BindingResult bindingResult) throws JsonProcessingException {
// field validations
this.getDataTypeValidator().validate(bodyRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
// business validations
if (this.getDataTypeValidator().existType(bodyRequest.getCode())) {
bindingResult.reject(DataTypeValidator.ERRCODE_ENTITY_TYPE_ALREADY_EXISTS, new String[] { bodyRequest.getCode() }, "entityType.exists");
}
if (bindingResult.hasErrors()) {
throw new ValidationConflictException(bindingResult);
}
DataTypeDto result = this.getDataObjectService().addDataType(bodyRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
logger.debug("Main Response -> {}", result);
return new ResponseEntity<>(new SimpleRestResponse<>(result), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataTypeController method getDataTypeAttributeType.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypeAttributes/{attributeTypeCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<AttributeTypeDto>> getDataTypeAttributeType(@PathVariable String attributeTypeCode) throws JsonProcessingException {
logger.debug("Extracting attribute type -> {}", attributeTypeCode);
AttributeTypeDto attribute = this.getDataObjectService().getAttributeType(attributeTypeCode);
logger.debug("Main Response -> {}", attribute);
return new ResponseEntity<>(new SimpleRestResponse<>(attribute), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl 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