portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlest...@apache.org
Subject svn commit: r349142 - in /portals/jetspeed-2/trunk/components: portal/src/test/org/apache/jetspeed/engine/ portal/src/test/org/apache/jetspeed/userinfo/ prefs/src/java/JETSPEED-INF/ojb/ prefs/src/java/org/apache/jetspeed/prefs/impl/ prefs/src/java/org/...
Date Sat, 26 Nov 2005 21:10:24 GMT
Author: dlestrat
Date: Sat Nov 26 13:10:13 2005
New Revision: 349142

URL: http://svn.apache.org/viewcvs?rev=349142&view=rev
Log:
Removing the PropertyManager.  Please make sure to read

http://issues.apache.org/jira/browse/JS2-431

The database schema has been changed as a result of this issue.

Added:
    portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesProvider.java
Removed:
    portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PropertyManagerImpl.java
    portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/om/impl/PropertyKeyImpl.java
    portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPropertyManager.java
Modified:
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/TestSpringEngine.java
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java
    portals/jetspeed-2/trunk/components/prefs/src/java/JETSPEED-INF/ojb/prefs_repository.xml
    portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java
    portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesFactoryImpl.java
    portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesImpl.java
    portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/om/impl/NodeImpl.java
    portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/om/impl/PropertyImpl.java
    portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/util/test/AbstractPrefsSupportedTestCase.java
    portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferences.java
    portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesNoPropManager.java

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/TestSpringEngine.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/TestSpringEngine.java?rev=349142&r1=349141&r2=349142&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/TestSpringEngine.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/TestSpringEngine.java Sat Nov 26 13:10:13 2005
@@ -20,7 +20,6 @@
 import org.apache.jetspeed.container.window.PortletWindowAccessor;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.prefs.PreferencesProvider;
-import org.apache.jetspeed.prefs.PropertyManager;
 import org.apache.jetspeed.profiler.Profiler;
 import org.apache.jetspeed.request.RequestContextComponent;
 import org.apache.jetspeed.security.GroupManager;
@@ -50,7 +49,7 @@
     {        
         keysToCheck = new Object[] {"IdGenerator", "DecorationLocator", "TemplateLocator", "IdGenerator", "PageFileCache", PageManager.class, 
                                      PortletRegistry.class, PortletEntityAccessComponent.class, "PortalServices",
-                                     Profiler.class, Capabilities.class, PropertyManager.class, PreferencesProvider.class, UserManager.class,
+                                     Profiler.class, Capabilities.class, PreferencesProvider.class, UserManager.class,
                                      GroupManager.class, RoleManager.class, PermissionManager.class, RdbmsPolicy.class, SecurityProvider.class,
                                      UserInfoManager.class, RequestContextComponent.class, PortletWindowAccessor.class,
                                      PortletRenderer.class, PageAggregator.class, PortletAggregator.class, "PAM",

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java?rev=349142&r1=349141&r2=349142&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java Sat Nov 26 13:10:13 2005
@@ -17,7 +17,6 @@
 import java.io.FileReader;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.prefs.Preferences;
@@ -30,8 +29,6 @@
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.mockobjects.request.MockRequestContext;
 import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
-import org.apache.jetspeed.prefs.PropertyException;
-import org.apache.jetspeed.prefs.om.Property;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.SecurityHelper;
@@ -196,32 +193,8 @@
             assertTrue("user exists. should not have thrown an exception.", false);
         }
         Preferences userInfoPrefs = user.getPreferences().node("userinfo");
-        Map propertyKeys = initPropertyKeysMap();
-        try
-        {
-            propertyManager.addPropertyKeys(userInfoPrefs, propertyKeys);
-        }
-        catch (PropertyException pex)
-        {
-            assertTrue("should have add propertyKeys. should not have thrown an exception.", false);
-        }
         userInfoPrefs.put("user.name.given", "Test Dude");
         userInfoPrefs.put("user.name.family", "Dudley");
-    }
-
-    /**
-     * <p>
-     * Init property property keys map.
-     * </p>
-     */
-    protected Map initPropertyKeysMap()
-    {
-        // Build a few property keys.
-        Map propertyKeys = new HashMap();
-        propertyKeys.put("user.name.given", new Integer(Property.STRING_TYPE));
-        propertyKeys.put("user.name.family", new Integer(Property.STRING_TYPE));
-
-        return propertyKeys;
     }
 
     /**

Modified: portals/jetspeed-2/trunk/components/prefs/src/java/JETSPEED-INF/ojb/prefs_repository.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/prefs/src/java/JETSPEED-INF/ojb/prefs_repository.xml?rev=349142&r1=349141&r2=349142&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/prefs/src/java/JETSPEED-INF/ojb/prefs_repository.xml (original)
+++ portals/jetspeed-2/trunk/components/prefs/src/java/JETSPEED-INF/ojb/prefs_repository.xml Sat Nov 26 13:10:13 2005
@@ -77,18 +77,6 @@
 	    >
 	    </field-descriptor>
 	    <collection-descriptor
-	        name="nodeKeys"
-	        element-class-ref="org.apache.jetspeed.prefs.om.impl.PropertyKeyImpl"
-	        auto-retrieve="true"
-	        auto-delete="false"
-	        auto-update="true"
-	        indirection-table="PREFS_NODE_PROPERTY_KEY"
-	    >
-	        <documentation>This is the reference to the property keys allowed for that node.</documentation>
-	        <fk-pointing-to-this-class column="NODE_ID"/>
-	        <fk-pointing-to-element-class column="PROPERTY_KEY_ID"/>
-	    </collection-descriptor>
-	    <collection-descriptor
 	        name="nodeProperties"
 	        element-class-ref="org.apache.jetspeed.prefs.om.impl.PropertyImpl"
 	        auto-retrieve="true"
@@ -102,54 +90,6 @@
 	</class-descriptor>
 	
 	<!--
-	   - P R O P E R T Y  K E Y
-	-->	
-	
-	<class-descriptor
-	    class="org.apache.jetspeed.prefs.om.impl.PropertyKeyImpl"
-	    table="PREFS_PROPERTY_KEY"
-	>
-	    <documentation>Represents a property key.</documentation>
-	    <field-descriptor
-	        name="propertyKeyId"
-	        column="PROPERTY_KEY_ID"
-	        jdbc-type="BIGINT"
-	        primarykey="true"
-	        autoincrement="true"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="propertyKeyName"
-	        column="PROPERTY_NAME"
-	        jdbc-type="VARCHAR"
-	        nullable="false"
-	        length="100"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="propertyKeyType"
-	        column="PROPERTY_TYPE"
-	        jdbc-type="SMALLINT"
-	        nullable="false"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="creationDate"
-	        column="CREATION_DATE"
-	        jdbc-type="TIMESTAMP"
-	        nullable="false"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="modifiedDate"
-	        column="MODIFIED_DATE"
-	        jdbc-type="TIMESTAMP"
-	        nullable="false"
-	    >
-	    </field-descriptor>
-	</class-descriptor>
-	
-	<!--
 	   - P R O P E R T Y
 	-->	
 	
@@ -173,45 +113,17 @@
 	        nullable="false"
 	    >
 	    </field-descriptor>
-	    <field-descriptor
-	        name="propertyKeyId"
-	        column="PROPERTY_KEY_ID"
-	        jdbc-type="BIGINT"
+        <field-descriptor
+	        name="propertyName"
+	        column="PROPERTY_NAME"
+	        jdbc-type="VARCHAR"
 	        nullable="false"
+	        length="100"
 	    >
 	    </field-descriptor>
 	    <field-descriptor
-	        name="booleanPropertyValue"
-	        column="BOOLEAN_VALUE"
-	        jdbc-type="INTEGER"
-	        conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
-	        nullable="true"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="datePropertyValue"
-	        column="DATETIME_VALUE"
-	        jdbc-type="TIMESTAMP"
-	        nullable="true"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="longPropertyValue"
-	        column="LONG_VALUE"
-	        jdbc-type="BIGINT"
-	        nullable="true"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="doublePropertyValue"
-	        column="DOUBLE_VALUE"
-	        jdbc-type="DOUBLE"
-	        nullable="true"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="textPropertyValue"
-	        column="TEXT_VALUE"
+	        name="propertyValue"
+	        column="PROPERTY_VALUE"
 	        jdbc-type="VARCHAR"
 	        nullable="true"
 	        length="254"
@@ -231,17 +143,6 @@
 	        nullable="false"
 	    >
 	    </field-descriptor>
-	    <reference-descriptor
-	        name="propertyKey"
-	        class-ref="org.apache.jetspeed.prefs.om.impl.PropertyKeyImpl"
-	        refresh="true"
-	        auto-retrieve="true"
-	        auto-delete="false"
-	        auto-update="true"
-	    >
-	        <documentation>This is the reference to a property key.</documentation>
-	        <foreignkey field-ref="propertyKeyId"/>
-	    </reference-descriptor>
 	</class-descriptor>
 	
 </descriptor-repository>

Modified: portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java?rev=349142&r1=349141&r2=349142&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java (original)
+++ portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java Sat Nov 26 13:10:13 2005
@@ -20,7 +20,6 @@
 import java.util.HashMap;
 
 import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport;
-import org.apache.jetspeed.page.document.NodeNotFoundException;
 import org.apache.jetspeed.prefs.FailedToCreateNodeException;
 import org.apache.jetspeed.prefs.NodeAlreadyExistsException;
 import org.apache.jetspeed.prefs.NodeDoesNotExistException;
@@ -45,6 +44,9 @@
 
     private static class NodeCache implements Serializable
     {
+        /** The serial uid. */
+        private static final long serialVersionUID = 1853381807991868844L;
+
         Node node;
 
         String fullpath;
