use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class WidgetController method getWidget.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/widgets/{widgetCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getWidget(@PathVariable String widgetCode) {
logger.trace("getWidget by code {}", widgetCode);
WidgetDto group = this.widgetService.getWidget(widgetCode);
return new ResponseEntity<>(new RestResponse(group), HttpStatus.OK);
}
use of org.entando.entando.web.common.model.RestResponse 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.model.RestResponse in project entando-core by entando.
the class CategoryController method updateCategory.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{categoryCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateCategory(@PathVariable String categoryCode, @Valid @RequestBody CategoryDto categoryRequest, BindingResult bindingResult) {
logger.debug("updating category {} with request {}", categoryCode, categoryRequest);
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
this.getCategoryValidator().validatePutReferences(categoryCode, categoryRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
CategoryDto category = this.getCategoryService().updateCategory(categoryRequest);
Map<String, String> metadata = new HashMap<>();
return new ResponseEntity<>(new RestResponse(category, new ArrayList<>(), metadata), HttpStatus.OK);
}
use of org.entando.entando.web.common.model.RestResponse 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.model.RestResponse 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);
}
Aggregations