@Override protected void loadTargetPortletPreferences( IPortletEntity portletEntity, Map<String, IPortletPreference> targetPortletPreferences) { final List<IPortletPreference> entityPreferences = portletEntity.getPortletPreferences(); for (final IPortletPreference preference : entityPreferences) { targetPortletPreferences.put(preference.getName(), preference); } }
@Override protected void loadTargetPortletPreferences( IPortletDefinition portletDefinition, Map<String, IPortletPreference> targetPortletPreferences) { final List<IPortletPreference> entityPreferences = portletDefinition.getPortletPreferences(); for (final IPortletPreference preference : entityPreferences) { targetPortletPreferences.put(preference.getName(), preference); } }
@Override protected void loadTargetPortletPreferences( IPortletDefinition portletDefinition, Map<String, IPortletPreference> targetPortletPreferences) { final List<IPortletPreference> entityPreferences = portletDefinition.getPortletPreferences(); for (final IPortletPreference preference : entityPreferences) { targetPortletPreferences.put(preference.getName(), preference); } }
@Override protected void loadTargetPortletPreferences( IPortletEntity portletEntity, Map<String, IPortletPreference> targetPortletPreferences) { final List<IPortletPreference> entityPreferences = portletEntity.getPortletPreferences(); for (final IPortletPreference preference : entityPreferences) { targetPortletPreferences.put(preference.getName(), preference); } }
private void initKeywords() { List<IPortletPreference> portletPreferences = this.portletDefinition.getPortletPreferences(); for (IPortletPreference pref : portletPreferences) { if (MARKETPLACE_KEYWORDS_PREF.equalsIgnoreCase(pref.getName())) { this.keywords = new ArrayList<String>(Arrays.asList(pref.getValues())); break; } } }
private void initKeywords() { List<IPortletPreference> portletPreferences = this.portletDefinition.getPortletPreferences(); for (IPortletPreference pref : portletPreferences) { if (MARKETPLACE_KEYWORDS_PREF.equalsIgnoreCase(pref.getName())) { this.keywords = new ArrayList<String>(Arrays.asList(pref.getValues())); break; } } }
@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; } }
@Override public boolean test(final HttpServletRequest request) { try { final IPortletDefinition portletDefinition = utils.getPortletDefinitionFromServletRequest(request); Iterator<IPortletPreference> iterator = portletDefinition.getPortletPreferences().iterator(); while (iterator.hasNext()) { IPortletPreference cur = iterator.next(); if ("renderOnWeb".equalsIgnoreCase(cur.getName())) { return cur.getValues() != null && cur.getValues().length == 1 && Boolean.parseBoolean(cur.getValues()[0]); } } } catch (Exception e) { logger.error( "Failed to process renderOnWeb check for redirect during pipeline. Failing gracefully by returning false.", e); } return false; }
@Override public boolean test(final HttpServletRequest request) { try { final IPortletDefinition portletDefinition = utils.getPortletDefinitionFromServletRequest(request); Iterator<IPortletPreference> iterator = portletDefinition.getPortletPreferences().iterator(); while (iterator.hasNext()) { IPortletPreference cur = iterator.next(); if ("renderOnWeb".equalsIgnoreCase(cur.getName())) { return cur.getValues() != null && cur.getValues().length == 1 && Boolean.parseBoolean(cur.getValues()[0]); } } } catch (Exception e) { logger.error( "Failed to process renderOnWeb check for redirect during pipeline. Failing gracefully by returning false.", e); } return false; }
private void initShortURL() { List<IPortletPreference> portletPreferences = this.portletDefinition.getPortletPreferences(); for (IPortletPreference pref : portletPreferences) { if (MARKETPLACE_SHORT_LINK_PREF.equalsIgnoreCase(pref.getName()) && pref.getValues().length == 1) { setShortURL(pref.getValues()[0]); break; } } }
private void initShortURL() { List<IPortletPreference> portletPreferences = this.portletDefinition.getPortletPreferences(); for (IPortletPreference pref : portletPreferences) { if (MARKETPLACE_SHORT_LINK_PREF.equalsIgnoreCase(pref.getName()) && pref.getValues().length == 1) { setShortURL(pref.getValues()[0]); break; } } }
@Override protected void loadBasePortletPreferences( IPortletEntity portletEntity, Map<String, IPortletPreference> basePortletPreferences) { final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition(); // Add descriptor prefs to base Map final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId(); final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId); final Preferences descriptorPreferences = portletDescriptor.getPortletPreferences(); for (final Preference preference : descriptorPreferences.getPortletPreferences()) { final IPortletPreference preferenceWrapper = new PortletPreferenceImpl(preference); basePortletPreferences.put(preferenceWrapper.getName(), preferenceWrapper); } // Add definition prefs to base Map final List<IPortletPreference> definitionPreferences = portletDefinition.getPortletPreferences(); for (final IPortletPreference preference : definitionPreferences) { basePortletPreferences.put(preference.getName(), preference); } }
@Override protected void loadBasePortletPreferences( IPortletEntity portletEntity, Map<String, IPortletPreference> basePortletPreferences) { final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition(); // Add descriptor prefs to base Map final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId(); final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId); final Preferences descriptorPreferences = portletDescriptor.getPortletPreferences(); for (final Preference preference : descriptorPreferences.getPortletPreferences()) { final IPortletPreference preferenceWrapper = new PortletPreferenceImpl(preference); basePortletPreferences.put(preferenceWrapper.getName(), preferenceWrapper); } // Add definition prefs to base Map final List<IPortletPreference> definitionPreferences = portletDefinition.getPortletPreferences(); for (final IPortletPreference preference : definitionPreferences) { basePortletPreferences.put(preference.getName(), preference); } }
@Override protected void loadBasePortletPreferences( IPortletDefinition portletDefinition, Map<String, IPortletPreference> basePortletPreferences) { // Add descriptor prefs to base Map final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId(); final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId); final Preferences descriptorPreferences = portletDescriptor.getPortletPreferences(); for (final Preference preference : descriptorPreferences.getPortletPreferences()) { final IPortletPreference preferenceWrapper = new PortletPreferenceImpl(preference); basePortletPreferences.put(preferenceWrapper.getName(), preferenceWrapper); } }
@Override protected void loadBasePortletPreferences( IPortletDefinition portletDefinition, Map<String, IPortletPreference> basePortletPreferences) { // Add descriptor prefs to base Map final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId(); final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId); final Preferences descriptorPreferences = portletDescriptor.getPortletPreferences(); for (final Preference preference : descriptorPreferences.getPortletPreferences()) { final IPortletPreference preferenceWrapper = new PortletPreferenceImpl(preference); basePortletPreferences.put(preferenceWrapper.getName(), preferenceWrapper); } }
@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 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 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 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()); }