use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataTypeController method updateDataType.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypes/{dataTypeCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<DataTypeDto>> 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 ResourceNotFoundException(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 SimpleRestResponse<>(dto), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DatabaseController method initBackup.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/initBackup", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> initBackup() {
logger.debug("Required actual component configuration");
List<ComponentDto> dtos = this.getDatabaseService().getCurrentComponents();
logger.debug("Actual component configuration -> {}", dtos);
return new ResponseEntity<>(new RestResponse(dtos), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DatabaseController method getTableDump.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/report/{reportCode}/dump/{dataSource}/{tableName}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getTableDump(@PathVariable String reportCode, @PathVariable String dataSource, @PathVariable String tableName) {
logger.debug("Required dump report -> code {} - database {} - table {}", reportCode, dataSource, tableName);
byte[] base64 = this.getDatabaseService().getTableDump(reportCode, dataSource, tableName);
Map<String, Object> response = new HashMap<>();
response.put("base64", base64);
Map<String, String> metadata = new HashMap<>();
metadata.put("reportCode", reportCode);
metadata.put("dataSource", dataSource);
metadata.put("tableName", tableName);
return new ResponseEntity<>(new RestResponse(response, new ArrayList<>(), metadata), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataTypeController method getDataTypes.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getDataTypes(@Valid RestListRequest requestList) throws JsonProcessingException {
this.getDataTypeValidator().validateRestListRequest(requestList);
PagedMetadata<EntityTypeShortDto> result = this.getDataObjectService().getShortDataTypes(requestList);
this.getDataTypeValidator().validateRestListResult(requestList, result);
logger.debug("Main Response -> {}", result);
return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataObjectModelController method deleteGroup.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataModelId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deleteGroup(@PathVariable String dataModelId) throws ApsSystemException {
logger.info("deleting data object model -> {}", dataModelId);
MapBindingResult bindingResult = new MapBindingResult(new HashMap<>(), "dataModels");
Long dataId = this.getDataObjectModelValidator().checkValidModelId(dataModelId, bindingResult);
if (null == dataId) {
throw new ValidationGenericException(bindingResult);
}
this.getDataObjectModelService().removeDataObjectModel(Long.parseLong(dataModelId));
Map<String, String> payload = new HashMap<>();
payload.put("modelId", dataModelId);
return new ResponseEntity<>(new RestResponse(payload), HttpStatus.OK);
}
Aggregations