How to retrieve 'repository root' id/children from CMIS repository?

霸气de小男生 提交于 2020-01-07 02:51:08

问题


I am using the openCMIS library against a cmis 1.0 compliant server and I noticed that whenever I call getRepositories on the server (an alfresco v3.2 & v5.0 server) I only receive a list with one repository as opposed to what I was expecting, i.e. the list of roots on the server. How do I retrieve the list of repository roots using the opencmis library?

EDIT
I inappropriately phrased the question so I will explain better.
What I would like to do is to be able to get the actual repository root id(i.e. store_root in alfresco for instance) NOT the root folder id , such that I can leverage that against the api to retrieve it's direct children i.e. objects at the same hierarchical level as root folder (Company Home in alfresco)


回答1:


Alfresco only has one repository, so what you are seeing is correct.

To understand how to get the root folder (which is Company Home), then how to get the root folder's children, see here.




回答2:


worked fine for me test it : first you have to create a session and connect it with this :

private static Session getSession(String serverUrl, String username, String password) {
    SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
    Map<String, String> params = new HashMap<>();
    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();
} 

after that only use this

Folder folder = session.getRootFolder();

hope that helped you



来源:https://stackoverflow.com/questions/39230517/how-to-retrieve-repository-root-id-children-from-cmis-repository

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