You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2008/06/04 18:23:26 UTC

svn commit: r663293 - in /portals/jetspeed-2/portal: branches/JETSPEED-2.1.2-POSTRELEASE/components/registry/src/java/org/apache/jetspeed/components/portletentity/ branches/JETSPEED-2.1.2-POSTRELEASE/components/registry/src/test/org/apache/jetspeed/com...

Author: taylor
Date: Wed Jun  4 09:23:25 2008
New Revision: 663293

URL: http://svn.apache.org/viewvc?rev=663293&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-849
NullPointerException in org.apache.jetspeed.prefs.impl.NodeImplProxy.getFullPath(NodeImplProxy.java:45)

Modified:
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java?rev=663293&r1=663292&r2=663293&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java Wed Jun  4 09:23:25 2008
@@ -69,7 +69,6 @@
     protected static RequestContextComponent rcc;
     
     protected Map perPrincipalPrefs = new HashMap();
-    protected Map originalValues;
     private PortletApplicationEntity applicationEntity = null;
     private PortletWindowList portletWindows = new PortletWindowListImpl();
     private PortletDefinitionComposite portletDefinition = null;  
@@ -140,7 +139,6 @@
                 {
                     mergePreferencesSet(preferenceSet);
                 }
-                backupValues(preferenceSet);
                 dirty = true;
             }
         }
@@ -179,29 +177,6 @@
         }        
     }
 
-    /**
-     * <p>
-     * backupValues
-     * </p>
-     * 
-     *  
-     */
-    protected void backupValues( PreferenceSet preferenceSet )
-    {
-        originalValues = new HashMap();
-        Iterator itr = preferenceSet.iterator();
-        while (itr.hasNext())
-        {
-            PrefsPreference pref = (PrefsPreference) itr.next();
-
-            String[] currentValues = pref.getValueArray();
-            String[] backUp = new String[currentValues.length];
-            System.arraycopy(currentValues, 0, backUp, 0, currentValues.length);
-            originalValues.put(pref.getName(), backUp);
-
-        }
-    }
-
     public PortletDefinition getPortletDefinition()
     {
         // there are cases when jetspeed gets initialized before
@@ -277,64 +252,12 @@
         PreferenceSet preferenceSet = (PreferenceSet)perPrincipalPrefs.get(principal);
         pac.storePreferenceSet(preferenceSet, this);
         dirty = false;
-        if (preferenceSet != null)
-        {
-            backupValues(preferenceSet);
-        }
     }
 
-    /**
-     * 
-     * <p>
-     * reset
-     * </p>
-     *  
-     */
-
     public void reset() throws IOException
     {
-        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) perPrincipalPrefs.get(getPrincipal());
-        try
-        {
-            if (originalValues != null && preferenceSet != null)
-            {
-                Iterator prefs = preferenceSet.iterator();
-
-                while (prefs.hasNext())
-                {
-                    PrefsPreference pref = (PrefsPreference) prefs.next();
-                    if (originalValues.containsKey(pref.getName()))
-                    {
-                        pref.setValues((String[]) originalValues.get(pref.getName()));
-                    }
-                    else
-                    {
-                        preferenceSet.remove(pref);
-                    }
-                    preferenceSet.flush();
-                }
-
-                Iterator keys = originalValues.keySet().iterator();
-                while (keys.hasNext())
-                {
-                    String key = (String) keys.next();
-                    if (preferenceSet.get(key) == null)
-                    {
-                        preferenceSet.add(key, Arrays.asList((String[]) originalValues.get(key)));
-                    }
-                }
-            }
-            dirty = false;
-            backupValues(preferenceSet);
-        }
-        catch (BackingStoreException e)
-        {
-            String msg = "Preference backing store failed: " + e.toString();
-            IOException ioe = new IOException(msg);
-            ioe.initCause(e);
-            throw ioe;
-        }
-
+        dirty = true;
+        getPreferenceSet(getPrincipal());        
     }
 
     // internal methods used for debugging purposes only

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java?rev=663293&r1=663292&r2=663293&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java Wed Jun  4 09:23:25 2008
@@ -138,20 +138,6 @@
 
         assertEquals("2", pref.getValueAt(0));
 
-        entity.reset();
-
-        pref = (PreferenceComposite) prefs.get("pref1");
-
-        assertEquals("1", pref.getValueAt(0));
-
-        prefs.remove(pref);
-
-        assertNull(prefs.get("pref1"));
-
-        entity.reset();
-
-        assertNotNull(prefs.get("pref1"));
-
         prefs.add("pref2", Arrays.asList(new String[]
         { "2", "3" }));
 
