jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r433998 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ state/
Date Wed, 23 Aug 2006 09:56:27 GMT
Author: mreutegg
Date: Wed Aug 23 02:56:24 2006
New Revision: 433998

URL: http://svn.apache.org/viewvc?rev=433998&view=rev
Log:
- Use ItemStateLifeCycleListener instead of ItemStateListener in ItemImpl.
- Remove usage of ItemState.dispose() and the method itself.
- Remove method ItemStateListener.stateDiscarded() and all implementations of that method.
- Remove unused methods in ChangeLog: disconnect() and undo()
- Remove ItemState.discard() and related methods
- Rename ItemState.copy() to ItemState.copyFrom()
- Remove ItemState.STATUS_UNDEFINED. An ItemState always has a defined status!
- Rename TransientItemStateManager.disposeAllItemStates() to simply dispose().
- Introduce method ItemState.refresh() which is called instead of discard(). (Not yet implemented!)
- Clarify useage of WorkspaceManager.onEventReceived()

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
    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/state/CachingItemStateManager.java
    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/ItemState.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateListener.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/PropertyState.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.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/state/WorkspaceItemStateManager.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?rev=433998&r1=433997&r2=433998&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
Wed Aug 23 02:56:24 2006
@@ -23,7 +23,7 @@
 import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
-import org.apache.jackrabbit.jcr2spi.state.ItemStateListener;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateLifeCycleListener;
 import org.apache.jackrabbit.jcr2spi.operation.Remove;
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
@@ -59,7 +59,7 @@
  * <code>ItemImpl</code>...
  * TODO: remove status in ItemImpl and ask item state for status!
  */
