Search in sources :

Example 71 with IPage

use of com.agiletec.aps.system.services.page.IPage 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, true, pageCode, null, null, false, null, null);
    Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage.getCode(), "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 72 with IPage

use of com.agiletec.aps.system.services.page.IPage in project entando-core by entando.

the class PageServiceWidgetIntegrationTest method testGetPageConfiguration.

public void testGetPageConfiguration() throws JsonProcessingException {
    IPage draftRoot = this.pageManager.getDraftRoot();
    PageConfigurationDto pageConfigurationDto = (PageConfigurationDto) this.pageService.getPageConfiguration(draftRoot.getCode(), IPageService.STATUS_DRAFT);
    ObjectMapper mapper = new ObjectMapper();
    String out = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(pageConfigurationDto);
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) PageConfigurationDto(org.entando.entando.aps.system.services.page.model.PageConfigurationDto) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 73 with IPage

use of com.agiletec.aps.system.services.page.IPage in project entando-core by entando.

the class TestApiWidgetTypeInterface method setPageWidgets.

private void setPageWidgets(String pageCode, int frame, Widget widget) throws ApsSystemException {
    IPage page = this._pageManager.getDraftPage(pageCode);
    page.getWidgets()[frame] = widget;
    this._pageManager.updatePage(page);
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage)

Example 74 with IPage

use of com.agiletec.aps.system.services.page.IPage in project entando-core by entando.

the class ApiWidgetTypeInterface method deleteWidgetType.

public void deleteWidgetType(Properties properties) throws ApiException, Throwable {
    String code = properties.getProperty("code");
    try {
        WidgetType widgetType = this.getWidgetTypeManager().getWidgetType(code);
        if (null == widgetType) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Widget Type with code " + code + " does not exists", Response.Status.CONFLICT);
        }
        if (widgetType.isLocked()) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Widget Type '" + code + "' is locked", Response.Status.CONFLICT);
        }
        List<IPage> referencedPages = this.getPageManager().getDraftWidgetUtilizers(code);
        if (null != referencedPages && !referencedPages.isEmpty()) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Widget Type '" + code + "' is published into some pages", Response.Status.CONFLICT);
        }
        this.getWidgetTypeManager().deleteWidgetType(code);
    } catch (ApiException ae) {
        throw ae;
    } catch (Throwable t) {
        _logger.error("Error deleting widget type throw api", t);
        throw t;
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 75 with IPage

use of com.agiletec.aps.system.services.page.IPage in project entando-core by entando.

the class WidgetService method getWidgetInfo.

@Override
public WidgetInfoDto getWidgetInfo(String widgetCode) {
    try {
        List<IPage> publishedUtilizer = this.getPageManager().getOnlineWidgetUtilizers(widgetCode);
        List<IPage> draftUtilizer = this.getPageManager().getDraftWidgetUtilizers(widgetCode);
        WidgetType type = this.getWidgetManager().getWidgetType(widgetCode);
        WidgetInfoDto info = new WidgetInfoDto();
        info.setCode(widgetCode);
        info.setTitles(type.getTitles());
        publishedUtilizer.stream().forEach(page -> info.addPublishedUtilizer(getWidgetDetails(page, widgetCode)));
        draftUtilizer.stream().forEach(page -> info.addDraftUtilizer(getWidgetDetails(page, widgetCode)));
        return info;
    } catch (ApsSystemException e) {
        logger.error("Failed to load widget info for widgetCode {} ", widgetCode);
        throw new RestServerError("error in loading widget info", e);
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) WidgetInfoDto(org.entando.entando.aps.system.services.widgettype.model.WidgetInfoDto) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Aggregations

IPage (com.agiletec.aps.system.services.page.IPage)253 Widget (com.agiletec.aps.system.services.page.Widget)55 ArrayList (java.util.ArrayList)41 Page (com.agiletec.aps.system.services.page.Page)37 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)30 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)25 HashMap (java.util.HashMap)23 ApsProperties (com.agiletec.aps.util.ApsProperties)20 List (java.util.List)20 RestServerError (org.entando.entando.aps.system.exception.RestServerError)18 IPageManager (com.agiletec.aps.system.services.page.IPageManager)16 UserDetails (com.agiletec.aps.system.services.user.UserDetails)16 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)16 RequestContext (com.agiletec.aps.system.RequestContext)15 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)15 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)15 Test (org.junit.Test)14 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)13 Lang (com.agiletec.aps.system.services.lang.Lang)12 ResultActions (org.springframework.test.web.servlet.ResultActions)12