AnsweredAssumed Answered

CMIS find a folder for object path

Question asked by kartech11 on Aug 24, 2018
Latest reply on Aug 24, 2018 by angelborroy

I have the below findFolder method, when I pass the path I am not able to find the folder. Please can you let me know what the path should be or what is incorrect below.

 

I have a folder at the path specified.

 

 

 

FindFolder method

public static Folder findFolder(@NotNull Session session, @NotNull String path) throws FolderNotFoundException{
    CmisObject obj = session.getObjectByPath(path);
    if(obj instanceof Folder){
        return (Folder)obj;
    }else{
        throw new FolderNotFoundException("The path " + path + " does not return reference to a folder");
    }
}

 

Test class

String user = "admin";
String pwd = "admin";
String serviceUrl = "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser";
Session session = SessionManager.getInstance().createSession(new SessionContext(user, pwd, serviceUrl));
try {
    Folder folder = FolderService.findFolder(session, "/app:company_home/st:sites/cm:testsite/cm:documentLibrary/cm:Contracts");
    assertNotNull(folder);
} catch (FolderNotFoundException e) {
    e.printStackTrace();
}

Exception

Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException: Object not found: /app:company_home/st:sites/cm:test-site/cm:documentLibrary/cm:Contracts
at org.apache.chemistry.opencmis.client.bindings.spi.browser.AbstractBrowserBindingService.convertStatusCode(AbstractBrowserBindingService.java:296)
at org.apache.chemistry.opencmis.client.bindings.spi.browser.AbstractBrowserBindingService.read(AbstractBrowserBindingService.java:410)

Outcomes