Connection with alfresco cmis

前端 未结 2 1923
温柔的废话
温柔的废话 2021-01-29 10:03

I am trying to connect alfresco using config parameters but i am getting error:

Config: sessionParameters.put(SessionParameter.USER, \"admin\");
    sessionParam         


        
2条回答
  •  执念已碎
    2021-01-29 10:41

    Use the following method to get session

     public Session getSession() {
        if (session == null) {
            logger.info("Not connected, creating new connection");
    
            // default factory implementation
            SessionFactory factory = SessionFactoryImpl.newInstance();
            Map parameter = new HashMap();
    
            // user credentials
            parameter.put(SessionParameter.USER, "admin");
            parameter.put(SessionParameter.PASSWORD, "admin");
    
            // connection settings
            parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.0/atom"); 
            parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); 
    
            List repositories = factory.getRepositories(parameter);
    
            if (repositories != null && repositories.size() > 0) {
                logger.info("Found (" + repositories.size() + ") Alfresco repositories");
                this.session = repositories.get(0).createSession();
            } else {
                throw new CmisConnectionException("Could not connect to the Alfresco Server,"
                        + " no repository found!");
            }       
        }
        return this.session;
    }
    

提交回复
热议问题