}
}
SVNodeData currentNode = new SVNodeData(currentPath, exoId, parentId, 0, orderNumber);
AccessControlList acl =
ACLInitializationHelper.initAcl(parents.size() == 0 ? null : parents.peek().getACL(),
null, null);
currentNode.setACL(acl);
// 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);
}
catch (IllegalArgumentException e)
{
propertyType = ExtendedPropertyType.valueFromName(svType);
}
// exo:multivalued optional, assigned for multivalued properties only
String exoMultivalued = reader.getAttributeValue(exoURI, Constants.EXO_MULTIVALUED);
currentProperty =
new SVPropertyData(currentPath, exoId, 0, propertyType, parent.getIdentifier(),
("true".equals(exoMultivalued) ? true : false));
}
else
LOG.warn("Property can'b be first name=" + svName + " type=" + svType + " id=" + exoId
+ ". Node should be prior. Context node "
+ (parents.size() > 0 ? parents.peek().getQPath().getAsString() : "/"));
}
else
LOG.warn("Property skipped name=" + svName + " type=" + svType + " id=" + exoId
+ ". Context node "
+ (parents.size() > 0 ? parents.peek().getQPath().getAsString() : "/"));
}
else if (Constants.SV_VALUE.equals(lname) && propertyType != -1)
{
if (propertyType == PropertyType.BINARY)
propertyValue = new BinaryValueWriter();
else
propertyValue = new StringValueWriter();
}
}
break;
}
case StartElement.CHARACTERS : {
if (propertyValue != null)
{
// read property value text
propertyValue.write(reader.getText());
}
break;
}
case StartElement.END_ELEMENT : {
String lname = reader.getLocalName();
String prefix = reader.getPrefix();
if (Constants.NS_SV_PREFIX.equals(prefix))
{
if (Constants.SV_NODE.equals(lname))
{
// change current context
// - pop parent from the stack
SVNodeData parent = parents.pop();
if (parent.getMixinTypeNames() == null)
{
// mixins cannot be null
parent.setMixinTypeNames(new InternalQName[0]);
}
}
else if (Constants.SV_PROPERTY.equals(lname))
{
// apply property to the current node and changes log
if (currentProperty != null)
{
SVNodeData parent = parents.peek();
// check NodeData specific properties
if (currentProperty.getQPath().getName().equals(Constants.JCR_PRIMARYTYPE))
{
parent.setPrimartTypeName(InternalQName.parse(new String(currentProperty.getValues().get(
0).getAsByteArray())));
}
else if (currentProperty.getQPath().getName().equals(Constants.JCR_MIXINTYPES))
{
InternalQName[] mixins = new InternalQName[currentProperty.getValues().size()];
for (int i = 0; i < currentProperty.getValues().size(); i++)
{
mixins[i] =
InternalQName
.parse(new String(currentProperty.getValues().get(i).getAsByteArray()));
}
parent.setMixinTypeNames(mixins);
}
else if (currentProperty.getQPath().getName().equals(Constants.EXO_OWNER))
{
String exoOwner =
new String(currentProperty.getValues().get(0).getAsByteArray(),
Constants.DEFAULT_ENCODING);
parent.setExoOwner(exoOwner);
SVNodeData curParent = parents.pop();
AccessControlList acl =
ACLInitializationHelper.initAcl(parents.size() == 0 ? null : parents.peek().getACL(),
exoOwner, curParent.getExoPrivileges());
curParent.setACL(acl);
parents.push(curParent);
}
else if (currentProperty.getQPath().getName().equals(Constants.EXO_PERMISSIONS))
{
List<String> exoPrivileges = new ArrayList<String>();
for (int i = 0; i < currentProperty.getValues().size(); i++)
{
exoPrivileges.add(new String(currentProperty.getValues().get(i).getAsByteArray(),
Constants.DEFAULT_ENCODING));
}
parent.setExoPrivileges(exoPrivileges);
SVNodeData curParent = parents.pop();
AccessControlList acl =
ACLInitializationHelper.initAcl(parents.size() == 0 ? null : parents.peek().getACL(),
curParent.getExoOwner(), exoPrivileges);
curParent.setACL(acl);
parents.push(curParent);