List of usage examples for com.liferay.portal.kernel.model Layout getLayoutSet
public LayoutSet getLayoutSet();
From source file:com.liferay.asset.publisher.web.portlet.action.AssetPublisherConfigurationAction.java
License:Open Source License
protected void updateDefaultAssetPublisher(ActionRequest actionRequest) throws Exception { boolean defaultAssetPublisher = ParamUtil.getBoolean(actionRequest, "defaultAssetPublisher"); Layout layout = (Layout) actionRequest.getAttribute(WebKeys.LAYOUT); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties(); if (defaultAssetPublisher) { typeSettingsProperties.setProperty(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID, portletResource);//from w w w . j a v a 2s .c o m } else { String defaultAssetPublisherPortletId = typeSettingsProperties .getProperty(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID); if (Validator.isNotNull(defaultAssetPublisherPortletId) && defaultAssetPublisherPortletId.equals(portletResource)) { typeSettingsProperties.setProperty(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID, StringPool.BLANK); } } layout = layoutLocalService.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), layout.getTypeSettings()); if (LayoutStagingUtil.isBranchingLayout(layout)) { HttpServletRequest request = portal.getHttpServletRequest(actionRequest); LayoutSetBranch layoutSetBranch = LayoutStagingUtil.getLayoutSetBranch(layout.getLayoutSet()); long layoutSetBranchId = layoutSetBranch.getLayoutSetBranchId(); long layoutRevisionId = staging.getRecentLayoutRevisionId(request, layoutSetBranchId, layout.getPlid()); LayoutRevision layoutRevision = layoutRevisionLocalService.getLayoutRevision(layoutRevisionId); PortletPreferencesImpl portletPreferences = (PortletPreferencesImpl) actionRequest.getPreferences(); if (layoutRevision != null) { portletPreferences.setPlid(layoutRevision.getLayoutRevisionId()); } } }
From source file:com.liferay.journal.util.impl.JournalUtil.java
License:Open Source License
private static void _populateTokens(Map<String, String> tokens, long articleGroupId, ThemeDisplay themeDisplay) throws PortalException { Layout layout = themeDisplay.getLayout(); Group group = layout.getGroup(); LayoutSet layoutSet = layout.getLayoutSet(); String friendlyUrlCurrent = null; if (layout.isPublicLayout()) { friendlyUrlCurrent = themeDisplay.getPathFriendlyURLPublic(); } else if (group.isUserGroup()) { friendlyUrlCurrent = themeDisplay.getPathFriendlyURLPrivateUser(); } else {/* www. j a v a 2 s . com*/ friendlyUrlCurrent = themeDisplay.getPathFriendlyURLPrivateGroup(); } String layoutSetFriendlyUrl = themeDisplay.getI18nPath(); String virtualHostname = layoutSet.getVirtualHostname(); if (Validator.isNull(virtualHostname) || !virtualHostname.equals(themeDisplay.getServerName())) { layoutSetFriendlyUrl = friendlyUrlCurrent + group.getFriendlyURL(); } tokens.put("article_group_id", String.valueOf(articleGroupId)); tokens.put("cdn_host", themeDisplay.getCDNHost()); tokens.put("company_id", String.valueOf(themeDisplay.getCompanyId())); tokens.put("friendly_url_current", friendlyUrlCurrent); tokens.put("friendly_url_private_group", themeDisplay.getPathFriendlyURLPrivateGroup()); tokens.put("friendly_url_private_user", themeDisplay.getPathFriendlyURLPrivateUser()); tokens.put("friendly_url_public", themeDisplay.getPathFriendlyURLPublic()); tokens.put("group_friendly_url", group.getFriendlyURL()); tokens.put("image_path", themeDisplay.getPathImage()); tokens.put("layout_set_friendly_url", layoutSetFriendlyUrl); tokens.put("main_path", themeDisplay.getPathMain()); tokens.put("portal_ctx", themeDisplay.getPathContext()); tokens.put("portal_url", HttpUtil.removeProtocol(themeDisplay.getURLPortal())); tokens.put("protocol", HttpUtil.getProtocol(themeDisplay.getURLPortal())); tokens.put("root_path", themeDisplay.getPathContext()); tokens.put("scope_group_id", String.valueOf(themeDisplay.getScopeGroupId())); tokens.put("site_group_id", String.valueOf(themeDisplay.getSiteGroupId())); tokens.put("theme_image_path", themeDisplay.getPathThemeImages()); _populateCustomTokens(tokens, themeDisplay.getCompanyId()); // Deprecated tokens tokens.put("friendly_url", themeDisplay.getPathFriendlyURLPublic()); tokens.put("friendly_url_private", themeDisplay.getPathFriendlyURLPrivateGroup()); tokens.put("group_id", String.valueOf(articleGroupId)); tokens.put("page_url", themeDisplay.getPathFriendlyURLPublic()); }
From source file:com.liferay.journal.util.impl.JournalUtil.java
License:Open Source License
private static void _populateTokens(Map<String, String> tokens, long articleGroupId, ThemeDisplayModel themeDisplayModel) throws Exception { Layout layout = LayoutLocalServiceUtil.getLayout(themeDisplayModel.getPlid()); Group group = layout.getGroup(); LayoutSet layoutSet = layout.getLayoutSet(); String friendlyUrlCurrent = null; if (layout.isPublicLayout()) { friendlyUrlCurrent = themeDisplayModel.getPathFriendlyURLPublic(); } else if (group.isUserGroup()) { friendlyUrlCurrent = themeDisplayModel.getPathFriendlyURLPrivateUser(); } else {/* w w w . ja v a 2s .c om*/ friendlyUrlCurrent = themeDisplayModel.getPathFriendlyURLPrivateGroup(); } String layoutSetFriendlyUrl = themeDisplayModel.getI18nPath(); String virtualHostname = layoutSet.getVirtualHostname(); if (Validator.isNull(virtualHostname) || !virtualHostname.equals(themeDisplayModel.getServerName())) { layoutSetFriendlyUrl = friendlyUrlCurrent + group.getFriendlyURL(); } tokens.put("article_group_id", String.valueOf(articleGroupId)); tokens.put("cdn_host", themeDisplayModel.getCdnHost()); tokens.put("company_id", String.valueOf(themeDisplayModel.getCompanyId())); tokens.put("friendly_url_current", friendlyUrlCurrent); tokens.put("friendly_url_private_group", themeDisplayModel.getPathFriendlyURLPrivateGroup()); tokens.put("friendly_url_private_user", themeDisplayModel.getPathFriendlyURLPrivateUser()); tokens.put("friendly_url_public", themeDisplayModel.getPathFriendlyURLPublic()); tokens.put("group_friendly_url", group.getFriendlyURL()); tokens.put("image_path", themeDisplayModel.getPathImage()); tokens.put("layout_set_friendly_url", layoutSetFriendlyUrl); tokens.put("main_path", themeDisplayModel.getPathMain()); tokens.put("portal_ctx", themeDisplayModel.getPathContext()); tokens.put("portal_url", HttpUtil.removeProtocol(themeDisplayModel.getURLPortal())); tokens.put("protocol", HttpUtil.getProtocol(themeDisplayModel.getURLPortal())); tokens.put("root_path", themeDisplayModel.getPathContext()); tokens.put("scope_group_id", String.valueOf(themeDisplayModel.getScopeGroupId())); tokens.put("theme_image_path", themeDisplayModel.getPathThemeImages()); _populateCustomTokens(tokens, themeDisplayModel.getCompanyId()); // Deprecated tokens tokens.put("friendly_url", themeDisplayModel.getPathFriendlyURLPublic()); tokens.put("friendly_url_private", themeDisplayModel.getPathFriendlyURLPrivateGroup()); tokens.put("group_id", String.valueOf(articleGroupId)); tokens.put("page_url", themeDisplayModel.getPathFriendlyURLPublic()); }
From source file:com.liferay.journal.web.social.JournalArticleActivityInterpreter.java
License:Open Source License
@Override protected String getPath(SocialActivity activity, ServiceContext serviceContext) throws Exception { JournalArticle article = _journalArticleLocalService.getLatestArticle(activity.getClassPK()); Layout layout = article.getLayout(); if (layout != null) { String groupFriendlyURL = _portal.getGroupFriendlyURL(layout.getLayoutSet(), serviceContext.getThemeDisplay()); return groupFriendlyURL.concat(JournalArticleConstants.CANONICAL_URL_SEPARATOR) .concat(article.getUrlTitle()); }//from w ww . ja v a 2s . c o m return null; }
From source file:com.liferay.layout.admin.web.internal.portlet.action.AddLayoutMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { UploadPortletRequest uploadPortletRequest = _portal.getUploadPortletRequest(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(actionRequest, "groupId"); long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId"); long stagingGroupId = ParamUtil.getLong(actionRequest, "stagingGroupId"); boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout"); long parentLayoutId = ParamUtil.getLong(uploadPortletRequest, "parentLayoutId"); Map<Locale, String> nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name"); Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(actionRequest, "title"); Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description"); Map<Locale, String> keywordsMap = LocalizationUtil.getLocalizationMap(actionRequest, "keywords"); Map<Locale, String> robotsMap = LocalizationUtil.getLocalizationMap(actionRequest, "robots"); String type = ParamUtil.getString(uploadPortletRequest, "type"); boolean hidden = ParamUtil.getBoolean(uploadPortletRequest, "hidden"); Map<Locale, String> friendlyURLMap = LocalizationUtil.getLocalizationMap(actionRequest, "friendlyURL"); long layoutPrototypeId = ParamUtil.getLong(uploadPortletRequest, "layoutPrototypeId"); ServiceContext serviceContext = ServiceContextFactory.getInstance(Layout.class.getName(), actionRequest); Layout layout = null; boolean inheritFromParentLayoutId = ParamUtil.getBoolean(uploadPortletRequest, "inheritFromParentLayoutId"); UnicodeProperties typeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest, "TypeSettingsProperties--"); String linkToLayoutUuid = ParamUtil.getString(actionRequest, "linkToLayoutUuid"); if (Validator.isNotNull(linkToLayoutUuid)) { Layout linkToLayout = _layoutLocalService.getLayoutByUuidAndGroupId(linkToLayoutUuid, groupId, privateLayout);/*from w w w .j a va2 s.co m*/ typeSettingsProperties.put("linkToLayoutId", String.valueOf(linkToLayout.getLayoutId())); } if (inheritFromParentLayoutId && (parentLayoutId > 0)) { Layout parentLayout = _layoutLocalService.getLayout(groupId, privateLayout, parentLayoutId); layout = _layoutService.addLayout(groupId, privateLayout, parentLayoutId, nameMap, titleMap, parentLayout.getDescriptionMap(), parentLayout.getKeywordsMap(), parentLayout.getRobotsMap(), parentLayout.getType(), parentLayout.getTypeSettings(), hidden, friendlyURLMap, serviceContext); inheritMobileRuleGroups(layout, serviceContext); if (parentLayout.isTypePortlet()) { com.liferay.portlet.sites.action.ActionUtil.copyPreferences(actionRequest, layout, parentLayout); SitesUtil.copyLookAndFeel(layout, parentLayout); } } else if (layoutPrototypeId > 0) { LayoutPrototype layoutPrototype = _layoutPrototypeService.getLayoutPrototype(layoutPrototypeId); boolean layoutPrototypeLinkEnabled = ParamUtil.getBoolean(uploadPortletRequest, "layoutPrototypeLinkEnabled" + layoutPrototype.getUuid()); serviceContext.setAttribute("layoutPrototypeLinkEnabled", layoutPrototypeLinkEnabled); serviceContext.setAttribute("layoutPrototypeUuid", layoutPrototype.getUuid()); layout = _layoutService.addLayout(groupId, privateLayout, parentLayoutId, nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, LayoutConstants.TYPE_PORTLET, typeSettingsProperties.toString(), hidden, friendlyURLMap, serviceContext); // Force propagation from page template to page. See LPS-48430. SitesUtil.mergeLayoutPrototypeLayout(layout.getGroup(), layout); } else { long copyLayoutId = ParamUtil.getLong(uploadPortletRequest, "copyLayoutId"); Layout copyLayout = null; String layoutTemplateId = ParamUtil.getString(uploadPortletRequest, "layoutTemplateId", PropsValues.DEFAULT_LAYOUT_TEMPLATE_ID); if (copyLayoutId > 0) { copyLayout = _layoutLocalService.fetchLayout(groupId, privateLayout, copyLayoutId); if ((copyLayout != null) && copyLayout.isTypePortlet()) { LayoutTypePortlet copyLayoutTypePortlet = (LayoutTypePortlet) copyLayout.getLayoutType(); layoutTemplateId = copyLayoutTypePortlet.getLayoutTemplateId(); typeSettingsProperties = copyLayout.getTypeSettingsProperties(); } } layout = _layoutService.addLayout(groupId, privateLayout, parentLayoutId, nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, type, typeSettingsProperties.toString(), hidden, friendlyURLMap, serviceContext); LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); layoutTypePortlet.setLayoutTemplateId(themeDisplay.getUserId(), layoutTemplateId); _layoutService.updateLayout(groupId, privateLayout, layout.getLayoutId(), layout.getTypeSettings()); if ((copyLayout != null) && copyLayout.isTypePortlet()) { com.liferay.portlet.sites.action.ActionUtil.copyPreferences(actionRequest, layout, copyLayout); SitesUtil.copyLookAndFeel(layout, copyLayout); } } _actionUtil.updateLookAndFeel(actionRequest, themeDisplay.getCompanyId(), liveGroupId, stagingGroupId, privateLayout, layout.getLayoutId(), layout.getTypeSettingsProperties()); String portletResource = ParamUtil.getString(uploadPortletRequest, "portletResource"); MultiSessionMessages.add(actionRequest, portletResource + "layoutAdded", layout); String redirect = ParamUtil.getString(actionRequest, "redirect"); if (Validator.isNull(redirect)) { redirect = _portal.getLayoutFullURL(layout, themeDisplay); if (layout.isTypeURL()) { redirect = _portal.getGroupFriendlyURL(layout.getLayoutSet(), themeDisplay); } } actionRequest.setAttribute(WebKeys.REDIRECT, redirect); }
From source file:com.liferay.layout.admin.web.internal.product.navigation.control.menu.InformationMessagesProductNavigationControlMenuEntry.java
License:Open Source License
protected boolean isModifiedLayout(ThemeDisplay themeDisplay) throws PortalException { Layout layout = themeDisplay.getLayout(); LayoutSet layoutSet = layout.getLayoutSet(); if (!layoutSet.isLayoutSetPrototypeLinkActive() || !SitesUtil.isLayoutModifiedSinceLastMerge(layout)) { return false; }//w ww . jav a 2 s. c o m if (!hasUpdateLayoutPermission(themeDisplay)) { return false; } return true; }