Create a session
Esta página aún no está disponible en tu idioma.
There are three ways to connect to CMIS repository:
| Binding Type | Description |
|---|---|
| Browser | The fastest and the recommended for CMIS 1.1 repositories |
| Atom | Recommended for CMIS 1.0 repositories |
| Web services | The slowest one and not recommended. |
Browser binding
Section titled “Browser binding”Sample to create a connection to the CMIS reposiroty using Browser binding:
// default factory implementationSessionFactory factory = SessionFactoryImpl.newInstance();Map<String, String> parameters = new HashMap<String, String>();
// user credentialsparameters.put(SessionParameter.USER, "okmAdmin");parameters.put(SessionParameter.PASSWORD, "admin");
// connection settingsparameters.put(SessionParameter.BROWSER_URL, "http://localhost:8080/OpenKM/cmis/browser");parameters.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());
// create sessionList<Repository> list= factory.getRepositories(parameters);
// List every repository foundfor (Repository repository: list) { System.out.println("New repository found: " + repository.getId()); System.out.println("Capabilities: "); System.out.println(repository.getCapabilities()); // Create session Session session = repository.createSession();}The session object created will be used in the following sections to operate with the repository.
Atom binding
Section titled “Atom binding”Sample to create a connection to the CMIS repository using Atom binding:
// default factory implementationSessionFactory factory = SessionFactoryImpl.newInstance();Map<String, String> parameters = new HashMap<String, String>();
// user credentialsparameters.put(SessionParameter.USER, "okmAdmin");parameters.put(SessionParameter.PASSWORD, "admin");
// connection settingsparameters.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/OpenKM/cmis/atom");parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// create sessionList<Repository> list= factory.getRepositories(parameters);
// List every repository foundfor (Repository repository: list) { System.out.println("New repository found: " + repository.getId()); System.out.println("Capabilities: "); System.out.println(repository.getCapabilities()); // Create session Session session = repository.createSession();}The session object created will be used in the following sections to operate with the repository.
Web services
Section titled “Web services”With this code a user can connect to the repository using web services.
// default factory implementationSessionFactory factory = SessionFactoryImpl.newInstance();Map<String, String> parameters = new HashMap<String, String>();
// user credentialsparameters.put(SessionParameter.USER, "okmAdmin");parameters.put(SessionParameter.PASSWORD, "admin");
// connection settingsparameters.put(SessionParameter.BINDING_TYPE, BindingType.WEBSERVICES.value());parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, "http://localhost:8080/OpenKM/services/cmis/ACLService?wsdl");parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, "http://localhost:8080/OpenKM/services/cmis/DiscoveryService?wsdl");parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, "http://localhost:8080/OpenKM/services/cmis/MultiFilingService?wsdl");parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, "http://localhost:8080/OpenKM/services/cmis/NavigationService?wsdl");parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, "http://localhost:8080/OpenKM/services/cmis/ObjectService?wsdl");parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, "http://localhost:8080/OpenKM/services/cmis/PolicyService?wsdl");parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, "http://localhost:8080/OpenKM/services/cmis/RelationshipService?wsdl");parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, "http://localhost:8080/OpenKM/services/cmis/RepositoryService?wsdl");parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, "http://localhost:8080/OpenKM/services/cmis/VersioningService?wsdl");
// create sessionList<Repository> list= factory.getRepositories(parameters);
// List every repository foundfor (Repository repository: list) { System.out.println("New repository found: " + repository.getId()); System.out.println("Capabilities: "); System.out.println(repository.getCapabilities()); // Create session Session session = repository.createSession();}The session object created will be used in the following sections to operate with the repository.