@@ -126,8 +128,6 @@
 
     private HashMap nodeMap = new HashMap();
 
-    private boolean enablePropertyManager;
-
     /**
      * @param repository
      *            Location of repository mapping file. Must be available within the classpath.
@@ -139,33 +139,14 @@
      *             if the <code>prefsFactoryImpl</code> argument does not reperesent a Class that exists in the
      *             current classPath.
      */
-    public PersistenceBrokerPreferencesProvider(String repositoryPath, boolean enablePropertyManager)
+    public PersistenceBrokerPreferencesProvider(String repositoryPath)
             throws ClassNotFoundException
     {
         super(repositoryPath);
-        this.enablePropertyManager = enablePropertyManager;
-    }
-    
-    /**
-     * @param enablePropertyManager Whether to enable the <code>PropertyManager</code>.
-     */
-    public void setEnablePropertyManager(boolean enablePropertyManager)
-    {
-        this.enablePropertyManager = enablePropertyManager;
     }
 
     /**
-     * <p>
-     * Get the node id from the full path.
-     * </p>
-     * 
-     * @param fullPath
-     *            The full path.
-     * @param nodeType
-     *            The node type.
-     * @return An array of value returned including:
-     * @throws NodeNotFoundException
-     *             if the node does not exist
+     * @see org.apache.jetspeed.prefs.PreferencesProvider#getNode(java.lang.String, int)
      */
     public Node getNode(String fullPath, int nodeType) throws NodeDoesNotExistException
     {
@@ -195,13 +176,7 @@
     }
 
     /**
-     * <p>
-     * nodeExists
-     * </p>
-     * 
-     * @param fullPath
-     * @param nodeType
-     * @return
+     * @see org.apache.jetspeed.prefs.PreferencesProvider#nodeExists(java.lang.String, int)
      */
     public boolean nodeExists(String fullPath, int nodeType)
     {
@@ -217,21 +192,7 @@
     }
 
     /**
-     * <p>
-     * Create a new preference node in the backing store.
-     * </p>
-     * 
-     * @param parent
-     *            The parent node.
-     * @param nodeName
-     *            The node name.
-     * @param nodeType
-     *            The node type.
-     * @param fullPath
-     *            The node full path.
-     * @return the newly created node
-     * @throws NodeAlreadyExistsException
-     *             if a node of the same type having the same path already exists.
+     * @see org.apache.jetspeed.prefs.PreferencesProvider#createNode(org.apache.jetspeed.prefs.om.Node, java.lang.String, int, java.lang.String)
      */
     public Node createNode(Node parent, String nodeName, int nodeType, String fullPath)
             throws FailedToCreateNodeException, NodeAlreadyExistsException
@@ -265,15 +226,9 @@
 
         }
     }
-
+  
     /**
-     * <p>
-     * getChildren
-     * </p>
-     * 
      * @see org.apache.jetspeed.prefs.PreferencesProvider#getChildren(org.apache.jetspeed.prefs.om.Node)
-     * @param parentNode
-     * @return
      */
     public Collection getChildren(Node parentNode)
     {
@@ -300,6 +255,9 @@
         return children;
     }
 
+    /**
+     * @see org.apache.jetspeed.prefs.PreferencesProvider#storeNode(org.apache.jetspeed.prefs.om.Node)
+     */
     public void storeNode(Node node)
     {
         NodeCache key = new NodeCache(node);
@@ -307,6 +265,9 @@
         getPersistenceBrokerTemplate().store(node);
     }
 
+    /**
+     * @see org.apache.jetspeed.prefs.PreferencesProvider#removeNode(org.apache.jetspeed.prefs.om.Node, org.apache.jetspeed.prefs.om.Node)
+     */
     public void removeNode(Node parentNode, Node node)
     {
         NodeCache key = new NodeCache(node);
@@ -322,41 +283,27 @@
         }
         getPersistenceBrokerTemplate().delete(node);        
     }
-
+    
     /**
-     * <p>
-     * isPropertyManagerEnabled
-     * </p>
-     * 
-     * @see org.apache.jetspeed.prefs.PreferencesProvider#isPropertyManagerEnabled()
-     * @return
+     * @see org.apache.jetspeed.prefs.PreferencesProvider#lookupPreference(java.lang.String, java.lang.String, java.lang.String)
      */