@@ -181,22 +167,11 @@
         }
         assertEquals(3, count);
 
-        entity.reset();
-
-        prefsValues = pref2.getValues();
-        count = 0;
-        while (prefsValues.hasNext())
-        {
-            assertEquals(String.valueOf(count + 2), prefsValues.next());
-            count++;
-        }
-        assertEquals(2, count);
-
         // testing preferences null values assignments fix, issue JS2-607
         pref2.setValueAt(0, null);        
         assertNull("pref2.value[0] should be null", pref2.getValueAt(0));        
         String[] values = pref2.getValueArray();
-        assertEquals(2, values.length);
+        assertEquals(3, values.length);
         assertNull("pref2.value[0] should be null", values[0]);
         assertEquals("3", values[1]);
         pref2.setValues(new String[]{"2",null,"3"});
@@ -210,13 +185,9 @@
         pref2.setValues((String[])null);
         assertFalse(pref2.isValueSet());
         assertTrue(pref2.getValueArray().length == 0);
-        entity.reset();
-        assertTrue(pref2.getValueArray().length == 2);
         pref2.setValues(new String[]{});
         assertFalse(pref2.isValueSet());
         assertTrue(pref2.getValueArray().length == 0);
-        entity.reset();
-        assertTrue(pref2.getValueArray().length == 2);
 
         MutablePortletEntity entity2 = entityAccess.getPortletEntityForFragment(f1);
         assertTrue("entity id ", entity2.getId().toString().equals(TEST_ENTITY));

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java?rev=663293&r1=663292&r2=663293&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java Wed Jun  4 09:23:25 2008
@@ -79,7 +79,6 @@
     
     protected PrefsPreferenceSetImpl pagePreferenceSet;
     protected Map perPrincipalPrefs = new HashMap();
-    protected Map originalValues;
     private PortletApplicationEntity applicationEntity = null;
     private PortletWindowList portletWindows = new PortletWindowListImpl();
     private PortletDefinitionComposite portletDefinition = null;  
@@ -157,7 +156,6 @@
                 {
                     mergePreferencesSet(preferenceSet);
                 }
-                backupValues(preferenceSet);
                 dirty = true;
             }
         }
@@ -197,8 +195,6 @@
                         preferenceSet.add(preference.getName(), preferenceValues);
                     }
                 }
-                
-                backupValues(preferenceSet);
                 dirty = true;
             }
         }
@@ -237,29 +233,6 @@
         }        
     }
 
-    /**
-     * <p>
-     * backupValues
-     * </p>
-     * 
-     *  
-     */
-    protected void backupValues( PreferenceSet preferenceSet )
-    {
-        originalValues = new HashMap();
-        Iterator itr = preferenceSet.iterator();
-        while (itr.hasNext())
-        {
-            PrefsPreference pref = (PrefsPreference) itr.next();
-
-            String[] currentValues = pref.getValueArray();
-            String[] backUp = new String[currentValues.length];
-            System.arraycopy(currentValues, 0, backUp, 0, currentValues.length);
-            originalValues.put(pref.getName(), backUp);
-
-        }
-    }
-
     public PortletDefinition getPortletDefinition()
     {
         // there are cases when jetspeed gets initialized before
@@ -343,10 +316,6 @@
         PreferenceSet preferenceSet = (PreferenceSet)perPrincipalPrefs.get(principal);
         pac.storePreferenceSet(preferenceSet, this);
         dirty = false;
-        if (preferenceSet != null)
-        {
-            backupValues(preferenceSet);
-        }
     }
     
     private void storeToPage() throws IOException
@@ -388,10 +357,6 @@
         }
         
         dirty = false;
