Search in sources :

Example 86 with RestResponse

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) WidgetDto(org.entando.entando.aps.system.services.widgettype.model.WidgetDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 87 with RestResponse

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 88 with RestResponse

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);
}
Also used : CategoryDto(org.entando.entando.aps.system.services.category.model.CategoryDto) ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) RestResponse(org.entando.entando.web.common.model.RestResponse) ArrayList(java.util.ArrayList) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 89 with RestResponse

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 90 with RestResponse

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RestResponse (org.entando.entando.web.common.model.RestResponse)95 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)86 ResponseEntity (org.springframework.http.ResponseEntity)86 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)86 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)34 HashMap (java.util.HashMap)33 ArrayList (java.util.ArrayList)18 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)8 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)8 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)8 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)8 PageDto (org.entando.entando.aps.system.services.page.model.PageDto)7 BindingResult (org.springframework.validation.BindingResult)7 UserDto (org.entando.entando.aps.system.services.user.model.UserDto)6 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)5 CategoryDto (org.entando.entando.aps.system.services.category.model.CategoryDto)4 DataModelDto (org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto)4 LabelDto (org.entando.entando.aps.system.services.label.model.LabelDto)4 RoleDto (org.entando.entando.aps.system.services.role.model.RoleDto)4 WidgetDto (org.entando.entando.aps.system.services.widgettype.model.WidgetDto)4