Search in sources :

Example 1 with JcrDavSession

use of org.apache.jackrabbit.webdav.jcr.JcrDavSession in project jackrabbit by apache.

the class ResourceFactoryImpl method getNode.

/**
     * Returns the <code>Node</code> corresponding to the given locator or
     * <code>null</code> if it does not exist or if the existing item represents
     * a <code>Property</code>.
     *
     * @param sessionImpl
     * @param locator
     * @return
     * @throws RepositoryException
     */
private Node getNode(DavSession sessionImpl, DavResourceLocator locator) throws RepositoryException {
    Node node = null;
    try {
        String repoPath = locator.getRepositoryPath();
        if (repoPath != null) {
            Session session = ((JcrDavSession) sessionImpl).getRepositorySession();
            Item item = session.getItem(repoPath);
            if (item instanceof Node) {
                node = (Node) item;
            }
        // else: item is a property -> return null
        }
    } catch (PathNotFoundException e) {
    // item does not exist (yet). return null -> create null-resource
    }
    return node;
}
Also used : Item(javax.jcr.Item) Node(javax.jcr.Node) JcrDavSession(org.apache.jackrabbit.webdav.jcr.JcrDavSession) PathNotFoundException(javax.jcr.PathNotFoundException) JcrDavSession(org.apache.jackrabbit.webdav.jcr.JcrDavSession) Session(javax.jcr.Session) DavSession(org.apache.jackrabbit.webdav.DavSession)

Example 2 with JcrDavSession

use of org.apache.jackrabbit.webdav.jcr.JcrDavSession in project jackrabbit by apache.

the class ResourceFactoryImpl method createNullResource.

/**
     * Create a 'null resource'
     *
     * @param locator
     * @param session
     * @param isCollection
     * @return
     * @throws DavException
     */
private DavResource createNullResource(DavResourceLocator locator, DavSession session, boolean isCollection) throws DavException {
    JcrDavSession.checkImplementation(session);
    JcrDavSession sessionImpl = (JcrDavSession) session;
    DavResource resource;
    if (versioningSupported(sessionImpl.getRepositorySession())) {
        resource = new VersionControlledResourceImpl(locator, this, sessionImpl, resourceConfig, isCollection);
    } else {
        resource = new DavResourceImpl(locator, this, sessionImpl, resourceConfig, isCollection);
    }
    return resource;
}
Also used : DavResource(org.apache.jackrabbit.webdav.DavResource) JcrDavSession(org.apache.jackrabbit.webdav.jcr.JcrDavSession)

Example 3 with JcrDavSession

use of org.apache.jackrabbit.webdav.jcr.JcrDavSession in project jackrabbit by apache.

the class ResourceFactoryImpl method createResource.

/**
     * Tries to retrieve the repository item defined by the locator's resource
     * path and build the corresponding WebDAV resource. If the repository
     * supports the versioning option different resources are created for
     * version, versionhistory and common nodes.
     *
     * @param node
     * @param locator
     * @param session
     * @return
     * @throws DavException
     */
private DavResource createResource(Node node, DavResourceLocator locator, DavSession session) throws DavException {
    JcrDavSession.checkImplementation(session);
    JcrDavSession sessionImpl = (JcrDavSession) session;
    DavResource resource;
    if (versioningSupported(sessionImpl.getRepositorySession())) {
        // create special resources for Version and VersionHistory
        if (node instanceof Version) {
            resource = new VersionResourceImpl(locator, this, sessionImpl, resourceConfig, node);
        } else if (node instanceof VersionHistory) {
            resource = new VersionHistoryResourceImpl(locator, this, sessionImpl, resourceConfig, node);
        } else {
            resource = new VersionControlledResourceImpl(locator, this, sessionImpl, resourceConfig, node);
        }
    } else {
        resource = new DavResourceImpl(locator, this, session, resourceConfig, node);
    }
    return resource;
}
Also used : DavResource(org.apache.jackrabbit.webdav.DavResource) Version(javax.jcr.version.Version) JcrDavSession(org.apache.jackrabbit.webdav.jcr.JcrDavSession) VersionHistory(javax.jcr.version.VersionHistory)

Aggregations

JcrDavSession (org.apache.jackrabbit.webdav.jcr.JcrDavSession)3 DavResource (org.apache.jackrabbit.webdav.DavResource)2 Item (javax.jcr.Item)1 Node (javax.jcr.Node)1 PathNotFoundException (javax.jcr.PathNotFoundException)1 Session (javax.jcr.Session)1 Version (javax.jcr.version.Version)1 VersionHistory (javax.jcr.version.VersionHistory)1 DavSession (org.apache.jackrabbit.webdav.DavSession)1