-        if (preferenceSet != null)
-        {
-            backupValues(preferenceSet);
-        }
     }
 
     /**
@@ -404,48 +369,8 @@
 
     public void reset() throws IOException
     {
-        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) perPrincipalPrefs.get(getPrincipal());
-        try
-        {
-            if (originalValues != null && preferenceSet != null)
-            {
-                Iterator prefs = preferenceSet.iterator();
-
-                while (prefs.hasNext())
-                {
-                    PrefsPreference pref = (PrefsPreference) prefs.next();
-                    if (originalValues.containsKey(pref.getName()))
-                    {
-                        pref.setValues((String[]) originalValues.get(pref.getName()));
-                    }
-                    else
-                    {
-                        preferenceSet.remove(pref);
-                    }
-                    preferenceSet.flush();
-                }
-
-                Iterator keys = originalValues.keySet().iterator();
-                while (keys.hasNext())
-                {
-                    String key = (String) keys.next();
-                    if (preferenceSet.get(key) == null)
-                    {
-                        preferenceSet.add(key, Arrays.asList((String[]) originalValues.get(key)));
-                    }
-                }
-            }
-            dirty = false;
-            backupValues(preferenceSet);
-        }
-        catch (BackingStoreException e)
-        {
-            String msg = "Preference backing store failed: " + e.toString();
-            IOException ioe = new IOException(msg);
-            ioe.initCause(e);
-            throw ioe;
-        }
-
+        dirty = true;
+        getPreferenceSet(getPrincipal());        
     }
 
     // internal methods used for debugging purposes only

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java?rev=663293&r1=663292&r2=663293&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java Wed Jun  4 09:23:25 2008
@@ -138,20 +138,6 @@
 
         assertEquals("2", pref.getValueAt(0));
 
-        entity.reset();
-
-        pref = (PreferenceComposite) prefs.get("pref1");
-
-        assertEquals("1", pref.getValueAt(0));
-
-        prefs.remove(pref);
-
-        assertNull(prefs.get("pref1"));
-
-        entity.reset();
-
-        assertNotNull(prefs.get("pref1"));
-
         prefs.add("pref2", Arrays.asList(new String[]
         { "2", "3" }));
 
@@ -181,22 +167,11 @@
         }
         assertEquals(3, count);
 
-        entity.reset();
-
-        prefsValues = pref2.getValues();
-        count = 0;
-        while (prefsValues.hasNext())
-        {
-            assertEquals(String.valueOf(count + 2), prefsValues.next());
-            count++;
-        }
-        assertEquals(2, count);
-
         // testing preferences null values assignments fix, issue JS2-607
         pref2.setValueAt(0, null);        
         assertNull("pref2.value[0] should be null", pref2.getValueAt(0));        
         String[] values = pref2.getValueArray();
-        assertEquals(2, values.length);
+        assertEquals(3, values.length);
         assertNull("pref2.value[0] should be null", values[0]);
         assertEquals("3", values[1]);
         pref2.setValues(new String[]{"2",null,"3"});
@@ -210,13 +185,9 @@
         pref2.setValues((String[])null);
         assertFalse(pref2.isValueSet());
         assertTrue(pref2.getValueArray().length == 0);
-        entity.reset();
-        assertTrue(pref2.getValueArray().length == 2);
         pref2.setValues(new String[]{});
         assertFalse(pref2.isValueSet());
         assertTrue(pref2.getValueArray().length == 0);
-        entity.reset();
-        assertTrue(pref2.getValueArray().length == 2);
 
         MutablePortletEntity entity2 = entityAccess.getPortletEntityForFragment(f1);
         assertTrue("entity id ", entity2.getId().toString().equals(TEST_ENTITY));

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java?rev=663293&r1=663292&r2=663293&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java Wed Jun  4 09:23:25 2008
@@ -79,7 +79,6 @@
     
     protected PrefsPreferenceSetImpl pagePreferenceSet;
     protected Map perPrincipalPrefs = new HashMap();
-    protected Map originalValues;
     private PortletApplicationEntity applicationEntity = null;
     private PortletWindowList portletWindows = new PortletWindowListImpl();
     private PortletDefinitionComposite portletDefinition = null;  
@@ -157,7 +156,6 @@
                 {
                     mergePreferencesSet(preferenceSet);
                 }
-                backupValues(preferenceSet);
                 dirty = true;
             }
         }
@@ -197,8 +195,6 @@
                         preferenceSet.add(preference.getName(), preferenceValues);
                     }
                 }
-                
-                backupValues(preferenceSet);
                 dirty = true;
             }
         }
@@ -237,29 +233,6 @@
         }        
     }
 
-    /**
-     * <p>
-     * backupValues
-     * </p>
-     * 
-     *  
-     */
-    protected void backupValues( PreferenceSet preferenceSet )
-    {
-        originalValues = new HashMap();
-        Iterator itr = preferenceSet.iterator();
-        while (itr.hasNext())
-        {
-            PrefsPreference pref = (PrefsPreference) itr.next();
-
-            String[] currentValues = pref.getValueArray();
-            String[] backUp = new String[currentValues.length];
-            System.arraycopy(currentValues, 0, backUp, 0, currentValues.length);
-            originalValues.put(pref.getName(), backUp);
-
-        }
-    }
-
     public PortletDefinition getPortletDefinition()
     {
         // there are cases when jetspeed gets initialized before
@@ -343,10 +316,6 @@
         PreferenceSet preferenceSet = (PreferenceSet)perPrincipalPrefs.get(principal);
         pac.storePreferenceSet(preferenceSet, this);
         dirty = false;
-        if (preferenceSet != null)
-        {
-            backupValues(preferenceSet);
-        }
     }
     
     private void storeToPage() throws IOException
