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