use of com.agiletec.aps.system.services.page.PageMetadata in project entando-core by entando.
the class CmsPageUtil method isContentPublishableOnPage.
/**
* Check if is possible to publish the content in the given page, checking
* the given page metadata.
*
* @param publishingContent
* The publishing content.
* @param page
* The page where you want to publish the content.
* @param metadata
* The metadata of the page where you want to publish the content.
* @return True/false if is possible to publish the content in the given
* page.
*/
public static boolean isContentPublishableOnPage(Content publishingContent, IPage page) {
if (publishingContent.getMainGroup().equals(Group.FREE_GROUP_NAME) || publishingContent.getGroups().contains(Group.FREE_GROUP_NAME)) {
return true;
}
// tutti i gruppi posseduti dalla pagina devono essere contemplati nel
// contenuto.
List<String> pageGroups = new ArrayList<String>();
pageGroups.add(page.getGroup());
PageMetadata metadata = page.getMetadata();
if (metadata != null && null != metadata.getExtraGroups()) {
pageGroups.addAll(metadata.getExtraGroups());
}
List<String> contentGroups = getContentGroups(publishingContent);
for (int i = 0; i < pageGroups.size(); i++) {
String pageGroup = pageGroups.get(i);
if (!pageGroup.equals(Group.ADMINS_GROUP_NAME) && !contentGroups.contains(pageGroup))
return false;
}
return true;
}
use of com.agiletec.aps.system.services.page.PageMetadata in project entando-core by entando.
the class CmsPageUtil method isOnlineFreeViewerPage.
/**
* Check whether the page can publish free content, related to the online
* 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 isOnlineFreeViewerPage(IPage page, String viewerWidgetCode) {
if (!page.isOnlineInstance()) {
_logger.warn("this check expects an online 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 PageServiceWidgetIntegrationTest method testRemovePageWidget.
public void testRemovePageWidget() 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"));
this.pageService.deleteWidgetConfiguration(pageToAdd.getCode(), 0);
assertThat(widgetConfigurationDto, is(nullValue()));
} finally {
pageManager.deletePage(pageCode);
}
}
use of com.agiletec.aps.system.services.page.PageMetadata in project entando-core by entando.
the class PageService method valueMetadataFromRequest.
private void valueMetadataFromRequest(PageMetadata metadata, PageRequest request) {
if (metadata.getModel() == null || !metadata.getModel().getCode().equals(request.getPageModel())) {
// Ho cambiato modello e allora cancello tutte le showlets
// Precedenti
PageModel model = this.getPageModelManager().getPageModel(request.getPageModel());
metadata.setModel(model);
}
metadata.setShowable(request.isDisplayedInMenu());
metadata.setUseExtraTitles(request.isSeo());
Optional<Map<String, String>> titles = Optional.ofNullable(request.getTitles());
ApsProperties apsTitles = new ApsProperties();
titles.ifPresent(values -> values.keySet().forEach((lang) -> {
apsTitles.put(lang, values.get(lang));
}));
metadata.setTitles(apsTitles);
Optional<List<String>> groups = Optional.ofNullable(request.getJoinGroups());
groups.ifPresent(values -> values.forEach((group) -> {
metadata.addExtraGroup(group);
}));
String charset = request.getCharset();
metadata.setCharset(StringUtils.isNotBlank(charset) ? charset : null);
String mimetype = request.getContentType();
metadata.setMimeType(StringUtils.isNotBlank(mimetype) ? mimetype : null);
}
use of com.agiletec.aps.system.services.page.PageMetadata in project entando-core by entando.
the class PageService method createPage.
private IPage createPage(PageRequest pageRequest) {
Page page = new Page();
page.setCode(pageRequest.getCode());
page.setShowable(pageRequest.isDisplayedInMenu());
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());
if (pageRequest.getParentCode() != null) {
IPage parent = this.getPageManager().getDraftPage(pageRequest.getParentCode());
page.setParent(parent);
}
PageMetadata metadata = new PageMetadata();
this.valueMetadataFromRequest(metadata, pageRequest);
page.setMetadata(metadata);
return page;
}
Aggregations