Search in sources :

Example 1 with WidgetConfigurationDto

use of org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto 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 2 with WidgetConfigurationDto

use of org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto in project entando-core by entando.

the class PageService method getWidgetConfiguration.

@Override
public WidgetConfigurationDto getWidgetConfiguration(String pageCode, int frameId, String status) {
    IPage page = this.loadPage(pageCode, status);
    if (null == page) {
        throw new RestRourceNotFoundException(ERRCODE_PAGE_NOT_FOUND, "page", pageCode);
    }
    if (frameId > page.getWidgets().length) {
        throw new RestRourceNotFoundException(ERRCODE_FRAME_INVALID, "frame", String.valueOf(frameId));
    }
    Widget widget = page.getWidgets()[frameId];
    if (null == widget) {
        return null;
    }
    return new WidgetConfigurationDto(widget);
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) IPage(com.agiletec.aps.system.services.page.IPage) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) Widget(com.agiletec.aps.system.services.page.Widget)

Example 3 with WidgetConfigurationDto

use of org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto in project entando-core by entando.

the class PageServiceWidgetIntegrationTest method testUpdatePageWidget.

public void testUpdatePageWidget() throws JsonProcessingException, ApsSystemException {
    String pageCode = "temp001";
    IPage parentPage = pageManager.getDraftRoot();
    PageModel pageModel = parentPage.getMetadata().getModel();
    PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, pageCode, null, null, false, null, null);
    Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage, "free", metadata, null);
    try {
        pageManager.addPage(pageToAdd);
        WidgetConfigurationDto widgetConfigurationDto = this.pageService.getWidgetConfiguration(pageToAdd.getCode(), 0, IPageService.STATUS_DRAFT);
        assertThat(widgetConfigurationDto, is(nullValue()));
        WidgetConfigurationRequest widgetConfigurationRequest = new WidgetConfigurationRequest();
        widgetConfigurationRequest.setCode("login_form");
        widgetConfigurationRequest.setConfig(null);
        this.pageService.updateWidgetConfiguration(pageCode, 0, widgetConfigurationRequest);
        assertThat(this.pageService.getWidgetConfiguration(pageToAdd.getCode(), 0, IPageService.STATUS_DRAFT).getCode(), is("login_form"));
    } finally {
        pageManager.deletePage(pageCode);
    }
}
Also used : WidgetConfigurationRequest(org.entando.entando.web.page.model.WidgetConfigurationRequest) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel)

Example 4 with WidgetConfigurationDto

use of org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto in project entando-core by entando.

the class PageConfigurationController method updatePageWidget.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/pages/{pageCode}/widgets/{frameId}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updatePageWidget(@PathVariable String pageCode, @PathVariable int frameId, @Valid @RequestBody WidgetConfigurationRequest widget, BindingResult bindingResult) {
    logger.trace("updating widget configuration in page {} and frame {}", pageCode, frameId);
    WidgetConfigurationDto widgetConfiguration = this.getPageService().updateWidgetConfiguration(pageCode, frameId, widget);
    Map<String, String> metadata = new HashMap<>();
    metadata.put("status", IPageService.STATUS_DRAFT);
    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 5 with WidgetConfigurationDto

use of org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto in project entando-core by entando.

the class PageServiceWidgetIntegrationTest method testGetPageWidget.

public void testGetPageWidget() throws JsonProcessingException {
    IPage draftRoot = this.pageManager.getDraftRoot();
    WidgetConfigurationDto widgetConfigurationDto = this.pageService.getWidgetConfiguration(draftRoot.getCode(), 0, IPageService.STATUS_DRAFT);
    assertThat(widgetConfigurationDto.getCode(), is("content_viewer_list"));
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto)

Aggregations

WidgetConfigurationDto (org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto)7 IPage (com.agiletec.aps.system.services.page.IPage)5 Page (com.agiletec.aps.system.services.page.Page)2 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)2 Widget (com.agiletec.aps.system.services.page.Widget)2 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)2 HashMap (java.util.HashMap)2 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)2 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)2 RestResponse (org.entando.entando.web.common.model.RestResponse)2 WidgetConfigurationRequest (org.entando.entando.web.page.model.WidgetConfigurationRequest)2 ResponseEntity (org.springframework.http.ResponseEntity)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 ApsProperties (com.agiletec.aps.util.ApsProperties)1 RestServerError (org.entando.entando.aps.system.exception.RestServerError)1 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)1 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)1 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)1