// process node
NodeState node = null;
NodeId id = nodeInfo.getId();
QName nodeName = nodeInfo.getName();
QName ntName = nodeInfo.getNodeTypeName();
QName[] mixins = nodeInfo.getMixinNames();
if (parent == null) {
// parent node was skipped, skip this child node also
parents.push(null); // push null onto stack for skipped node
succeeded = true;
log.debug("skipping node " + nodeName);
return;
}
if (parent.hasChildNodeEntry(nodeName)) {
// a node with that name already exists...
NodeState.ChildNodeEntry entry =
parent.getChildNodeEntry(nodeName, 1);
NodeId idExisting = entry.getId();
NodeState existing = (NodeState) itemOps.getItemState(idExisting);
NodeDef def = ntReg.getNodeDef(existing.getDefinitionId());
if (!def.allowsSameNameSiblings()) {
// existing doesn't allow same-name siblings,
// check for potential conflicts
EffectiveNodeType entExisting =
itemOps.getEffectiveNodeType(existing);
if (def.isProtected() && entExisting.includesNodeType(ntName)) {
// skip protected node
parents.push(null); // push null onto stack for skipped node
succeeded = true;
log.debug("skipping protected node "
+ itemOps.safeGetJCRPath(existing.getNodeId()));
return;
}
if (def.isAutoCreated() && entExisting.includesNodeType(ntName)) {
// this node has already been auto-created,
// no need to create it
node = existing;
} else {
throw new ItemExistsException(itemOps.safeGetJCRPath(existing.getNodeId()));
}
}
}
if (node == null) {
// there's no node with that name...
if (id == null) {
// no potential uuid conflict, always create new node
NodeDef def =
itemOps.findApplicableNodeDefinition(nodeName, ntName, parent);
if (def.isProtected()) {
// skip protected node
parents.push(null); // push null onto stack for skipped node
succeeded = true;
log.debug("skipping protected node " + nodeName);
return;
}
if (parent.hasPropertyName(nodeName)) {
/**
* a property with the same name already exists; if this property
* has been imported as well (e.g. through document view import
* where an element can have the same name as one of the attributes
* of its parent element) we have to rename the onflicting property;
*
* see http://issues.apache.org/jira/browse/JCR-61
*/
PropertyId propId = new PropertyId(parent.getNodeId(), nodeName);
PropertyState conflicting = itemOps.getPropertyState(propId);
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() + "_");
if (parent.hasPropertyName(newName)) {
newName = new QName(newName.getNamespaceURI(), newName.getLocalName() + "_");
}
PropertyState newProp =
itemOps.createPropertyState(parent, newName,
conflicting.getType(), conflicting.getValues().length);
newProp.setValues(conflicting.getValues());