Connect to Alfresco with CMIS

I start with Alfresco. I installed the version of Alfresco 4 Community and I am trying to connect to it using OpenCMIS. I took this piece of code on the OpenCMIS page:

SessionFactory sessionFactory = SessionFactoryImpl.newInstance(); Map<String, String> parameter = new HashMap<String, String>(); parameter.put(SessionParameter.USER, "admin"); parameter.put(SessionParameter.PASSWORD, "admin"); parameter.put(SessionParameter.ATOMPUB_URL, "http://repo.opencmis.org/inmemory/atom/"); parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); parameter.put(SessionParameter.REPOSITORY_ID, ""); Session s = sessionFactory.createSession(parameter); 

However, I could not find out what the repository ID should be and how to specify the Alfresco URL. Can anyone explain this to me? Thanks.

+4
source share
1 answer

TL; DR:

 // User credentials. parameters.put(SessionParameter.USER, "admin"); parameters.put(SessionParameter.PASSWORD, "admin"); // Connection settings. parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); parameters.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/service/cmis"); // URL to your CMIS server. parameters.put(SessionParameter.AUTH_HTTP_BASIC, "true" ); parameters.put(SessionParameter.COOKIES, "true" ); // Create session. // Alfresco only provides one repository. Repository repository = sessionFactory.getRepositories(parameters).get(0); Session session = repository.createSession(); 

From the CMIS spec :

An application MUST use the getRepositories CMIS service to get a list of available repositories at this endpoint.

Repository identifiers are opaque strings created by the CMIS repository that you usually discover, rather than know in advance. In addition, a single CMIS server can contain multiple repositories (although Alfresco only supports one).

When it comes to Alfresco, the repository identifier is different for each instance, so if you restart the clean database to be regenerated again, break the application if it relies on a hard-coded relay identifier.

Discovery of the repository identifier was made possible thanks to the service document in the AtomPub binding and through cmisRepositoryEntryType in the web services binding.

+12
source

Source: https://habr.com/ru/post/1399534/


All Articles