Search in sources :

Example 6 with PageMetadata

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

the class PageAction method getUpdatedPage.

protected IPage getUpdatedPage() throws ApsSystemException {
    Page page = null;
    try {
        page = (Page) this.getPage(this.getPageCode());
        page.setGroup(this.getGroup());
        PageMetadata metadata = page.getMetadata();
        if (metadata == null) {
            metadata = new PageMetadata();
            page.setMetadata(metadata);
        }
        PageModel oldModel = metadata.getModel();
        this.valueMetadataFromForm(metadata);
        if (oldModel == null || !oldModel.getCode().equals(this.getModel())) {
            // The model is changed, so I drop all the previous widgets
            page.setWidgets(new Widget[metadata.getModel().getFrames().length]);
        }
    // if (this.isDefaultShowlet()) {
    // this.setDefaultWidgets(page);
    // }
    } catch (Throwable t) {
        _logger.error("Error updating page", t);
        throw new ApsSystemException("Error updating page", t);
    }
    return page;
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel)

Example 7 with PageMetadata

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

the class PageConfigurationControllerWidgetsIntegrationTest method createPage.

protected Page createPage(String pageCode) {
    IPage parentPage = pageManager.getDraftPage("service");
    PageModel pageModel = parentPage.getMetadata().getModel();
    PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, pageCode + "_title", null, null, false, null, null);
    ApsProperties config = PageTestUtil.createProperties("temp", "tempValue", "contentId", "ART11");
    Widget widgetToAdd = PageTestUtil.createWidget("content_viewer", config, this.widgetTypeManager);
    Widget[] widgets = { widgetToAdd };
    Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage, "free", metadata, widgets);
    return pageToAdd;
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 8 with PageMetadata

use of com.agiletec.aps.system.services.page.PageMetadata 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 9 with PageMetadata

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

the class PreviewRequestValidator method getDesiredPage.

private Page getDesiredPage(String pageCode) {
    Page page = null;
    IPage currentPage = this.getPageManager().getDraftPage(pageCode);
    if (null != currentPage) {
        page = new Page();
        page.setCode(currentPage.getCode());
        page.setParent(currentPage.getParent());
        page.setParentCode(currentPage.getParentCode());
        page.setGroup(currentPage.getGroup());
        PageMetadata metadata = currentPage.getMetadata();
        page.setMetadata(metadata);
        String[] children = currentPage.getChildrenCodes();
        page.setChildrenCodes(children);
        Widget[] widgets = currentPage.getWidgets();
        page.setWidgets(widgets);
    }
    return page;
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage)

Example 10 with PageMetadata

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

the class WidgetValidatorCmsHelper method validateSingleContentOnPage.

public static void validateSingleContentOnPage(String widgetCode, IPage page, String contentId, IContentManager contentManager, BeanPropertyBindingResult errors) throws ApsSystemException {
    if (StringUtils.isBlank(contentId)) {
        errors.reject(ERRCODE_CONTENT_ID_NULL, new String[] {}, widgetCode + ".contentId.required");
        return;
    }
    Content publishingContent = contentManager.loadContent(contentId, true);
    if (null == publishingContent) {
        errors.reject(ERRCODE_CONTENT_ID_NULL, new String[] { contentId }, widgetCode + ".contentId.not_found");
        return;
    }
    if (!CmsPageUtil.isContentPublishableOnPageDraft(publishingContent, page)) {
        PageMetadata metadata = page.getMetadata();
        List<String> pageGroups = new ArrayList<String>();
        pageGroups.add(page.getGroup());
        if (null != metadata.getExtraGroups()) {
            pageGroups.addAll(metadata.getExtraGroups());
        }
        List<String> contentGroups = CmsPageUtil.getContentGroups(publishingContent);
        errors.reject(ERRCODE_CONTENT_INVALID, new String[] { StringUtils.join(pageGroups, ", "), StringUtils.join(contentGroups, ", ") }, widgetCode + ".contentId.group.invalid");
        return;
    }
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ArrayList(java.util.ArrayList)

Aggregations

PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)23 IPage (com.agiletec.aps.system.services.page.IPage)18 Page (com.agiletec.aps.system.services.page.Page)13 Widget (com.agiletec.aps.system.services.page.Widget)9 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)9 ArrayList (java.util.ArrayList)7 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)6 ApsProperties (com.agiletec.aps.util.ApsProperties)6 WidgetConfigurationDto (org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto)5 WidgetConfigurationRequest (org.entando.entando.web.page.model.WidgetConfigurationRequest)5 List (java.util.List)4 IManager (com.agiletec.aps.system.common.IManager)3 GroupUtilizer (com.agiletec.aps.system.services.group.GroupUtilizer)3 IGroupManager (com.agiletec.aps.system.services.group.IGroupManager)3 IPageManager (com.agiletec.aps.system.services.page.IPageManager)3 IPageModelManager (com.agiletec.aps.system.services.pagemodel.IPageModelManager)3 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)3 Arrays (java.util.Arrays)3 Map (java.util.Map)3 Optional (java.util.Optional)3