You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by md...@apache.org on 2010/02/08 16:35:58 UTC
svn commit: r907693 -
/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
Author: mduerig
Date: Mon Feb 8 15:35:57 2010
New Revision: 907693
URL: http://svn.apache.org/viewvc?rev=907693&view=rev
Log:
JCR-2487: WorkspaceItemStateFactory#createItemStates throws ClassCastException
Modified:
jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?rev=907693&r1=907692&r2=907693&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java Mon Feb 8 15:35:57 2010
@@ -193,9 +193,13 @@
throws ItemNotFoundException, RepositoryException {
NodeState nodeState;
ItemInfos infos = new ItemInfos(itemInfos);
+
// first entry in the iterator is the originally requested Node.
- if (infos.hasNext()) {
- NodeInfo first = (NodeInfo) infos.next();
+ NodeInfo first = first(infos);
+ if (first == null) {
+ throw new ItemNotFoundException("Node with id " + nodeId + " could not be found.");
+ }
+ else {
if (isDeep) {
// for a deep state, the hierarchy entry does not correspond to
// the given NodeEntry -> retrieve NodeState before executing
@@ -208,9 +212,6 @@
assertMatchingPath(first, entry);
nodeState = createNodeState(first, entry);
}
- } else {
- // empty iterator
- throw new ItemNotFoundException("Node with id " + nodeId + " could not be found.");
}
// deal with all additional ItemInfos that may be present.
@@ -229,6 +230,17 @@
return nodeState;
}
+ private static NodeInfo first(ItemInfos infos) {
+ if (infos.hasNext()) {
+ ItemInfo first = infos.next();
+ if (first.denotesNode()) {
+ return (NodeInfo) first;
+ }
+ }
+
+ return null;
+ }
+
/**
* Creates the node with information retrieved from <code>info</code>.
*