Search in sources :

Example 1 with SlingLocatorFactory

use of org.apache.sling.jcr.webdav.impl.helper.SlingLocatorFactory in project sling by apache.

the class SlingWebDavServlet method getLocatorFactory.

@Override
public DavLocatorFactory getLocatorFactory() {
    if (locatorFactory == null) {
        // configured default workspace name
        SlingRepository slingRepo = (SlingRepository) getRepository();
        String workspace = slingRepo.getDefaultWorkspace();
        // no configuration, try to login and acquire the default name
        if (workspace == null || workspace.length() == 0) {
            Session tmp = null;
            try {
                tmp = slingRepo.login();
                workspace = tmp.getWorkspace().getName();
            } catch (Throwable t) {
                // TODO: log !!
                // fall back name
                workspace = "default";
            } finally {
                if (tmp != null) {
                    tmp.logout();
                }
            }
        }
        locatorFactory = new SlingLocatorFactory(workspace);
    }
    return locatorFactory;
}
Also used : SlingRepository(org.apache.sling.jcr.api.SlingRepository) SlingLocatorFactory(org.apache.sling.jcr.webdav.impl.helper.SlingLocatorFactory) Session(javax.jcr.Session)

Aggregations

Session (javax.jcr.Session)1 SlingRepository (org.apache.sling.jcr.api.SlingRepository)1 SlingLocatorFactory (org.apache.sling.jcr.webdav.impl.helper.SlingLocatorFactory)1