use of org.apache.jackrabbit.vault.util.DocViewNode in project sling by apache.
the class ContentXmlHandler method startElement.
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
ResourceProxy current;
// name is equal to label except for SNS
String label = ISO9075.decode(qName);
String name = label;
// code mostly taken from {@link org.apache.jackrabbit.vault.fs.impl.io.DocViewSaxImporter}
DocViewNode node;
try {
node = new DocViewNode(name, label, attributes, npResolver);
if (qName.equals(JCR_ROOT)) {
current = root;
} else {
ResourceProxy parent = queue.peekLast();
StringBuilder path = new StringBuilder(parent.getPath());
if (path.charAt(path.length() - 1) != '/')
path.append('/');
path.append(qName);
current = new ResourceProxy(ISO9075.decode(path.toString()));
parent.addChild(current);
}
for (Map.Entry<String, DocViewProperty> entry : node.props.entrySet()) {
try {
Object typedValue = TypeHint.convertDocViewPropertyToTypedValue(entry.getValue());
// unsupported
if (typedValue == null) {
continue;
}
current.addProperty(entry.getKey(), typedValue);
} catch (Throwable t) {
Activator.getDefault().getPluginLogger().error("Could not parse property '" + entry.getValue().name, t);
}
}
queue.add(current);
} catch (NamespaceException e) {
Activator.getDefault().getPluginLogger().error("Could not resolve a JCR namespace.", e);
}
}
Aggregations