-public abstract class ItemImpl implements Item, ItemStateListener {
+public abstract class ItemImpl implements Item, ItemStateLifeCycleListener {
 
     private static Logger log = LoggerFactory.getLogger(ItemImpl.class);
 
@@ -276,7 +276,7 @@
         session.getSessionItemStateManager().execute(rm);
     }
 
-    //--------------------------------------------------< ItemStateListener >---
+    //-----------------------------------------< ItemStateLifeCycleListener >---
     /**
      * {@inheritDoc}
      */
@@ -307,82 +307,41 @@
     public void stateModified(ItemState modified) {
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void stateDiscarded(ItemState discarded) {
-        /**
-         * the state of this item has been discarded, probably as a result
-         * of calling Node.revert() or ItemImpl.setRemoved()
-         */
-        if (isTransient()) {
-            switch (state.getStatus()) {
-                /**
-                 * persistent item that has been transiently removed
-                 */
-                case ItemState.STATUS_EXISTING_REMOVED:
-                    /**
-                     * persistent item that has been transiently modified
-                     */
-                case ItemState.STATUS_EXISTING_MODIFIED:
-                    /**
-                     * persistent item that has been transiently modified or removed
-                     * and the underlying persistent state has been externally
-                     * modified since the transient modification/removal.
-                     */
-                case ItemState.STATUS_STALE_MODIFIED:
-                    ItemState persistentState = state.getOverlayedState();
-                    /**
-                     * the state is a transient wrapper for the underlying
-                     * persistent state, therefore restore the
-                     * persistent state and resurrect this item instance
-                     * if necessary
-                     */
-                    // DIFF JACKRABBIT: this is now done in stateUncovering()
-//                    state.removeListener(this);
-//                    persistentState.addListener(this);
-//                    itemStateMgr.disconnectTransientItemState(state);
-//                    state = persistentState;
-
-                    return;
-
-                    /**
-                     * persistent item that has been transiently modified or removed
-                     * and the underlying persistent state has been externally
-                     * destroyed since the transient modification/removal.
-                     */
-                case ItemState.STATUS_STALE_DESTROYED:
-                    /**
-                     * first notify the listeners that this instance has been
-                     * permanently invalidated
-                     */
-                    notifyDestroyed();
-                    // finally dispose state
-                    state.removeListener(this);
-                    state = null;
-                    return;
-
-                    /**
-                     * new item that has been transiently added
-                     */
-                case ItemState.STATUS_NEW:
-                    /**
-                     * first notify the listeners that this instance has been
-                     * permanently invalidated
-                     */
-                    notifyDestroyed();
-                    // finally dispose state
-                    state.removeListener(this);
-                    state = null;
-                    return;
-            }
+    public void statusChanged(ItemState state, int previousStatus) {
+        // TODO: remove this ItemImpl as listener from ItemState when it is destroyed?
+        switch (state.getStatus()) {
+            case ItemState.STATUS_EXISTING:
+                // this item was modified and is now reverted or has been saved
+                // -> nothing to do
+                break;
+            case ItemState.STATUS_EXISTING_MODIFIED:
+                // item was modified and is not existing-modified
+                // -> nothing to do
+                break;
+            case ItemState.STATUS_EXISTING_REMOVED:
+                // item is transiently removed
+                // notify listeners of this item that this item has been destroyed
+                notifyDestroyed();
+                break;
+            case ItemState.STATUS_NEW:
+                // should never happen. an item cannot change its state to new
+                log.warn("invalid state change to STATUS_NEW");
+                break;
+            case ItemState.STATUS_REMOVED:
+                // item has been removed permanently
+                notifyDestroyed();
+                break;
+            case ItemState.STATUS_STALE_DESTROYED:
+                // item has been removed permanently while there were transient
+                // changes pending
+                notifyDestroyed();
+                break;
+            case ItemState.STATUS_STALE_MODIFIED:
+                // item has been modified externaly while there were transient
+                // changes pending
+                // -> nothing to do
+                break;
         }
-
-        /**
-         * first notify the listeners that this instance has been
-         * invalidated
-         */
-        notifyInvalidated();
     }
 
     //----------------------------------------------------------< LiveCycle >---

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?rev=433998&r1=433997&r2=433998&view=diff
==============================================================================
--- 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 Aug 23 02:56:24 2006
@@ -270,7 +270,8 @@
         if (Boolean.getBoolean(desc)) {
             l = new EventListener() {
                 public void onEvent(EventIterator events) {
-                    onEventReceived(null, events, false); // external
+                    // external change
+                    onEventReceived(null, events);
                 }
             };
             int allTypes = Event.NODE_ADDED | Event.NODE_REMOVED |
@@ -461,15 +462,32 @@
 
     /**
      * Called when local or external events occured. This method is called after
-     * changes have been applied to the repository.
+     * changes have been applied to the repository. Depending on <code>changeLog</code>
+     * this method is called as a result of:
+     * <ul>
+     * <li>a local <code>save</code> of transient changes. In this case
+     * <code>changeLog</code> is non-<code>null</code>.</li>
+     * <li>an execution of a workspace operation. In this case
+     * <code>changeLog</code> is <code>null</code></li>
+     * <li>an external change to the workspace (another session modified the
+     * workspace). In this case <code>changeLog</code> is <code>null</code></li>
+     * </ul>
      *
-     * @param changeLog
-     * @param events the events.
-     * @param isLocal <code>true</code> if changes were local.
+     * @param changeLog the local <code>ChangeLog</code> which contains the
+     *                  affected transient <code>ItemState</code>s and the
+     *                  relevant {@link Operation}s that lead to the
+     *                  modifications. If <code>null</code> this method is
+     *                  called as a consequence of an external change or a call
+     *                  of a workspace operation. In that case there are no
+     *                  local transient changes.
+     * @param events    the events generated by the repository service as a
+     *                  response to the changes.
      */
-    private void onEventReceived(ChangeLog changeLog, EventIterator events, boolean isLocal)
{
+    private void onEventReceived(ChangeLog changeLog, EventIterator events) {
         if (changeLog != null) {
-            // use current change log for notification
+            // now we need to apply the transient changes in changeLog to
+            // the ItemStates in the workspace layer
+            changeLog.push();
             changeLog.persisted();
         }
 
@@ -483,7 +501,7 @@
 
         InternalEventListener[] lstnrs = (InternalEventListener[]) listeners.toArray(new
InternalEventListener[listeners.size()]);
         for (int i = 0; i < lstnrs.length; i++) {
-           lstnrs[i].onEvent(new EventIteratorImpl(eventList), isLocal);
+           lstnrs[i].onEvent(new EventIteratorImpl(eventList), changeLog != null);
         }
     }
 
@@ -520,7 +538,7 @@
             } finally {
                 if (batch != null) {
                     EventIterator events = service.submit(batch);
-                    onEventReceived(changeLog, events, true);
+                    onEventReceived(changeLog, events);
                     // reset batch field
                     batch = null;
                 }
@@ -538,7 +556,8 @@
                 success = true;
             } finally {
                 if (success && events != null) {
-                    onEventReceived(null, events, true);
+                    // a workspace operation is like an external change
+                    onEventReceived(null, events);
                 }
             }
         }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java?rev=433998&r1=433997&r2=433998&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java
Wed Aug 23 02:56:24 2006
@@ -270,8 +270,5 @@
 
         public void stateDestroyed(ItemState destroyed) {
         }
-
-        public void stateDiscarded(ItemState discarded) {
-        }
     }
 }

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=433998&r1=433997&r2=433998&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
Wed Aug 23 02:56:24 2006
@@ -284,20 +284,19 @@
         while (iter.hasNext()) {
             ItemState state = (ItemState) iter.next();
             state.setStatus(ItemState.STATUS_EXISTING);
-            state.notifyStateUpdated();
+            state.notifyStateUpdated();  // TODO: is this needed anymore?
         }
         iter = deletedStates();
         while (iter.hasNext()) {
             ItemState state = (ItemState) iter.next();
-            state.setStatus(ItemState.STATUS_EXISTING_REMOVED);
-            state.notifyStateDestroyed();
-            state.discard();
+            state.setStatus(ItemState.STATUS_REMOVED);
+            state.notifyStateDestroyed();  // TODO: is this needed anymore?
         }
         iter = addedStates();
         while (iter.hasNext()) {
             ItemState state = (ItemState) iter.next();
             state.setStatus(ItemState.STATUS_EXISTING);
-            state.notifyStateCreated();
+            state.notifyStateCreated();  // TODO: is this needed anymore?
         }
     }
 
@@ -312,60 +311,6 @@
         modifiedRefs.clear();
         // also clear all operations
         operations.clear();
-    }
-
-    /**
-     * Disconnect all states in the change log from their overlaid
-     * states.
-     */
-    public void disconnect() {
-        Iterator iter = modifiedStates();
-        while (iter.hasNext()) {
-            ((ItemState) iter.next()).disconnect();
-        }
-        iter = deletedStates();
-        while (iter.hasNext()) {
-            ((ItemState) iter.next()).disconnect();
-        }
-        iter = addedStates();
-        while (iter.hasNext()) {
-            ((ItemState) iter.next()).disconnect();
-        }
-    }
-
-    /**
-     * Undo changes made to items in the change log. Discards
-     * added items, refreshes modified and resurrects deleted
-     * items.
-     *
-     * @param parent parent manager that will hold current data
-     */
-    public void undo(ItemStateManager parent) {
-        Iterator iter = modifiedStates();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
-            try {
-                state.connect(parent.getItemState(state.getId()));
-                state.pull();
-            } catch (ItemStateException e) {
-                state.discard();
-            }
-        }
-        iter = deletedStates();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
-            try {
-                state.connect(parent.getItemState(state.getId()));
-                state.pull();
-            } catch (ItemStateException e) {
-                state.discard();
-            }
-        }
-        iter = addedStates();
-        while (iter.hasNext()) {
-            ((ItemState) iter.next()).discard();
-        }
-        reset();
     }
 
     //-------------------------------------------------------------< Object >---

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java?rev=433998&r1=433997&r2=433998&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
Wed Aug 23 02:56:24 2006
@@ -37,10 +37,6 @@
 
      //----------------< flags defining the current status of this instance >---
     /**
-     * the status is undefined
-     */
-    public static final int STATUS_UNDEFINED = 0;
-    /**
      * 'existing', i.e. persistent state
      */
     public static final int STATUS_EXISTING = 1;
