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;
}
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());
}
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;
}
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);
}
}
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;
}
Aggregations