You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by cd...@apache.org on 2006/01/19 02:33:22 UTC
svn commit: r370340 -
/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java
Author: cdoremus
Date: Wed Jan 18 17:33:20 2006
New Revision: 370340
URL: http://svn.apache.org/viewcvs?rev=370340&view=rev
Log:
Removed preferences.clear() call in reset(), which fixes SimplePreferenceTest.checkPreferencesValuesNotModified(). There are still problems with reset() and isReadOnly().
Modified:
portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java
Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java?rev=370340&r1=370339&r2=370340&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java Wed Jan 18 17:33:20 2006
@@ -19,6 +19,7 @@
package org.apache.pluto.core.impl;
+import java.io.IOException;
import java.util.*;
import javax.portlet.PortletPreferences;
@@ -89,6 +90,8 @@
}
try {
+ //Store the preferences from portlet.xml
+ store();
PortletPreference[] prefs =
factory.getStoredPreferences(window, request);
@@ -96,8 +99,17 @@
preferences.put(prefs[i].getName(), prefs[i]);
}
}
- catch(PortletContainerException pe) {
- LOG.error("Error retrieving preferences.", pe);
+ catch(PortletContainerException e) {
+ LOG.error("Error retrieving preferences.", e);
+ //TODO: Rethrow up the stack????
+ }
+ catch (IOException e) {
+ LOG.error("Error retrieving preferences.", e);
+ //TODO: Rethrow up the stack????
+ }
+ catch (ValidatorException e) {
+ LOG.warn("ValidatorException initializing portlet preferences. " +
+ "This is not illegal at this point since we are just retreiving from portlet.xml.", e);
}
}
@@ -204,7 +216,7 @@
}
- preferences.clear();
+// preferences.clear();
for(int i=0;i<defaultPreferences.length;i++) {
if(key.equals(defaultPreferences[i].getName())) {
preferences.put(key, defaultPreferences[i]);
@@ -233,11 +245,14 @@
(PreferencesValidator) clazz.newInstance();
validator.validate(this);
} catch (InstantiationException e) {
+ LOG.error("Problem instantiating validator: " + e.toString());
throw new ValidatorException(e, null);
} catch (IllegalAccessException e) {
+ LOG.error("Problem instantiating validator: " + e.toString());
+ throw new ValidatorException(e, null);
+ } catch (ClassNotFoundException e) {
+ LOG.error("Problem instantiating validator: " + e.toString());
throw new ValidatorException(e, null);
- } catch (ClassNotFoundException t) {
- throw new ValidatorException(t, null);
}
}
@@ -254,4 +269,31 @@
}
}
+ public String toString() {
+ StringBuffer sb = new StringBuffer("PortletPreferencesImpl[");
+ Enumeration names = getNames();
+ while(names.hasMoreElements()) {
+ String name = (String)names.nextElement();
+ sb.append(name);
+ sb.append("=");
+ String[] vals = getValues(name, new String[]{"Default"});
+ if (vals != null) {
+ int len = vals.length;
+ for (int i = 0; i < len; i++) {
+ sb.append(vals[i]);
+ sb.append(",");
+ }
+ if (len == 0) {
+ sb.append(",");
+ }
+ } else {
+ sb.append("NULL,");
+ }
+ sb.append("readonly=");
+ sb.append(isReadOnly(name));
+ sb.append(";");
+ }
+ sb.append("]");
+ return sb.toString();
+ }
}