List of usage examples for com.liferay.portal.kernel.portletdisplaytemplate PortletDisplayTemplateManager DISPLAY_STYLE_PREFIX
String DISPLAY_STYLE_PREFIX
To view the source code for com.liferay.portal.kernel.portletdisplaytemplate PortletDisplayTemplateManager DISPLAY_STYLE_PREFIX.
Click Source Link
From source file:com.liferay.exportimport.test.util.lar.BasePortletExportImportTestCase.java
License:Open Source License
protected void testExportImportDisplayStyle(long displayStyleGroupId, String scopeType) throws Exception { Portlet portlet = PortletLocalServiceUtil.getPortletById(group.getCompanyId(), getPortletId()); if (portlet == null) { return;/*from w w w. j a va 2s . co m*/ } if (scopeType.equals("layout") && !portlet.isScopeable()) { Assert.assertTrue("This test does not apply", true); return; } TemplateHandler templateHandler = portlet.getTemplateHandlerInstance(); if ((templateHandler == null) || !templateHandler.isDisplayTemplateHandler()) { Assert.assertTrue("This test does not apply", true); return; } String className = templateHandler.getClassName(); long resourceClassNameId = PortalUtil .getClassNameId("com.liferay.portlet.display.template.PortletDisplayTemplate"); DDMTemplate ddmTemplate = DDMTemplateTestUtil.addTemplate(displayStyleGroupId, PortalUtil.getClassNameId(className), 0, resourceClassNameId); Map<String, String[]> preferenceMap = new HashMap<>(); String displayStyle = PortletDisplayTemplateManager.DISPLAY_STYLE_PREFIX + ddmTemplate.getTemplateKey(); preferenceMap.put("displayStyle", new String[] { displayStyle }); preferenceMap.put("displayStyleGroupId", new String[] { String.valueOf(ddmTemplate.getGroupId()) }); if (scopeType.equals("layout")) { preferenceMap.put("lfrScopeLayoutUuid", new String[] { this.layout.getUuid() }); } preferenceMap.put("lfrScopeType", new String[] { scopeType }); PortletPreferences portletPreferences = getImportedPortletPreferences(preferenceMap); String importedDisplayStyle = portletPreferences.getValue("displayStyle", StringPool.BLANK); Assert.assertEquals(displayStyle, importedDisplayStyle); long importedDisplayStyleGroupId = GetterUtil .getLong(portletPreferences.getValue("displayStyleGroupId", null)); long expectedDisplayStyleGroupId = importedGroup.getGroupId(); if (scopeType.equals("company")) { Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(importedGroup.getCompanyId()); expectedDisplayStyleGroupId = companyGroup.getGroupId(); } else if (displayStyleGroupId != group.getGroupId()) { expectedDisplayStyleGroupId = displayStyleGroupId; } Assert.assertEquals(expectedDisplayStyleGroupId, importedDisplayStyleGroupId); }
From source file:com.liferay.portlet.display.template.exportimport.portlet.preferences.processor.PortletDisplayTemplateImportCapability.java
License:Open Source License
protected PortletPreferences importDisplayStyle(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception { PortletPreferences processedPreferences = portletPreferences; String displayStyle = getDisplayStyle(portletDataContext, portletId, portletPreferences); if (Validator.isNull(displayStyle) || !displayStyle.startsWith(PortletDisplayTemplateManager.DISPLAY_STYLE_PREFIX)) { return processedPreferences; }// www . j a va 2 s . c o m StagedModelDataHandlerUtil.importReferenceStagedModels(portletDataContext, DDMTemplate.class); long displayStyleGroupId = getDisplayStyleGroupId(portletDataContext, portletId, portletPreferences); Map<Long, Long> groupIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(Group.class); long groupId = MapUtil.getLong(groupIds, displayStyleGroupId, displayStyleGroupId); DDMTemplate ddmTemplate = PortletDisplayTemplateUtil.getPortletDisplayTemplateDDMTemplate(groupId, getClassNameId(portletDataContext, portletId), displayStyle, false); if (ddmTemplate != null) { portletPreferences.setValue("displayStyleGroupId", String.valueOf(ddmTemplate.getGroupId())); } else { portletPreferences.setValue("displayStyleGroupId", StringPool.BLANK); } return processedPreferences; }
From source file:com.liferay.site.navigation.breadcrumb.web.internal.upgrade.v1_0_0.UpgradePortletPreferences.java
License:Open Source License
protected void upgradeDisplayStyle(PortletPreferences portletPreferences) throws ReadOnlyException { String displayStyle = GetterUtil.getString(portletPreferences.getValue("displayStyle", null)); if (Validator.isNull(displayStyle) || displayStyle.startsWith(PortletDisplayTemplateManager.DISPLAY_STYLE_PREFIX)) { return;/* w ww .j av a2s . c o m*/ } if (displayStyle.equals("horizontal") || displayStyle.equals("1")) { portletPreferences.setValue("displayStyle", PortletDisplayTemplateManager.DISPLAY_STYLE_PREFIX + "breadcrumb-horizontal-ftl"); } else if (displayStyle.equals("vertical") || displayStyle.equals("2")) { portletPreferences.setValue("displayStyle", PortletDisplayTemplateManager.DISPLAY_STYLE_PREFIX + "breadcrumb-vertical-ftl"); } else { portletPreferences.reset("displayStyle"); if (_log.isWarnEnabled()) { _log.warn("Display styles for breadcrumbs are deprecated in favor " + "of application display templates"); } } }
From source file:com.liferay.site.navigation.menu.web.internal.upgrade.v1_0_0.UpgradePortletPreferences.java
License:Open Source License
protected void upgradeDisplayStyle(PortletPreferences portletPreferences) throws ReadOnlyException { String displayStyle = GetterUtil.getString(portletPreferences.getValue("displayStyle", null)); if (Validator.isNull(displayStyle) || displayStyle.startsWith(PortletDisplayTemplateManager.DISPLAY_STYLE_PREFIX)) { return;/* w ww . ja v a2 s . co m*/ } portletPreferences.setValue("displayStyle", PortletDisplayTemplateManager.DISPLAY_STYLE_PREFIX + "list-menu-ftl"); // Remove unsupported preferences portletPreferences.reset("bulletStyle"); portletPreferences.reset("headerType"); portletPreferences.reset("nestedChildren"); }