[pal-cvs 3222] [959] fixed JS2-849

svnno****@sourc***** svnno****@sourc*****
2008年 6月 5日 (木) 10:00:40 JST


Revision: 959
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=959
Author:   shinsuke
Date:     2008-06-05 10:00:40 +0900 (Thu, 05 Jun 2008)

Log Message:
-----------
fixed JS2-849

Modified Paths:
--------------
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java


-------------- next part --------------
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java	2008-06-05 00:49:22 UTC (rev 958)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java	2008-06-05 01:00:40 UTC (rev 959)
@@ -88,8 +88,6 @@
 
     protected Map perPrincipalPrefs = new HashMap();
 
-    protected Map originalValues;
-
     private PortletApplicationEntity applicationEntity = null;
 
     private PortletWindowList portletWindows = new PortletWindowListImpl();
@@ -178,7 +176,6 @@
                 {
                     mergePreferencesSet(preferenceSet);
                 }
-                backupValues(preferenceSet);
                 dirty = true;
             }
         }
@@ -223,8 +220,6 @@
                                 preferenceValues);
                     }
                 }
-
-                backupValues(preferenceSet);
                 dirty = true;
             }
         }
@@ -263,29 +258,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
@@ -371,10 +343,6 @@
                 .get(principal);
         pac.storePreferenceSet(preferenceSet, this);
         dirty = false;
-        if (preferenceSet != null)
-        {
-            backupValues(preferenceSet);
-        }
     }
 
     private void storeToPage() throws IOException
@@ -414,10 +382,6 @@
         }
 
         dirty = false;
-        if (preferenceSet != null)
-        {
-            backupValues(preferenceSet);
-        }
     }
 
     /**
@@ -430,51 +394,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: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java	2008-06-05 00:49:22 UTC (rev 958)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java	2008-06-05 01:00:40 UTC (rev 959)
@@ -147,20 +147,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"}));
 
@@ -190,22 +176,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[]
@@ -220,14 +195,10 @@
         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);


pal-cvs メーリングリストの案内