Search in sources :

Example 21 with PropertyId

use of org.apache.jackrabbit.spi.PropertyId in project jackrabbit by apache.

the class URIResolverImpl method getPropertyId.

/**
 * @inheritDoc
 */
public PropertyId getPropertyId(String uri, SessionInfo sessionInfo) throws RepositoryException {
    IdURICache cache = getCache(sessionInfo.getWorkspaceName());
    ItemId id = cache.getItemId(uri);
    if (id != null) {
        if (!id.denotesNode()) {
            return (PropertyId) id;
        }
    }
    // separate parent uri and property JCRName
    String parentUri = Text.getRelativeParent(uri, 1, true);
    // make sure propName is unescaped
    String propName = Text.unescape(Text.getName(uri, true));
    // retrieve parent node id
    NodeId parentId = getNodeId(parentUri, sessionInfo, false);
    // build property id
    try {
        Name name = service.getNamePathResolver(sessionInfo).getQName(propName);
        PropertyId propertyId = service.getIdFactory().createPropertyId(parentId, name);
        cache.add(uri, propertyId);
        return propertyId;
    } catch (NameException e) {
        throw new RepositoryException(e);
    }
}
Also used : NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) NodeId(org.apache.jackrabbit.spi.NodeId) RepositoryException(javax.jcr.RepositoryException) ItemId(org.apache.jackrabbit.spi.ItemId) PropertyId(org.apache.jackrabbit.spi.PropertyId) Name(org.apache.jackrabbit.spi.Name)

Aggregations

PropertyId (org.apache.jackrabbit.spi.PropertyId)21 NodeId (org.apache.jackrabbit.spi.NodeId)13 Name (org.apache.jackrabbit.spi.Name)10 RepositoryException (javax.jcr.RepositoryException)8 ArrayList (java.util.ArrayList)6 Path (org.apache.jackrabbit.spi.Path)6 PropertyInfo (org.apache.jackrabbit.spi.PropertyInfo)5 QValue (org.apache.jackrabbit.spi.QValue)5 Batch (org.apache.jackrabbit.spi.Batch)4 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)4 IOException (java.io.IOException)3 ItemNotFoundException (javax.jcr.ItemNotFoundException)3 DavPropertySet (org.apache.jackrabbit.webdav.property.DavPropertySet)3 Serializable (java.io.Serializable)2 Node (javax.jcr.Node)2 HttpResponse (org.apache.http.HttpResponse)2 ChildInfo (org.apache.jackrabbit.spi.ChildInfo)2 ItemId (org.apache.jackrabbit.spi.ItemId)2 ItemInfo (org.apache.jackrabbit.spi.ItemInfo)2 NamePathResolver (org.apache.jackrabbit.spi.commons.conversion.NamePathResolver)2