You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2007/01/17 16:04:06 UTC

svn commit: r497037 - /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java

Author: angela
Date: Wed Jan 17 07:04:05 2007
New Revision: 497037

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

- add tmp workaround for 'reload' (tmp solution until state hierarchy has been reworked)
- minor improvement


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

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?view=diff&rev=497037&r1=497036&r2=497037
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java Wed Jan 17 07:04:05 2007
@@ -104,7 +104,7 @@
      * Constructs a new node state that is not connected.
      *
      * @param name          the name of this NodeState
-     * @param uuid          the uniqueID of this NodeState or <code>null</code> if
+     * @param uniqueID      the uniqueID of this NodeState or <code>null</code> if
      *                      this node state cannot be identified with a UUID.
      * @param parent        the parent of this NodeState
      * @param nodeTypeName  node type of this node
@@ -233,7 +233,15 @@
         if (isWorkspaceState()) {
             // reload from persistent storage ('keepChanges' not relevant).
             try {
+                /* TODO: TOBEFIXED.
+                   recreating nodestate not correct. parent still has entry pointing
+                   to this state and subsequently retrieving the childentries fails,
+                   since id of tmp state cannot be resolved.
+                   -> add workaround until state hierarchy has been modified
+                */
                 NodeState tmp = isf.createNodeState(getNodeId(), getParent());
+                tmp.childNodeEntries = isf.getChildNodeEntries(this);
+
                 if (merge(tmp, false) || getStatus() == Status.INVALIDATED) {
                     setStatus(Status.MODIFIED);
                 }
@@ -260,7 +268,7 @@
     }
 
     boolean merge(ItemState another, boolean keepChanges) {
-        if (another == null) {
+        if (another == null || another == this) {
             return false;
         }
         if (!another.isNode()) {
@@ -889,8 +897,10 @@
                 NodeState overlayedParent = (NodeState) parent.overlayedState;
                 if (state.isNode()) {
                     overlayedParent.childNodeEntries().remove((NodeState)state.overlayedState);
+                    parent.childNodeEntries().remove((NodeState)state);
                 } else {
                     overlayedParent.removePropertyEntry(state.overlayedState.getQName());
+                    parent.removePropertyEntry(state.getQName());
                 }
                 modifiedParent(parent, state, modParents);
             }
@@ -940,7 +950,6 @@
                 if (parent.getStatus() == Status.EXISTING_MODIFIED) {
                     modifiedParent(parent, addedState, modParents);
                 }
-
                 it.remove();
             } catch (ItemStateException e) {
                 log.error("Internal error.", e);
@@ -965,7 +974,6 @@
                     // and mark the moved state existing
                     modNodeState.setStatus(Status.EXISTING);
                     it.remove();
-
                 } else {
                     modifiedParent((NodeState)modState, null, modParents);
                 }
@@ -1010,8 +1018,7 @@
             if (!(state.getStatus() == Status.EXISTING ||
                   state.getStatus() == Status.REMOVED ||
                   state.getStatus() == Status.INVALIDATED)) {
-                // should not occur: state has not been processed
-                log.error("State " + state + " has not been processed upon ChangeLog.persisted => invalidate");
+                log.info("State " + state + " with Status " + Status.getName(state.getStatus()) + " has not been processed upon ChangeLog.persisted => invalidate");
                 state.invalidate(false);
             }
         }