You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2006/10/12 18:53:07 UTC
svn commit: r463316 -
/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
Author: angela
Date: Thu Oct 12 09:53:04 2006
New Revision: 463316
URL: http://svn.apache.org/viewvc?view=rev&rev=463316
Log:
work in progress
- add check for existing property or node, that does not allow SNS
at move-destination
Modified:
jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java?view=diff&rev=463316&r1=463315&r2=463316
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java Thu Oct 12 09:53:04 2006
@@ -19,6 +19,8 @@
import org.apache.jackrabbit.jcr2spi.util.LogUtil;
import org.apache.jackrabbit.jcr2spi.HierarchyManager;
import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
+import org.apache.jackrabbit.jcr2spi.state.entry.ChildNodeEntry;
import org.apache.jackrabbit.name.Path;
import org.apache.jackrabbit.name.QName;
import org.apache.jackrabbit.name.MalformedPathException;
@@ -85,7 +87,9 @@
}
//------------------------------------------------------------< Factory >---
- public static Operation create(Path srcPath, Path destPath, HierarchyManager hierMgr, NamespaceResolver nsResolver) throws RepositoryException , NoSuchNodeTypeException {
+ public static Operation create(Path srcPath, Path destPath,
+ HierarchyManager hierMgr, NamespaceResolver nsResolver)
+ throws ItemExistsException, NoSuchNodeTypeException, RepositoryException {
// src must not be ancestor of destination
try {
if (srcPath.isAncestorOf(destPath)) {
@@ -117,7 +121,22 @@
NodeState srcState = getNodeState(srcPath, hierMgr, nsResolver);
NodeState srcParentState = getNodeState(srcPath.getAncestor(1), hierMgr, nsResolver);
NodeState destParentState = getNodeState(destPath.getAncestor(1), hierMgr, nsResolver);
- Move move = new Move(srcState, srcParentState, destParentState, destElement.getName());
+ QName destName = destElement.getName();
+
+ if (destParentState.hasPropertyName(destName)) {
+ throw new ItemExistsException("Move destination already exists (Property).");
+ } else if (destParentState.hasChildNodeEntry(destName)) {
+ ChildNodeEntry existing = destParentState.getChildNodeEntry(destName, Path.INDEX_DEFAULT);
+ try {
+ if (!existing.getNodeState().getDefinition().allowsSameNameSiblings()) {
+ throw new ItemExistsException("Node existing at move destination does not allow same name siblings.");
+ }
+ } catch (ItemStateException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ Move move = new Move(srcState, srcParentState, destParentState, destName);
return move;
}
}