jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r433630 - /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
Date Tue, 22 Aug 2006 13:49:59 GMT
Author: mreutegg
Date: Tue Aug 22 06:49:59 2006
New Revision: 433630

URL: http://svn.apache.org/viewvc?rev=433630&view=rev
Log:
- Remove status from ItemImpl and use status in ItemState
- Fixed ItemImpl.isSame(). ItemState always has an overlayed state.

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.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=433630&r1=433629&r2=433630&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
Tue Aug 22 06:49:59 2006
@@ -63,12 +63,6 @@
 
     private static Logger log = LoggerFactory.getLogger(ItemImpl.class);
 
-    protected static final int STATUS_NORMAL = 0;
-    protected static final int STATUS_MODIFIED = 1;
-    protected static final int STATUS_DESTROYED = 2;
-    protected static final int STATUS_INVALIDATED = 3;
-
-    private int status;
     private ItemState state;
 
     // protected fields for VersionImpl and VersionHistoryImpl
@@ -86,7 +80,6 @@
 
         this.itemMgr = itemManager;
         this.state = state;
-        status = STATUS_NORMAL;
 
         if (listeners != null) {
             for (int i = 0; i < listeners.length; i++) {
@@ -172,22 +165,14 @@
      * @see javax.jcr.Item#isNew()
      */
     public boolean isNew() {
-        // short-cut: read-only implementations always return false.
-        if (!isSupportedOption(Repository.LEVEL_2_SUPPORTED)) {
-            return false;
-        }
-        return state.isTransient() && state.getOverlayedState() == null;
+        return state.getStatus() == ItemState.STATUS_NEW;
     }
 
     /**
      * @see javax.jcr.Item#isModified()
      */
     public boolean isModified() {
-        // short-cut: read-only implementations always return false.
-        if (!isSupportedOption(Repository.LEVEL_2_SUPPORTED)) {
-            return false;
-        }
-        return state.isTransient() && state.getOverlayedState() != null;
+        return state.getStatus() == ItemState.STATUS_EXISTING_MODIFIED;
     }
 
     /**
@@ -199,15 +184,17 @@
         }
         if (otherItem instanceof ItemImpl) {
             ItemImpl other = (ItemImpl) otherItem;
+            if (this.state == other.state) {
+                return true;
+            }
             // 2 items may only be the same if the were accessed from Sessions
             // bound to the same workspace
             String otherWspName = other.session.getWorkspace().getName();
             if (session.getWorkspace().getName().equals(otherWspName)) {
                 // in addition they must provide the same id irrespective of
                 // any transient modifications.
-                // TODO: TO_BE_FIXED check if this is sufficient check (SPI-id)
-                ItemId thisId = (state.hasOverlayedState()) ? state.getOverlayedState().getId()
: state.getId();
-                ItemId otherId = (other.getItemState().hasOverlayedState()) ? other.getItemState().getOverlayedState().getId()
: other.getItemState().getId();
+                ItemId thisId = state.getOverlayedState().getId();
+                ItemId otherId = other.state.getOverlayedState().getId();
                 return thisId.equals(otherId);
             }
         }
@@ -294,7 +281,6 @@
      * {@inheritDoc}
      */
     public void stateCreated(ItemState created) {
-        status = STATUS_NORMAL;
     }
 
     /**
@@ -303,8 +289,6 @@
     public void stateDestroyed(ItemState destroyed) {
         // underlying state has been permanently destroyed
 
-        // set state of this instance to 'destroyed'
-        status = STATUS_DESTROYED;
         // dispose state
         if (state == destroyed) {
             state.removeListener(this);
@@ -321,7 +305,6 @@
      * {@inheritDoc}
      */
     public void stateModified(ItemState modified) {
-        status = STATUS_MODIFIED;
     }
 
     /**
@@ -374,8 +357,6 @@
                      * permanently invalidated
                      */
                     notifyDestroyed();
-                    // now set state of this instance to 'destroyed'
-                    status = STATUS_DESTROYED;
                     // finally dispose state
                     state.removeListener(this);
                     state = null;
@@ -390,8 +371,6 @@
                      * permanently invalidated
                      */
                     notifyDestroyed();
-                    // now set state of this instance to 'destroyed'
-                    status = STATUS_DESTROYED;
                     // finally dispose state
                     state.removeListener(this);
                     state = null;
@@ -404,8 +383,6 @@
          * invalidated
          */
         notifyInvalidated();
-        // now render this instance 'invalid'
-        status = STATUS_INVALIDATED;
     }
 
     //----------------------------------------------------------< LiveCycle >---
@@ -480,14 +457,8 @@
         // check session status
         session.checkIsAlive();
         // check status of this item for read operation
-        switch (status) {
-            case STATUS_NORMAL:
-            case STATUS_MODIFIED:
-                return;
-
-            case STATUS_DESTROYED:
-            case STATUS_INVALIDATED:
-                throw new InvalidItemStateException("Item '" + getPath() + "' doesn't exist
anymore");
+        if (state == null || !state.isValid()) {
+            throw new InvalidItemStateException("Item '" + getPath() + "' doesn't exist anymore");
         }
     }
 



Mime
View raw message