@@ -73,7 +69,7 @@
     /**
      * the internal status of this item state
      */
-    protected int status = STATUS_UNDEFINED;
+    protected int status;
 
     /**
      * Flag indicating whether this state is transient
@@ -158,14 +154,14 @@
      * Copy state information from another state into this state
      * @param state source state information
      */
-    abstract void copy(ItemState state);
+    abstract void copyFrom(ItemState state);
 
     /**
      * Pull state information from overlayed state.
      */
     void pull() {
         if (overlayedState != null) {
-            copy(overlayedState);
+            copyFrom(overlayedState);
         }
     }
 
@@ -174,21 +170,7 @@
      */
     void push() {
         if (overlayedState != null) {
-            overlayedState.copy(this);
-        }
-    }
-
-    /**
-     * Called by <code>TransientItemStateManager</code> and
-     * <code>LocalItemStateManager</code> when this item state has been disposed.
-     */
-    void onDisposed() {
-        disconnect();
-        overlayedState = null;
-        setStatus(STATUS_UNDEFINED);
-        // prepare this instance so it can be gc'ed
-        synchronized (listeners) {
-            listeners.clear();
+            overlayedState.copyFrom(this);
         }
     }
 
@@ -227,34 +209,12 @@
         }
     }
 
-
-    /**
-     * Discards this instance, i.e. renders it 'invalid'.
-     */
-    protected void discard() {
-        if (status != STATUS_UNDEFINED) {
-            // notify listeners
-            notifyStateDiscarded();
-            // reset status
-            setStatus(STATUS_UNDEFINED);
-        }
-    }
-
     /**
-     * Notify the listeners that the persistent state this object is
-     * representing has been discarded.
+     * Refreshes this item state
      */
