Search in sources :

Example 11 with Path

use of org.nuxeo.common.utils.Path in project nuxeo-filesystem-connectors by nuxeo.

the class SimpleBackend method resolveParent.

protected DocumentModel resolveParent(String location) {
    DocumentModel doc = null;
    doc = getPathCache().get(location.toString());
    if (doc != null) {
        return doc;
    }
    DocumentRef docRef = new PathRef(location.toString());
    if (exists(docRef)) {
        doc = getSession().getDocument(docRef);
    } else {
        Path locationPath = new Path(location);
        String filename = locationPath.lastSegment();
        Path parentLocation = locationPath.removeLastSegments(1);
        // first try with spaces (for create New Folder)
        String folderName = filename;
        DocumentRef folderRef = new PathRef(parentLocation.append(folderName).toString());
        if (exists(folderRef)) {
            doc = getSession().getDocument(folderRef);
        }
    }
    getPathCache().put(location.toString(), doc);
    return doc;
}
Also used : Path(org.nuxeo.common.utils.Path) DocumentRef(org.nuxeo.ecm.core.api.DocumentRef) PathRef(org.nuxeo.ecm.core.api.PathRef) DocumentModel(org.nuxeo.ecm.core.api.DocumentModel)

Aggregations

Path (org.nuxeo.common.utils.Path)11 DocumentModel (org.nuxeo.ecm.core.api.DocumentModel)6 PathRef (org.nuxeo.ecm.core.api.PathRef)5 ArrayList (java.util.ArrayList)2 DocumentRef (org.nuxeo.ecm.core.api.DocumentRef)2 NuxeoException (org.nuxeo.ecm.core.api.NuxeoException)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 SynchronizationRoots (org.nuxeo.drive.service.SynchronizationRoots)1 Blob (org.nuxeo.ecm.core.api.Blob)1 UnrestrictedSessionRunner (org.nuxeo.ecm.core.api.UnrestrictedSessionRunner)1 BlobHolder (org.nuxeo.ecm.core.api.blobholder.BlobHolder)1 FileManager (org.nuxeo.ecm.platform.filemanager.api.FileManager)1 Backend (org.nuxeo.ecm.webdav.backend.Backend)1