Search in sources :

Example 26 with PathRef

use of org.nuxeo.ecm.core.api.PathRef 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

PathRef (org.nuxeo.ecm.core.api.PathRef)26 DocumentModel (org.nuxeo.ecm.core.api.DocumentModel)21 Test (org.junit.Test)14 DocumentRef (org.nuxeo.ecm.core.api.DocumentRef)8 Path (org.nuxeo.common.utils.Path)5 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)4 Blob (org.nuxeo.ecm.core.api.Blob)4 ArrayList (java.util.ArrayList)3 Blob (org.nuxeo.ecm.automation.client.model.Blob)3 IdRef (org.nuxeo.ecm.core.api.IdRef)3 ACE (org.nuxeo.ecm.core.api.security.ACE)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 StringBlob (org.nuxeo.ecm.automation.client.model.StringBlob)2 CollectionManager (org.nuxeo.ecm.collections.api.CollectionManager)2 CoreSession (org.nuxeo.ecm.core.api.CoreSession)2 DocumentModelList (org.nuxeo.ecm.core.api.DocumentModelList)2 NuxeoException (org.nuxeo.ecm.core.api.NuxeoException)2 BlobHolder (org.nuxeo.ecm.core.api.blobholder.BlobHolder)2 StringBlob (org.nuxeo.ecm.core.api.impl.blob.StringBlob)2