@Override public ModifiableSettings setValues(String key, String[] values) { try { _portletPreferences.setValues(key, values); } catch (ReadOnlyException roe) { _log.error( "Portlet preferences used to persist settings should never " + "be read only", roe); } return this; }
protected void upgradeMultiValuePreference( PortletPreferences portletPreferences, String key) throws ReadOnlyException { String value = portletPreferences.getValue(key, StringPool.BLANK); if (Validator.isNotNull(value)) { portletPreferences.setValues(key, StringUtil.split(value)); } }
@Override protected String upgradePreferences( long companyId, long ownerId, int ownerType, long plid, String portletId, String xml) throws Exception { PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.fromXML( companyId, ownerId, ownerType, plid, portletId, xml); Map<String, String[]> preferencesMap = portletPreferences.getMap(); for (Map.Entry<String, String[]> entry : preferencesMap.entrySet()) { String oldName = entry.getKey(); String newName = TextFormatter.format(oldName, TextFormatter.M); portletPreferences.reset(oldName); portletPreferences.setValues(newName, entry.getValue()); } return PortletPreferencesFactoryUtil.toXML(portletPreferences); }
@Override protected String upgradePreferences( long companyId, long ownerId, int ownerType, long plid, String portletId, String xml) throws Exception { PortletPreferences preferences = PortletPreferencesFactoryUtil.fromXML( companyId, ownerId, ownerType, plid, portletId, xml); Map<String, String[]> preferencesMap = preferences.getMap(); Map<String, String> preferenceNamesMap = getPreferenceNamesMap(); for (Map.Entry<String, String> entry : preferenceNamesMap.entrySet()) { String name = entry.getKey(); String[] values = preferencesMap.get(name); if (values == null) { continue; } preferences.reset(name); String newName = entry.getValue(); String[] newValues = preferencesMap.get(newName); if (newValues == null) { preferences.setValues(newName, values); } } return PortletPreferencesFactoryUtil.toXML(preferences); }
public void setValues(String[] values) throws ReadOnlyException { mPreferences.setValues(mPreferenceKey, values); } }
public void setValues(String[] values) throws ReadOnlyException { portletPreferences.setValues(name, values); }
public void setValues(String[] values) throws ReadOnlyException { portletPreferences.setValues(name, values); }
portletPreferences.setValues(key, newValues);
portletPreferences.setValues(key, newValues);
protected void setScopes( ActionRequest actionRequest, PortletPreferences preferences) throws Exception { String[] scopeIds = StringUtil.split( getParameter(actionRequest, "scopeIds")); preferences.setValues("scopeIds", scopeIds); }
protected void moveSelectionDown( ActionRequest actionRequest, PortletPreferences preferences) throws Exception { int assetEntryOrder = ParamUtil.getInteger( actionRequest, "assetEntryOrder"); String[] manualEntries = preferences.getValues( "assetEntryXml", new String[0]); if ((assetEntryOrder >= (manualEntries.length - 1)) || (assetEntryOrder < 0)) { return; } String temp = manualEntries[assetEntryOrder + 1]; manualEntries[assetEntryOrder + 1] = manualEntries[assetEntryOrder]; manualEntries[assetEntryOrder] = temp; preferences.setValues("assetEntryXml", manualEntries); }
protected void removeScope( ActionRequest actionRequest, PortletPreferences preferences) throws Exception { String[] scopeIds = preferences.getValues( "scopeIds", new String[] { AssetPublisherUtil.SCOPE_ID_GROUP_PREFIX + GroupConstants.DEFAULT }); String scopeId = ParamUtil.getString(actionRequest, "scopeId"); scopeIds = ArrayUtil.remove(scopeIds, scopeId); if (scopeId.startsWith( AssetPublisherUtil.SCOPE_ID_PARENT_GROUP_PREFIX)) { scopeId = scopeId.substring("Parent".length()); scopeIds = ArrayUtil.remove(scopeIds, scopeId); } preferences.setValues("scopeIds", scopeIds); }
protected void moveSelectionUp( ActionRequest actionRequest, PortletPreferences preferences) throws Exception { int assetEntryOrder = ParamUtil.getInteger( actionRequest, "assetEntryOrder"); String[] manualEntries = preferences.getValues( "assetEntryXml", new String[0]); if ((assetEntryOrder >= manualEntries.length) || (assetEntryOrder <= 0)) { return; } String temp = manualEntries[assetEntryOrder - 1]; manualEntries[assetEntryOrder - 1] = manualEntries[assetEntryOrder]; manualEntries[assetEntryOrder] = temp; preferences.setValues("assetEntryXml", manualEntries); }
protected void removeSelection( ActionRequest actionRequest, PortletPreferences preferences) throws Exception { int assetEntryOrder = ParamUtil.getInteger( actionRequest, "assetEntryOrder"); String[] manualEntries = preferences.getValues( "assetEntryXml", new String[0]); if (assetEntryOrder >= manualEntries.length) { return; } String[] newEntries = new String[manualEntries.length - 1]; int i = 0; int j = 0; for (; i < manualEntries.length; i++) { if (i != assetEntryOrder) { newEntries[j++] = manualEntries[i]; } } preferences.setValues("assetEntryXml", newEntries); }
public static void removeAndStoreSelection( List<String> assetEntryUuids, PortletPreferences portletPreferences) throws Exception { if (assetEntryUuids.isEmpty()) { return; } String[] assetEntryXmls = portletPreferences.getValues( "assetEntryXml", new String[0]); List<String> assetEntryXmlsList = ListUtil.fromArray(assetEntryXmls); Iterator<String> itr = assetEntryXmlsList.iterator(); while (itr.hasNext()) { String assetEntryXml = itr.next(); Document document = SAXReaderUtil.read(assetEntryXml); Element rootElement = document.getRootElement(); String assetEntryUuid = rootElement.elementText("asset-entry-uuid"); if (assetEntryUuids.contains(assetEntryUuid)) { itr.remove(); } } portletPreferences.setValues( "assetEntryXml", assetEntryXmlsList.toArray(new String[assetEntryXmlsList.size()])); portletPreferences.store(); }
private void _removeAndStoreSelection( List<String> assetEntryUuids, PortletPreferences portletPreferences) throws Exception { if (assetEntryUuids.isEmpty()) { return; } String[] assetEntryXmls = portletPreferences.getValues( "assetEntryXml", new String[0]); List<String> assetEntryXmlsList = ListUtil.fromArray(assetEntryXmls); Iterator<String> itr = assetEntryXmlsList.iterator(); while (itr.hasNext()) { String assetEntryXml = itr.next(); Document document = SAXReaderUtil.read(assetEntryXml); Element rootElement = document.getRootElement(); String assetEntryUuid = rootElement.elementText("asset-entry-uuid"); if (assetEntryUuids.contains(assetEntryUuid)) { itr.remove(); } } portletPreferences.setValues( "assetEntryXml", assetEntryXmlsList.toArray(new String[assetEntryXmlsList.size()])); portletPreferences.store(); }
protected void restorePortletPreference( PortletDataContext portletDataContext, String name, PortletPreferences portletPreferences) throws Exception { Layout layout = _layoutLocalService.getLayout( portletDataContext.getPlid()); PortletPreferences originalPortletPreferences = PortletPreferencesFactoryUtil.getLayoutPortletSetup( layout, portletDataContext.getPortletId()); String[] values = originalPortletPreferences.getValues( name, new String[] {StringPool.BLANK}); portletPreferences.setValues(name, values); }
@Override protected String upgradePreferences( long companyId, long ownerId, int ownerType, long plid, String portletId, String xml) throws Exception { PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.fromXML( companyId, ownerId, ownerType, plid, portletId, xml); String[] assetEntryXmls = portletPreferences.getValues( "assetEntryXml", new String[0]); if (ArrayUtil.isNotEmpty(assetEntryXmls)) { upgradeTypes(assetEntryXmls); portletPreferences.setValues("assetEntryXml", assetEntryXmls); } return PortletPreferencesFactoryUtil.toXML(portletPreferences); }
protected void updateExportScopeIds( PortletDataContext portletDataContext, PortletPreferences portletPreferences, String key, long plid) throws Exception { String[] oldValues = portletPreferences.getValues(key, null); if (oldValues == null) { return; } Layout layout = _layoutLocalService.getLayout(plid); String[] newValues = new String[oldValues.length]; Element rootElement = portletDataContext.getExportDataRootElement(); Element groupIdMappingsElement = rootElement.addElement( "group-id-mappings"); for (int i = 0; i < oldValues.length; i++) { newValues[i] = _getExportScopeId( portletDataContext, groupIdMappingsElement, layout, oldValues[i]); } portletPreferences.setValues(key, newValues); }
protected void addScope( ActionRequest actionRequest, PortletPreferences preferences) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute( WebKeys.THEME_DISPLAY); String[] scopeIds = preferences.getValues( "scopeIds", new String[] { AssetPublisherUtil.SCOPE_ID_GROUP_PREFIX + GroupConstants.DEFAULT }); long groupId = ParamUtil.getLong(actionRequest, "groupId"); Group selectedGroup = groupLocalService.fetchGroup(groupId); String scopeId = AssetPublisherUtil.getScopeId( selectedGroup, themeDisplay.getScopeGroupId()); checkPermission(actionRequest, scopeId); if (!ArrayUtil.contains(scopeIds, scopeId)) { scopeIds = ArrayUtil.append(scopeIds, scopeId); } preferences.setValues("scopeIds", scopeIds); }