jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r520315 [2/2] - in /jackrabbit/trunk/contrib/spi/jcr2spi: ./ src/main/java/org/apache/jackrabbit/jcr2spi/ src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ src/main/java/org/apache/jackrabbit/jcr2spi/lock/ src/main/java/org/apache/jack...
Date Tue, 20 Mar 2007 08:22:25 GMT
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?view=diff&rev=520315&r1=520314&r2=520315
==============================================================================
--- 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
Tue Mar 20 01:22:22 2007
@@ -55,7 +55,6 @@
 import org.apache.jackrabbit.uuid.UUID;
 
 import javax.jcr.InvalidItemStateException;
-import javax.jcr.ItemNotFoundException;
 import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.RepositoryException;
 import javax.jcr.AccessDeniedException;
@@ -130,7 +129,7 @@
      * @param state the root state of the update operation
      */
     public void save(ItemState state) throws ReferentialIntegrityException,
-        RepositoryException, StaleItemStateException, ItemStateException {
+            InvalidItemStateException, RepositoryException {
         // shortcut, if no modifications are present
         if (!hasPendingChanges()) {
             return;
@@ -155,18 +154,26 @@
      * items of <code>state</code> inside this item state manager.
      *
      * @param itemState the root state of the cancel operation.
-     * @throws ItemStateException if undoing changes made to <code>state</code>
+     * @throws ConstraintViolationException
+     * @throws RepositoryException if undoing changes made to <code>state</code>
      * and descendant items is not a closed set of changes. That is, at least
      * another item needs to be canceled as well in another sub-tree.
      */
-    public void undo(ItemState itemState) throws ItemStateException, ConstraintViolationException
{
-        ChangeLog changeLog = getChangeLog(itemState, false);
-        if (!changeLog.isEmpty()) {
-            // let changelog revert all changes
-            changeLog.undo();
-            // remove transient states and related operations from the t-statemanager
-            transientStateMgr.dispose(changeLog);
-            changeLog.reset();
+    public void undo(ItemState itemState) throws ConstraintViolationException, RepositoryException
{
+        try {
+            ChangeLog changeLog = getChangeLog(itemState, false);
+            if (!changeLog.isEmpty()) {
+                // let changelog revert all changes
+                changeLog.undo();
+                // remove transient states and related operations from the t-statemanager
+                transientStateMgr.dispose(changeLog);
+                changeLog.reset();
+            }
+        } catch (InvalidItemStateException e) {
+            // should never get here
+            String msg = "Unable to undo item.";
+            log.debug(msg);
+            throw new RepositoryException(e);
         }
     }
 
@@ -336,45 +343,40 @@
         NodeState nState = operation.getNodeState();
         NodeEntry nEntry = (NodeEntry) nState.getHierarchyEntry();
 
-        try {
-            // new array of mixinNames to be set on the nodestate (and corresponding property
state)
-            PropertyEntry mixinEntry = nEntry.getPropertyEntry(QName.JCR_MIXINTYPES);
-            if (mixinNames != null && mixinNames.length > 0) {
-                // update/create corresponding property state
-                if (mixinEntry != null) {
-                    // execute value of existing property
-                    PropertyState pState = mixinEntry.getPropertyState();
-                    int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
-                    setPropertyStateValue(pState, getQValues(mixinNames, qValueFactory),
PropertyType.NAME, options);
-                } else {
-                    // create new jcr:mixinTypes property
-                    EffectiveNodeType ent = validator.getEffectiveNodeType(nState);
-                    QPropertyDefinition pd = ent.getApplicablePropertyDefinition(QName.JCR_MIXINTYPES,
PropertyType.NAME, true);
-                    QValue[] mixinValue = getQValues(mixinNames, qValueFactory);
-                    int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
-                    addPropertyState(nState, pd.getQName(), pd.getRequiredType(), mixinValue,
pd, options);
-                }
-                nState.markModified();
-                transientStateMgr.addOperation(operation);
+        // new array of mixinNames to be set on the nodestate (and corresponding property
state)
+        PropertyEntry mixinEntry = nEntry.getPropertyEntry(QName.JCR_MIXINTYPES);
+        if (mixinNames != null && mixinNames.length > 0) {
+            // update/create corresponding property state
+            if (mixinEntry != null) {
+                // execute value of existing property
+                PropertyState pState = mixinEntry.getPropertyState();
+                int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
+                setPropertyStateValue(pState, getQValues(mixinNames, qValueFactory), PropertyType.NAME,
options);
             } else {
-                // remove the jcr:mixinTypes property state if already present
-                if (mixinEntry != null) {
-                    PropertyState pState = mixinEntry.getPropertyState();
-                    boolean newMixinState = pState.getStatus() == Status.NEW;
-                    int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
-                    removeItemState(pState, options);
-                    // only added the remove-mixin operation if it doesn't revert
-                    // a previous 'add-mixin' (which has been removed automatically
-                    // upon notification of removing the prop-state).
-                    if (!newMixinState) {
-                        nState.markModified();
-                        transientStateMgr.addOperation(operation);
-                    }
+                // create new jcr:mixinTypes property
+                EffectiveNodeType ent = validator.getEffectiveNodeType(nState);
+                QPropertyDefinition pd = ent.getApplicablePropertyDefinition(QName.JCR_MIXINTYPES,
PropertyType.NAME, true);
+                QValue[] mixinValue = getQValues(mixinNames, qValueFactory);
+                int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
+                addPropertyState(nState, pd.getQName(), pd.getRequiredType(), mixinValue,
pd, options);
+            }
+            nState.markModified();
+            transientStateMgr.addOperation(operation);
+        } else {
+            // remove the jcr:mixinTypes property state if already present
+            if (mixinEntry != null) {
+                PropertyState pState = mixinEntry.getPropertyState();
+                boolean newMixinState = pState.getStatus() == Status.NEW;
+                int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
+                removeItemState(pState, options);
+                // only added the remove-mixin operation if it doesn't revert
+                // a previous 'add-mixin' (which has been removed automatically
+                // upon notification of removing the prop-state).
+                if (!newMixinState) {
+                    nState.markModified();
+                    transientStateMgr.addOperation(operation);
                 }
             }
-        } catch (ItemStateException e) {
-            // should not occur, since existance has been asserted before
-            throw new RepositoryException(e);
         }
     }
 
@@ -398,12 +400,7 @@
     public void visit(ReorderNodes operation) throws ConstraintViolationException, AccessDeniedException,
UnsupportedRepositoryOperationException, VersionException, RepositoryException {
         NodeState parent = operation.getParentState();
         // modify the parent node state
-        try {
-            parent.reorderChildNodeEntries(operation.getInsertNode(), operation.getBeforeNode());
-        } catch (NoSuchItemStateException e) {
-            // invalid reorder-ids
-            throw new ItemNotFoundException(e);
-        }
+        parent.reorderChildNodeEntries(operation.getInsertNode(), operation.getBeforeNode());
         // remember the operation
         transientStateMgr.addOperation(operation);
     }
@@ -532,28 +529,28 @@
     /**
      *
      * @param itemState
-     * @param throwOnStale Throws StaleItemStateException if either the given
+     * @param throwOnStale Throws InvalidItemStateException if either the given
      * <code>ItemState</code> or any of its decendants is stale and the flag
is true.
      * @return
-     * @throws StaleItemStateException if a stale <code>ItemState</code> is
+     * @throws InvalidItemStateException if a stale <code>ItemState</code> is
      * encountered while traversing the state hierarchy. The <code>changeLog</code>
      * might have been populated with some transient item states. A client should
      * therefore not reuse the <code>changeLog</code> if such an exception is
thrown.
-     * @throws ItemStateException if <code>state</code> is a new item state.
+     * @throws RepositoryException if <code>state</code> is a new item state.
      */
-    private ChangeLog getChangeLog(ItemState itemState, boolean throwOnStale) throws StaleItemStateException,
ItemStateException, ConstraintViolationException {
+    private ChangeLog getChangeLog(ItemState itemState, boolean throwOnStale) throws InvalidItemStateException,
ConstraintViolationException, RepositoryException {
         // build changelog for affected and decendant states only
         ChangeLog changeLog = new ChangeLog(itemState);
         // fail-fast test: check status of this item's state
         if (itemState.getStatus() == Status.NEW) {
             String msg = "Cannot save an item with status NEW (" +itemState+ ").";
             log.debug(msg);
-            throw new ItemStateException(msg);
+            throw new RepositoryException(msg);
         }
         if (throwOnStale && Status.isStale(itemState.getStatus())) {
             String msg =  "Attempt to save an item, that has been externally modified ("
+itemState+ ").";
             log.debug(msg);
-            throw new StaleItemStateException(msg);
+            throw new InvalidItemStateException(msg);
         }
         // collect transient/stale states that should be persisted or reverted
         itemState.getHierarchyEntry().collectStates(changeLog, throwOnStale);
@@ -658,7 +655,7 @@
         try {
             itemState.getHierarchyEntry().transientRemove();
             success = true;
-        } catch (ItemStateException e) {
+        } catch (RepositoryException e) {
             throw new RepositoryException("Cannot remove item: " + e.getMessage(), e);
         } finally {
             if (!success) {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java?view=diff&rev=520315&r1=520314&r2=520315
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java
Tue Mar 20 01:22:22 2007
@@ -27,6 +27,8 @@
 import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistry;
 
+import javax.jcr.RepositoryException;
+import javax.jcr.ItemNotFoundException;
 import java.util.Iterator;
 
 /**
@@ -77,9 +79,8 @@
     /**
      * @inheritDoc
      * @see ItemStateFactory#createRootState(NodeEntry)
-     * @param entry
      */
-    public NodeState createRootState(NodeEntry entry) throws ItemStateException {
+    public NodeState createRootState(NodeEntry entry) throws ItemNotFoundException, RepositoryException
{
         // retrieve state to overlay
         NodeState overlayedState = workspaceStateFactory.createRootState(entry);
         return buildNodeState(overlayedState, Status.EXISTING);
@@ -90,7 +91,7 @@
      * @see ItemStateFactory#createNodeState(NodeId,NodeEntry)
      */
     public NodeState createNodeState(NodeId nodeId, NodeEntry entry)
-        throws NoSuchItemStateException, ItemStateException {
+            throws ItemNotFoundException, RepositoryException {
         // retrieve state to overlay
         NodeState overlayedState = workspaceStateFactory.createNodeState(nodeId, entry);
         return buildNodeState(overlayedState, getInitialStatus(entry.getParent()));
@@ -100,7 +101,8 @@
      * @inheritDoc
      * @see ItemStateFactory#createDeepNodeState(NodeId, NodeEntry)
      */
-    public NodeState createDeepNodeState(NodeId nodeId, NodeEntry anyParent) throws NoSuchItemStateException,
ItemStateException {
+    public NodeState createDeepNodeState(NodeId nodeId, NodeEntry anyParent)
+            throws ItemNotFoundException, RepositoryException {
         NodeState overlayedState = workspaceStateFactory.createDeepNodeState(nodeId, anyParent);
         return buildNodeState(overlayedState, getInitialStatus(anyParent));
     }
@@ -111,7 +113,7 @@
      */
     public PropertyState createPropertyState(PropertyId propertyId,
                                              PropertyEntry entry)
-        throws NoSuchItemStateException, ItemStateException {
+            throws ItemNotFoundException, RepositoryException {
         // retrieve state to overlay
         PropertyState overlayedState = workspaceStateFactory.createPropertyState(propertyId,
entry);
         return buildPropertyState(overlayedState, getInitialStatus(entry.getParent()));
@@ -120,7 +122,7 @@
     /**
      * @see ItemStateFactory#createDeepPropertyState(PropertyId, NodeEntry)
      */
-    public PropertyState createDeepPropertyState(PropertyId propertyId, NodeEntry anyParent)
throws NoSuchItemStateException, ItemStateException {
+    public PropertyState createDeepPropertyState(PropertyId propertyId, NodeEntry anyParent)
throws ItemNotFoundException, RepositoryException {
         PropertyState overlayedState = workspaceStateFactory.createDeepPropertyState(propertyId,
anyParent);
         return buildPropertyState(overlayedState, getInitialStatus(anyParent));
     }
@@ -128,16 +130,14 @@
     /**
      * @inheritDoc
      * @see ItemStateFactory#getChildNodeInfos(NodeId)
-     * @param nodeId
      */
-    public Iterator getChildNodeInfos(NodeId nodeId) throws NoSuchItemStateException, ItemStateException
{
+    public Iterator getChildNodeInfos(NodeId nodeId) throws ItemNotFoundException, RepositoryException
{
         return workspaceStateFactory.getChildNodeInfos(nodeId);
     }
 
     /**
      * @inheritDoc
      * @see ItemStateFactory#getNodeReferences(NodeState)
-     * @param nodeState
      */
     public NodeReferences getNodeReferences(NodeState nodeState) {
         if (nodeState.getStatus() == Status.NEW) {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?view=diff&rev=520315&r1=520314&r2=520315
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
Tue Mar 20 01:22:22 2007
@@ -72,15 +72,10 @@
     /**
      * @inheritDoc
      * @see ItemStateFactory#createRootState(NodeEntry)
-     * @param entry
      */
-    public NodeState createRootState(NodeEntry entry) throws ItemStateException {
-        try {
-            NodeInfo info = service.getNodeInfo(sessionInfo, service.getRootId(sessionInfo));
-            return createNodeState(info, entry);
-        } catch (RepositoryException e) {
-            throw new ItemStateException("Internal error while building root state.");
-        }
+    public NodeState createRootState(NodeEntry entry) throws ItemNotFoundException, RepositoryException
{
+        NodeInfo info = service.getNodeInfo(sessionInfo, service.getRootId(sessionInfo));
+        return createNodeState(info, entry);
     }
 
     /**
@@ -91,20 +86,16 @@
      * @see ItemStateFactory#createNodeState(NodeId,NodeEntry)
      */
     public NodeState createNodeState(NodeId nodeId, NodeEntry entry)
-            throws NoSuchItemStateException, ItemStateException {
+            throws ItemNotFoundException, RepositoryException {
         try {
             NodeInfo info = service.getNodeInfo(sessionInfo, nodeId);
             return createNodeState(info, entry);
         } catch (PathNotFoundException e) {
-            throw new NoSuchItemStateException(e.getMessage(), e);
-        } catch (ItemNotFoundException e) {
-            throw new NoSuchItemStateException(e.getMessage(), e);
-        } catch (RepositoryException e) {
-            throw new ItemStateException(e.getMessage(), e);
+            throw new ItemNotFoundException(e.getMessage(), e);
         }
     }
 
-    public NodeState createDeepNodeState(NodeId nodeId, NodeEntry anyParent) throws NoSuchItemStateException,
ItemStateException {
+    public NodeState createDeepNodeState(NodeId nodeId, NodeEntry anyParent) throws ItemNotFoundException,
RepositoryException {
         try {
             NodeInfo info = service.getNodeInfo(sessionInfo, nodeId);
             // node for nodeId exists -> build missing entries in hierarchy
@@ -125,17 +116,13 @@
                 }
             }
             if (entry == anyParent) {
-                throw new ItemStateException("Internal error while getting deep itemState");
+                throw new RepositoryException("Internal error while getting deep itemState");
             }
             return createNodeState(info, entry);
         } catch (PathNotFoundException e) {
-            throw new NoSuchItemStateException(e.getMessage(), e);
-        } catch (ItemNotFoundException e) {
-            throw new NoSuchItemStateException(e.getMessage(), e);
-        }  catch (RepositoryException e) {
-            throw new ItemStateException(e.getMessage(), e);
+            throw new ItemNotFoundException(e.getMessage(), e);
         } catch (MalformedPathException e) {
-            throw new ItemStateException(e.getMessage(), e);
+            throw new RepositoryException(e.getMessage(), e);
         }
     }
 
@@ -148,20 +135,16 @@
      */
     public PropertyState createPropertyState(PropertyId propertyId,
                                              PropertyEntry entry)
-            throws NoSuchItemStateException, ItemStateException {
+            throws ItemNotFoundException, RepositoryException {
         try {
             PropertyInfo info = service.getPropertyInfo(sessionInfo, propertyId);
             return createPropertyState(info, entry);
         } catch (PathNotFoundException e) {
-            throw new NoSuchItemStateException(e.getMessage());
-        } catch (ItemNotFoundException e) {
-            throw new NoSuchItemStateException(e.getMessage());
-        } catch (RepositoryException e) {
-            throw new ItemStateException(e.getMessage());
+            throw new ItemNotFoundException(e.getMessage());
         }
     }
 
-    public PropertyState createDeepPropertyState(PropertyId propertyId, NodeEntry anyParent)
throws NoSuchItemStateException, ItemStateException {
+    public PropertyState createDeepPropertyState(PropertyId propertyId, NodeEntry anyParent)
throws ItemNotFoundException, RepositoryException {
         try {
             PropertyInfo info = service.getPropertyInfo(sessionInfo, propertyId);
             // prop for propertyId exists -> build missing entries in hierarchy
@@ -193,13 +176,9 @@
             }
             return createPropertyState(info, propEntry);
         } catch (PathNotFoundException e) {
-            throw new NoSuchItemStateException(e.getMessage());
-        } catch (ItemNotFoundException e) {
-            throw new NoSuchItemStateException(e.getMessage());
-        } catch (RepositoryException e) {
-            throw new ItemStateException(e.getMessage());
+            throw new ItemNotFoundException(e.getMessage());
         } catch (MalformedPathException e) {
-            throw new ItemStateException(e.getMessage());
+            throw new RepositoryException(e.getMessage());
         }
     }
 
@@ -209,16 +188,8 @@
      * @param nodeId
      */
     public Iterator getChildNodeInfos(NodeId nodeId)
-        throws NoSuchItemStateException, ItemStateException {
-        try {
-            return service.getChildInfos(sessionInfo, nodeId);
-        } catch (PathNotFoundException e) {
-            throw new NoSuchItemStateException(e.getMessage());
-        } catch (ItemNotFoundException e) {
-            throw new NoSuchItemStateException(e.getMessage());
-        } catch (RepositoryException e) {
-            throw new ItemStateException(e.getMessage());
-        }
+            throws ItemNotFoundException, RepositoryException {
+        return service.getChildInfos(sessionInfo, nodeId);
     }
 
     /**
@@ -252,8 +223,10 @@
      * @param info the <code>NodeInfo</code> to use to create the <code>NodeState</code>.
      * @param entry
      * @return the new <code>NodeState</code>.
+     * @throws ItemNotFoundException
+     * @throws RepositoryException
      */
-    private NodeState createNodeState(NodeInfo info, NodeEntry entry) throws NoSuchItemStateException,
RepositoryException {
+    private NodeState createNodeState(NodeInfo info, NodeEntry entry) throws ItemNotFoundException,
RepositoryException {
         assertMatchingPath(info, entry);
 
         // make sure the entry has the correct ItemId
@@ -286,9 +259,6 @@
             } catch (RepositoryException e) {
                 // should not get here
                 log.warn("Internal error", e.getMessage());
-            } catch (ItemStateException e) {
-                // should not get here
-                log.warn("Internal error", e.getMessage());
             } catch (NodeTypeConflictException e) {
                 // should not get here
                log.warn("Internal error", e.getMessage());
@@ -323,8 +293,11 @@
      *               <code>PropertyState</code>.
      * @param entry
      * @return the new <code>PropertyState</code>.
+     * @throws ItemNotFoundException
+     * @throws RepositoryException
      */
-    private PropertyState createPropertyState(PropertyInfo info, PropertyEntry entry) throws
NoSuchItemStateException, RepositoryException {
+    private PropertyState createPropertyState(PropertyInfo info, PropertyEntry entry)
+            throws ItemNotFoundException, RepositoryException {
         assertMatchingPath(info, entry);
 
         // make sure uuid part of id is correct
@@ -348,9 +321,6 @@
                 } else {
                     definition = service.getPropertyDefinition(sessionInfo, entry.getId());
                 }
-            } catch (ItemStateException e) {
-                // should not get here
-                log.warn("Internal error", e.getMessage());
             } catch (RepositoryException e) {
                 // should not get here
                 log.warn("Internal error", e.getMessage());
@@ -375,10 +345,16 @@
      * Validation check: Path of the given ItemInfo must match to the Path of
      * the HierarchyEntry. This is required for Items that are identified by
      * a uniqueID that may move within the hierarchy upon restore or clone.
+     *
+     * @param info
+     * @param entry
+     * @throws ItemNotFoundException
+     * @throws RepositoryException
      */
-    private void assertMatchingPath(ItemInfo info, HierarchyEntry entry) throws NoSuchItemStateException,
RepositoryException {
+    private void assertMatchingPath(ItemInfo info, HierarchyEntry entry)
+            throws ItemNotFoundException, RepositoryException {
         if (!info.getPath().equals(entry.getWorkspacePath())) {
-            throw new NoSuchItemStateException("HierarchyEntry does not belong the given
ItemInfo.");
+            throw new ItemNotFoundException("HierarchyEntry does not belong the given ItemInfo.");
         }
     }
 

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=520315&r1=520314&r2=520315
==============================================================================
--- 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
Tue Mar 20 01:22:22 2007
@@ -26,7 +26,6 @@
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
-import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.NameException;
 import org.apache.jackrabbit.name.NoPrefixDeclaredException;
@@ -373,9 +372,6 @@
             }
         } catch (NameException e) {
             throw new RepositoryException(e);
-        } catch (ItemStateException e) {
-            // should not occure
-            throw new RepositoryException(e);
         }
     }
 
@@ -431,10 +427,6 @@
 
     private void refreshEntry(NodeEntry entry) throws RepositoryException {
         // TODO: check again.. is this correct? or should NodeEntry be altered
-        try {
-            entry.getNodeState();
-        } catch (ItemStateException e) {
-            throw new RepositoryException(e);
-        }
+        entry.getNodeState();
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java?view=diff&rev=520315&r1=520314&r2=520315
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
Tue Mar 20 01:22:22 2007
@@ -19,7 +19,6 @@
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.state.Status;
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
-import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
 import org.apache.jackrabbit.jcr2spi.operation.Checkout;
 import org.apache.jackrabbit.jcr2spi.operation.Checkin;
@@ -35,6 +34,7 @@
 import org.slf4j.Logger;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.version.VersionException;
 
 import org.apache.jackrabbit.name.QName;
@@ -99,7 +99,7 @@
             PropertyState propState = nodeEntry.getPropertyEntry(QName.JCR_ISCHECKEDOUT).getPropertyState();
             Boolean b = Boolean.valueOf(propState.getValue().getString());
             return b.booleanValue();
-        } catch (ItemStateException e) {
+        } catch (ItemNotFoundException e) {
             // error while accessing jcr:isCheckedOut property state.
             // -> assume that checkedOut status is ok. see above for general
             // notes about the capabilities of the jcr2spi implementation.
@@ -161,66 +161,53 @@
                                      boolean done) throws RepositoryException {
         NodeState wspState = getWorkspaceState(nodeState);
         NodeId vId = getWorkspaceState(versionState).getNodeId();
-        try {
-            PropertyState mergeFailedState = wspState.getPropertyState(QName.JCR_MERGEFAILED);
-            QValue[] vs = mergeFailedState.getValues();
 
-            NodeId[] mergeFailedIds = new NodeId[vs.length - 1];
-            for (int i = 0, j = 0; i < vs.length; i++) {
-                NodeId id = workspaceManager.getIdFactory().createNodeId(vs[i].getString());
-                if (!id.equals(vId)) {
-                    mergeFailedIds[j] = id;
-                    j++;
-                }
-                // else: the version id is being solved by this call and not
-                // part of 'jcr:mergefailed' any more
-            }
+        PropertyState mergeFailedState = wspState.getPropertyState(QName.JCR_MERGEFAILED);
+        QValue[] vs = mergeFailedState.getValues();
 
-            PropertyState predecessorState = wspState.getPropertyState(QName.JCR_PREDECESSORS);
-            vs = predecessorState.getValues();
+        NodeId[] mergeFailedIds = new NodeId[vs.length - 1];
+        for (int i = 0, j = 0; i < vs.length; i++) {
+            NodeId id = workspaceManager.getIdFactory().createNodeId(vs[i].getString());
+            if (!id.equals(vId)) {
+                mergeFailedIds[j] = id;
+                j++;
+            }
+            // else: the version id is being solved by this call and not
+            // part of 'jcr:mergefailed' any more
+        }
 
-            int noOfPredecessors = (done) ? vs.length + 1 : vs.length;
-            NodeId[] predecessorIds = new NodeId[noOfPredecessors];
+        PropertyState predecessorState = wspState.getPropertyState(QName.JCR_PREDECESSORS);
+        vs = predecessorState.getValues();
 
-            int i = 0;
-            while (i < vs.length) {
-                predecessorIds[i] = workspaceManager.getIdFactory().createNodeId(vs[i].getString());
-                i++;
-            }
-            if (done) {
-                predecessorIds[i] = vId;
-            }
-            Operation op = ResolveMergeConflict.create(wspState, mergeFailedIds, predecessorIds,
done);
-            workspaceManager.execute(op);
+        int noOfPredecessors = (done) ? vs.length + 1 : vs.length;
+        NodeId[] predecessorIds = new NodeId[noOfPredecessors];
 
-        } catch (ItemStateException e) {
-            throw new RepositoryException(e);
+        int i = 0;
+        while (i < vs.length) {
+            predecessorIds[i] = workspaceManager.getIdFactory().createNodeId(vs[i].getString());
+            i++;
         }
+        if (done) {
+            predecessorIds[i] = vId;
+        }
+        Operation op = ResolveMergeConflict.create(wspState, mergeFailedIds, predecessorIds,
done);
+        workspaceManager.execute(op);
     }
 
     public NodeEntry getVersionableNodeState(NodeState versionState) throws RepositoryException
{
-        try {
-            NodeState ns = versionState.getChildNodeState(QName.JCR_FROZENNODE, Path.INDEX_DEFAULT);
-            PropertyState ps = ns.getPropertyState(QName.JCR_FROZENUUID);
-            String uniqueID = ps.getValue().toString();
-
-            NodeId versionableId = workspaceManager.getIdFactory().createNodeId(uniqueID);
-            return (NodeEntry) workspaceManager.getHierarchyManager().getHierarchyEntry(versionableId);
-        } catch (ItemStateException e) {
-            throw new RepositoryException(e);
-        }
+        NodeState ns = versionState.getChildNodeState(QName.JCR_FROZENNODE, Path.INDEX_DEFAULT);
+        PropertyState ps = ns.getPropertyState(QName.JCR_FROZENUUID);
+        String uniqueID = ps.getValue().toString();
+
+        NodeId versionableId = workspaceManager.getIdFactory().createNodeId(uniqueID);
+        return (NodeEntry) workspaceManager.getHierarchyManager().getHierarchyEntry(versionableId);
     }
 
     public NodeEntry getVersionHistoryNodeState(NodeState versionableState) throws RepositoryException
{
-        try {
-            PropertyState ps = versionableState.getPropertyState(QName.JCR_VERSIONHISTORY);
-            String uniqueID = ps.getValue().getString();
-            NodeId vhId = workspaceManager.getIdFactory().createNodeId(uniqueID);
-            return (NodeEntry) workspaceManager.getHierarchyManager().getHierarchyEntry(vhId);
-        } catch (ItemStateException e) {
-            // should not occur
-            throw new RepositoryException(e);
-        }
+        PropertyState ps = versionableState.getPropertyState(QName.JCR_VERSIONHISTORY);
+        String uniqueID = ps.getValue().getString();
+        NodeId vhId = workspaceManager.getIdFactory().createNodeId(uniqueID);
+        return (NodeEntry) workspaceManager.getHierarchyManager().getHierarchyEntry(vhId);
     }
 
     //------------------------------------------------------------< private >---

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java?view=diff&rev=520315&r1=520314&r2=520315
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
Tue Mar 20 01:22:22 2007
@@ -20,8 +20,6 @@
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.SessionItemStateManager;
-import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
-import org.apache.jackrabbit.jcr2spi.state.NoSuchItemStateException;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
 import org.apache.jackrabbit.jcr2spi.state.Status;
 import org.apache.jackrabbit.jcr2spi.SessionImpl;
@@ -142,7 +140,7 @@
             refTracker = new ReferenceChangeTracker();
             parents = new Stack();
             parents.push(importTarget);
-        } catch (ItemNotFoundException infe) {
+        } catch (ItemNotFoundException e) {
             throw new PathNotFoundException(LogUtil.safeGetJCRPath(parentPath, session.getNamespaceResolver()));
         }
     }
@@ -202,13 +200,8 @@
                        throw new ItemExistsException(LogUtil.safeGetJCRPath(existing, session.getNamespaceResolver()));
                    }
                }
-           } catch (NoSuchItemStateException e) {
+           } catch (ItemNotFoundException e) {
                // 'existing' doesn't exist any more -> ignore
-           } catch (ItemStateException e) {
-               // undefined internal error
-               String msg = "Internal error. Failed to retrieve existing nodeState.";
-               log.debug(msg);
-               throw new RepositoryException(msg, e);
            }
        }
 
@@ -230,13 +223,9 @@
                    conflicting.getItemState();
 
                    nodeState = resolveUUIDConflict(parent, (NodeEntry) conflicting, nodeInfo);
-               } catch (NoSuchItemStateException e) {
+               } catch (ItemNotFoundException e) {
                    // no conflict: create new with given uuid
                    nodeState = importNode(nodeInfo, parent);
-               } catch (ItemStateException e) {
-                   String msg = "Internal error: failed to retrieve conflicting node state";
-                   log.debug(msg);
-                   throw new RepositoryException(msg, e);
                }
            }
        }
@@ -334,8 +323,7 @@
      * @throws RepositoryException
      */
     NodeState resolveUUIDConflict(NodeState parent, NodeEntry conflicting,
-                                  NodeInfo nodeInfo)
-        throws ItemExistsException, RepositoryException, ItemStateException {
+                                  NodeInfo nodeInfo) throws ItemExistsException, RepositoryException
{
         NodeState nodeState;
         switch (uuidBehavior) {
             case ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW:
@@ -372,8 +360,12 @@
                     throw new RepositoryException(msg, e);
                 }
                 // do remove conflicting (recursive) including validation check
-                Operation op = Remove.create(conflicting.getNodeState());
-                stateMgr.execute(op);
+                try {
+                    Operation op = Remove.create(conflicting.getNodeState());
+                    stateMgr.execute(op);
+                } catch (ItemNotFoundException e) {
+                    // conflicting does not exist any more. no need for a removal
+                }
                 // create new with given uuid:
                 nodeState = importNode(nodeInfo, parent);
                 break;
@@ -389,7 +381,7 @@
                 parent = conflicting.getParent().getNodeState();
 
                 // do remove conflicting (recursive), including validation checks
-                op = Remove.create(conflicting.getNodeState());
+                Operation op = Remove.create(conflicting.getNodeState());
                 stateMgr.execute(op);
                 // create new with given uuid at same location as conflicting
                 nodeState = importNode(nodeInfo, parent);
@@ -453,7 +445,7 @@
                     Operation rm = Remove.create(conflicting);
                     stateMgr.execute(rm);
                 }
-            } catch (ItemStateException e) {
+            } catch (RepositoryException e) {
                 // should not occur. existance has been checked before
                 throw new RepositoryException(e);
             }
@@ -474,17 +466,12 @@
             stateMgr.execute(an);
             // retrieve id of state that has been created during execution of AddNode
             NodeState childState;
-            try {
-                List cne = parent.getNodeEntry().getNodeEntries(nodeInfo.getName());
-                if (def.allowsSameNameSiblings()) {
-                    // TODO TOBEFIXED find proper solution. problem with same-name-siblings
-                    childState = ((NodeEntry)cne.get(cne.size()-1)).getNodeState();
-                } else {
-                    childState = ((NodeEntry)cne.get(0)).getNodeState();
-                }
-            } catch (ItemStateException e) {
-                // should not occur, since nodestate is retrieved from cne-list
-                throw new RepositoryException(e);
+            List cne = parent.getNodeEntry().getNodeEntries(nodeInfo.getName());
+            if (def.allowsSameNameSiblings()) {
+                // TODO TOBEFIXED find proper solution. problem with same-name-siblings
+                childState = ((NodeEntry)cne.get(cne.size()-1)).getNodeState();
+            } else {
+                childState = ((NodeEntry)cne.get(0)).getNodeState();
             }
 
             // and set mixin types
@@ -508,7 +495,7 @@
         int infoType = pi.getType();
 
         PropertyState propState = null;
-        QPropertyDefinition def;
+        QPropertyDefinition def = null;
 
         NodeEntry parentEntry = (NodeEntry) parentState.getHierarchyEntry();
         PropertyEntry pEntry = parentEntry.getPropertyEntry(propName);
@@ -530,26 +517,28 @@
                 } else {
                     throw new ItemExistsException(LogUtil.safeGetJCRPath(existing, session.getNamespaceResolver()));
                 }
-            } catch (ItemStateException e) {
-                // should not occur. existance has been checked before
-                throw new RepositoryException(e);
-            }
-        } else {
-            // there's no property with that name, find applicable definition
-            if (tva.length == 1) {
-                // could be single- or multi-valued (n == 1)
-                def = session.getValidator().getApplicablePropertyDefinition(propName, infoType,
parentState);
-            } else {
-                // can only be multi-valued (n == 0 || n > 1)
-                def = session.getValidator().getApplicablePropertyDefinition(propName, infoType,
true, parentState);
-            }
-            if (def.isProtected()) {
-                // skip protected property
-                log.debug("skipping protected property " + propName);
-                return;
+            } catch (ItemNotFoundException e) {
+                // property apperently doesn't exist any more
+                // -> ignore
             }
         }
 
+       if (def == null) {
+           // there's no property with that name, find applicable definition
+           if (tva.length == 1) {
+               // could be single- or multi-valued (n == 1)
+               def = session.getValidator().getApplicablePropertyDefinition(propName, infoType,
parentState);
+           } else {
+               // can only be multi-valued (n == 0 || n > 1)
+               def = session.getValidator().getApplicablePropertyDefinition(propName, infoType,
true, parentState);
+           }
+           if (def.isProtected()) {
+               // skip protected property
+               log.debug("skipping protected property " + propName);
+               return;
+           }
+       }
+
         // retrieve the target property type needed for creation of QValue(s)
         // including an eventual conversion. the targetType is then needed for
         // setting/updating the type of the property-state.
@@ -567,12 +556,7 @@
             // create new property
             Operation ap = AddProperty.create(parentState, propName, targetType, def, values);
             stateMgr.execute(ap);
-            try {
-                propState = parentEntry.getPropertyEntry(propName).getPropertyState();
-            } catch (ItemStateException e) {
-                // should not occur since prop-state has been created before
-                throw new RepositoryException(e);
-            }
+            propState = parentEntry.getPropertyEntry(propName).getPropertyState();
         } else {
             // modify value of existing property
             Operation sp = SetPropertyValue.create(propState, values, targetType);



Mime
View raw message