String svName = reader.getAttributeValue(svURI, Constants.SV_NAME);
String exoId = reader.getAttributeValue(exoURI, Constants.EXO_ID);
if (svName != null && exoId != null)
{
// create subnode
QPath currentPath;
String parentId;
int orderNumber;
if (parents.size() > 0)
{
// path to a new node
SVNodeData parent = parents.peek();
InternalQName name = locationFactory.parseJCRName(svName).getInternalName();
int[] chi = parent.addChildNode(name);
orderNumber = chi[0];
int index = chi[1];
currentPath = QPath.makeChildPath(parent.getQPath(), name, index);
parentId = parent.getIdentifier();
}
else
{
// root
currentPath = Constants.ROOT_PATH;
parentId = null;
orderNumber = 0;
// register namespaces from jcr:root node
for (int i = 0; i < reader.getNamespaceCount(); i++)
{
String nsp = reader.getNamespacePrefix(i);
try
{
namespaceRegistry.getURI(nsp);
}
catch (NamespaceException e)
{
namespaceRegistry.registerNamespace(nsp, reader.getNamespaceURI(i));
}
}
}
SVNodeData currentNode = new SVNodeData(currentPath, exoId, parentId, 0, orderNumber);
// push current node as parent
parents.push(currentNode);
// add current node to changes log.
// add node, no event fire, persisted, internally created, root is ancestor to save
changes.add(new ItemState(currentNode, ItemState.ADDED, false, Constants.ROOT_PATH, true,
true));
}
else
log.warn("Node skipped name=" + svName + " id=" + exoId + ". Context node "
+ (parents.size() > 0 ? parents.peek().getQPath().getAsString() : "/"));
}
else if (Constants.SV_PROPERTY.equals(lname))
{
String svName = reader.getAttributeValue(svURI, Constants.SV_NAME);
String exoId = reader.getAttributeValue(exoURI, Constants.EXO_ID);
String svType = reader.getAttributeValue(svURI, Constants.SV_TYPE);
if (svName != null && svType != null && exoId != null)
{
if (parents.size() > 0)
{
SVNodeData parent = parents.peek();
QPath currentPath =
QPath.makeChildPath(parent.getQPath(), locationFactory.parseJCRName(svName)
.getInternalName());
try
{
propertyType = PropertyType.valueFromName(svType);