Search in sources :

Example 1 with PageMetadata

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

the class CmsPageUtil method isDraftFreeViewerPage.

/**
 * Check whether the page can publish free content, related to the draft
 * configuration of the page.
 *
 * @param page
 * The page to check.
 * @param viewerWidgetCode
 * The code of the viewer widget (optional)
 * @return True if the page can publish free content, false else.
 */
public static boolean isDraftFreeViewerPage(IPage page, String viewerWidgetCode) {
    if (page.isOnlineInstance()) {
        _logger.warn("this check expects a draft instance of the page");
        return false;
    }
    boolean found = false;
    PageMetadata metadata = page.getMetadata();
    Widget[] widgets = page.getWidgets();
    if (metadata != null) {
        found = isFreeViewerPage(metadata.getModel(), widgets, viewerWidgetCode);
    }
    return found;
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) Widget(com.agiletec.aps.system.services.page.Widget)

Example 2 with PageMetadata

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

the class TestPageTreeAction method testMoveTreeSuccess.

public void testMoveTreeSuccess() throws Throwable {
    String pageCode = "testPage";
    IPage root = this._pageManager.getDraftRoot();
    try {
        Page testPage = new Page();
        testPage.setCode(pageCode);
        testPage.setParent(this._pageManager.getDraftRoot());
        testPage.setParentCode(root.getCode());
        PageMetadata draft = new PageMetadata();
        draft.setTitle("en", pageCode);
        draft.setTitle("it", pageCode);
        draft.setModel(root.getMetadata().getModel());
        testPage.setMetadata(draft);
        testPage.setGroup(Group.FREE_GROUP_NAME);
        this._pageManager.addPage(testPage);
        this.setUserOnSession("pageManagerCoach");
        this.initAction("/do/rs/Page", "moveTree");
        this.addParameter("selectedNode", pageCode);
        this.addParameter("parentPageCode", "pagina_2");
        String result = this.executeAction();
        assertEquals("success", result);
    } finally {
        this._pageManager.deletePage(pageCode);
    }
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage)

Example 3 with PageMetadata

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

the class PageAction method valueFormForEdit.

protected void valueFormForEdit(IPage pageToEdit) throws CloneNotSupportedException {
    this.setStrutsAction(ApsAdminSystemConstants.EDIT);
    this.setParentPageCode(pageToEdit.getParent().getCode());
    this.setPageCode(pageToEdit.getCode());
    this.setGroup(pageToEdit.getGroup());
    PageMetadata draftMetadata = pageToEdit.getMetadata();
    this.copyMetadataToForm(draftMetadata);
    this.setGroupSelectLock(true);
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata)

Example 4 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 5 with PageMetadata

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

the class PageService method updatePage.

