Search in sources :

Example 56 with NamespaceException

use of javax.jcr.NamespaceException 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);
    }
}
Also used : DocViewNode(org.apache.jackrabbit.vault.util.DocViewNode) DocViewProperty(org.apache.jackrabbit.vault.util.DocViewProperty) NamespaceException(javax.jcr.NamespaceException) HashMap(java.util.HashMap) Map(java.util.Map) ResourceProxy(org.apache.sling.ide.transport.ResourceProxy)

Aggregations

NamespaceException (javax.jcr.NamespaceException)56 Name (org.apache.jackrabbit.spi.Name)26 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)17 Path (org.apache.jackrabbit.spi.Path)13 InvalidQueryException (javax.jcr.query.InvalidQueryException)10 RepositoryException (javax.jcr.RepositoryException)7 PathQueryNode (org.apache.jackrabbit.spi.commons.query.PathQueryNode)7 NamespaceRegistry (javax.jcr.NamespaceRegistry)6 IllegalNameException (org.apache.jackrabbit.spi.commons.conversion.IllegalNameException)6 LocationStepQueryNode (org.apache.jackrabbit.spi.commons.query.LocationStepQueryNode)6 IOException (java.io.IOException)5 Session (javax.jcr.Session)5 DerefQueryNode (org.apache.jackrabbit.spi.commons.query.DerefQueryNode)5 PropertyFunctionQueryNode (org.apache.jackrabbit.spi.commons.query.PropertyFunctionQueryNode)5 SAXException (org.xml.sax.SAXException)5 InvalidSerializedDataException (javax.jcr.InvalidSerializedDataException)4 NodeTypeQueryNode (org.apache.jackrabbit.spi.commons.query.NodeTypeQueryNode)4 NotQueryNode (org.apache.jackrabbit.spi.commons.query.NotQueryNode)4 OrderQueryNode (org.apache.jackrabbit.spi.commons.query.OrderQueryNode)4 QueryNode (org.apache.jackrabbit.spi.commons.query.QueryNode)4