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/07/26 16:04:22 UTC
svn commit: r425737 - in
/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi:
NodeImpl.java operation/AddNode.java xml/ImporterImpl.java
Author: angela
Date: Wed Jul 26 07:04:21 2006
New Revision: 425737
URL: http://svn.apache.org/viewvc?rev=425737&view=rev
Log:
work in progress
Modified:
jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java
jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImporterImpl.java
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=425737&r1=425736&r2=425737&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java Wed Jul 26 07:04:21 2006
@@ -1274,8 +1274,15 @@
Operation an = AddNode.create(getNodeState(), nodeName, nodeTypeName, null);
itemStateMgr.execute(an);
- // TODO: find better solution...
- NodeId childId = AddNode.getLastCreated(getNodeState(), nodeName);
+ // retrieve id of state that has been created during execution of AddNode
+ NodeId childId;
+ List cne = getNodeState().getChildNodeEntries(nodeName);
+ if (definition.allowsSameNameSiblings()) {
+ // TODO: find proper solution. problem with same-name-siblings
+ childId = ((NodeState.ChildNodeEntry)cne.get(cne.size()-1)).getId();
+ } else {
+ childId = ((NodeState.ChildNodeEntry)cne.get(0)).getId();
+ }
// finally retrieve the new node
return (Node) itemMgr.getItem(childId);
}
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java?rev=425737&r1=425736&r2=425737&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java Wed Jul 26 07:04:21 2006
@@ -30,7 +30,6 @@
import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.version.VersionException;
import javax.jcr.lock.LockException;
-import java.util.List;
/**
* <code>AddNode</code>...
@@ -85,13 +84,5 @@
QName nodeTypeName, NodeId id) {
AddNode an = new AddNode(parentState.getNodeId(), nodeName, nodeTypeName, id);
return an;
- }
-
- public static NodeId getLastCreated(NodeState parentState, QName nodeName) {
- // TODO: check if this really retrieves the child state that was created before
- // problem: we don't know the id of the nodestate in advance -> retrieval of new state not possible.
- List cne = parentState.getChildNodeEntries(nodeName);
- NodeId childId = ((NodeState.ChildNodeEntry)cne.get(cne.size()-1)).getId();
- return childId;
}
}
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImporterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImporterImpl.java?rev=425737&r1=425736&r2=425737&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImporterImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImporterImpl.java Wed Jul 26 07:04:21 2006
@@ -398,8 +398,7 @@
* @throws RepositoryException
*/
private NodeState importNode(NodeInfo nodeInfo, NodeState parent) throws ConstraintViolationException, ItemNotFoundException, RepositoryException {
- QName nodeName = nodeInfo.getName();
- if (parent.hasPropertyName(nodeName)) {
+ if (parent.hasPropertyName(nodeInfo.getName())) {
/**
* a property with the same name already exists; if this property
* has been imported as well (e.g. through document view import
@@ -408,12 +407,12 @@
*
* see http://issues.apache.org/jira/browse/JCR-61
*/
- PropertyState conflicting = validator.getPropertyState(parent.getNodeId(), nodeName);
+ PropertyState conflicting = validator.getPropertyState(parent.getNodeId(), nodeInfo.getName());
if (conflicting.getStatus() == ItemState.STATUS_NEW) {
// assume this property has been imported as well;
// rename conflicting property
// @todo use better reversible escaping scheme to create unique name
- QName newName = new QName(nodeName.getNamespaceURI(), nodeName.getLocalName() + "_");
+ QName newName = new QName(nodeInfo.getName().getNamespaceURI(), nodeInfo.getName().getLocalName() + "_");
if (parent.hasPropertyName(newName)) {
newName = new QName(newName.getNamespaceURI(), newName.getLocalName() + "_");
}
@@ -449,11 +448,19 @@
} else {
Operation an = AddNode.create(parent, nodeInfo.getName(), nodeInfo.getNodeTypeName(), nodeInfo.getId());
stateMgr.execute(an);
- NodeId nId = AddNode.getLastCreated(parent, nodeInfo.getName());
- NodeState nodeState = validator.getNodeState(nId);
+ // retrieve id of state that has been created during execution of AddNode
+ NodeId childId;
+ List cne = parent.getChildNodeEntries(nodeInfo.getName());
+ if (def.allowsSameNameSiblings()) {
+ // TODO: find proper solution. problem with same-name-siblings
+ childId = ((NodeState.ChildNodeEntry)cne.get(cne.size()-1)).getId();
+ } else {
+ childId = ((NodeState.ChildNodeEntry)cne.get(0)).getId();
+ }
+ NodeState nodeState = validator.getNodeState(childId);
// and set mixin types
- PropertyId mixinPId = idFactory.createPropertyId(nId, QName.JCR_MIXINTYPES);
+ PropertyId mixinPId = idFactory.createPropertyId(childId, QName.JCR_MIXINTYPES);
Operation sm = SetMixin.create(mixinPId, nodeInfo.getMixinNames());
stateMgr.execute(sm);
return nodeState;