-    protected void notifyStateDiscarded() {
-        // copy listeners to array to avoid ConcurrentModificationException
-        ItemStateListener[] la;
-        synchronized (listeners) {
-            la = (ItemStateListener[]) listeners.toArray(new ItemStateListener[listeners.size()]);
-        }
-        for (int i = 0; i < la.length; i++) {
-            if (la[i] != null) {
-                la[i].stateDiscarded(this);
-            }
-        }
+    protected void refresh() {
+        // TODO: how is this done? where is the new state retrieved from???
+        // TODO: pass in as argument?
     }
 
     /**
@@ -345,7 +305,6 @@
                 // is stale anyway.
                 break;
             case STATUS_EXISTING_REMOVED:
-            case STATUS_UNDEFINED:
             default:
                 String msg = "Cannot mark item state with status " + status + " modified.";
                 throw new IllegalStateException(msg);
@@ -431,7 +390,6 @@
             case STATUS_EXISTING_MODIFIED:
             case STATUS_STALE_MODIFIED:
             case STATUS_STALE_DESTROYED:
-            case STATUS_UNDEFINED:
                 status = newStatus;
                 break;
             default:
@@ -557,13 +515,5 @@
                 notifyStateUpdated();
             }
         }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void stateDiscarded(ItemState discarded) {
-        // underlying persistent state has been discarded, discard this instance too
-        discard();
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateListener.java?rev=433998&r1=433997&r2=433998&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateListener.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateListener.java
Wed Aug 23 02:56:24 2006
@@ -47,13 +47,4 @@
      * @param destroyed the <code>ItemState</code> that has been 'destroyed'
      */
     void stateDestroyed(ItemState destroyed);
-
-    /**
-     * Called when an <code>ItemState</code> has been discarded (i.e. it has
-     * been rendered 'invalid').
-     *
-     * @param discarded the <code>ItemState</code> that has been discarded
-     * @see ItemState#discard
-     */
-    void stateDiscarded(ItemState discarded);
 }

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?rev=433998&r1=433997&r2=433998&view=diff
==============================================================================
--- 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 Aug 23 02:56:24 2006
@@ -172,7 +172,7 @@
     /**
      * {@inheritDoc}
      */
