Package org.apache.jackrabbit.webdav.xml

Examples of org.apache.jackrabbit.webdav.xml.Namespace


    private DavPropertyName getDavName(String jcrName, Session session) throws RepositoryException {
        // make sure the local name is xml compliant
        String localName = ISO9075.encode(Text.getLocalName(jcrName));
        String prefix = Text.getNamespacePrefix(jcrName);
        String uri = session.getNamespaceURI(prefix);
        Namespace namespace = Namespace.getNamespace(prefix, uri);
        DavPropertyName name = DavPropertyName.create(localName, namespace);
        return name;
    }
View Full Code Here


     * @throws RepositoryException
     */
    private String getJcrName(DavPropertyName propName, Session session) throws RepositoryException {
        // remove any encoding necessary for xml compliance
        String pName = ISO9075.decode(propName.getName());
        Namespace propNamespace = propName.getNamespace();
        if (!Namespace.EMPTY_NAMESPACE.equals(propNamespace)) {
            String prefix;
            String emptyPrefix = Namespace.EMPTY_NAMESPACE.getPrefix();
            try {
                // lookup 'prefix' in the session-ns-mappings / namespace-registry
                prefix = session.getNamespacePrefix(propNamespace.getURI());
            } catch (NamespaceException e) {
                // namespace uri has not been registered yet
                NamespaceRegistry nsReg = session.getWorkspace().getNamespaceRegistry();
                prefix = propNamespace.getPrefix();
                // avoid trouble with default namespace
                if (emptyPrefix.equals(prefix)) {
                    prefix = "_pre" + nsReg.getPrefixes().length + 1;
                }
                // NOTE: will fail if prefix is already in use in the namespace registry
                nsReg.registerNamespace(prefix, propNamespace.getURI());
            }
            if (prefix != null && !emptyPrefix.equals(prefix)) {
                pName = prefix + ":" + pName;
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.webdav.xml.Namespace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.