jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r452512 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state: ChangeLog.java SessionItemStateManager.java
Date Tue, 03 Oct 2006 14:32:44 GMT
Author: angela
Date: Tue Oct  3 07:32:43 2006
New Revision: 452512

URL: http://svn.apache.org/viewvc?view=rev&rev=452512
Log:
work in progress

- remove DIFF comment
- SessionISM should not handle workspace operations.
- SessionISM.getReferingStates not correct. add TODO
- fix ChangeLog.isSelfContained: retrieve list of all affected states
  from the list of operations and compare to states collected before.

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?view=diff&rev=452512&r1=452511&r2=452512
==============================================================================
--- 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 Oct  3 07:32:43 2006
@@ -24,6 +24,7 @@
 import java.util.Set;
 import java.util.LinkedHashSet;
 import java.util.HashSet;
+import java.util.Collection;
 
 /**
  * Registers changes made to states and references and consolidates
@@ -54,7 +55,7 @@
 
     /**
      * Type of operation this changelog is collection state modifications for.
-     */  
+     */
     private Set operations = new LinkedHashSet();
 
     /**
@@ -196,55 +197,18 @@
         affectedStates.addAll(modifiedStates);
         affectedStates.addAll(deletedStates);
         affectedStates.addAll(addedStates);
-        Iterator it = new IteratorChain(modifiedStates(), deletedStates());
+
+        // check if the affected states listed by the operations are all
+        // listed in the modified,deleted or added states collected by this
+        // changelog.
+        Iterator it = getOperations();
         while (it.hasNext()) {
-            ItemState transientState = (ItemState) it.next();
-            if (transientState.isNode()) {
-                NodeState nodeState = (NodeState) transientState;
-                Set dependentStates = new HashSet();
-                if (nodeState.hasOverlayedState()) {
-                    // TODO: oldParentState is overlayed state from workspace. do not use!
-                    NodeState oldParentState = nodeState.getOverlayedState().getParent();
-                    NodeState newParentState = nodeState.getParent();
-                    if (oldParentState != null) {
-                        if (newParentState == null) {
-                            // node has been removed, add old parent
-                            // to dependencies
-                            dependentStates.add(oldParentState);
-                        } else {
-                            if (!oldParentState.equals(newParentState)) {
-                                // node has been moved, add old and new parent
-                                // to dependencies
-                                dependentStates.add(oldParentState);
-                                dependentStates.add(newParentState);
-                            }
-                        }
-                    }
-                }
-                // removed child node entries
-                Iterator cneIt = nodeState.getRemovedChildNodeEntries().iterator();
-                while (cneIt.hasNext()) {
-                    ChildNodeEntry cne = (ChildNodeEntry) cneIt.next();
-                    dependentStates.add(cne.getNodeState());
-                }
-                // added child node entries
-                cneIt = nodeState.getAddedChildNodeEntries().iterator();
-                while (cneIt.hasNext()) {
-                    ChildNodeEntry cne = (ChildNodeEntry) cneIt.next();
-                    dependentStates.add(cne.getNodeState());
-                }
-
-                // now walk through dependencies and check whether they
-                // are within the scope of this save operation
-                Iterator depIt = dependentStates.iterator();
-                while (depIt.hasNext()) {
-                    NodeState dependantState = (NodeState) depIt.next();
-                    if (!affectedStates.contains(dependantState)) {
-                        // need to save the parent as well
-                        String msg = dependantState.getNodeId().toString() + " needs to be
saved as well.";
-                        throw new ItemStateException(msg);
-                    }
-                }
+            Operation op = (Operation) it.next();
+            Collection opStates = op.getAffectedItemStates();
+            if (!affectedStates.containsAll(opStates)) {
+                // need to save the parent as well
+                String msg = "ChangeLog is not self contained.";
+                throw new ItemStateException(msg);
             }
         }
     }

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?view=diff&rev=452512&r1=452511&r2=452512
==============================================================================
--- 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 Oct  3 07:32:43 2006
@@ -119,9 +119,7 @@
                                    NamespaceResolver nsResolver) {
         this.workspaceItemStateMgr = workspaceItemStateMgr;
         this.transientStateMgr = new TransientItemStateManager(idFactory, workspaceItemStateMgr);
-        // DIFF JR: validator added
         this.validator = validator;
-
         this.nsResolver = nsResolver;
 
         // create hierarchy manager
@@ -193,6 +191,7 @@
      * @param nodeState
      */
     public Collection getReferingStates(NodeState nodeState) throws ItemStateException {
+        // TODO: not correct. ItemManager later on expectes overlaying state
         return workspaceItemStateMgr.getReferingStates(nodeState);
     }
 
@@ -340,9 +339,9 @@
         // build changelog for affected and decendant states only
         ChangeLog changeLog = new ChangeLog(itemState);
         collectTransientStates(itemState, changeLog, true);
+        changeLog.collectOperations(transientStateMgr.getOperations());
 
         changeLog.checkIsSelfContained();
-        changeLog.collectOperations(transientStateMgr.getOperations());
         return changeLog;
     }
 
@@ -470,20 +469,6 @@
     /**
      * @inheritDoc
      */
