How to retrieve 'repository root' id/child

2019-09-10 02:00发布

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)

2条回答
干净又极端
2楼-- · 2019-09-10 02:29

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.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-09-10 02:38

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

查看更多
登录 后发表回答