jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r433611 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state: ChangeLog.java SessionItemStateManager.java
Date Tue, 22 Aug 2006 12:36:25 GMT
Author: mreutegg
Date: Tue Aug 22 05:36:23 2006
New Revision: 433611

URL: http://svn.apache.org/viewvc?rev=433611&view=rev
Log:
Move method SessionItemStateManager.collectOperations() to ChangeLog.

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java?rev=433611&r1=433610&r2=433611&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java
Tue Aug 22 05:36:23 2006
@@ -230,7 +230,32 @@
         }
     }
 
+    /**
+     * Populates this <code>ChangeLog</code> with operations that are within
the
+     * scope of this change set.
+     *
+     * @param operations an Iterator of <code>Operation</code>s which are the
+     *                   candidates to be included in this <code>ChangeLog</code>.
+     */
+    public void collectOperations(Iterator operations) {
+        Set affectedStates = new HashSet();
+        affectedStates.addAll(deletedStates);
+        affectedStates.addAll(modifiedStates);
+        while (operations.hasNext()) {
+            Operation op = (Operation) operations.next();
+            Iterator states = op.getAffectedItemStates().iterator();
+            while (states.hasNext()) {
+                ItemState state = (ItemState) states.next();
+                if (affectedStates.contains(state)) {
+                    addOperation(op);
+                    break;
+                }
+            }
+        }
+    }
+
     //-----------------------------< Inform ChangeLog about Success/Failure >---
+
     /**
      * Push all states contained in the various maps of
      * items we have.

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java?rev=433611&r1=433610&r2=433611&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
Tue Aug 22 05:36:23 2006
@@ -284,13 +284,12 @@
         ChangeLog changeLog = new ChangeLog();
         collectTransientStates(itemState, changeLog, false);
         changeLog.checkIsSelfContained();
+        changeLog.collectOperations(transientStateMgr.getOperations());
 
         // now do it for real
         Set affectedItemStates = new HashSet();
         itemState.revert(affectedItemStates);
 
-        collectOperations(affectedItemStates, changeLog);
-
         // remove all canceled operations
         transientStateMgr.disposeOperations(changeLog.getOperations());
     }
@@ -355,7 +354,7 @@
         }
 
         changeLog.checkIsSelfContained();
-        collectOperations(affectedStates, changeLog);
+        changeLog.collectOperations(transientStateMgr.getOperations());
 
         return changeLog;
     }
@@ -452,28 +451,6 @@
                     log.debug("unexpected state status (" + transientState.getStatus() +
")");
                     // ignore
                     break;
-            }
-        }
-    }
-
-    /**
-     * Retuns a list of operations that are in the scope the the change set
-     * defined by the affected <code>ItemState</code>s.
-     *
-     * @param affectedStates
-     * @param changeLog
-     */
-    private void collectOperations(Set affectedStates, ChangeLog changeLog) {
-        Iterator opsIter = transientStateMgr.getOperations();
-        while (opsIter.hasNext()) {
-            Operation op = (Operation) opsIter.next();
-            Iterator states = op.getAffectedItemStates().iterator();
-            while (states.hasNext()) {
-                ItemState state = (ItemState) states.next();
-                if (affectedStates.contains(state)) {
-                    changeLog.addOperation(op);
-                    break;
-                }
             }
         }
     }



Mime
View raw message