-    public void visit(Clone operation) throws NoSuchWorkspaceException, LockException, ConstraintViolationException,
AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException, VersionException,
RepositoryException {
-        workspaceItemStateMgr.execute(operation);
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public void visit(Copy operation) throws NoSuchWorkspaceException, LockException, ConstraintViolationException,
AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException, VersionException,
RepositoryException {
-        workspaceItemStateMgr.execute(operation);
-    }
-
-    /**
-     * @inheritDoc
-     */
     public void visit(Move operation) throws LockException, ConstraintViolationException,
AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException, VersionException,
RepositoryException {
 
         // retrieve states and assert they are modifiable
@@ -516,10 +501,6 @@
         transientStateMgr.addOperation(operation);
     }
 
-    public void visit(Update operation) throws NoSuchWorkspaceException, AccessDeniedException,
LockException, InvalidItemStateException, RepositoryException {
-        workspaceItemStateMgr.execute(operation);
-    }
-
     /**
      * @inheritDoc
      */
@@ -664,44 +645,56 @@
         transientStateMgr.addOperation(operation);
     }
 
+    public void visit(Clone operation) throws NoSuchWorkspaceException, LockException, ConstraintViolationException,
AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException, VersionException,
RepositoryException {
+        throw new UnsupportedOperationException("Internal error: Clone cannot be handled
by session ItemStateManager.");
+    }
+
+    public void visit(Copy operation) throws NoSuchWorkspaceException, LockException, ConstraintViolationException,
AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException, VersionException,
RepositoryException {
+        throw new UnsupportedOperationException("Internal error: Copy cannot be handled by
session ItemStateManager.");
+    }
+
     public void visit(Checkout operation) throws RepositoryException, UnsupportedRepositoryOperationException
{
-        workspaceItemStateMgr.execute(operation);
+        throw new UnsupportedOperationException("Internal error: Checkout cannot be handled
by session ItemStateManager.");
     }
 
     public void visit(Checkin operation) throws UnsupportedRepositoryOperationException,
LockException, InvalidItemStateException, RepositoryException {
-        workspaceItemStateMgr.execute(operation);
+        throw new UnsupportedOperationException("Internal error: Checkin cannot be handled
by session ItemStateManager.");
+    }
+
+    public void visit(Update operation) throws NoSuchWorkspaceException, AccessDeniedException,
LockException, InvalidItemStateException, RepositoryException {
+        throw new UnsupportedOperationException("Internal error: Update cannot be handled
by session ItemStateManager.");
     }
 
     public void visit(Restore operation) throws VersionException, PathNotFoundException,
ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException,
RepositoryException {
-        workspaceItemStateMgr.execute(operation);
+        throw new UnsupportedOperationException("Internal error: Restore cannot be handled
by session ItemStateManager.");
     }
 
     public void visit(Merge operation) throws NoSuchWorkspaceException, AccessDeniedException,
MergeException, LockException, InvalidItemStateException, RepositoryException {
-        workspaceItemStateMgr.execute(operation);
+        throw new UnsupportedOperationException("Internal error: Merge cannot be handled
by session ItemStateManager.");
     }
 
     public void visit(ResolveMergeConflict operation) throws VersionException, InvalidItemStateException,
UnsupportedRepositoryOperationException, RepositoryException {
-        workspaceItemStateMgr.execute(operation);
+        throw new UnsupportedOperationException("Internal error: Update cannot be handled
by session ItemStateManager.");
     }
 
     public void visit(LockOperation operation) throws AccessDeniedException, InvalidItemStateException,
UnsupportedRepositoryOperationException, LockException, RepositoryException {
-        workspaceItemStateMgr.execute(operation);
+        throw new UnsupportedOperationException("Internal error: Lock cannot be handled by
session ItemStateManager.");
     }
 
     public void visit(LockRefresh operation) throws AccessDeniedException, InvalidItemStateException,
UnsupportedRepositoryOperationException, LockException, RepositoryException {
-        workspaceItemStateMgr.execute(operation);
+        throw new UnsupportedOperationException("Internal error: LockRefresh cannot be handled
by session ItemStateManager.");
     }
 
     public void visit(LockRelease operation) throws AccessDeniedException, InvalidItemStateException,
UnsupportedRepositoryOperationException, LockException, RepositoryException {
-        workspaceItemStateMgr.execute(operation);
+        throw new UnsupportedOperationException("Internal error: LockRelease cannot be handled
by session ItemStateManager.");
     }
 
     public void visit(AddLabel operation) throws VersionException, RepositoryException {
-        workspaceItemStateMgr.execute(operation);
+        throw new UnsupportedOperationException("Internal error: AddLabel cannot be handled
by session ItemStateManager.");
     }
 
     public void visit(RemoveLabel operation) throws VersionException, RepositoryException
{
-        workspaceItemStateMgr.execute(operation);
+        throw new UnsupportedOperationException("Internal error: RemoveLabel cannot be handled
by session ItemStateManager.");
     }
 
     //--------------------------------------------< Internal State Handling >---



Mime
View raw message