Search in sources :

Example 6 with Namespace

use of org.apache.jackrabbit.webdav.xml.Namespace in project jackrabbit by apache.

the class DefaultHandler method getJcrName.

/**
 * Build jcr property name from dav property name. If the property name
 * defines a namespace uri, that has not been registered yet, an attempt
 * is made to register the uri with the prefix defined.
 *
 * @param propName name of the dav property
 * @param session repository session
 * @return jcr name
 * @throws RepositoryException if an error during repository access occurs.
 */
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)) {
        NamespaceHelper helper = new NamespaceHelper(session);
        String prefix = helper.registerNamespace(propNamespace.getPrefix(), propNamespace.getURI());
        pName = prefix + ":" + pName;
    }
    return pName;
}
Also used : NamespaceHelper(org.apache.jackrabbit.commons.NamespaceHelper) Namespace(org.apache.jackrabbit.webdav.xml.Namespace)

Example 7 with Namespace

use of org.apache.jackrabbit.webdav.xml.Namespace in project jackrabbit by apache.

the class DefaultHandler method getDavName.

// ------------------------------------------------------------< private >---
/**
 * Builds a webdav property name from the given jcrName. In case the jcrName
 * contains a namespace prefix that would conflict with any of the predefined
 * webdav namespaces a new prefix is assigned.<br>
 * Please note, that the local part of the jcrName is checked for XML
 * compatibility by calling {@link ISO9075#encode(String)}
 *
 * @param jcrName name of the jcr property
 * @param session session
 * @return a <code>DavPropertyName</code> for the given jcr name.
 * @throws RepositoryException if an error during repository access occurs.
 */
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;
}
Also used : Namespace(org.apache.jackrabbit.webdav.xml.Namespace) DavPropertyName(org.apache.jackrabbit.webdav.property.DavPropertyName)

Aggregations

Namespace (org.apache.jackrabbit.webdav.xml.Namespace)7 DavPropertyName (org.apache.jackrabbit.webdav.property.DavPropertyName)2 Privilege (org.apache.jackrabbit.webdav.security.Privilege)2 Element (org.w3c.dom.Element)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 RepositoryException (javax.jcr.RepositoryException)1 NamespaceHelper (org.apache.jackrabbit.commons.NamespaceHelper)1 MultiStatusResponse (org.apache.jackrabbit.webdav.MultiStatusResponse)1 HrefProperty (org.apache.jackrabbit.webdav.property.HrefProperty)1 CurrentUserPrivilegeSetProperty (org.apache.jackrabbit.webdav.security.CurrentUserPrivilegeSetProperty)1 SupportedPrivilege (org.apache.jackrabbit.webdav.security.SupportedPrivilege)1 DeltaVResource (org.apache.jackrabbit.webdav.version.DeltaVResource)1 ElementIterator (org.apache.jackrabbit.webdav.xml.ElementIterator)1