@Test(expected = ReadOnlyException.class) public void testSetReadOnlyValues() throws ReadOnlyException, ValidatorException, IOException { addPref(basePrefs, "key", true, new String[] {"default"}); portletPreferences.setValues("key", new String[] {"modified"}); }
@Override public final void setValues(String key, String[] values) throws ReadOnlyException { Assert.notNull(key, "Preference Key cannot be null"); final Map<String, IPortletPreference> targetPortletPreferences = this.getTargetPortletPreferences(); final Map<String, IPortletPreference> basePortletPreferences = this.getBasePortletPreferences(); final IPortletPreference basePreference = basePortletPreferences.get(key); if (basePreference != null) { if (this.isReadOnly(basePreference)) { throw new ReadOnlyException("Preference '" + key + "' is read only"); } if (Arrays.equals(values, basePreference.getValues())) { this.reset(key); return; } } IPortletPreference portletPreference = targetPortletPreferences.get(key); if (portletPreference == null) { portletPreference = new PortletPreferenceImpl(key, false, values != null ? values.clone() : null); targetPortletPreferences.put(key, portletPreference); final Map<String, IPortletPreference> compositePortletPreferences = this.getCompositePortletPreferences(); compositePortletPreferences.put(key, portletPreference); this.modified = true; } else if (!Arrays.equals(values, portletPreference.getValues())) { portletPreference.setValues(values != null ? values.clone() : null); this.modified = true; } }
AbstractPortletPreferencesImpl implements PortletPreferences { @Override public final void setValues(String key, String[] values) throws ReadOnlyException { Assert.notNull(key, "Preference Key cannot be null"); final Map<String, IPortletPreference> targetPortletPreferences = this.getTargetPortletPreferences(); final Map<String, IPortletPreference> basePortletPreferences = this.getBasePortletPreferences(); final IPortletPreference basePreference = basePortletPreferences.get(key); if (basePreference != null) { if (this.isReadOnly(basePreference)) { throw new ReadOnlyException("Preference '" + key + "' is read only"); } if (Arrays.equals(values, basePreference.getValues())) { this.reset(key); return; } } IPortletPreference portletPreference = targetPortletPreferences.get(key); if (portletPreference == null) { portletPreference = new PortletPreferenceImpl(key, false, values != null ? values.clone() : null); targetPortletPreferences.put(key, portletPreference); final Map<String, IPortletPreference> compositePortletPreferences = this.getCompositePortletPreferences(); compositePortletPreferences.put(key, portletPreference); this.modified = true; } else if (!Arrays.equals(values, portletPreference.getValues())) { portletPreference.setValues(values != null ? values.clone() : null); this.modified = true; } } }
AbstractPortletPreferencesImpl implements PortletPreferences { @Override public final void setValues(String key, String[] values) throws ReadOnlyException { Assert.notNull(key, "Preference Key cannot be null"); final Map<String, IPortletPreference> targetPortletPreferences = this.getTargetPortletPreferences(); final Map<String, IPortletPreference> basePortletPreferences = this.getBasePortletPreferences(); final IPortletPreference basePreference = basePortletPreferences.get(key); if (basePreference != null) { if (this.isReadOnly(basePreference)) { throw new ReadOnlyException("Preference '" + key + "' is read only"); } if (Arrays.equals(values, basePreference.getValues())) { this.reset(key); return; } } IPortletPreference portletPreference = targetPortletPreferences.get(key); if (portletPreference == null) { portletPreference = new PortletPreferenceImpl(key, false, values != null ? values.clone() : null); targetPortletPreferences.put(key, portletPreference); final Map<String, IPortletPreference> compositePortletPreferences = this.getCompositePortletPreferences(); compositePortletPreferences.put(key, portletPreference); this.modified = true; } else if (!Arrays.equals(values, portletPreference.getValues())) { portletPreference.setValues(values != null ? values.clone() : null); this.modified = true; } } AbstractPortletPreferencesImpl(boolean render); }
AbstractPortletPreferencesImpl implements PortletPreferences { @Override public final void setValues(String key, String[] values) throws ReadOnlyException { Assert.notNull(key, "Preference Key cannot be null"); final Map<String, IPortletPreference> targetPortletPreferences = this.getTargetPortletPreferences(); final Map<String, IPortletPreference> basePortletPreferences = this.getBasePortletPreferences(); final IPortletPreference basePreference = basePortletPreferences.get(key); if (basePreference != null) { if (this.isReadOnly(basePreference)) { throw new ReadOnlyException("Preference '" + key + "' is read only"); } if (Arrays.equals(values, basePreference.getValues())) { this.reset(key); return; } } IPortletPreference portletPreference = targetPortletPreferences.get(key); if (portletPreference == null) { portletPreference = new PortletPreferenceImpl(key, false, values != null ? values.clone() : null); targetPortletPreferences.put(key, portletPreference); final Map<String, IPortletPreference> compositePortletPreferences = this.getCompositePortletPreferences(); compositePortletPreferences.put(key, portletPreference); this.modified = true; } else if (!Arrays.equals(values, portletPreference.getValues())) { portletPreference.setValues(values != null ? values.clone() : null); this.modified = true; } } AbstractPortletPreferencesImpl(boolean render); @Override final boolean isReadOnly(String key); @Override final String getValue(String key, String def); @Override final String[] getValues(String key, String[] def); @Override final void setValue(String key, String value); @Override final void setValues(String key, String[] values); @Override final Enumeration<String> getNames(); @Override final Map<String, String[]> getMap(); @Override final void reset(String key); @Override final void store(); }
AbstractPortletPreferencesImpl implements PortletPreferences { @Override public final void setValues(String key, String[] values) throws ReadOnlyException { Assert.notNull(key, "Preference Key cannot be null"); final Map<String, IPortletPreference> targetPortletPreferences = this.getTargetPortletPreferences(); final Map<String, IPortletPreference> basePortletPreferences = this.getBasePortletPreferences(); final IPortletPreference basePreference = basePortletPreferences.get(key); if (basePreference != null) { if (this.isReadOnly(basePreference)) { throw new ReadOnlyException("Preference '" + key + "' is read only"); } if (Arrays.equals(values, basePreference.getValues())) { this.reset(key); return; } } IPortletPreference portletPreference = targetPortletPreferences.get(key); if (portletPreference == null) { portletPreference = new PortletPreferenceImpl(key, false, values != null ? values.clone() : null); targetPortletPreferences.put(key, portletPreference); final Map<String, IPortletPreference> compositePortletPreferences = this.getCompositePortletPreferences(); compositePortletPreferences.put(key, portletPreference); this.modified = true; } else if (!Arrays.equals(values, portletPreference.getValues())) { portletPreference.setValues(values != null ? values.clone() : null); this.modified = true; } } AbstractPortletPreferencesImpl(boolean render); @Override final boolean isReadOnly(String key); @Override final String getValue(String key, String def); @Override final String[] getValues(String key, String[] def); @Override final void setValue(String key, String value); @Override final void setValues(String key, String[] values); @Override final Enumeration<String> getNames(); @Override final Map<String, String[]> getMap(); @Override final void reset(String key); @Override final void store();  }