-    public boolean isPropertyManagerEnabled()
-    {
-        return this.enablePropertyManager;
-    }
-    
     public Collection lookupPreference(String nodeName, String propertyName, String propertyValue)
     {
-// if the OJB fails, try this
-//        String LOOKUP_BY_EMAIL = 
-//            "SELECT p.full_path, k.property_name, v.text_value " +
-//            "FROM `prefs_node` p, prefs_property_key k, prefs_property_value v " +
-//            "WHERE p.NODE_NAME = 'userinfo' and v.node_id = p.node_id " + 
-//            "AND v.property_key_id = k.property_key_id " +
-//            "AND k.property_name = ? " +
-//            "AND v.text_value = ?"    
-
         Criteria c = new Criteria();
         if (nodeName != null)
+        {
             c.addEqualTo("nodeName", nodeName);
+        }
         if (propertyName != null)
-            c.addEqualTo("nodeKeys.propertyKeyName", propertyName);
+        {
+            c.addEqualTo("nodeProperties.propertyName", propertyName);
+        }
         if (propertyValue != null)
-            c.addEqualTo("nodeProperties.textPropertyValue", propertyValue);
+        {
+            c.addEqualTo("nodeProperties.propertyValue", propertyValue);
+        }
         Query query = QueryFactory.newQuery(NodeImpl.class, c);
         Collection children = getPersistenceBrokerTemplate().getCollectionByQuery(query);
-        return children;
-        
+        return children;       
     }
 }

Modified: portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesFactoryImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesFactoryImpl.java?rev=349142&r1=349141&r2=349142&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesFactoryImpl.java (original)
+++ portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesFactoryImpl.java Sat Nov 26 13:10:13 2005
@@ -29,16 +29,13 @@
 public class PreferencesFactoryImpl implements PreferencesFactory
 {
     
-    
     protected static PreferencesProvider prefsProvider;
 
     public PreferencesFactoryImpl()
     {
         super();        
         System.setProperty("java.util.prefs.PreferencesFactory", getClass().getName());
-    }
-    
-     
+    }  
 
     /**
      * @see java.util.prefs.PreferencesFactory#systemRoot()
@@ -56,6 +53,13 @@
         return  PreferencesImpl.userRoot;
     }
     
+    /**
+     * <p>
+     * Initializes the factory.
+     * </p>
+     * 
+     * @throws Exception
+     */
     public void init() throws Exception
     {        
         try
@@ -71,14 +75,22 @@
         }
     }
     
-    
-
+    /**
+     * @return The {@link PreferencesProvider}
+     */
     public PreferencesProvider getPrefsProvider()
     {
         return prefsProvider;
     }
     
-    public void setPrefsProvider( PreferencesProvider prefsProvider )
+    /**
+     * <p>
+     * Set the preferences provider.
+     * </p>
+     * 
+     * @param prefsProvider The {@link PreferencesProvider}
+     */
+    public void setPrefsProvider(PreferencesProvider prefsProvider)
     {
         PreferencesFactoryImpl.prefsProvider = prefsProvider;
     }

Modified: portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesImpl.java?rev=349142&r1=349141&r2=349142&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesImpl.java (original)
+++ portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesImpl.java Sat Nov 26 13:10:13 2005
@@ -28,17 +28,14 @@
 import org.apache.jetspeed.prefs.NodeAlreadyExistsException;
 import org.apache.jetspeed.prefs.NodeDoesNotExistException;
 import org.apache.jetspeed.prefs.PreferencesProvider;
-import org.apache.jetspeed.prefs.PropertyException;
 import org.apache.jetspeed.prefs.om.Node;
 import org.apache.jetspeed.prefs.om.Property;
-import org.apache.jetspeed.prefs.om.PropertyKey;
 import org.apache.jetspeed.prefs.om.impl.PropertyImpl;
-import org.apache.jetspeed.prefs.om.impl.PropertyKeyImpl;
 
 /**
- * <p>S
- * {@link Preferences}implementation relying on Jetspeed OJB based persistence
- * plugin.
+ * <p>
+ * S {@link Preferences}implementation relying on Jetspeed OJB based
+ * persistence plugin.
  * </p>
  * 
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
@@ -58,12 +55,11 @@
     /** Logger. */
     private static final Log log = LogFactory.getLog(PreferencesImpl.class);
 
-
     protected static PreferencesProvider prefsProvider;
 
     static PreferencesImpl systemRoot;
+
     static PreferencesImpl userRoot;
-   
 
     /**
      * <p>
@@ -74,17 +70,14 @@
      * Logs a warning if the underlying datastore is unavailable.
      * </p>
      * 
-     * @param parent
-     *            The parent object.
-     * @param nodeName
-     *            The node name.
-     * @param nodeType
-     *            The node type.
+     * @param parent The parent object.
+     * @param nodeName The node name.
+     * @param nodeType The node type.
      */
-    public PreferencesImpl( PreferencesImpl parent, String nodeName, int nodeType ) throws IllegalStateException
+    public PreferencesImpl(PreferencesImpl parent, String nodeName, int nodeType) throws IllegalStateException
     {
         super(parent, nodeName);
-        
+
         try
         {
             if (parent != null)
@@ -115,11 +108,15 @@
             catch (NodeDoesNotExistException e1)
             {
                 // If we get this at this point something is very wrong
-                IllegalStateException ise = new IllegalStateException("Unable to create node for Preferences of type "+nodeType+" for path "+this.absolutePath() +
-                               ".  If you see this exception at this, it more than likely means that the Preferences backing store is corrupt.");
+                IllegalStateException ise = new IllegalStateException(
+                        "Unable to create node for Preferences of type "
+                                + nodeType
+                                + " for path "
+                                + this.absolutePath()
+                                + ".  If you see this exception at this, it more than likely means that the Preferences backing store is corrupt.");
                 ise.initCause(e1);
                 throw ise;
-            }            
+            }
         }
 
     }
@@ -152,7 +149,7 @@
     /**
      * @see java.util.prefs.Preferences#childSpi(java.lang.String)
      */
-    public AbstractPreferences childSpi( String name )
+    public AbstractPreferences childSpi(String name)
     {
         return new PreferencesImpl(this, name, node.getNodeType());
     }
@@ -168,22 +165,20 @@
     /**
      * @see java.util.prefs.Preferences#getSpi(java.lang.String)
      */
-    public String getSpi( String key )
+    public String getSpi(String key)
     {
-
+        String value = null;
         Collection properties = node.getNodeProperties();
 
         for (Iterator i = properties.iterator(); i.hasNext();)
         {
             Property curProp = (Property) i.next();
-            if (curProp.getPropertyKey().getPropertyKeyName().equals(key))
+            if ((null != curProp) && (null != curProp.getPropertyName()) && (curProp.getPropertyName().equals(key)))
             {
-                return curProp.getPropertyValue(curProp.getPropertyKey().getPropertyKeyType());
+                value = curProp.getPropertyValue();
             }
         }
-
-        //prop not found
-        return null;
+        return value;
     }
 
     /**
@@ -199,9 +194,13 @@
             for (Iterator j = propCol.iterator(); j.hasNext();)
             {
                 Property curprop = (Property) j.next();
-                propertyNames.add(curprop.getPropertyKey().getPropertyKeyName());
+                if ((null != curprop) && (null != curprop.getPropertyName())
+                        && !propertyNames.contains(curprop.getPropertyName()))
+                {
+                    propertyNames.add(curprop.getPropertyName());
+                }
             }
-        }    
+        }
 
         return (String[]) propertyNames.toArray(new String[propertyNames.size()]);
     }
@@ -209,17 +208,9 @@
     /**
      * @see java.util.prefs.Preferences#putSpi(java.lang.String,
      *      java.lang.String)
-     *      <p>
-     *      In addition to java.util.prefs.Preferences, this implementation is
-     *      enforcing that node used as property sets have been defined as such
-     *      and that only the keys defined associated to the property set can be
-     *      added as properties of the current node.
-     *      </p>
      */