private IPage updatePage(IPage oldPage, PageRequest pageRequest) {
    Page page = new Page();
    PageMetadata metadata = oldPage.getMetadata();
    if (metadata == null) {
        metadata = new PageMetadata();
    }
    this.valueMetadataFromRequest(metadata, pageRequest);
    page.setMetadata(metadata);
    page.setCode(pageRequest.getCode());
    page.setShowable(pageRequest.isDisplayedInMenu());
    if (!oldPage.getModel().getCode().equals(pageRequest.getPageModel())) {
        PageModel model = this.getPageModelManager().getPageModel(pageRequest.getPageModel());
        model.setCode(pageRequest.getPageModel());
        page.setModel(model);
        page.setWidgets(new Widget[model.getFrames().length]);
    } else {
        page.setWidgets(oldPage.getWidgets());
    }
    page.setCharset(pageRequest.getCharset());
    page.setMimeType(pageRequest.getContentType());
    page.setParentCode(pageRequest.getParentCode());
    page.setUseExtraTitles(pageRequest.isSeo());
    Optional<Map<String, String>> titles = Optional.ofNullable(pageRequest.getTitles());
    ApsProperties apsTitles = new ApsProperties();
    titles.ifPresent(values -> values.keySet().forEach((lang) -> {
        apsTitles.put(lang, values.get(lang));
    }));
    page.setTitles(apsTitles);
    page.setGroup(pageRequest.getOwnerGroup());
    if (page.getExtraGroups() != null) {
        List<String> oldGroups = new ArrayList<>(page.getExtraGroups());
        oldGroups.forEach(page::removeExtraGroup);
    }
    if (pageRequest.getJoinGroups() != null) {
        pageRequest.getJoinGroups().forEach(page::addExtraGroup);
    }
    page.setParentCode(pageRequest.getParentCode());
    page.setPosition(oldPage.getPosition());
    page.setChildrenCodes(oldPage.getChildrenCodes());
    return page;
}
Also used : ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException) Arrays(java.util.Arrays) BeanComparator(org.apache.commons.beanutils.BeanComparator) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) Group(com.agiletec.aps.system.services.group.Group) IPage(com.agiletec.aps.system.services.page.IPage) PageConfigurationDto(org.entando.entando.aps.system.services.page.model.PageConfigurationDto) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) PageSearchDto(org.entando.entando.aps.system.services.page.model.PageSearchDto) IGroupManager(com.agiletec.aps.system.services.group.IGroupManager) WidgetValidatorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetValidatorFactory) Widget(com.agiletec.aps.system.services.page.Widget) Map(java.util.Map) PagePositionRequest(org.entando.entando.web.page.model.PagePositionRequest) PageDtoBuilder(org.entando.entando.aps.system.services.page.model.PageDtoBuilder) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) JsonNode(com.fasterxml.jackson.databind.JsonNode) PageModelUtilizer(com.agiletec.aps.system.services.pagemodel.PageModelUtilizer) PageSearchRequest(org.entando.entando.web.page.model.PageSearchRequest) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) DataBinder(org.springframework.validation.DataBinder) ComponentUsageEntity(org.entando.entando.web.component.ComponentUsageEntity) Collectors(java.util.stream.Collectors) PagesStatus(com.agiletec.aps.system.services.page.PagesStatus) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) List(java.util.List) RestListRequest(org.entando.entando.web.common.model.RestListRequest) GroupUtilizer(com.agiletec.aps.system.services.group.GroupUtilizer) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) Optional(java.util.Optional) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) IPageModelManager(com.agiletec.aps.system.services.pagemodel.IPageModelManager) PageUtils(org.entando.entando.aps.util.PageUtils) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) ApplicationContextAware(org.springframework.context.ApplicationContextAware) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) BeanUtils(org.springframework.beans.BeanUtils) JsonPatchService(org.entando.entando.aps.system.services.jsonpatch.JsonPatchService) Page(com.agiletec.aps.system.services.page.Page) HashMap(java.util.HashMap) BindingResult(org.springframework.validation.BindingResult) ApsProperties(com.agiletec.aps.util.ApsProperties) IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) PageUtilizer(com.agiletec.aps.system.services.page.PageUtilizer) ArrayList(java.util.ArrayList) RestServerError(org.entando.entando.aps.system.exception.RestServerError) IPageManager(com.agiletec.aps.system.services.page.IPageManager) IManager(com.agiletec.aps.system.common.IManager) PagedMetadataMapper(org.entando.entando.web.common.assembler.PagedMetadataMapper) WidgetConfigurationRequest(org.entando.entando.web.page.model.WidgetConfigurationRequest) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) GroupServiceUtilizer(org.entando.entando.aps.system.services.group.GroupServiceUtilizer) PageSearchMapper(org.entando.entando.web.common.assembler.PageSearchMapper) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) PageRequest(org.entando.entando.web.page.model.PageRequest) PagesStatusDto(org.entando.entando.aps.system.services.page.model.PagesStatusDto) BeansException(org.springframework.beans.BeansException) PageValidator(org.entando.entando.web.page.validator.PageValidator) ApplicationContext(org.springframework.context.ApplicationContext) PageModelServiceUtilizer(org.entando.entando.aps.system.services.pagemodel.PageModelServiceUtilizer) WidgetProcessorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetProcessorFactory) Collections(java.util.Collections) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) ArrayList(java.util.ArrayList) IPage(com.agiletec.aps.system.services.page.IPage) Page(com.agiletec.aps.system.services.page.Page) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) Map(java.util.Map) HashMap(java.util.HashMap) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)29 IPage (com.agiletec.aps.system.services.page.IPage)22 Page (com.agiletec.aps.system.services.page.Page)17 Widget (com.agiletec.aps.system.services.page.Widget)15 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)9 ApsProperties (com.agiletec.aps.util.ApsProperties)8 ArrayList (java.util.ArrayList)7 WidgetConfigurationDto (org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto)5 WidgetConfigurationRequest (org.entando.entando.web.page.model.WidgetConfigurationRequest)5 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)4 PagesStatus (com.agiletec.aps.system.services.page.PagesStatus)4 HashMap (java.util.HashMap)4 List (java.util.List)4 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)3 IManager (com.agiletec.aps.system.common.IManager)3 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)3 Group (com.agiletec.aps.system.services.group.Group)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