jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r523326 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ hierarchy/ operation/ state/ version/
Date Wed, 28 Mar 2007 13:50:26 GMT
Author: angela
Date: Wed Mar 28 06:50:25 2007
New Revision: 523326

URL: http://svn.apache.org/viewvc?view=rev&rev=523326
Log:
- NodeEntry: retrieving child node entries may throw RepositoryException -> adjust methods
that add/remove/access child node entries.
- HierarchyEventListener: ignore local events

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddLabel.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Operation.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveLabel.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?view=diff&rev=523326&r1=523325&r2=523326
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Wed Mar 28 06:50:25 2007
@@ -302,7 +302,7 @@
     /**
      * Sets the <code>InternalEventListener</code> that gets notifications about
      * local and external changes.
-     * 
+     *
      * @param listener the new listener.
      */
     public void addEventListener(InternalEventListener listener) {
@@ -457,8 +457,13 @@
             throw new RepositoryException(e);
         }
         try {
-            // execute operation and delegate invalidation of affected item
-            // states to the operation.
+            /*
+            Execute operation and delegate invalidation of affected item
+            states to the operation.
+            NOTE, that the invalidation is independant of the cache behaviour
+            due to the fact, that local eventbundles are not processed by
+            the HierarchyEventListener.
+            */
             new OperationVisitorImpl(sessionInfo).execute(operation);
             // TODO: remove parameter CacheBehaviour
             operation.persisted(CacheBehaviour.INVALIDATE);
@@ -615,7 +620,7 @@
      * @param eventBundles the event bundles generated by the repository service
      * as the effect of an local or external change.
      */
-    private void onEventReceived(EventBundle[] eventBundles) {
+    private void onEventReceived(EventBundle[] eventBundles, InternalEventListener[] lstnrs)
{
         if (log.isDebugEnabled()) {
             log.debug("received {} event bundles.", new Integer(eventBundles.length));
             for (int i = 0; i < eventBundles.length; i++) {
@@ -656,10 +661,6 @@
         }
         try {
             // notify listener
-            InternalEventListener[] lstnrs;
-            synchronized (listeners) {
-                lstnrs = (InternalEventListener[]) listeners.toArray(new InternalEventListener[listeners.size()]);
-            }
             for (int i = 0; i < eventBundles.length; i++) {
                 for (int j = 0; j < lstnrs.length; j++) {
                     lstnrs[j].onEvent(eventBundles[i]);
@@ -717,7 +718,7 @@
             workspaceOperation.accept(this);
         }
 
-        //-----------------------< OperationVisitor >---------------------------
+        //-----------------------------------------------< OperationVisitor >---
         /**
          * @inheritDoc
          * @see OperationVisitor#visit(AddNode)
@@ -948,6 +949,7 @@
         }
     }
 
+    //------------------------------------------------------< ChangePolling >---
     /**
      * Implements the polling for changes on the repository service.
      */
@@ -996,7 +998,7 @@
                         break;
                     }
                     if (bundles.length > 0) {
-                        onEventReceived(bundles);
+                        onEventReceived(bundles, iel);
                     }
                 } catch (UnsupportedRepositoryOperationException e) {
                     log.error("SPI implementation does not support observation: " + e);

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java?view=diff&rev=523326&r1=523325&r2=523326
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java
Wed Mar 28 06:50:25 2007
@@ -25,7 +25,6 @@
 import org.apache.commons.collections.iterators.UnmodifiableIterator;
 
 import javax.jcr.RepositoryException;
-import javax.jcr.ItemNotFoundException;
 import java.util.Collection;
 import java.util.Map;
 import java.util.HashMap;
@@ -370,7 +369,12 @@
             LinkedEntries.LinkNode previous = getLinkNode(nodeName, previousIndex);
             if (previous == null) {
                 // add missing entry (or entries)
-                parent.addNodeEntry(nodeName, null, previousIndex);
+                try {
+                    parent.addNodeEntry(nodeName, null, previousIndex);
+                } catch (RepositoryException e) {
+                    // should never occur
+                    log.debug("Internal error", e.getMessage());
+                }
 
             } // else: all intermediate entries exist
         } // else: undefined or default index are not affected

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java?view=diff&rev=523326&r1=523325&r2=523326
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
Wed Mar 28 06:50:25 2007
@@ -98,8 +98,6 @@
             } catch (ItemNotFoundException e) {
                 remove();
                 throw e;
-            } catch (RepositoryException e) {
-                e.printStackTrace();
             }
         } else if (state.getStatus() == Status.INVALIDATED) {
             // completely reload this entry, but don't reload recursively

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java?view=diff&rev=523326&r1=523325&r2=523326
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java
Wed Mar 28 06:50:25 2007
@@ -54,8 +54,8 @@
         if (cacheBehaviour == CacheBehaviour.OBSERVATION) {
             EventFilter filter = null;
             try {
-                // TODO: improve. for now listen to everything
-                filter = wspManager.createEventFilter(Event.ALL_TYPES, Path.ROOT, true, null,
null, false);
+                // listen to all events except 'local' ones
+                filter = wspManager.createEventFilter(Event.ALL_TYPES, Path.ROOT, true, null,
null, true);
             } catch (RepositoryException e) {
                 // spi does not support observation, or another error occurred.
             }
@@ -84,6 +84,10 @@
      * @see InternalEventListener#onEvent(EventBundle)
      */
     public void onEvent(EventBundle eventBundle) {
+        if (eventBundle.isLocal()) {
+            log.debug("Local event bundle -> not processed by HierarchyEventListener.");
+            return;
+        }
         pushEvents(getEventCollection(eventBundle));
     }
 
@@ -95,6 +99,7 @@
      */
     private void pushEvents(Collection events) {
         if (events.isEmpty()) {
+            log.debug("Empty event bundle");
             return;
         }
         // collect set of removed node ids
@@ -179,4 +184,4 @@
         }
         return evs;
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java?view=diff&rev=523326&r1=523325&r2=523326
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
Wed Mar 28 06:50:25 2007
@@ -92,6 +92,8 @@
      *
      * @param path
      * @return the entry at the given path.
+     * @throws PathNotFoundException
+     * @throws RepositoryException
      */
     public HierarchyEntry getDeepEntry(Path path) throws PathNotFoundException, RepositoryException;
 
@@ -135,8 +137,9 @@
      * @param index 1-based index if there are same-name child node entries.
      * @return The <code>NodeEntry</code> with the specified name and index
      * or <code>null</code> if there's no matching entry.
+     * @throws RepositoryException If an unexpected error occurs.
      */
-    public NodeEntry getNodeEntry(QName nodeName, int index);
+    public NodeEntry getNodeEntry(QName nodeName, int index) throws RepositoryException;
 
     /**
      * Returns the <code>NodeEntry</code> with the specified
@@ -146,16 +149,18 @@
      * @param childId the id of the child entry.
      * @return the <code>NodeEntry</code> with the specified
      * <code>NodeId</code> or <code>null</code> if there's no matching
entry.
+     * @throws RepositoryException If an unexpected error occurs.
      */
-    public NodeEntry getNodeEntry(NodeId childId);
+    public NodeEntry getNodeEntry(NodeId childId) throws RepositoryException;
 
     /**
      * Returns a unmodifiable iterator of <code>NodeEntry</code> objects
      * denoting the the valid child NodeEntries present on this <code>NodeEntry</code>.
      *
      * @return iterator of <code>NodeEntry</code> objects
+     * @throws RepositoryException If an unexpected error occurs.
      */
-    public Iterator getNodeEntries();
+    public Iterator getNodeEntries() throws RepositoryException;
 
     /**
      * Returns a unmodifiable List of <code>NodeEntry</code>s with the
@@ -163,8 +168,9 @@
      *
      * @param nodeName name of the child node entries that should be returned
      * @return list of <code>NodeEntry</code> objects
+     * @throws RepositoryException If an unexpected error occurs.
      */
-    public List getNodeEntries(QName nodeName);
+    public List getNodeEntries(QName nodeName) throws RepositoryException;
 
     /**
      * Adds a new child NodeEntry to this entry.
@@ -172,8 +178,9 @@
      * @param nodeName
      * @param uniqueID
      * @return the new <code>NodeEntry</code>
+     * @throws RepositoryException If an unexpected error occurs.
      */
-    public NodeEntry addNodeEntry(QName nodeName, String uniqueID, int index);
+    public NodeEntry addNodeEntry(QName nodeName, String uniqueID, int index) throws RepositoryException;
 
     /**
      * Adds a new, transient child <code>NodeEntry</code>
@@ -183,9 +190,9 @@
      * @param primaryNodeType
      * @param definition
      * @return
-     * @throws ItemExistsException
+     * @throws RepositoryException If an error occurs.
      */
-    public NodeState addNewNodeEntry(QName nodeName, String uniqueID, QName primaryNodeType,
QNodeDefinition definition) throws ItemExistsException;
+    public NodeState addNewNodeEntry(QName nodeName, String uniqueID, QName primaryNodeType,
QNodeDefinition definition) throws RepositoryException;
 
     /**
      * Determines if there is a property entry with the specified <code>QName</code>.
@@ -218,8 +225,10 @@
      *
      * @param propName
      * @return
+     * @throws ItemExistsException if a child item exists with the given name
+     * @throws RepositoryException if an unexpected error occurs.
      */
-    public PropertyEntry addPropertyEntry(QName propName) throws ItemExistsException;
+    public PropertyEntry addPropertyEntry(QName propName) throws ItemExistsException, RepositoryException;
 
     /**
      * Adds property entries for the given <code>QName</code>s. It depends on
@@ -229,15 +238,18 @@
      *
      * @param propNames
      * @throws ItemExistsException
+     * @throws RepositoryException if an unexpected error occurs.
      */
-    public void addPropertyEntries(Collection propNames) throws ItemExistsException;
+    public void addPropertyEntries(Collection propNames) throws ItemExistsException, RepositoryException;
 
     /**
      *
      * @param propName
-     * @return
+     * @return The PropertyState associated with the new property entry.
+     * @throws ItemExistsException
+     * @throws RepositoryException if an unexpected error occurs.
      */
-    public PropertyState addNewPropertyEntry(QName propName, QPropertyDefinition definition)
throws ItemExistsException;
+    public PropertyState addNewPropertyEntry(QName propName, QPropertyDefinition definition)
throws ItemExistsException, RepositoryException;
 
     /**
      * Reorders this NodeEntry before the sibling entry specified by the given
@@ -245,13 +257,16 @@
      *
      * @param beforeEntry the child node where to insert the node before. If
      * <code>null</code> this entry is moved to the end of its parents child
node entries.
+     * @throws RepositoryException If an unexpected error occurs.
      */
-    public void orderBefore(NodeEntry beforeEntry) ;
+    public void orderBefore(NodeEntry beforeEntry) throws RepositoryException;
 
     /**
      * @param newName
      * @param newParent
-     * @return
+     * @return the moved entry
+     * @throws RepositoryException If the entry to be moved is not a child of this
+     * NodeEntry or if an unexpected error occurs.
      */
     public NodeEntry move(QName newName, NodeEntry newParent, boolean transientMove) throws
RepositoryException;
 
@@ -268,4 +283,4 @@
      * @param childEvent
      */
     public void refresh(Event childEvent) ;
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java?view=diff&rev=523326&r1=523325&r2=523326
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
Wed Mar 28 06:50:25 2007
@@ -236,6 +236,7 @@
             }
         }
 
+        // TODO: deal with childNodeAttic
         // now traverse all child-entries and mark the attached states removed
         // without removing the child-entries themselves. this is not required
         // since this (i.e. the parent is removed as well).
@@ -258,7 +259,7 @@
         super.collectStates(changeLog, throwOnStale);
 
         // collect transient child states including properties in attic.
-        for (Iterator it = getAllChildEntries(false, true); it.hasNext();) {
+        for (Iterator it = getAllChildEntries(true, true); it.hasNext();) {
             HierarchyEntry ce = (HierarchyEntry) it.next();
             ce.collectStates(changeLog, throwOnStale);
         }
@@ -477,15 +478,20 @@
      * @see NodeEntry#hasNodeEntry(QName)
      */
     public synchronized boolean hasNodeEntry(QName nodeName) {
-        List namedEntries = childNodeEntries().get(nodeName);
-        if (namedEntries.isEmpty()) {
+        try {
+            List namedEntries = childNodeEntries().get(nodeName);
+            if (namedEntries.isEmpty()) {
+                return false;
+            } else {
+                // copy list since during validation the childNodeEntries may be
+                // modified if upon NodeEntry.getItemState the entry is removed.
+                List l = new ArrayList(namedEntries.size());
+                l.addAll(namedEntries);
+                return EntryValidation.containsValidNodeEntry(l.iterator());
+            }
+        } catch (RepositoryException e) {
+            log.debug("Unable to determine if a child node with name " + nodeName + " exists.");
             return false;
-        } else {
-            // copy list since during validation the childNodeEntries may be
-            // modified if upon NodeEntry.getItemState the entry is removed.
-            List l = new ArrayList(namedEntries.size());
-            l.addAll(namedEntries);
-            return EntryValidation.containsValidNodeEntry(l.iterator());
         }
     }
 
@@ -494,14 +500,19 @@
      * @see NodeEntry#hasNodeEntry(QName, int)
      */
     public synchronized boolean hasNodeEntry(QName nodeName, int index) {
-        return EntryValidation.isValidNodeEntry(childNodeEntries().get(nodeName, index));
+        try {
+            return EntryValidation.isValidNodeEntry(childNodeEntries().get(nodeName, index));
+        } catch (RepositoryException e) {
+            log.debug("Unable to determine if a child node with name " + nodeName + " exists.");
+            return false;
+        }
     }
 
     /**
      * @inheritDoc
      * @see NodeEntry#getNodeEntry(QName, int)
      */
-    public synchronized NodeEntry getNodeEntry(QName nodeName, int index) {
+    public synchronized NodeEntry getNodeEntry(QName nodeName, int index) throws RepositoryException
{
         NodeEntry cne = childNodeEntries().get(nodeName, index);
         if (EntryValidation.isValidNodeEntry(cne)) {
             return cne;
@@ -515,7 +526,7 @@
      * @inheritDoc
      * @see NodeEntry#getNodeEntry(NodeId)
      */
-    public synchronized NodeEntry getNodeEntry(NodeId childId) {
+    public synchronized NodeEntry getNodeEntry(NodeId childId) throws RepositoryException
{
         String uid = childId.getUniqueID();
         Path path = childId.getPath();
         NodeEntry cne;
@@ -539,7 +550,7 @@
      * @inheritDoc
      * @see NodeEntry#getNodeEntries()
      */
-    public synchronized Iterator getNodeEntries() {
+    public synchronized Iterator getNodeEntries() throws RepositoryException {
         Collection entries = new ArrayList();
         Object[] arr = childNodeEntries().toArray();
         for (int i = 0; i < arr.length; i++) {
@@ -552,13 +563,9 @@
     }
 
     /**
-     * Returns a unmodifiable list of <code>NodeEntry</code>s with the
-     * specified name.
-     *
-     * @param nodeName name of the child node entries that should be returned
-     * @return list of <code>NodeEntry</code> objects
+     * @see NodeEntry#getNodeEntries(QName)
      */
-    public synchronized List getNodeEntries(QName nodeName) {
+    public synchronized List getNodeEntries(QName nodeName) throws RepositoryException {
         List namedEntries = childNodeEntries().get(nodeName);
         if (namedEntries.isEmpty()) {
             return Collections.EMPTY_LIST;
@@ -581,7 +588,7 @@
      * @inheritDoc
      * @see NodeEntry#addNodeEntry(QName, String, int)
      */
-    public NodeEntry addNodeEntry(QName nodeName, String uniqueID, int index) {
+    public NodeEntry addNodeEntry(QName nodeName, String uniqueID, int index) throws RepositoryException
{
         return internalAddNodeEntry(nodeName, uniqueID, index, childNodeEntries());
     }
 
@@ -590,7 +597,7 @@
      * @see NodeEntry#addNewNodeEntry(QName, String, QName, QNodeDefinition)
      */
     public NodeState addNewNodeEntry(QName nodeName, String uniqueID,
-                                     QName primaryNodeType, QNodeDefinition definition) throws
ItemExistsException {
+                                     QName primaryNodeType, QNodeDefinition definition) throws
RepositoryException {
         NodeEntryImpl entry = internalAddNodeEntry(nodeName, uniqueID, Path.INDEX_UNDEFINED,
childNodeEntries());
         NodeState state = factory.getItemStateFactory().createNewNodeState(entry, primaryNodeType,
definition);
         entry.internalSetItemState(state);
@@ -690,7 +697,7 @@
      * @inheritDoc
      * @see NodeEntry#addPropertyEntries(Collection)
      */
-    public void addPropertyEntries(Collection propNames) throws ItemExistsException {
+    public void addPropertyEntries(Collection propNames) throws ItemExistsException, RepositoryException
{
         Set diff = new HashSet();
         diff.addAll(properties.keySet());
         boolean containsExtra = diff.removeAll(propNames);
@@ -722,7 +729,8 @@
      * @inheritDoc
      * @see NodeEntry#addNewPropertyEntry(QName, QPropertyDefinition)
      */
-    public PropertyState addNewPropertyEntry(QName propName, QPropertyDefinition definition)
throws ItemExistsException {
+    public PropertyState addNewPropertyEntry(QName propName, QPropertyDefinition definition)
+            throws ItemExistsException, RepositoryException {
         // check for an existing property
         PropertyEntry existing = (PropertyEntry) properties.get(propName);
         if (existing != null) {
@@ -779,7 +787,7 @@
      * @inheritDoc
      * @see NodeEntry#orderBefore(NodeEntry)
      */
-    public void orderBefore(NodeEntry beforeEntry) {
+    public void orderBefore(NodeEntry beforeEntry) throws RepositoryException {
         if (Status.NEW == getStatus()) {
             // new states get remove upon revert
             parent.childNodeEntries().reorder(this, beforeEntry);
@@ -846,19 +854,21 @@
                 }
                 // first check if no matching child entry exists.
                 // TODO: TOBEFIXED for SNSs
-                NodeEntry cne;
-                if (uniqueChildID != null) {
-                    cne = childNodeEntries().get(eventName, uniqueChildID);
-                } else {
-                    cne = childNodeEntries().get(eventName, index);
-                }
-                if (cne == null) {
-                    internalAddNodeEntry(eventName, uniqueChildID, index, childNodeEntries());
-                } else {
-                    // child already exists -> deal with NEW entries, that were
-                    // added by some other session.
-                    // TODO: TOBEFIXED
-                }
+                if (childNodeEntries != null) {
+                    NodeEntry cne;
+                    if (uniqueChildID != null) {
+                        cne = childNodeEntries.get(eventName, uniqueChildID);
+                    } else {
+                        cne = childNodeEntries.get(eventName, index);
+                    }
+                    if (cne == null) {
+                        internalAddNodeEntry(eventName, uniqueChildID, index, childNodeEntries);
+                    } else {
+                        // child already exists -> deal with NEW entries, that were
+                        // added by some other session.
+                        // TODO: TOBEFIXED
+                    }
+                } // else: childNodeEntries not yet loaded -> ignore
                 break;
 
             case Event.PROPERTY_ADDED:
@@ -882,7 +892,10 @@
 
             case Event.PROPERTY_CHANGED:
                 child = lookupEntry(childEvent.getItemId(), childEvent.getQPath());
-                if (child != null) {
+                if (child == null) {
+                    // prop-Entry has not been loaded yet -> add propEntry
+                    internalAddPropertyEntry(eventName);
+                } else if (child.isAvailable()) {
                     // 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.
@@ -892,17 +905,13 @@
                     if (StateUtility.isUuidOrMixin(eventName)) {
                         notifyUUIDorMIXINModified((PropertyEntry) child);
                     }
-                } else {
-                    // prop-Entry has not been loaded yet -> add propEntry
-                    internalAddPropertyEntry(eventName);
-                }
+                } // else: existing entry but state not yet built -> ignore event
                 break;
             default:
                 // ILLEGAL
                 throw new IllegalArgumentException("Illegal event type " + childEvent.getType()
+ " for NodeState.");
         }
     }
-
     //-------------------------------------------------< HierarchyEntryImpl >---
     /**
      * @inheritDoc
@@ -1130,91 +1139,82 @@
      *
      * @return
      */
-    private ChildNodeEntries childNodeEntries() {
-        if (childNodeEntries == null) {
-            loadChildNodeEntries();
-        } else if (childNodeEntries.getStatus() == ChildNodeEntries.STATUS_INVALIDATED) {
-            reloadChildNodeEntries(childNodeEntries);
-            childNodeEntries.setStatus(ChildNodeEntries.STATUS_OK);
+    private ChildNodeEntries childNodeEntries() throws InvalidItemStateException, RepositoryException
{
+        try {
+            if (childNodeEntries == null) {
+                childNodeEntries = new ChildNodeEntries(this);
+                loadChildNodeEntries();
+            } else if (childNodeEntries.getStatus() == ChildNodeEntries.STATUS_INVALIDATED)
{
+                reloadChildNodeEntries(childNodeEntries);
+                childNodeEntries.setStatus(ChildNodeEntries.STATUS_OK);
+            }
+        } catch (ItemNotFoundException e) {
+            log.debug("NodeEntry does not exist (anymore) -> remove.");
+            remove();
+            throw new InvalidItemStateException(e);
         }
         return childNodeEntries;
     }
 
-    private void loadChildNodeEntries() {
-        try {
-            childNodeEntries = new ChildNodeEntries(this);
-            if (getStatus() == Status.NEW || Status.isTerminal(getStatus())) {
-                return; // cannot retrieve child-entries from persistent layer
-            }
+    private void loadChildNodeEntries() throws ItemNotFoundException, RepositoryException
{
 
-            NodeId id = getWorkspaceId();
-            Iterator it = factory.getItemStateFactory().getChildNodeInfos(id);
-            // simply add all child entries to the empty collection
-            while (it.hasNext()) {
-                ChildInfo ci = (ChildInfo) it.next();
-                internalAddNodeEntry(ci.getName(), ci.getUniqueID(), ci.getIndex(), childNodeEntries);
-            }
-        } catch (ItemNotFoundException e) {
-            log.error("Cannot retrieve child node entries.", e);
-            // ignore (TODO correct?)
-        } catch (RepositoryException e) {
-            log.error("Cannot retrieve child node entries.", e);
-            // ignore (TODO correct?)
+        if (getStatus() == Status.NEW || Status.isTerminal(getStatus())) {
+            return; // cannot retrieve child-entries from persistent layer
+        }
+
+        NodeId id = getWorkspaceId();
+        Iterator it = factory.getItemStateFactory().getChildNodeInfos(id);
+        // simply add all child entries to the empty collection
+        while (it.hasNext()) {
+            ChildInfo ci = (ChildInfo) it.next();
+            internalAddNodeEntry(ci.getName(), ci.getUniqueID(), ci.getIndex(), childNodeEntries);
         }
     }
 
-    private void reloadChildNodeEntries(ChildNodeEntries cnEntries) {
+    private void reloadChildNodeEntries(ChildNodeEntries cnEntries) throws ItemNotFoundException,
RepositoryException {
         if (getStatus() == Status.NEW || Status.isTerminal(getStatus())) {
             // nothing to do
             return;
         }
-        try {
-            NodeId id = getWorkspaceId();
-            Iterator it = factory.getItemStateFactory().getChildNodeInfos(id);
-            // create list from all ChildInfos (for multiple loop)
-            List cInfos = new ArrayList();
-            while (it.hasNext()) {
-                cInfos.add((ChildInfo) it.next());
-            }
-            // first make sure the ordering of all existing entries is ok
-            NodeEntry entry = null;
-            for (it = cInfos.iterator(); it.hasNext();) {
-                ChildInfo ci = (ChildInfo) it.next();
-                NodeEntry nextEntry = cnEntries.get(ci);
-                if (nextEntry != null) {
-                    if (entry != null) {
-                        cnEntries.reorder(entry, nextEntry);
-                    }
-                    entry = nextEntry;
-                }
-            }
-            // then insert the 'new' entries
-            List newEntries = new ArrayList();
-            for (it = cInfos.iterator(); it.hasNext();) {
-                ChildInfo ci = (ChildInfo) it.next();
-                NodeEntry beforeEntry = cnEntries.get(ci);
-                if (beforeEntry == null) {
-                    NodeEntry ne = new NodeEntryImpl(this, ci.getName(), ci.getUniqueID(),
factory);
-                    newEntries.add(ne);
-                } else {
-                    // insert all new entries from the list BEFORE the existing
-                    // 'nextEntry'. Then clear the list.
-                    for (int i = 0; i < newEntries.size(); i++) {
-                        cnEntries.add((NodeEntry) newEntries.get(i), beforeEntry);
-                    }
-                    newEntries.clear();
+        NodeId id = getWorkspaceId();
+        Iterator it = factory.getItemStateFactory().getChildNodeInfos(id);
+        // create list from all ChildInfos (for multiple loop)
+        List cInfos = new ArrayList();
+        while (it.hasNext()) {
+            cInfos.add((ChildInfo) it.next());
+        }
+        // first make sure the ordering of all existing entries is ok
+        NodeEntry entry = null;
+        for (it = cInfos.iterator(); it.hasNext();) {
+            ChildInfo ci = (ChildInfo) it.next();
+            NodeEntry nextEntry = cnEntries.get(ci);
+            if (nextEntry != null) {
+                if (entry != null) {
+                    cnEntries.reorder(entry, nextEntry);
+                }
+                entry = nextEntry;
+            }
+        }
+        // then insert the 'new' entries
+        List newEntries = new ArrayList();
+        for (it = cInfos.iterator(); it.hasNext();) {
+            ChildInfo ci = (ChildInfo) it.next();
+            NodeEntry beforeEntry = cnEntries.get(ci);
+            if (beforeEntry == null) {
+                NodeEntry ne = new NodeEntryImpl(this, ci.getName(), ci.getUniqueID(), factory);
+                newEntries.add(ne);
+            } else {
+                // insert all new entries from the list BEFORE the existing
+                // 'nextEntry'. Then clear the list.
+                for (int i = 0; i < newEntries.size(); i++) {
+                    cnEntries.add((NodeEntry) newEntries.get(i), beforeEntry);
                 }
+                newEntries.clear();
             }
-            // deal with new entries at the end
-            for (int i = 0; i < newEntries.size(); i++) {
-                cnEntries.add((NodeEntry) newEntries.get(i));
-            }
-        } catch (ItemNotFoundException e) {
-            log.error("Cannot retrieve child node entries.", e);
-            // ignore (TODO correct?)
-        } catch (RepositoryException e) {
-            log.error("Cannot retrieve child node entries.", e);
-            // ignore (TODO correct?)
+        }
+        // deal with new entries at the end
+        for (int i = 0; i < newEntries.size(); i++) {
+            cnEntries.add((NodeEntry) newEntries.get(i));
         }
     }
 
@@ -1259,7 +1259,7 @@
      * @throws ItemNotFoundException if the given entry isn't a valid child of
      * this <code>NodeEntry</code>.
      */
-    private int getChildIndex(NodeEntry cne) throws ItemNotFoundException {
+    private int getChildIndex(NodeEntry cne) throws ItemNotFoundException, RepositoryException
{
         List sns = childNodeEntries().get(cne.getQName());
         // index is one based
         int index = Path.INDEX_DEFAULT;
@@ -1291,7 +1291,7 @@
     /**
      * Special handling for MOVE and REORDER with same-name-siblings
      */
-    private void createSiblingRevertInfos() {
+    private void createSiblingRevertInfos() throws RepositoryException {
         if (revertInfo != null) {
             return; // nothing to do
         }
@@ -1311,7 +1311,7 @@
     /**
      * Revert a transient move and reordering of child entries
      */
-    private void revertTransientChanges() {
+    private void revertTransientChanges() throws RepositoryException {
         if (revertInfo == null) {
             return; // nothing to do
         }
@@ -1464,7 +1464,11 @@
                     // stop listening
                     state.removeListener(this);
                     // remove from the attic
-                    revertTransientChanges();
+                    try {
+                        revertTransientChanges();
+                    } catch (RepositoryException e) {
+                        log.warn("Internal error", e);
+                    }
                     break;
             }
         }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddLabel.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddLabel.java?view=diff&rev=523326&r1=523325&r2=523326
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddLabel.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddLabel.java
Wed Mar 28 06:50:25 2007
@@ -79,9 +79,13 @@
      */
     public void persisted(CacheBehaviour cacheBehaviour) {
         if (cacheBehaviour == CacheBehaviour.INVALIDATE) {
-            NodeEntry vhEntry = (NodeEntry) versionHistoryState.getHierarchyEntry();
-            NodeEntry lnEntry = vhEntry.getNodeEntry(QName.JCR_VERSIONLABELS, Path.INDEX_DEFAULT);
-            lnEntry.invalidate(moveLabel);
+            try {
+                NodeEntry vhEntry = (NodeEntry) versionHistoryState.getHierarchyEntry();
+                NodeEntry lnEntry = vhEntry.getNodeEntry(QName.JCR_VERSIONLABELS, Path.INDEX_DEFAULT);
+                lnEntry.invalidate(moveLabel);
+            } catch (RepositoryException e) {
+                log.debug(e.getMessage());
+            }
         }
     }
     //----------------------------------------< Access Operation Parameters >---

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Operation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Operation.java?view=diff&rev=523326&r1=523325&r2=523326
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Operation.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Operation.java
Wed Mar 28 06:50:25 2007
@@ -56,12 +56,7 @@
     public Collection getAffectedItemStates();
 
     /**
-     * In case of {@link CacheBehaviour#INVALIDATE}
-     * the result of the operation will not be pushed by observation events.
-     * Instead the workspace operations must make sure, that the affected
-     * item states are properly refreshed or invalidated.
-     *
-     * @param cacheBehaviour
+     * Informs this Operation that it has been successfully executed.
      */
     public void persisted(CacheBehaviour cacheBehaviour);
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveLabel.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveLabel.java?view=diff&rev=523326&r1=523325&r2=523326
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveLabel.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveLabel.java
Wed Mar 28 06:50:25 2007
@@ -76,9 +76,13 @@
      */
     public void persisted(CacheBehaviour cacheBehaviour) {
         if (cacheBehaviour == CacheBehaviour.INVALIDATE) {
-            NodeEntry vhEntry = (NodeEntry) versionHistoryState.getHierarchyEntry();
-            NodeEntry lnEntry = vhEntry.getNodeEntry(QName.JCR_VERSIONLABELS, Path.INDEX_DEFAULT);
-            lnEntry.invalidate(true);
+            try {
+                NodeEntry vhEntry = (NodeEntry) versionHistoryState.getHierarchyEntry();
+                NodeEntry lnEntry = vhEntry.getNodeEntry(QName.JCR_VERSIONLABELS, Path.INDEX_DEFAULT);
+                lnEntry.invalidate(true);
+            } catch (RepositoryException e) {
+                log.debug(e.getMessage());
+            }
         }
     }
 

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=523326&r1=523325&r2=523326
==============================================================================
--- 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 Mar 28 06:50:25 2007
@@ -468,7 +468,7 @@
      * <code>beforeNode</code> is not a child node of this <code>NodeState</code>.
      */
     synchronized void reorderChildNodeEntries(NodeState insertNode, NodeState beforeNode)
-        throws ItemNotFoundException {
+        throws ItemNotFoundException, RepositoryException {
         checkIsSessionState();
 
         NodeEntry before = (beforeNode == null) ? null : beforeNode.getNodeEntry();

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java?view=diff&rev=523326&r1=523325&r2=523326
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
Wed Mar 28 06:50:25 2007
@@ -98,7 +98,7 @@
      */
     NodeState createNewNodeState(QName nodeName, String uniqueID, QName nodeTypeName,
                                  QNodeDefinition definition, NodeState parent)
-        throws ItemExistsException {
+            throws RepositoryException {
 
         parent.checkIsSessionState();
         NodeState nodeState = ((NodeEntry) parent.getHierarchyEntry()).addNewNodeEntry(nodeName,
uniqueID, nodeTypeName, definition);

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java?view=diff&rev=523326&r1=523325&r2=523326
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
Wed Mar 28 06:50:25 2007
@@ -60,7 +60,7 @@
 
     public VersionHistoryImpl(ItemManager itemMgr, SessionImpl session,
                               NodeState state, ItemLifeCycleListener[] listeners)
-        throws VersionException {
+        throws VersionException, RepositoryException {
         super(itemMgr, session, state, listeners);
         this.vhEntry = (NodeEntry) state.getHierarchyEntry();
 



Mime
View raw message