Java Code Examples for org.apache.chemistry.opencmis.client.api.SessionFactory#getRepositories()
The following examples show how to use
org.apache.chemistry.opencmis.client.api.SessionFactory#getRepositories() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenCmisLocalTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private Repository getRepository(String user, String password) { // default factory implementation SessionFactory sessionFactory = SessionFactoryImpl.newInstance(); Map<String, String> parameters = new HashMap<String, String>(); // user credentials parameters.put(SessionParameter.USER, "admin"); parameters.put(SessionParameter.PASSWORD, "admin"); // connection settings parameters.put(SessionParameter.BINDING_TYPE, BindingType.LOCAL.value()); parameters.put(SessionParameter.LOCAL_FACTORY, "org.alfresco.opencmis.OpenCmisLocalTest$TestCmisServiceFactory"); // create session List<Repository> repositories = sessionFactory.getRepositories(parameters); return repositories.size() > 0 ? repositories.get(0) : null; }
Example 2
Source File: CMISDataCreatorTest.java From SearchServices with GNU Lesser General Public License v3.0 | 6 votes |
private static Session getSession(String user, String pwd) { String url = "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom"; SessionFactory factory = SessionFactoryImpl.newInstance(); Map<String, String> parameter = new HashMap<String, String>(); parameter.put(SessionParameter.USER, user); parameter.put(SessionParameter.PASSWORD, pwd); parameter.put(SessionParameter.ATOMPUB_URL, url); parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); List<Repository> repositories = factory.getRepositories(parameter); Session session = repositories.get(0).createSession(); return session; }
Example 3
Source File: TestCMIS.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
private void testCanConnectCMISUsingDefaultTenantImpl(Binding binding, String cmisVersion) { String url = httpClient.getPublicApiCmisUrl(TenantUtil.DEFAULT_TENANT, binding, cmisVersion, null); Map<String, String> parameters = new HashMap<String, String>(); // user credentials parameters.put(SessionParameter.USER, "admin"); parameters.put(SessionParameter.PASSWORD, "admin"); parameters.put(SessionParameter.ATOMPUB_URL, url); parameters.put(SessionParameter.BROWSER_URL, url); parameters.put(SessionParameter.BINDING_TYPE, binding.getOpenCmisBinding().value()); SessionFactory factory = SessionFactoryImpl.newInstance(); // perform request : http://host:port/alfresco/api/-default-/public/cmis/versions/${cmisVersion}/${binding} List<Repository> repositories = factory.getRepositories(parameters); assertTrue(repositories.size() > 0); parameters.put(SessionParameter.REPOSITORY_ID, TenantUtil.DEFAULT_TENANT); Session session = factory.createSession(parameters); // perform request : http://host:port/alfresco/api/-default-/public/cmis/versions/${cmisVersion}/${binding}/type?id=cmis:document ObjectType objectType = session.getTypeDefinition("cmis:document"); assertNotNull(objectType); }
Example 4
Source File: PublicApiClient.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * Get CMIS repositories (Enterprise AtomPub CMIS binding) * * @return List<Repository> */ public List<Repository> getCMISRepositories() { List<Repository> repositories = null; RequestContext rc = getRequestContext(); if(rc == null) { throw new RuntimeException("Must set a request context"); } UserData userData = findUser(rc.getRunAsUser()); if(userData != null) { // default factory implementation SessionFactory factory = SessionFactoryImpl.newInstance(); Map<String, String> parameters = new HashMap<String, String>(); // user credentials parameters.put(SessionParameter.USER, rc.getRunAsUser()); parameters.put(SessionParameter.PASSWORD, userData.getPassword()); // connection settings parameters.put(SessionParameter.ATOMPUB_URL, client.getCmisUrl(null, null)); parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); repositories = factory.getRepositories(parameters); } return repositories; }
Example 5
Source File: PublicApiClient.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public List<String> getNetworkIds(String version) { RequestContext rc = getRequestContext(); UserData userData = findUser(rc.getRunAsUser()); if(userData == null) { throw new RuntimeException("Must provide a valid username"); } SessionFactory factory = SessionFactoryImpl.newInstance(); Map<String, String> parameters = new HashMap<String, String>(); // connection settings parameters.put(SessionParameter.ATOMPUB_URL, client.getPublicApiCmisUrl(null, Binding.atom, version, null)); parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); // user credentials parameters.put(SessionParameter.USER, rc.getRunAsUser()); parameters.put(SessionParameter.PASSWORD, userData.getPassword()); List<Repository> repositories = factory.getRepositories(parameters); List<String> repositoryIds = new ArrayList<String>(repositories.size()); for(Repository repository : repositories) { repositoryIds.add(repository.getId()); } return repositoryIds; }