@@ -388,10 +357,6 @@
         }
         
         dirty = false;
-        if (preferenceSet != null)
-        {
-            backupValues(preferenceSet);
-        }
     }
 
     /**
@@ -404,48 +369,8 @@
 
     public void reset() throws IOException
     {
-        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) perPrincipalPrefs.get(getPrincipal());
-        try
-        {
-            if (originalValues != null && preferenceSet != null)
-            {
-                Iterator prefs = preferenceSet.iterator();
-
-                while (prefs.hasNext())
-                {
-                    PrefsPreference pref = (PrefsPreference) prefs.next();
-                    if (originalValues.containsKey(pref.getName()))
-                    {
-                        pref.setValues((String[]) originalValues.get(pref.getName()));
-                    }
-                    else
-                    {
-                        preferenceSet.remove(pref);
-                    }
-                    preferenceSet.flush();
-                }
-
-                Iterator keys = originalValues.keySet().iterator();
-                while (keys.hasNext())
-                {
-                    String key = (String) keys.next();
-                    if (preferenceSet.get(key) == null)
-                    {
-                        preferenceSet.add(key, Arrays.asList((String[]) originalValues.get(key)));
-                    }
-                }
-            }
-            dirty = false;
-            backupValues(preferenceSet);
-        }
-        catch (BackingStoreException e)
-        {
-            String msg = "Preference backing store failed: " + e.toString();
-            IOException ioe = new IOException(msg);
-            ioe.initCause(e);
-            throw ioe;
-        }
-
+        dirty = true;
+        getPreferenceSet(getPrincipal());        
     }
 
     // internal methods used for debugging purposes only

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java?rev=663293&r1=663292&r2=663293&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java Wed Jun  4 09:23:25 2008
@@ -139,20 +139,6 @@
 
         assertEquals("2", pref.getValueAt(0));
 
-        entity.reset();
-
-        pref = (PreferenceComposite) prefs.get("pref1");
-
-        assertEquals("1", pref.getValueAt(0));
-
-        prefs.remove(pref);
-
-        assertNull(prefs.get("pref1"));
-
-        entity.reset();
-
-        assertNotNull(prefs.get("pref1"));
-
         prefs.add("pref2", Arrays.asList(new String[]
         { "2", "3" }));
 
@@ -182,22 +168,11 @@
         }
         assertEquals(3, count);
 
-        entity.reset();
-
-        prefsValues = pref2.getValues();
-        count = 0;
-        while (prefsValues.hasNext())
-        {
-            assertEquals(String.valueOf(count + 2), prefsValues.next());
-            count++;
-        }
-        assertEquals(2, count);
-
         // testing preferences null values assignments fix, issue JS2-607
         pref2.setValueAt(0, null);        
         assertNull("pref2.value[0] should be null", pref2.getValueAt(0));        
         String[] values = pref2.getValueArray();
-        assertEquals(2, values.length);
+        assertEquals(3, values.length);
         assertNull("pref2.value[0] should be null", values[0]);
         assertEquals("3", values[1]);
         pref2.setValues(new String[]{"2",null,"3"});
@@ -211,13 +186,9 @@
         pref2.setValues((String[])null);
         assertFalse(pref2.isValueSet());
         assertTrue(pref2.getValueArray().length == 0);
-        entity.reset();
-        assertTrue(pref2.getValueArray().length == 2);
         pref2.setValues(new String[]{});
         assertFalse(pref2.isValueSet());
         assertTrue(pref2.getValueArray().length == 0);
-        entity.reset();
-        assertTrue(pref2.getValueArray().length == 2);
 
         MutablePortletEntity entity2 = entityAccess.getPortletEntityForFragment(f1);
         assertTrue("entity id ", entity2.getId().toString().equals(TEST_ENTITY));



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