jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1176922 - /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
Date Wed, 28 Sep 2011 15:39:15 GMT
Author: mduerig
Date: Wed Sep 28 15:39:15 2011
New Revision: 1176922

URL: http://svn.apache.org/viewvc?rev=1176922&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
refactor: remove obsolete refresh method

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java?rev=1176922&r1=1176921&r2=1176922&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
Wed Sep 28 15:39:15 2011
@@ -31,9 +31,7 @@ import org.apache.jackrabbit.jcr2spi.sta
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.apache.jackrabbit.jcr2spi.state.Status;
 import org.apache.jackrabbit.spi.ChildInfo;
-import org.apache.jackrabbit.spi.Event;
 import org.apache.jackrabbit.spi.IdFactory;
-import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.Path;
@@ -155,11 +153,7 @@ public class NodeEntry extends Hierarchy
      * Upon transient 'move' ('rename') or 'reorder' of SNSs this
      * {@code NodeEntry} remembers the original parent, name and index
      * for later revert as well as for the creation of the
-     * {@link #getWorkspaceId() workspace id}. Finally the revertInfo is
-     * used to find the target of an {@code Event} indicating external
-     * modification.
-     *
-     * @see #refresh(Event)
+     * {@link #getWorkspaceId() workspace id}. 
      */
     private RevertInfo revertInfo;
 
@@ -1016,109 +1010,6 @@ public class NodeEntry extends Hierarchy
         return revertInfo != null && revertInfo.isMoved();
     }
 
-    /**
-     * The parent entry of a external event gets informed about the modification.
-     * Note, that {@link Event#getParentId()} of the given childEvent must point
-     * to this {@code NodeEntry}.
-     *
-     * @param childEvent
-     */
-    public void refresh(Event childEvent) {
-        ItemId eventId = childEvent.getItemId();
-        Path eventPath = childEvent.getPath();
-        Name eventName = eventPath.getName();
-        HierarchyEntry<?> child = eventId == null ? null : lookupEntry(eventId, eventPath);
-
-        switch (childEvent.getType()) {
-            case Event.NODE_ADDED:
-            case Event.PROPERTY_ADDED:
-                if (child == null || child.getStatus() == Status.REMOVED) {
-                    // no such child or a colliding new child existed but got
-                    // removed already -> add the new entry.
-                    if (childEvent.getType() ==  Event.NODE_ADDED) {
-                        String uniqueChildID = eventId.getPath() == null ? eventId.getUniqueID()
: null;
-                        int index = eventPath.getNormalizedIndex();
-                        internalAddNodeEntry(eventName, uniqueChildID, index);
-                    } else {
-                        internalAddPropertyEntry(eventName, true);
-                    }
-                } else {
-                    // item already present
-                    Status status = child.getStatus();
-                    if (Status.NEW == status) {
-                        // event conflicts with a transiently added item on this
-                        // node entry -> mark the parent node (this) stale.
-                        internalGetItemState().setStatus(Status.MODIFIED);
-                    } // else: child already added -> ignore
-                }
-                break;
-
-            case Event.NODE_REMOVED:
-            case Event.PROPERTY_REMOVED:
-                if (child != null) {
-                    Status status = child.getStatus();
-                    if (Status.EXISTING_REMOVED == status) {
-                        // colliding item removal -> mark parent stale
-                        internalGetItemState().setStatus(Status.MODIFIED);
-                    }
-                    child.remove();
-                } // else: child-Entry has not been loaded yet -> ignore
-                break;
-
-            case Event.PROPERTY_CHANGED:
-                if (child == null) {
-                    // prop-Entry has not been loaded yet -> add propEntry
-                    internalAddPropertyEntry(eventName, true);
-                } else if (child.isAvailable()) {
-                    Status status = child.getStatus();
-                    // if the child has pending changes -> stale.
-                    // Reload data from server and try to merge them with the
-                    // current session-state. if the latter is transiently
-                    // modified and merge fails it must be marked STALE afterwards.
-                    if (Status.isStale(status))  {
-                        // ignore. nothing to do.
-                    } else if (Status.isTransient(child.getStatus())) {
-                        // pending changes -> don't reload entry but rather
-                        // mark it stale
-                        child.internalGetItemState().setStatus(Status.MODIFIED);
-                    } else {
-                        // no pending changes -> invalidate and force reload
-                        // upon next access.
-                        child.invalidate(false);
-                        // special cases: jcr:uuid and jcr:mixinTypes affect the
-                        // parent (i.e. this NodeEntry)
-                        if (isUuidOrMixin(eventName)) {
-                            if (!(child instanceof PropertyEntry)) {
-                                IllegalArgumentException e = new IllegalArgumentException("Invalid
event: " + childEvent);
-                                log.error(e.getMessage(), e);
-                                throw e;
-                            }
-
-                            notifyUUIDorMIXINModified(Unchecked.<PropertyEntry>cast(child));
-                        }
-                    }
-                } // else: existing entry but state not yet built -> ignore event
-                break;
-            case Event.NODE_MOVED:
-                // TODO: implementation missing
-                UnsupportedOperationException e = new UnsupportedOperationException("Not
implemented");
-                log.error(e.getMessage(), e);
-                throw e;
-                //break;
-            case Event.PERSIST:
-                // TODO: implementation missing
-                UnsupportedOperationException e0 = new UnsupportedOperationException("Not
implemented");
-                log.error(e0.getMessage(), e0);
-                throw e0;
-            default:
-                // ILLEGAL
-                IllegalArgumentException e1 = new IllegalArgumentException("Illegal event
type " +
-                        childEvent.getType() + " for NodeState.");
-                log.error(e1.getMessage(), e1);
-                throw e1;
-        }
-    }
-
     //-------------------------------------------------< HierarchyEntry >---
 
     @Override
@@ -1322,30 +1213,6 @@ public class NodeEntry extends Hierarchy
         }
     }
 
-    /**
-     * Searches the child-entries of this NodeEntry for a matching child.
-     * Since {@link #refresh(Event)} must always be called on the parent
-     * NodeEntry, there is no need to check if a given event id would point
-     * to this NodeEntry itself.
-     *
-     * @param eventId
-     * @param eventPath
-     * @return the entry or {@code null} if the matching entry has a status
-     * {@code Status#NEW}.
-     */
-    private HierarchyEntry<?> lookupEntry(ItemId eventId, Path eventPath) {
-        Name childName = eventPath.getName();
-        HierarchyEntry<?> child;
-        if (eventId.denotesNode()) {
-            String uniqueChildID = eventId.getPath() == null ? eventId.getUniqueID() : null;
-            int index = eventPath.getNormalizedIndex();
-            child = lookupNodeEntry(uniqueChildID, childName, index);
-        } else {
-            child = lookupPropertyEntry(childName);
-        }
-        return child;
-    }
-
     private NodeEntry lookupNodeEntry(String uniqueChildId, Name childName, int index) {
         NodeEntry child = null;
         if (uniqueChildId != null) {



Mime
View raw message