@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); }
@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); }
protected Map<String, String[]> getPortletPreferenceValues() { return getPortletPreferences().getMap(); }
/** * Returns a <code>Map</code> of the preferences. * <p> * The values in the returned <code>Map</code> are from type String array (<code>String[]</code>). * <p> * If no preferences exist this method returns an empty <code>Map</code>. * * @return an immutable <code>Map</code> containing preference names as * keys and preference values as map values, or an empty * <code>Map</code> if no preference exist. The keys in the * preference map are of type String. The values in the preference * map are of type String array (<code>String[]</code>). */ public static java.util.Map getMap() { PortletPreferences prefs = getPortletPreferences(); if (prefs == null) { throw new IllegalStateException( "Cannot retrieve PortletPreferences."); } return prefs.getMap(); }
public void setupPreferencesEdit(RenderRequest request, RenderResponse response) { Context context = getContext(request, response); PortletPreferences prefs = request.getPreferences(); Map map = prefs.getMap(); Iterator it = map.entrySet().iterator(); context.put("prefs", it); Map result = new HashMap(map.size()); Iterator f = map.entrySet().iterator(); while(f.hasNext()) { Map.Entry e = (Map.Entry)f.next(); String []why = (String[])e.getValue(); if (why == null || why[0] == null) { result.put(e.getKey(), ""); } else { result.put(e.getKey(), why[0]); } } context.put("prefsMap", result); }
/** * Returns a String hashcode of the values for the portlet preferences that are configurable by * the Dynamic Skin portlet. The hashcode is generated in a repeatable fashion by calculating it * based on sorted portlet preference names. Though hashcode does not guarantee uniqueness, from * a practical perspective we'll have so few different values we can reasonably assume * preference value combinations will be unique. * * @see DynamicSkinUniqueTokenGenerator#generateToken(DynamicSkinInstanceData) */ @Override public String generateToken(final DynamicSkinInstanceData data) { final PortletPreferences preferences = data.getPortletRequest().getPreferences(); int hash = 0; // Add the list of preference names to an ordered list so we can get reliable hashcode // calculations. final Map<String, String[]> prefs = preferences.getMap(); final TreeSet<String> orderedNames = new TreeSet<String>(prefs.keySet()); final Iterator<String> iterator = orderedNames.iterator(); while (iterator.hasNext()) { final String preferenceName = iterator.next(); if (preferenceName.startsWith(DynamicRespondrSkinConstants.CONFIGURABLE_PREFIX)) { hash = hash * 31 + preferences.getValue(preferenceName, "").trim().hashCode(); } } return Integer.toString(hash); } }
Map prefsMap = prefs.getMap();
Map prefsMap = prefs.getMap();
for (Map.Entry<String, String[]> y : prefs.getMap().entrySet()) { final String name = y.getKey();
for (Map.Entry<String, String[]> y : prefs.getMap().entrySet()) { final String name = y.getKey();
portletPreferencesValues = portletPreferences.getMap();
portletPreferencesValues = portletPreferences.getMap();
value = portletRequest.getPreferences().getMap();
value = portletRequest.getPreferences().getMap();
request.setAttribute(PREF_VALUES_ATTR_NAME, prc.getPortletRequest().getPreferences().getMap()); } catch (Exception e) { if (logger.isDebugEnabled()) {
case portletPreferencesValues: context.setPropertyResolved(true); return ((PortletRequest) extCtx.getRequest()).getPreferences().getMap(); default: return null;