Search in sources :

Example 6 with ActivityStreamAuditable

use of org.entando.entando.web.common.annotation.ActivityStreamAuditable in project entando-core by entando.

the class PageConfigurationController method updatePageWidget.

@ActivityStreamAuditable
@RestAccessControl(permission = Permission.MANAGE_PAGES)
@RequestMapping(value = "/pages/{pageCode}/widgets/{frameId}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse<WidgetConfigurationDto, Map>> updatePageWidget(@PathVariable String pageCode, @PathVariable String frameId, @Valid @RequestBody WidgetConfigurationRequest widget, BindingResult bindingResult) {
    logger.debug("updating widget configuration in page {} and frame {}", pageCode, frameId);
    this.validateFrameId(frameId, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    WidgetConfigurationDto widgetConfiguration = this.getPageService().updateWidgetConfiguration(pageCode, Integer.valueOf(frameId), widget);
    Map<String, String> metadata = new HashMap<>();
    metadata.put("status", IPageService.STATUS_DRAFT);
    return new ResponseEntity<>(new RestResponse<>(widgetConfiguration, metadata), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) HashMap(java.util.HashMap) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) ActivityStreamAuditable(org.entando.entando.web.common.annotation.ActivityStreamAuditable) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with ActivityStreamAuditable

use of org.entando.entando.web.common.annotation.ActivityStreamAuditable in project entando-core by entando.

the class PageConfigurationController method deletePageWidget.

@ActivityStreamAuditable
@RestAccessControl(permission = Permission.MANAGE_PAGES)
@RequestMapping(value = "/pages/{pageCode}/widgets/{frameId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse<Map, Map>> deletePageWidget(@PathVariable String pageCode, @PathVariable String frameId) {
    logger.debug("removing widget configuration in page {} and frame {}", pageCode, frameId);
    BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(frameId, "frameId");
    this.validateFrameId(frameId, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    this.getPageService().deleteWidgetConfiguration(pageCode, Integer.valueOf(frameId));
    Map<String, String> result = new HashMap<>();
    result.put("code", frameId);
    Map<String, String> metadata = new HashMap<>();
    metadata.put("status", IPageService.STATUS_DRAFT);
    return new ResponseEntity<>(new RestResponse<>(result, metadata), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) HashMap(java.util.HashMap) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) ActivityStreamAuditable(org.entando.entando.web.common.annotation.ActivityStreamAuditable) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with ActivityStreamAuditable

use of org.entando.entando.web.common.annotation.ActivityStreamAuditable in project entando-core by entando.

the class PageConfigurationController method updatePageConfiguration.

@ActivityStreamAuditable
@RestAccessControl(permission = Permission.MANAGE_PAGES)
@RequestMapping(value = "/pages/{pageCode}/configuration/restore", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse<PageConfigurationDto, Map>> updatePageConfiguration(@PathVariable String pageCode) {
    logger.debug("restore configuration on page {}", pageCode);
    PageConfigurationDto pageConfiguration = this.getPageService().restorePageConfiguration(pageCode);
    Map<String, String> metadata = new HashMap<>();
    return new ResponseEntity<>(new RestResponse<>(pageConfiguration, metadata), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) PageConfigurationDto(org.entando.entando.aps.system.services.page.model.PageConfigurationDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) ActivityStreamAuditable(org.entando.entando.web.common.annotation.ActivityStreamAuditable) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with ActivityStreamAuditable

use of org.entando.entando.web.common.annotation.ActivityStreamAuditable in project entando-core by entando.

the class PageConfigurationController method applyDefaultWidgetsPageConfiguration.

@ActivityStreamAuditable
@RestAccessControl(permission = Permission.MANAGE_PAGES)
@RequestMapping(value = "/pages/{pageCode}/configuration/defaultWidgets", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<PageConfigurationDto>> applyDefaultWidgetsPageConfiguration(@PathVariable String pageCode) {
    logger.debug("applying default widgets on page {}", pageCode);
    PageConfigurationDto pageConfiguration = this.getPageService().applyDefaultWidgets(pageCode);
    return new ResponseEntity<>(new SimpleRestResponse<>(pageConfiguration), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) PageConfigurationDto(org.entando.entando.aps.system.services.page.model.PageConfigurationDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) ActivityStreamAuditable(org.entando.entando.web.common.annotation.ActivityStreamAuditable) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ActivityStreamAuditable (org.entando.entando.web.common.annotation.ActivityStreamAuditable)9 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)9 ResponseEntity (org.springframework.http.ResponseEntity)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)7 HashMap (java.util.HashMap)6 PageDto (org.entando.entando.aps.system.services.page.model.PageDto)5 PageConfigurationDto (org.entando.entando.aps.system.services.page.model.PageConfigurationDto)2 WidgetConfigurationDto (org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto)1 ResourcePermissionsException (org.entando.entando.web.common.exceptions.ResourcePermissionsException)1 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)1 PagePositionRequest (org.entando.entando.web.page.model.PagePositionRequest)1 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)1 BindingResult (org.springframework.validation.BindingResult)1 DataBinder (org.springframework.validation.DataBinder)1