-    public void putSpi( String key, String value )
+    public void putSpi(String key, String value)
     {
-      
-        Collection nodeKeys = node.getNodeKeys();
         Collection properties = node.getNodeProperties();
         if (null == properties)
         {
@@ -227,72 +218,42 @@
             return;
         }
 
-        boolean foundProp = false;
-        boolean foundKey = false;
-        // First if the property exists, update its value.
+        // If the property exists, update its value.
+        boolean propFound = false;
         for (Iterator i = properties.iterator(); i.hasNext();)
         {
             Property curProp = (Property) i.next();
-            if (curProp.getPropertyKey().getPropertyKeyName().equals(key))
+            if ((null != curProp) && (null != curProp.getPropertyName()) && curProp.getPropertyName().equals(key))
             {
-                foundProp = true;
-                foundKey = true;
-                if (log.isDebugEnabled())
-                    log.debug("Update existing property: [" + key + ", " + value + "]");
-
-                curProp.setPropertyValue(curProp.getPropertyKey().getPropertyKeyType(), value);
+                propFound = true;
+                curProp.setPropertyValue(value);
                 curProp.setModifiedDate(new Timestamp(System.currentTimeMillis()));
-            }
-
-        }
-        // The property does not already exist. Create a new property, if
-        // the property key exits and is associated to this node.
-        if (prefsProvider.isPropertyManagerEnabled() && !foundProp)
-        {
-            for (Iterator i = nodeKeys.iterator(); i.hasNext();)
-            {
-                PropertyKey curpk = (PropertyKey) i.next();
-                if (curpk.getPropertyKeyName().equals(key))
+                if (log.isDebugEnabled())
                 {
-                    foundKey = true;
-                    if (log.isDebugEnabled())
-                        log.debug("New property value: [" + key + ", " + value + "]");
-
-                    properties.add(new PropertyImpl(node.getNodeId(), curpk.getPropertyKeyId(), curpk, curpk
-                            .getPropertyKeyType(), value));
+                    log.debug("Update existing property: " + curProp.toString());
                 }
+                // Property found, we break.
+                break;
             }
         }
-        else if (!prefsProvider.isPropertyManagerEnabled() && !foundProp)
+        if (!propFound)
         {
-            foundKey = true;
-            PropertyKey pKey = new PropertyKeyImpl(key, Property.STRING_TYPE);
-            properties.add(new PropertyImpl(node.getNodeId(), pKey.getPropertyKeyId(), pKey, pKey
-                    .getPropertyKeyType(), value));
-
+            properties.add(new PropertyImpl(node.getNodeId(), key, value));
         }
 
-        if (!foundKey)
-        {
-            if (log.isWarnEnabled())
-                log.warn(PropertyException.PROPERTYKEY_NOT_FOUND);
-            return;
-        }
-       
         prefsProvider.storeNode(node);
-
     }
 
     /**
      * @see java.util.prefs.Preferences#removeNodeSpi()
      */
     public void removeNodeSpi() throws BackingStoreException
