List of usage examples for com.liferay.portal.kernel.util UnicodeProperties load
public void load(String props) throws IOException
From source file:com.liferay.layout.admin.web.internal.exportimport.data.handler.LayoutStagedModelDataHandler.java
License:Open Source License
protected void mergePortlets(Layout layout, String newTypeSettings, String portletsMergeMode) { try {//from w ww . j a v a2s . co m UnicodeProperties previousTypeSettingsProperties = layout.getTypeSettingsProperties(); LayoutTypePortlet previousLayoutType = (LayoutTypePortlet) layout.getLayoutType(); LayoutTemplate previousLayoutTemplate = previousLayoutType.getLayoutTemplate(); List<String> previousColumns = previousLayoutTemplate.getColumns(); UnicodeProperties newTypeSettingsProperties = new UnicodeProperties(true); newTypeSettingsProperties.load(newTypeSettings); String layoutTemplateId = newTypeSettingsProperties .getProperty(LayoutTypePortletConstants.LAYOUT_TEMPLATE_ID); previousTypeSettingsProperties.setProperty(LayoutTypePortletConstants.LAYOUT_TEMPLATE_ID, layoutTemplateId); String nestedColumnIds = newTypeSettingsProperties .getProperty(LayoutTypePortletConstants.NESTED_COLUMN_IDS); if (Validator.isNotNull(nestedColumnIds)) { previousTypeSettingsProperties.setProperty(LayoutTypePortletConstants.NESTED_COLUMN_IDS, nestedColumnIds); String[] nestedColumnIdsArray = StringUtil.split(nestedColumnIds); for (String nestedColumnId : nestedColumnIdsArray) { String nestedColumnValue = newTypeSettingsProperties.getProperty(nestedColumnId); previousTypeSettingsProperties.setProperty(nestedColumnId, nestedColumnValue); } } LayoutTemplate newLayoutTemplate = _layoutTemplateLocalService.getLayoutTemplate(layoutTemplateId, false, null); String[] newPortletIds = new String[0]; for (String columnId : newLayoutTemplate.getColumns()) { String columnValue = newTypeSettingsProperties.getProperty(columnId); String[] portletIds = StringUtil.split(columnValue); if (!previousColumns.contains(columnId)) { newPortletIds = ArrayUtil.append(newPortletIds, portletIds); } else { String[] previousPortletIds = StringUtil .split(previousTypeSettingsProperties.getProperty(columnId)); portletIds = appendPortletIds(previousPortletIds, portletIds, portletsMergeMode); previousTypeSettingsProperties.setProperty(columnId, StringUtil.merge(portletIds)); } } // Add portlets in non-existent column to the first column String columnId = previousColumns.get(0); String[] portletIds = StringUtil.split(previousTypeSettingsProperties.getProperty(columnId)); appendPortletIds(portletIds, newPortletIds, portletsMergeMode); previousTypeSettingsProperties.setProperty(columnId, StringUtil.merge(portletIds)); layout.setTypeSettings(previousTypeSettingsProperties.toString()); } catch (IOException ioe) { layout.setTypeSettings(newTypeSettings); } }
From source file:com.liferay.layout.admin.web.internal.upgrade.v_1_0_0.UpgradeLayout.java
License:Open Source License
protected void updateLayout(long plid, String typeSettings) throws Exception { if (Validator.isNull(typeSettings)) { return;/*from w w w.j a v a 2 s . c om*/ } UnicodeProperties typeSettingsProperties = new UnicodeProperties(true); typeSettingsProperties.load(typeSettings); typeSettingsProperties.setProperty("embeddedLayoutURL", typeSettingsProperties.getProperty("url")); typeSettingsProperties.remove("url"); updateTypeSettings(plid, typeSettingsProperties.toString()); }