Search in sources :

Example 1 with Page

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

the class PageService method updatePage.

private IPage updatePage(IPage oldPage, PageRequest pageRequest) {
    Page page = new Page();
    page.setCode(pageRequest.getCode());
    page.setShowable(pageRequest.isDisplayedInMenu());
    if (oldPage.getModel().getCode().equals(pageRequest.getPageModel())) {
        PageModel model = this.getPageModelManager().getPageModel(pageRequest.getPageModel());
        page.setModel(model);
    }
    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());
    Optional<List<String>> groups = Optional.ofNullable(pageRequest.getJoinGroups());
    groups.ifPresent(values -> values.forEach((group) -> {
        page.addExtraGroup(group);
    }));
    page.setParentCode(pageRequest.getParentCode());
    PageMetadata metadata = oldPage.getMetadata();
    if (metadata == null) {
        metadata = new PageMetadata();
    }
    this.valueMetadataFromRequest(metadata, pageRequest);
    page.setMetadata(metadata);
    return page;
}
Also used : Arrays(java.util.Arrays) Page(com.agiletec.aps.system.services.page.Page) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) ApsProperties(com.agiletec.aps.util.ApsProperties) IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) IPage(com.agiletec.aps.system.services.page.IPage) PageConfigurationDto(org.entando.entando.aps.system.services.page.model.PageConfigurationDto) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) RestServerError(org.entando.entando.aps.system.exception.RestServerError) IGroupManager(com.agiletec.aps.system.services.group.IGroupManager) IPageManager(com.agiletec.aps.system.services.page.IPageManager) WidgetValidatorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetValidatorFactory) Widget(com.agiletec.aps.system.services.page.Widget) Map(java.util.Map) IManager(com.agiletec.aps.system.common.IManager) PagePositionRequest(org.entando.entando.web.page.model.PagePositionRequest) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) WidgetConfigurationRequest(org.entando.entando.web.page.model.WidgetConfigurationRequest) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) GroupServiceUtilizer(org.entando.entando.aps.system.services.group.GroupServiceUtilizer) Logger(org.slf4j.Logger) PageRequest(org.entando.entando.web.page.model.PageRequest) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) List(java.util.List) GroupUtilizer(com.agiletec.aps.system.services.group.GroupUtilizer) WidgetProcessorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetProcessorFactory) 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) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) ArrayList(java.util.ArrayList) List(java.util.List) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) Map(java.util.Map) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 2 with Page

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

the class CacheInfoManagerTest method updateFromPageChanged.

@Test
public void updateFromPageChanged() throws Throwable {
    PageChangedEvent event = new PageChangedEvent();
    Page page = new Page();
    page.setCode("code");
    event.setPage(page);
    cacheInfoManager.updateFromPageChanged(event);
    Mockito.verify(cache, Mockito.times(1)).get(Mockito.anyString());
    Mockito.verify(cache, Mockito.times(1)).put(Mockito.anyString(), Mockito.any(Map.class));
    Object requiredMap = cacheInfoManager.getFromCache(ICacheInfoManager.CACHE_INFO_MANAGER_CACHE_NAME, ICacheInfoManager.GROUP_CACHE_NAME_PREFIX + ICacheInfoManager.CACHE_INFO_MANAGER_CACHE_NAME);
    Assert.assertTrue(requiredMap instanceof Map);
    Assert.assertNotNull(requiredMap);
    Assert.assertEquals(2, ((Map) requiredMap).size());
}
Also used : PageChangedEvent(com.agiletec.aps.system.services.page.events.PageChangedEvent) Page(com.agiletec.aps.system.services.page.Page) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 3 with Page

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

the class TestPageActionReferences method createPage.

private Page createPage(String code) {
    Page page = new Page();
    Page parent = (Page) this._pageManager.getDraftRoot();
    page.setParentCode(parent.getCode());
    page.setParent(parent);
    page.setTitle("it", code);
    page.setTitle("en", code);
    page.setGroup(Group.FREE_GROUP_NAME);
    page.setModel(this.pageModelManager.getPageModel("internal"));
    page.setCode(code);
    return page;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Page(com.agiletec.aps.system.services.page.Page)

Example 4 with Page

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

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

the class PageAction method setDefaultWidgets.

public String setDefaultWidgets() {
    Page page = null;
    try {
        page = (Page) this.getPage(this.getPageCode());
        PageModel model = page.getMetadata().getModel();
        Widget[] defaultWidgets = model.getDefaultWidget();
        if (null == defaultWidgets) {
            _logger.info("No default Widget found for pagemodel '{}' of page '{}'", model.getCode(), page.getCode());
            return SUCCESS;
        }
        Widget[] widgets = new Widget[defaultWidgets.length];
        for (int i = 0; i < defaultWidgets.length; i++) {
            Widget defaultWidget = defaultWidgets[i];
            if (null != defaultWidget) {
                if (null == defaultWidget.getType()) {
                    _logger.info("Widget Type null when adding defaulWidget (of pagemodel '{}') on frame '{}' of page '{}'", model.getCode(), i, page.getCode());
                    continue;
                }
                widgets[i] = defaultWidget;
            }
        }
        page.setWidgets(widgets);
        this.getPageManager().updatePage(page);
    } catch (Throwable t) {
        _logger.error("Error setting default widget to page {}", page.getCode(), t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : 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)

Aggregations

Page (com.agiletec.aps.system.services.page.Page)29 IPage (com.agiletec.aps.system.services.page.IPage)23 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)12 Widget (com.agiletec.aps.system.services.page.Widget)9 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)9 Test (org.junit.Test)9 UserDetails (com.agiletec.aps.system.services.user.UserDetails)7 ResultActions (org.springframework.test.web.servlet.ResultActions)7 ApsProperties (com.agiletec.aps.util.ApsProperties)5 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)4 WidgetConfigurationDto (org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto)4 WidgetConfigurationRequest (org.entando.entando.web.page.model.WidgetConfigurationRequest)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 AbstractControllerTest (org.entando.entando.web.AbstractControllerTest)3 IManager (com.agiletec.aps.system.common.IManager)2 GroupUtilizer (com.agiletec.aps.system.services.group.GroupUtilizer)2 IGroupManager (com.agiletec.aps.system.services.group.IGroupManager)2