Search in sources :

Example 71 with ResponseEntity

use of org.springframework.http.ResponseEntity in project entando-core by entando.

the class GuiFragmentController method deleteGuiFragment.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{fragmentCode}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deleteGuiFragment(@PathVariable String fragmentCode) throws ApsSystemException {
    logger.info("deleting {}", fragmentCode);
    this.getGuiFragmentService().removeGuiFragment(fragmentCode);
    Map<String, String> result = new HashMap<>();
    result.put("code", fragmentCode);
    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 72 with ResponseEntity

use of org.springframework.http.ResponseEntity in project entando-core by entando.

the class PageConfigurationController method getPageWidget.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/pages/{pageCode}/widgets/{frameId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getPageWidget(@PathVariable String pageCode, @PathVariable int frameId, @RequestParam(value = "status", required = false, defaultValue = IPageService.STATUS_DRAFT) String status) {
    logger.trace("requested widget detail for page {} and frame {}", pageCode, frameId);
    WidgetConfigurationDto widgetConfiguration = this.getPageService().getWidgetConfiguration(pageCode, frameId, status);
    Map<String, String> metadata = new HashMap<>();
    metadata.put("status", status);
    return new ResponseEntity<>(new RestResponse(widgetConfiguration, null, metadata), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) 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 73 with ResponseEntity

use of org.springframework.http.ResponseEntity in project entando-core by entando.

the class PageConfigurationController method deletePageWidget.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/pages/{pageCode}/widgets/{frameId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> deletePageWidget(@PathVariable String pageCode, @PathVariable int frameId) {
    logger.trace("removing widget configuration in page {} and frame {}", pageCode, frameId);
    this.getPageService().deleteWidgetConfiguration(pageCode, frameId);
    Map<String, String> metadata = new HashMap<>();
    metadata.put("status", IPageService.STATUS_DRAFT);
    return new ResponseEntity<>(new RestResponse(frameId, null, metadata), 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 74 with ResponseEntity

use of org.springframework.http.ResponseEntity in project entando-core by entando.

the class PageController method getPages.

@RestAccessControl(permission = Permission.MANAGE_PAGES)
@RequestMapping(value = "/pages", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getPages(@ModelAttribute("user") UserDetails user, @RequestParam(value = "parentCode", required = false, defaultValue = "homepage") String parentCode) {
    logger.debug("getting page tree for parent {}", parentCode);
    List<PageDto> result = this.getAuthorizationService().filterList(user, this.getPageService().getPages(parentCode));
    Map<String, String> metadata = new HashMap<>();
    metadata.put("parentCode", parentCode);
    return new ResponseEntity<>(new RestResponse(result, new ArrayList<>(), metadata), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) HashMap(java.util.HashMap) RestResponse(org.entando.entando.web.common.model.RestResponse) ArrayList(java.util.ArrayList) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 75 with ResponseEntity

use of org.springframework.http.ResponseEntity in project entando-core by entando.

the class PageModelController method getPageModels.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getPageModels(RestListRequest requestList) {
    logger.trace("loading page models");
    this.getPagemModelValidator().validateRestListRequest(requestList);
    PagedMetadata<PageModelDto> result = this.getPageModelService().getPageModels(requestList);
    this.getPagemModelValidator().validateRestListResult(requestList, result);
    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) PageModelDto(org.entando.entando.aps.system.services.pagemodel.model.PageModelDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ResponseEntity (org.springframework.http.ResponseEntity)1188 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)419 HttpHeaders (org.springframework.http.HttpHeaders)398 Test (org.junit.Test)120 ApiOperation (io.swagger.annotations.ApiOperation)116 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)108 HashMap (java.util.HashMap)104 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)103 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)98 HttpStatus (org.springframework.http.HttpStatus)88 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)85 ArrayList (java.util.ArrayList)80 GetMapping (org.springframework.web.bind.annotation.GetMapping)79 Timed (com.codahale.metrics.annotation.Timed)68 IOException (java.io.IOException)67 List (java.util.List)65 URI (java.net.URI)49 MediaType (org.springframework.http.MediaType)48 Test (org.junit.jupiter.api.Test)46 HttpEntity (org.springframework.http.HttpEntity)46