System.out.println("Getting Started...");
System.out.println("------------------");
// Create a SessionFactory and set up the SessionParameter map
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map<String, String> parameter = new HashMap<String, String>();
// user credentials - using the standard admin/admin
parameter.put(SessionParameter.USER, "admin");
parameter.put(SessionParameter.PASSWORD, "admin");
// connection settings - we're connecting to a public cmis repo,
// using the AtomPUB binding, but there are other options here,
// or you can substitute your own URL
parameter.put(SessionParameter.ATOMPUB_URL,
"http://opencmis.cloudapp.net/inmemory/atom/");
// "http://cmis.alfresco.com/service/cmis");
// "http://localhost:8080/alfresco/service/api/cmis");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// find all the repositories at this URL - there should only be one.
List<Repository> repositories = new ArrayList<Repository>();
repositories = sessionFactory.getRepositories(parameter);
for (Repository r : repositories) {
System.out.println("Found repository: " + r.getName());
}
// create session with the first (and only) repository
Repository repository = repositories.get(0);
parameter.put(SessionParameter.REPOSITORY_ID, repository.getId());
Session session = sessionFactory.createSession(parameter);
System.out.println("Got a connection to repository: " + repository.getName()
+ ", with id: " + repository.getId());
// // An example of creating a session with a known repository id.