-    protected synchronized void copy(ItemState state) {
+    protected synchronized void copyFrom(ItemState state) {
         synchronized (state) {
             NodeState nodeState = (NodeState) state;
             name = nodeState.name;

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java?rev=433998&r1=433997&r2=433998&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
Wed Aug 23 02:56:24 2006
@@ -164,7 +164,7 @@
     /**
      * {@inheritDoc}
      */
-    protected synchronized void copy(ItemState state) {
+    protected synchronized void copyFrom(ItemState state) {
         synchronized (state) {
             PropertyState propState = (PropertyState) state;
             name = propState.name;

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=433998&r1=433997&r2=433998&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
Wed Aug 23 02:56:24 2006
@@ -228,7 +228,7 @@
      */
     public void dispose() {
         // discard all transient changes
-        transientStateMgr.disposeAllItemStates();
+        transientStateMgr.dispose();
         // dispose our (i.e. 'local') state manager
         workspaceItemStateMgr.dispose();
     }
@@ -387,12 +387,6 @@
                             log.debug(msg);
                             throw new StaleItemStateException(msg);
                         }
-                    case ItemState.STATUS_UNDEFINED:
-                        {
-                            String msg = LogUtil.safeGetJCRPath(state, nsResolver, hierMgr)
+ ": the item cannot be saved; it seems to have been removed externally.";
-                            log.debug(msg);
-                            throw new StaleItemStateException(msg);
-                        }
                 }
             }
         }
@@ -425,12 +419,6 @@
                 case ItemState.STATUS_STALE_DESTROYED:
                     if (throwOnStale) {
                         String msg = transientState.getId() + ": the item cannot be saved
because it has been deleted externally.";
-                        log.debug(msg);
-                        throw new StaleItemStateException(msg);
-                    }
-                case ItemState.STATUS_UNDEFINED:
-                    if (throwOnStale) {
-                        String msg = transientState.getId() + ": the item cannot be saved;
it seems to have been removed externally.";
                         log.debug(msg);
                         throw new StaleItemStateException(msg);
                     }

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?rev=433998&r1=433997&r2=433998&view=diff
==============================================================================
--- 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 Aug 23 02:56:24 2006
@@ -252,18 +252,10 @@
     }
 
     /**
-     * Disposes all transient item states in the cache and in the attic.
+     * Disposes this transient item state manager. Clears all references to
+     * transiently modified item states.
      */
-    public void disposeAllItemStates() {
-        IteratorChain it = new IteratorChain();
-        it.addIterator(changeLog.modifiedStates());
-        it.addIterator(changeLog.addedStates());
-        it.addIterator(changeLog.deletedStates());
-        while (it.hasNext()) {
-            ItemState state = (ItemState) it.next();
-            state.discard();
-            state.onDisposed();
-        }
+    public void dispose() {
         changeLog.reset();
     }
 
@@ -334,14 +326,6 @@
 
     /**
      * @inheritDoc
-     * @see ItemStateListener#stateDiscarded(ItemState)
-     */
-    public void stateDiscarded(ItemState discarded) {
-        // TODO: remove from modified (and deleted?) set of change log
-    }
-
-    /**
-     * @inheritDoc
      * @see ItemStateLifeCycleListener#statusChanged(ItemState, int)
      */
     public void statusChanged(ItemState state, int previousStatus) {
@@ -395,10 +379,6 @@
             case ItemState.STATUS_NEW:
                 // new state has been created
                 changeLog.added(state);
-                break;
-            case ItemState.STATUS_UNDEFINED:
-                // should never happen
-                log.warn("ItemState changed status to 'undefined'");
                 break;
             default:
                 log.warn("ItemState has invalid status: " + state.getStatus());

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateManager.java?rev=433998&r1=433997&r2=433998&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateManager.java
Wed Aug 23 02:56:24 2006
@@ -76,12 +76,12 @@
                     if (state != null) {
                         // TODO: item already exists ???
                         // invalidate
-                        state.discard();
+                        state.refresh();
                     }
                     parent = (NodeState) lookup(parentId);
                     if (parent != null) {
                         // discard and let wsp manager reload state when accessed next time
-                        parent.discard();
+                        parent.refresh();
                     }
                     break;
                 case Event.NODE_REMOVED:
@@ -98,7 +98,7 @@
                             // do not invalidate here
                         } else {
                             // discard and let wsp manager reload state when accessed next
time
-                            parent.discard();
+                            parent.refresh();
                         }
                     }
                     break;
@@ -106,7 +106,7 @@
                     state = lookup(itemId);
                     // discard and let wsp manager reload state when accessed next time
                     if (state != null) {
-                        state.discard();
+                        state.refresh();
                     }
             }
         }



Mime
View raw message