use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class DatabaseController method startBackup.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/startBackup", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> startBackup() throws Throwable {
logger.debug("Starting database backup");
this.getDatabaseService().startDatabaseBackup();
Map<String, String> response = new HashMap<>();
response.put("status", String.valueOf(this.getDatabaseService().getStatus()));
logger.debug("Database backup started");
return new ResponseEntity<>(new RestResponse(response), HttpStatus.OK);
}
use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class DataTypeController method deleteDataType.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataTypeCode}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deleteDataType(@PathVariable String dataTypeCode) throws ApsSystemException {
logger.debug("Deleting data type -> {}", dataTypeCode);
this.getDataObjectService().deleteDataType(dataTypeCode);
Map<String, String> payload = new HashMap<>();
payload.put("code", dataTypeCode);
return new ResponseEntity<>(new RestResponse(payload), HttpStatus.OK);
}
use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class DataTypeController method updateDataType.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataTypeCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateDataType(@PathVariable String dataTypeCode, @Valid @RequestBody DataTypeDtoRequest request, BindingResult bindingResult) throws JsonProcessingException {
int result = this.getDataTypeValidator().validateBodyName(dataTypeCode, request, bindingResult);
if (bindingResult.hasErrors()) {
if (result == 404) {
throw new RestRourceNotFoundException(DataTypeValidator.ERRCODE_ENTITY_TYPE_DOES_NOT_EXIST, "data type", dataTypeCode);
} else {
throw new ValidationGenericException(bindingResult);
}
}
DataTypeDto dto = this.getDataObjectService().updateDataType(request, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
logger.debug("Main Response -> {}", dto);
return new ResponseEntity<>(new RestResponse(dto), HttpStatus.OK);
}
use of org.entando.entando.web.common.model.RestResponse 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.web.common.model.RestResponse in project entando-core by entando.
the class DataObjectModelController method getDataObjectModels.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getDataObjectModels(RestListRequest requestList) {
this.getDataObjectModelValidator().validateRestListRequest(requestList);
PagedMetadata<DataModelDto> result = this.getDataObjectModelService().getDataObjectModels(requestList);
this.getDataObjectModelValidator().validateRestListResult(requestList, result);
logger.debug("Main Response -> {}", result);
return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
Aggregations