How can I access files in Alfresco using the CMIS REST API?

佐手、 提交于 2019-12-02 11:44:07

You can use this method to access to your repository

try this worked fine for me

 private static Session getSession(String serverUrl, String username, String password) {
    SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
    Map<String, String> params = new HashMap<String, String>();
    params.put(SessionParameter.USER, username);
    params.put(SessionParameter.PASSWORD, password);
    params.put(SessionParameter.ATOMPUB_URL, serverUrl);
    params.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
    List<Repository> repos = sessionFactory.getRepositories(params);
    if (repos.isEmpty()) {
        throw new RuntimeException("Server has no repositories!");
    }
    return repos.get(0).createSession();
}

This method get the session from your repository with your own informations

serverUrl : http://" + ipAlfresco + "/alfresco/api/-default-/public/cmis/versions/1.0/atom
username : admin 
password : admin 

Hope that helped you.

The official Alfresco documentation explains this pretty well. You shouldn't think of CMIS as a REST API itself. CMIS is an interoperability standard that aims to provide a generic, vendor-agnostic means of querying your data.

Anyway... Your problem seems to be that the noderef you're using is for a folder, which the service you're hitting doesn't work for. Try that instead with...

http://127.0.0.1:8080/alfresco/service/api/node/content/workspace/SpacesStore/9c3c6e63-e217-47a8-8216-298d2419cffa

...and see if you find your content.

For folders, try a WebDAV link, e.g.: http://localhost:8080/alfresco/webdav/Sites/swsdp/documentLibrary/Agency%20Files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!