List of usage examples for com.liferay.portal.kernel.model Layout isTypeURL
public boolean isTypeURL();
From source file:com.liferay.exportimport.resources.importer.test.ResourcesImporterTest.java
License:Open Source License
protected void validateLayouts(Group importedGroup) throws Exception { long privateLayoutsCount = LayoutLocalServiceUtil.getLayoutsCount(importedGroup, true); Assert.assertEquals(1, privateLayoutsCount); long publicLayoutsCount = LayoutLocalServiceUtil.getLayoutsCount(importedGroup, false); Assert.assertEquals(9, publicLayoutsCount); Layout layout = LayoutLocalServiceUtil.getFriendlyURLLayout(importedGroup.getGroupId(), false, "/home"); Map<Locale, String> nameMap = layout.getNameMap(); Assert.assertTrue(nameMap.containsValue("Bienvenue")); Assert.assertTrue(layout.isTypePortlet()); LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); List<Portlet> portlets = layoutTypePortlet.getAllPortlets(); Assert.assertEquals(portlets.toString(), 7, portlets.size()); UnicodeProperties layoutTypeSettingsProperties = layout.getTypeSettingsProperties(); String nestedColumnIds = layoutTypeSettingsProperties.get(LayoutTypePortletConstants.NESTED_COLUMN_IDS); Assert.assertTrue((nestedColumnIds != null) && nestedColumnIds.contains("column-1") && nestedColumnIds.contains("column-2")); layout = LayoutLocalServiceUtil.getFriendlyURLLayout(importedGroup.getGroupId(), false, "/layout-prototypes-page-1"); Assert.assertTrue(layout.isLayoutPrototypeLinkActive()); Assert.assertEquals("371647ba-3649-4039-bfe6-ae32cf404737", layout.getLayoutPrototypeUuid()); layout = LayoutLocalServiceUtil.getFriendlyURLLayout(importedGroup.getGroupId(), false, "/layout-prototypes-page-2"); Assert.assertFalse(layout.isLayoutPrototypeLinkActive()); Assert.assertEquals("c98067d0-fc10-9556-7364-238d39693bc4", layout.getLayoutPrototypeUuid()); layout = LayoutLocalServiceUtil.getFriendlyURLLayout(importedGroup.getGroupId(), false, "/url-page"); Assert.assertTrue(layout.isTypeURL()); layout = LayoutLocalServiceUtil.getFriendlyURLLayout(importedGroup.getGroupId(), false, "/hidden-page"); Assert.assertTrue(layout.isHidden()); }
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 www. j ava 2s . c o 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.tool.datamanipulator.handler.content.LayoutHandler.java
License:Open Source License
private List<KeyValuePair> _getLayoutNameIdPairs(long groupId, boolean privateLayout) throws SystemException { List<KeyValuePair> layoutNameIdPairs = new ArrayList<KeyValuePair>(); List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(groupId, privateLayout); for (Layout layout : layouts) { if (layout.isHidden() || !layout.isRootLayout() || layout.isTypeControlPanel() || layout.isTypeControlPanel() || layout.isTypeURL()) { continue; }// www . ja v a2 s. c o m String layoutId = String.valueOf(layout.getLayoutId()); String layoutName = layout.getNameCurrentValue(); //getName(); layoutNameIdPairs.add(new KeyValuePair(layoutName, layoutId)); } return layoutNameIdPairs; }