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

前端 未结 2 760
-上瘾入骨i
-上瘾入骨i 2021-01-26 06:35

I installed Alfresco Community v4.1 for use in my application. I want to access its contents (list files, add, delete etc.) using CMIS REST API. I don\'t find any e

2条回答
  •  醉酒成梦
    2021-01-26 06:56

    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 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 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.

提交回复
热议问题