use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class WidgetController method deleteWidget.
@RestAccessControl(permission = "widget_delete")
@RequestMapping(value = "/widgets/{widgetCode}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, name = "widget")
public ResponseEntity<RestResponse> deleteWidget(@PathVariable String widgetCode) throws ApsSystemException {
logger.info("deleting widget {}", widgetCode);
this.widgetService.removeWidget(widgetCode);
Map<String, String> result = new HashMap<>();
result.put("code", widgetCode);
return new ResponseEntity<>(new RestResponse(result), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class CategoryController method getCategoryReferences.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{categoryCode}/references/{holder}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getCategoryReferences(@PathVariable String categoryCode, @PathVariable String holder, RestListRequest requestList) {
logger.debug("getting category references - {}", categoryCode);
PagedMetadata<?> result = this.getCategoryService().getCategoryReferences(categoryCode, holder, requestList);
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 CategoryController method deleteCategory.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{categoryCode}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deleteCategory(@PathVariable String categoryCode) throws ApsSystemException {
logger.debug("Deleting category -> " + categoryCode);
this.getCategoryService().deleteCategory(categoryCode);
Map<String, String> payload = new HashMap<>();
payload.put("code", categoryCode);
return new ResponseEntity<>(new RestResponse(payload), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataObjectModelController method getDataObjectModel.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataModelId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<DataModelDto>> getDataObjectModel(@PathVariable String dataModelId) {
logger.debug("Requested data object model -> {}", dataModelId);
MapBindingResult bindingResult = new MapBindingResult(new HashMap<>(), "dataModels");
int result = this.getDataObjectModelValidator().checkModelId(dataModelId, bindingResult);
if (bindingResult.hasErrors()) {
if (404 == result) {
throw new ResourceNotFoundException(DataObjectModelValidator.ERRCODE_DATAOBJECTMODEL_DOES_NOT_EXIST, "dataObjectModel", dataModelId);
} else {
throw new ValidationGenericException(bindingResult);
}
}
DataModelDto dataModelDto = this.getDataObjectModelService().getDataObjectModel(Long.parseLong(dataModelId));
return new ResponseEntity<>(new SimpleRestResponse<>(dataModelDto), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataObjectModelController method patchDataObjectModel.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataModelId}", method = RequestMethod.PATCH, produces = MediaType.APPLICATION_JSON_VALUE, consumes = "application/json-patch+json")
public ResponseEntity<SimpleRestResponse<DataModelDto>> patchDataObjectModel(@PathVariable Long dataModelId, @RequestBody JsonNode jsonPatch, BindingResult bindingResult) throws JsonProcessingException {
logger.debug("Patching data object model -> {}", dataModelId);
this.getDataObjectModelValidator().validateDataObjectModelJsonPatch(jsonPatch, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
DataModelDto patchedDataModelDto = this.getDataObjectModelService().getPatchedDataObjectModel(dataModelId, jsonPatch);
DataObjectModelRequest dataObjectModelRequest = this.dataModelDtoToRequestConverter.convert(patchedDataModelDto);
return this.updateDataObjectModel(Long.toString(dataModelId), dataObjectModelRequest, bindingResult);
}
Aggregations