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