protected boolean isReadOnly(IPortletPreference portletPreference) { return portletPreference != null && portletPreference.isReadOnly(); }
protected boolean isReadOnly(IPortletPreference portletPreference) { return portletPreference != null && portletPreference.isReadOnly(); }
@Override public final boolean isReadOnly(String key) { final IPortletPreference portletPreference = this.getPortletPreference(key); return portletPreference != null && portletPreference.isReadOnly(); }
@Override public final boolean isReadOnly(String key) { final IPortletPreference portletPreference = this.getPortletPreference(key); return portletPreference != null && portletPreference.isReadOnly(); }
existingPreference.setReadOnly(preference.isReadOnly()); this.portletPreferences.add(existingPreference);
@Override public IPortletPreference apply(IPortletPreference newPreference) { if (newPreference == null) { return null; } final String name = newPreference.getName(); for (final IPortletPreference oldPreference : portletPreferences) { if (name.equals(oldPreference.getName())) { // Don't add the new preference, just replace the existing one when a match is // found oldPreference.setValues(newPreference.getValues()); oldPreference.setReadOnly(newPreference.isReadOnly()); return null; } } return newPreference; } }
@Test public void testNullSetValueValues() throws ReadOnlyException, ValidatorException, IOException { portletPreferences.setValues("key", null); portletPreferences.store(); assertEquals(1, this.storedPrefs.size()); final IPortletPreference pref = this.storedPrefs.get("key"); assertNotNull(pref); assertEquals("key", pref.getName()); assertNull(pref.getValues()); assertFalse(pref.isReadOnly()); }
@Test public void testNullEntryInValues() throws ReadOnlyException, ValidatorException, IOException { portletPreferences.setValues("key", new String[] {null}); portletPreferences.store(); assertEquals(1, this.storedPrefs.size()); final IPortletPreference pref = this.storedPrefs.get("key"); assertNotNull(pref); assertEquals("key", pref.getName()); assertArrayEquals(new String[] {null}, pref.getValues()); assertFalse(pref.isReadOnly()); }
@Test public void testNullSetValueValue() throws ReadOnlyException, ValidatorException, IOException { portletPreferences.setValue("key", null); portletPreferences.store(); assertEquals(1, this.storedPrefs.size()); final IPortletPreference pref = this.storedPrefs.get("key"); assertNotNull(pref); assertEquals("key", pref.getName()); assertArrayEquals(new String[] {null}, pref.getValues()); assertFalse(pref.isReadOnly()); }
@Test public void testSetUpdateExisting() throws ReadOnlyException, ValidatorException, IOException { addPref(basePrefs, "key", false, new String[] {"default"}); // Set a modified value portletPreferences.setValues("key", new String[] {"modified"}); // Initial store, check that correct stored map is created portletPreferences.store(); // Actually "store" the stored prefs this.targetPrefs = new LinkedHashMap<String, IPortletPreference>(this.storedPrefs); assertEquals(1, this.storedPrefs.size()); IPortletPreference pref = this.storedPrefs.get("key"); assertNotNull(pref); assertEquals("key", pref.getName()); assertArrayEquals(new String[] {"modified"}, pref.getValues()); assertFalse(pref.isReadOnly()); // Set a modified value portletPreferences.setValues("key", null); // Initial store, check that correct stored map is created portletPreferences.store(); // Actually "store" the stored prefs this.targetPrefs = new LinkedHashMap<String, IPortletPreference>(this.storedPrefs); assertEquals(1, this.storedPrefs.size()); pref = this.storedPrefs.get("key"); assertNotNull(pref); assertEquals("key", pref.getName()); assertArrayEquals(null, pref.getValues()); assertFalse(pref.isReadOnly()); }
@Test public void testSetMatchesBase() throws ReadOnlyException, ValidatorException, IOException { addPref(basePrefs, "key", false, new String[] {"default"}); // Set a modified value portletPreferences.setValues("key", new String[] {"modified"}); // Initial store, check that correct stored map is created portletPreferences.store(); // Actually "store" the stored prefs this.targetPrefs = new LinkedHashMap<String, IPortletPreference>(this.storedPrefs); assertEquals(1, this.storedPrefs.size()); IPortletPreference pref = this.storedPrefs.get("key"); assertNotNull(pref); assertEquals("key", pref.getName()); assertArrayEquals(new String[] {"modified"}, pref.getValues()); assertFalse(pref.isReadOnly()); // Set the default value portletPreferences.setValues("key", new String[] {"default"}); // Store again, should have nothing stored after this portletPreferences.store(); assertEquals(0, this.storedPrefs.size()); }
assertEquals("key", pref.getName()); assertArrayEquals(new String[] {"modified"}, pref.getValues()); assertFalse(pref.isReadOnly());
this.portletPreferences.put(pref.getName(), new StringListAttribute(pref.getValues())); this.portletPreferenceReadOnly.put( pref.getName(), new BooleanAttribute(pref.isReadOnly()));
new ExternalPortletPreference(); externalPortletPreference.setName(pref.getName()); externalPortletPreference.setReadOnly(pref.isReadOnly());