-    {      
+    {
         Node parentNode = null;
         Preferences parent = parent();
-        if ( parent != null && parent instanceof PreferencesImpl )
+        if (parent != null && parent instanceof PreferencesImpl)
         {
-            parentNode = ((PreferencesImpl)parent).getNode();
+            parentNode = ((PreferencesImpl) parent).getNode();
         }
         prefsProvider.removeNode(parentNode, node);
     }
@@ -300,7 +261,7 @@
     /**
      * @see java.util.prefs.Preferences#removeSpi(java.lang.String)
      */
-    public void removeSpi( String key )
+    public void removeSpi(String key)
     {
         Collection properties = node.getNodeProperties();
 
@@ -308,12 +269,11 @@
         {
             Property curProp = (Property) i.next();
 
-            if ((curProp.getPropertyKey().getPropertyKeyName().equals(key)))
+            if ((curProp.getPropertyName().equals(key)))
             {
                 i.remove();
             }
         }
-        
         // Update node.
         prefsProvider.storeNode(node);
     }
@@ -338,14 +298,16 @@
     {
         return node;
     }
-    
+
     /**
      * 
      * <p>
      * setPreferencesProvider
      * </p>
-     * Sets the <code>org.apache.jetspeed.prefs.PreferencesProvider</code> that
-     * will support backing store operations for all <code>PreferencesImpls</code>
+     * Sets the <code>org.apache.jetspeed.prefs.PreferencesProvider</code>
+     * that will support backing store operations for all
+     * <code>PreferencesImpls</code>
+     * 
      * @param prefsProvider
      */
     public static void setPreferencesProvider(PreferencesProvider prefsProvider)

Modified: portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/om/impl/NodeImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/om/impl/NodeImpl.java?rev=349142&r1=349141&r2=349142&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/om/impl/NodeImpl.java (original)
+++ portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/om/impl/NodeImpl.java Sat Nov 26 13:10:13 2005
@@ -32,13 +32,23 @@
  */
 public class NodeImpl implements Node
 {
+    /** The serial version uid. */
+    private static final long serialVersionUID = -5367800007757021163L;
+
     private long nodeId;
+
     private Long parentNodeId;
+
     private Collection nodeProperties;
+
     private Collection nodeKeys;
+
     private String nodeName;
+
     private int nodeType;
+
     private String fullPath;
+
     private Timestamp creationDate;
 
     /**
@@ -63,16 +73,12 @@
      * <li>Full path.</li>
      * </ul>
      * 
-     * @param parentNodeId
-     *            The parent node id.
-     * @param nodeName
-     *            The node name.
-     * @param nodeType
-     *            The node type.
-     * @param fullPath
-     *            The full path.
+     * @param parentNodeId The parent node id.
+     * @param nodeName The node name.
+     * @param nodeType The node type.
+     * @param fullPath The full path.
      */
-    public NodeImpl( Long parentNodeId, String nodeName, int nodeType, String fullPath )
+    public NodeImpl(Long parentNodeId, String nodeName, int nodeType, String fullPath)
     {
         this.parentNodeId = parentNodeId;
         this.nodeName = nodeName;
@@ -95,7 +101,7 @@
     /**
      * @see org.apache.jetspeed.prefs.om.Node#setNodeId(int)
      */
-    public void setNodeId( long nodeId )
+    public void setNodeId(long nodeId)
     {
         this.nodeId = nodeId;
     }
@@ -111,7 +117,7 @@
     /**
      * @see org.apache.jetspeed.prefs.om.Node#setParentNodeId(java.lang.Long)
      */
-    public void setParentNodeId( Long parentNodeId )
+    public void setParentNodeId(Long parentNodeId)
     {
         this.parentNodeId = parentNodeId;
     }
@@ -127,7 +133,7 @@
     /**
      * @see org.apache.jetspeed.prefs.om.Node#setNodeProperties(java.util.Collection)
      */
-    public void setNodeProperties( Collection nodeProperties )
+    public void setNodeProperties(Collection nodeProperties)
     {
         this.nodeProperties = nodeProperties;
     }
@@ -143,7 +149,7 @@
     /**
      * @see org.apache.jetspeed.prefs.om.Node#setNodeKeys(java.util.Collection)
      */
-    public void setNodeKeys( Collection nodeKeys )
+    public void setNodeKeys(Collection nodeKeys)
     {
         this.nodeKeys = nodeKeys;
     }
@@ -159,7 +165,7 @@
     /**
      * @see org.apache.jetspeed.prefs.om.Node#setNodeName(java.lang.String)
      */
-    public void setNodeName( String nodeName )
+    public void setNodeName(String nodeName)
     {
         this.nodeName = nodeName;
     }
@@ -175,7 +181,7 @@
     /**
      * @see org.apache.jetspeed.prefs.om.Node#setNodeType(int)
      */
-    public void setNodeType( int nodeType )
+    public void setNodeType(int nodeType)
     {
         this.nodeType = nodeType;
     }
@@ -191,7 +197,7 @@
     /**
      * @see org.apache.jetspeed.prefs.om.Node#setFullPath(java.lang.String)
      */
-    public void setFullPath( String fullPath )
+    public void setFullPath(String fullPath)
     {
         this.fullPath = fullPath;
     }
@@ -207,7 +213,7 @@
     /**
      * @see org.apache.jetspeed.prefs.om.Node#setCreationDate(java.sql.Timestamp)
      */
-    public void setCreationDate( Timestamp creationDate )
+    public void setCreationDate(Timestamp creationDate)
     {
         this.creationDate = creationDate;
     }
@@ -225,15 +231,15 @@
     /**
      * @see org.apache.jetspeed.prefs.om.Node#setModifiedDate(java.sql.Timestamp)
      */
-    public void setModifiedDate( Timestamp modifiedDate )
+    public void setModifiedDate(Timestamp modifiedDate)
     {
         this.modifiedDate = modifiedDate;
     }
-    
+
     public boolean equals(Object o)
     {
         return fullPath != null && o != null && o instanceof NodeImpl && ((NodeImpl) o).fullPath != null
-                        && fullPath.equals(((NodeImpl) o).fullPath);
+                && fullPath.equals(((NodeImpl) o).fullPath);
     }
 
     /**
@@ -245,14 +251,10 @@
      */
     public String toString()
     {
-        String toStringNode = "[[parentNodeId, " + this.parentNodeId + "], "
-            + "[nodeName, " + this.nodeName + "], "
-            + "[fullPath, " + this.fullPath + "], "
-            + "[nodeType, " + this.nodeType + "], "
-            + "[nodeKeys, " + this.nodeKeys + "], "
-            + "[nodeProperties, " + this.nodeProperties + "], "
-            + "[creationDate, " + this.creationDate + "], "
-            + "[modifiedDate, " + this.modifiedDate + "]]";
+        String toStringNode = "[[parentNodeId, " + this.parentNodeId + "], " + "[nodeName, " + this.nodeName + "], "
+                + "[fullPath, " + this.fullPath + "], " + "[nodeType, " + this.nodeType + "], " + "[nodeKeys, "
+                + this.nodeKeys + "], " + "[nodeProperties, " + this.nodeProperties + "], " + "[creationDate, "
+                + this.creationDate + "], " + "[modifiedDate, " + this.modifiedDate + "]]";
         return toStringNode;
     }
 

Modified: portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/om/impl/PropertyImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/om/impl/PropertyImpl.java?rev=349142&r1=349141&r2=349142&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/om/impl/PropertyImpl.java (original)
+++ portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/om/impl/PropertyImpl.java Sat Nov 26 13:10:13 2005
@@ -17,112 +17,71 @@
 import java.sql.Timestamp;
 
 import org.apache.jetspeed.prefs.om.Property;
-import org.apache.jetspeed.prefs.om.PropertyKey;
 
 /**
- * <p>{@link Property} interface implementation.</p>
- * <p>Represents a property key/value pair.</p>
- *
+ * <p>
+ * {@link Property} interface implementation.
+ * </p>
+ * <p>
+ * Represents a property key/value pair.
+ * </p>
+ * 
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
  */
 public class PropertyImpl implements Property
 {
+    /** The serial version uid. */
+    private static final long serialVersionUID = 7037975617489867366L;
+
     private long nodeId;
+
+    private String propertyName;
+
+    private String propertyValue;
+
     private long propertyValueId;
-    private long propertyKeyId;
-    
+
     /**
-     * <p>Property implementation default constructor.</p>
+     * <p>
+     * Property implementation default constructor.
+     * </p>
      */
     public PropertyImpl()
     {
     }
 
     /**
-     * Property constructor given a property key id, node id
-     * and the appropriate value object type and value:
-     *
-     * <ul>
-     *     <li>0=Boolean,</li>
-     *     <li>1=Long,</li>
-     *     <li>2=Double,</li>
-     *     <li>3=String,</li>
-     *     <li>4=Timestamp</li>
-     * </ul>
-     * @param propertyKeyId The property key id.
+     * Property constructor given a property key id, node id and the appropriate
+     * value.
+     * 
      * @param nodeId The node id.
-     * @param valueObjectType The value object type.
+     * @param propertyName The property name.
      * @param valueObject The value object.
      */
-    public PropertyImpl(long nodeId, long propertyKeyId, PropertyKey propertyKey, int valueObjectType, Object valueObject)
+    public PropertyImpl(long nodeId, String propertyName, Object valueObject)
     {
         this.nodeId = nodeId;
-        this.propertyKeyId = propertyKeyId;
-        this.propertyKey = propertyKey;
+        this.propertyName = propertyName;
         this.creationDate = new Timestamp(System.currentTimeMillis());
         this.modifiedDate = this.creationDate;
 
-        setPropertyValue(valueObjectType, (String) valueObject);
+        setPropertyValue((String) valueObject);
     }
 
     /**
-     * @see org.apache.jetspeed.prefs.om.Property#getPropertyValue(int)
+     * @see org.apache.jetspeed.prefs.om.Property#getPropertyValue()
      */
-    public final String getPropertyValue(int valueObjectType)
+    public final String getPropertyValue()
     {
-        String stringValue = null;
-
-        if (BOOLEAN_TYPE == valueObjectType)
-        {
-            stringValue = (Boolean.valueOf(this.booleanPropertyValue)).toString();
-        }
-        else if (LONG_TYPE == valueObjectType)
-        {
-            stringValue = Long.toString(this.longPropertyValue);
-        }
-        else if (DOUBLE_TYPE == valueObjectType)
-        {
-            stringValue = Double.toString(this.doublePropertyValue);
-        }
-        else if (STRING_TYPE == valueObjectType)
-        {
-            stringValue = this.textPropertyValue;
-        }
-        else if (TIMESTAMP_TYPE == valueObjectType)
-        {
-            stringValue = this.datePropertyValue.toString();
-        }
-        return stringValue;
+        return propertyValue;
     }
 
     /**
-     * @see org.apache.jetspeed.prefs.om.Property#setPropertyValue(int, java.lang.String)
-     */
-    public final void setPropertyValue(int valueObjectType, String valueObject)
-    {
-        if (null != valueObject)
-        {
-            if (BOOLEAN_TYPE == valueObjectType)
-            {
-                this.booleanPropertyValue = (Boolean.valueOf(valueObject)).booleanValue();
-            }
-            else if (LONG_TYPE == valueObjectType)
-            {
-                this.longPropertyValue = (Long.valueOf(valueObject)).longValue();
-            }
-            else if (DOUBLE_TYPE == valueObjectType)
-            {
-                this.doublePropertyValue = (Double.valueOf(valueObject)).doubleValue();
-            }
-            else if (STRING_TYPE == valueObjectType)
-            {
-                this.textPropertyValue = (String) valueObject;
-            }
-            else if (TIMESTAMP_TYPE == valueObjectType)
-            {
-                this.datePropertyValue = Timestamp.valueOf(valueObject);
-            }
-        }
+     * @see org.apache.jetspeed.prefs.om.Property#setPropertyValue(java.lang.String)
+     */
+    public final void setPropertyValue(String valueObject)
+    {
+        this.propertyValue = valueObject;
     }
 
     /**
@@ -158,127 +117,19 @@
     }
 
     /**
-     * @see org.apache.jetspeed.prefs.om.Property#getPropertyKeyId()
-     */
-    public long getPropertyKeyId()
-    {
-        return this.propertyKeyId;
-    }
-
-    /**
-     * @see org.apache.jetspeed.prefs.om.Property#setPropertyKeyId(long)
-     */
-    public void setPropertyKeyId(long propertyKeyId)
-    {
-        this.propertyKeyId = propertyKeyId;
-    }
-
-    private PropertyKey propertyKey;
-
-    /**
-     * @see org.apache.jetspeed.prefs.om.Property#getPropertyKey()
-     */
-    public PropertyKey getPropertyKey()
-    {
-        return this.propertyKey;
-    }
-
-    /**
-     * @see org.apache.jetspeed.prefs.om.Property#setPropertyKey(org.apache.jetspeed.prefs.om.PropertyKey)
-     */
-    public void setPropertyKey(PropertyKey propertyKey)
-    {
-        this.propertyKey = propertyKey;
-    }
-
-    private boolean booleanPropertyValue;
-
-    /**
-     * @see org.apache.jetspeed.prefs.om.Property#getBooleanPropertyValue()
-     */
-    public boolean getBooleanPropertyValue()
-    {
-        return this.booleanPropertyValue;
-    }
-
-    /**
-     * @see org.apache.jetspeed.prefs.om.Property#setBooleanPropertyValue(boolean)
-     */
-    public void setBooleanPropertyValue(boolean booleanPropertyValue)
-    {
-        this.booleanPropertyValue = booleanPropertyValue;
-    }
-
-    private Timestamp datePropertyValue;
-
-    /**
-     * @see org.apache.jetspeed.prefs.om.Property#getDatePropertyValue()
-     */
-    public Timestamp getDatePropertyValue()
-    {
-        return this.datePropertyValue;
-    }
-
-    /**
-     * @see org.apache.jetspeed.prefs.om.Property#setDatePropertyValue(java.sql.Timestamp)
-     */
-    public void setDatePropertyValue(Timestamp datePropertyValue)
-    {
-        this.datePropertyValue = datePropertyValue;
-    }
-
-    private long longPropertyValue;
-
-    /**
-     * @see org.apache.jetspeed.prefs.om.Property#getLongPropertyValue()
-     */
-    public long getLongPropertyValue()
-    {
-        return this.longPropertyValue;
-    }
-
-    /**
-     * @see org.apache.jetspeed.prefs.om.Property#setLongPropertyValue(long)
-     */
-    public void setLongPropertyValue(long longPropertyValue)
-    {
-        this.longPropertyValue = longPropertyValue;
-    }
-
-    private double doublePropertyValue;
-
-    /**
-     * @see org.apache.jetspeed.prefs.om.Property#getDoublePropertyValue()
-     */
-    public double getDoublePropertyValue()
-    {
-        return this.doublePropertyValue;
-    }
-
-    /**
-     * @see org.apache.jetspeed.prefs.om.Property#setDoublePropertyValue(double)
-     */
-    public void setDoublePropertyValue(double doublePropertyValue)
-    {
-        this.doublePropertyValue = doublePropertyValue;
-    }
-
-    private String textPropertyValue;
-
-    /**
-     * @see org.apache.jetspeed.prefs.om.Property#getTextPropertyValue()
+     * @return Returns the propertyName.
      */
-    public String getTextPropertyValue()
+    public String getPropertyName()
     {
-        return this.textPropertyValue;
+        return propertyName;
     }
 
     /**
-     * @see org.apache.jetspeed.prefs.om.Property#setTextPropertyValue(java.lang.String)
+     * @param propertyName The propertyName to set.
      */
-    public void setTextPropertyValue(String textPropertyValue)
+    public void setPropertyName(String propertyName)
     {
-        this.textPropertyValue = textPropertyValue;
+        this.propertyName = propertyName;
     }
 
     private Timestamp creationDate;
@@ -318,17 +169,16 @@
     }
 
     /**
-     * <p>Convert <code>Property</code> to string.</p>
+     * <p>
+     * Convert <code>Property</code> to string.
+     * </p>
+     * 
      * @return The Property string value.
      */
     public String toString()
     {
-        String toStringProperty = "[[nodeId, " + this.nodeId + "], "
-            + "[propertyKeyId, " + this.propertyKeyId + "], "
-            + "[propertyKey, " + this.propertyKey + "], "
-            + "[propertyValue, " + getPropertyValue(propertyKey.getPropertyKeyType()) + "], "
-            + "[creationDate, " + this.creationDate + "], "
-            + "[modifiedDate, " + this.modifiedDate + "]]";
+        String toStringProperty = "[[nodeId, " + this.nodeId + "], " + "[propertyValue, " + getPropertyValue() + "], "
+                + "[creationDate, " + this.creationDate + "], " + "[modifiedDate, " + this.modifiedDate + "]]";
         return toStringProperty;
     }
 

Modified: portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/util/test/AbstractPrefsSupportedTestCase.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/util/test/AbstractPrefsSupportedTestCase.java?rev=349142&r1=349141&r2=349142&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/util/test/AbstractPrefsSupportedTestCase.java (original)
+++ portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/util/test/AbstractPrefsSupportedTestCase.java Sat Nov 26 13:10:13 2005
@@ -17,7 +17,6 @@
 
 import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
 import org.apache.jetspeed.prefs.PreferencesProvider;
-import org.apache.jetspeed.prefs.PropertyManager;
 
 /**
  * <p>
@@ -29,8 +28,6 @@
  */
 public class AbstractPrefsSupportedTestCase extends DatasourceEnabledSpringTestCase
 {
-    protected PropertyManager propertyManager;
-
     protected PreferencesProvider prefsProvider;
 
     protected String[] getConfigurations()
@@ -49,6 +46,5 @@
     {
         super.setUp();
         prefsProvider = (PreferencesProvider) ctx.getBean("prefsProvider");
-        propertyManager = (PropertyManager) ctx.getBean("propertyManager");
     }
 }

Modified: portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferences.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferences.java?rev=349142&r1=349141&r2=349142&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferences.java (original)
+++ portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferences.java Sat Nov 26 13:10:13 2005
@@ -14,9 +14,6 @@
  */
 package org.apache.jetspeed.prefs;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
 import java.util.prefs.BackingStoreException;
 import java.util.prefs.Preferences;
 
@@ -24,9 +21,6 @@
 import junit.framework.TestSuite;
 
 import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
-import org.apache.jetspeed.prefs.impl.PersistenceBrokerPreferencesProvider;
-import org.apache.jetspeed.prefs.om.Node;
-import org.apache.jetspeed.prefs.om.Property;
 
 /**
  * <p>
@@ -38,38 +32,16 @@
 public class TestPreferences extends DatasourceEnabledSpringTestCase
 {
 
-    /** The property manager. */
-    private static PropertyManager pms;
-
-    /**
-     * <p>
-     * Defines property set types.
-     * </p>
-     */
-    private final static int USER_PROPERTY_SET_TYPE = 0;
-
-    private final static int SYSTEM_PROPERTY_SET_TYPE = 1;
-
-    private PreferencesProvider provider;
-
-    private PreferencesProvider providerNoProp;
-
     /**
      * @see junit.framework.TestCase#setUp()
      */
     public void setUp() throws Exception
     {
         super.setUp();
-        provider = (PreferencesProvider) ctx.getBean("prefsProvider");
-        pms = (PropertyManager) ctx.getBean("propertyManager");
-        PersistenceBrokerPreferencesProvider prefsPersistenceBroker = (PersistenceBrokerPreferencesProvider) ctx
-                .getBean("prefsPersistenceBroker");
-        prefsPersistenceBroker.setEnablePropertyManager(true);
-
+        
         // Make sure we are starting with a clean slate
         clearChildren(Preferences.userRoot());
         clearChildren(Preferences.systemRoot());
-
     }
 
     /**
@@ -77,59 +49,16 @@
      */
     public void tearDown() throws Exception
     {
-        clean();
-        // super.tearDown();
     }
 
+    /**
+     * @return The test suite.
+     */
     public static Test suite()
     {
         // All methods starting with "test" will be executed in the test suite.
         return new TestSuite(TestPreferences.class);
     }
-
-    public void testLookupProperty()
-    throws Exception
-    {
-        PersistenceBrokerPreferencesProvider broker = 
-            (PersistenceBrokerPreferencesProvider) ctx.getBean("prefsPersistenceBroker");
-        
-        Preferences info = Preferences.userRoot().node("/user/dynamite/userinfo");
-        Map keys = new HashMap();
-        keys.put("user.name.family", new Integer(Property.STRING_TYPE));
-        keys.put("user.name.given", new Integer(Property.STRING_TYPE));
-        keys.put("user.email", new Integer(Property.STRING_TYPE));
-        pms.addPropertyKeys(info, keys);
-
-        info.put("user.name.family", "Dynamite");
-        info.put("user.name.given", "Napolean");
-        info.put("user.email", "napolean@dynamite.xxx");
-        info.flush();
-        
-        Iterator result = broker.lookupPreference("userinfo", "user.email", "napolean@dynamite.xxx").iterator();
-        int count = 0;
-        while (result.hasNext())
-        {
-            Node node = (Node)result.next();
-            System.out.println("node = " + node.getFullPath());
-            Iterator props = node.getNodeProperties().iterator();
-            while (props.hasNext())
-            {
-                Property prop = (Property)props.next();
-                String name = prop.getPropertyKey().getPropertyKeyName();
-                String value = prop.getTextPropertyValue();
-                if ("user.name.family".equals(name))
-                    assertTrue("family name wrong " + value, "Dynamite".equals(value));
-                else if ("user.name.given".equals(name))
-                    assertTrue("given name wrong " + value, "Napolean".equals(value));
-                else if ("user.email".equals(name))
-                    assertTrue("email is wrong " + value, "napolean@dynamite.xxx".equals(value));
-                else
-                    assertTrue("bad property name " + name, false);                
-            }
-            count++;
-        }
-        assertTrue("test-1: count is one " + count, count == 1);                
-    }
     
     /**
      * <p>
@@ -240,10 +169,10 @@
      */
     public void testPropertyAndPropertyKeys() throws Exception
     {
-
-        // 1. Current node does not have any property associated to it.
-        // No property has been defined nor added to the node. There should be
-        // no property and adding a child should return null.
+        // 1. Current node does not have any property associated to it. We are adding
+        // a property at the user root level.
+        // No property has been defined nor added to the node. This should return
+        // the property value
         Preferences pref0 = Preferences.userRoot();
         try
         {
@@ -261,10 +190,9 @@
 
         pref0.put("propertyName0", "true");
         String prop = pref0.get("propertyName0", null);
-        assertNull("should be null.", prop);
+        assertTrue("should be prop == true.", prop.equals("true"));
 
         // 2. Current node has properties associated to it.
-        initPropertyKeys();
         Preferences pref1 = Preferences.userRoot().node("/user/principal1/propertyset1");
         pref1.put("propertyName0", "true");
         String prop1 = pref1.get("propertyName0", null);
@@ -284,7 +212,7 @@
         // Test remove property.
         pref1.remove("propertyName0");
         prop1 = pref1.get("propertyName0", null);
-        assertNull("should be null.", prop);
+        assertNull("should be null.", prop1);
 
         // Remove all nodes with properties assigned to property sets.
         pref1.put("propertyName0", "true");
@@ -333,68 +261,12 @@
 
     /**
      * <p>
-     * Init property property keys map.
-     * </p>
-     */
-    protected Map initPropertyKeysMap()
-    {
-        // Build a few property keys.
-        Map propertyKeys = new HashMap();
-        propertyKeys.put("propertyName0", new Integer("0"));
-        propertyKeys.put("propertyName1", new Integer("1"));
-        propertyKeys.put("propertyName2", new Integer("2"));
-        propertyKeys.put("propertyName3", new Integer("3"));
-
-        return propertyKeys;
-    }
-
-    /**
-     * <p>
-     * Init property property keys.
-     * </p>
-     */
-    protected void initPropertyKeys() throws Exception
-    {
-        Map propertyKeys = initPropertyKeysMap();
-        Preferences pref = Preferences.userRoot().node("/user/principal1/propertyset1");
-
-        try
-        {
-            pms.addPropertyKeys(pref, propertyKeys);
-        }
-        catch (PropertyException pex)
-        {
-        }
-    }
-
-    /**
-     * <p>
-     * Clean properties.
+     * Clear all the children.
      * </p>
+     * 
+     * @param node
+     * @throws Exception
      */
-    protected void clean() throws Exception
-    {
-        Preferences pref = Preferences.userRoot().node("/user/principal1/propertyset1");
-        try
-        {
-            Map propertyKeys = pms.getPropertyKeys(pref);
-            pms.removePropertyKeys(pref, propertyKeys.keySet());
-            Preferences.userRoot().node("/user").removeNode();
-            Preferences.userRoot().node("/an1").removeNode();
-            Preferences.userRoot().node("/rn1").removeNode();
-            Preferences.userRoot().node("/testOpenNode").removeNode();
-            Preferences.userRoot().node("/removeTest").removeNode();
-        }
-        catch (PropertyException pex)
-        {
-            System.out.println("PropertyException" + pex);
-        }
-        catch (BackingStoreException bse)
-        {
-            System.out.println("BackingStoreException" + bse);
-        }
-    }
-
     protected void clearChildren(Preferences node) throws Exception
     {
         String[] names = node.childrenNames();
@@ -402,8 +274,17 @@
         {
             node.node(names[i]).removeNode();
         }
+        // Remove the properties of the current node.
+        String[] keys = node.keys();
+        for (int j = 0; j < keys.length; j++)
+        {
+            node.remove(keys[j]);
+        }
     }
 
+    /**
+     * @see org.apache.jetspeed.components.test.AbstractSpringTestCase#getConfigurations()
+     */
     protected String[] getConfigurations()
     {
         return new String[]

Modified: portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesNoPropManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesNoPropManager.java?rev=349142&r1=349141&r2=349142&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesNoPropManager.java (original)
+++ portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesNoPropManager.java Sat Nov 26 13:10:13 2005
@@ -6,8 +6,6 @@
  */
 package org.apache.jetspeed.prefs;
 
-import java.util.Map;
-import java.util.prefs.BackingStoreException;
 import java.util.prefs.Preferences;
 
 import org.apache.jetspeed.prefs.util.test.AbstractPrefsSupportedTestCase;
@@ -41,8 +39,6 @@
      */
     public void tearDown() throws Exception
     {
-        clean();
-        // super.tearDown();
     }
 
     protected void clearChildren(Preferences node) throws Exception
@@ -56,32 +52,12 @@
 
     /**
      * <p>
-     * Clean properties.
+     * Legacy test from the times where we add a property manager. The property manager is
+     * since gone, but the test still tests the prefs implementation.
      * </p>
+     * 
+     * @throws Exception
      */
-    protected void clean() throws Exception
-    {
-        Preferences pref = Preferences.userRoot().node("/user/principal1/propertyset1");
-        try
-        {
-            Map propertyKeys = propertyManager.getPropertyKeys(pref);
-            propertyManager.removePropertyKeys(pref, propertyKeys.keySet());
-            Preferences.userRoot().node("/user").removeNode();
-            Preferences.userRoot().node("/an1").removeNode();
-            Preferences.userRoot().node("/rn1").removeNode();
-            Preferences.userRoot().node("/testOpenNode").removeNode();
-            Preferences.userRoot().node("/removeTest").removeNode();
-        }
-        catch (PropertyException pex)
-        {
-            System.out.println("PropertyException" + pex);
-        }
-        catch (BackingStoreException bse)
-        {
-            System.out.println("BackingStoreException" + bse);
-        }
-    }
-
     public void testSansPropertyManager() throws Exception
     {
 
@@ -98,6 +74,9 @@
 
     }
 
+    /**
+     * @see org.apache.jetspeed.components.test.AbstractSpringTestCase#getConfigurations()
+     */
     protected String[] getConfigurations()
     {
         return new String[]

Added: portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesProvider.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesProvider.java?rev=349142&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesProvider.java (added)
+++ portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesProvider.java Sat Nov 26 13:10:13 2005
@@ -0,0 +1,133 @@
+/* Copyright 2004 Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.prefs;
+
+import java.util.Iterator;
+import java.util.prefs.Preferences;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
+import org.apache.jetspeed.prefs.om.Node;
+import org.apache.jetspeed.prefs.om.Property;
+
+/**
+ * <p>
+ * Unit testing for {@link Preferences}.
+ * </p>
+ * 
+ * @author <a href="dlestrat@yahoo.com">David Le Strat </a>
+ */
+public class TestPreferencesProvider extends DatasourceEnabledSpringTestCase
+{
+    private PreferencesProvider provider;
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        provider = (PreferencesProvider) ctx.getBean("prefsProvider");
+
+        // Make sure we are starting with a clean slate
+        clearChildren(Preferences.userRoot());
+        clearChildren(Preferences.systemRoot());
+    }
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+    }
+
+    /**
+     * @return The test suite.
+     */
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(TestPreferencesProvider.class);
+    }
+
+    public void testLookupProperty() throws Exception
+    {
+        Preferences info = Preferences.userRoot().node("/user/dynamite/userinfo");
+        info.put("user.name.family", "Dynamite");
+        info.put("user.name.given", "Napolean");
+        info.put("user.email", "napolean@dynamite.xxx");
+        info.flush();
+
+        Iterator result = provider.lookupPreference("userinfo", "user.email", "napolean@dynamite.xxx").iterator();
+        int count = 0;
+        while (result.hasNext())
+        {
+            Node node = (Node) result.next();
+            System.out.println("node = " + node.getFullPath());
+            Iterator props = node.getNodeProperties().iterator();
+            while (props.hasNext())
+            {
+                Property prop = (Property) props.next();
+                String name = prop.getPropertyName();
+                String value = prop.getPropertyValue();
+                if ("user.name.family".equals(name))
+                {
+                    assertTrue("family name wrong " + value, "Dynamite".equals(value));
+                }
+                else if ("user.name.given".equals(name))
+                {
+                    assertTrue("given name wrong " + value, "Napolean".equals(value));
+                }
+                else if ("user.email".equals(name))
+                {
+                    assertTrue("email is wrong " + value, "napolean@dynamite.xxx".equals(value));
+                }       
+                else
+                {
+                    assertTrue("bad property name " + name, false);
+                }
+            }
+            count++;
+        }
+        assertTrue("test-1: count is one " + count, count == 1);
+    }
+
+    /**
+     * <p>
+     * Clears all test data.
+     * </p>
+     * 
+     * @param node
+     * @throws Exception
+     */
+    protected void clearChildren(Preferences node) throws Exception
+    {
+        String[] names = node.childrenNames();
+        for (int i = 0; i < names.length; i++)
+        {
+            node.node(names[i]).removeNode();
+        }
+    }
+
+    /**
+     * @see org.apache.jetspeed.components.test.AbstractSpringTestCase#getConfigurations()
+     */
+    protected String[] getConfigurations()
+    {
+        return new String[] { "prefs.xml", "transaction.xml" };
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message