06-27-2020 04:48 PM
I am using chemistry-opencmis-1.1.0.
My understanding is, we first create Session and from Session, we get the ServiceRegistry.
However, when I look at the org.apache.chemistry.opencmis.client.api.Session, I do not see any method called getServiceRegistry. Should I import a different package of Session, which will have the method called getServiceRegistry?
How should we get the serviceRegistry? (This application is not an android mobile app, just a regular Java class).
In my Java project classpath, I have:
chemistry-opencmis-client-api-1.1.0.jar
chemistry-opencmis-client-bindings-1.1.0.jar
chemistry-opencmis-client-impl-1.1.0.jar
chemistry-opencmis-commons-api-1.1.0.jar
chemistry-opencmis-commons-impl-1.1.0.jar
I have written code similar to the following:
//I have the following imports: org.apache.chemistry.opencmis.commons.SessionParameter; org.apache.chemistry.opencmis.commons.enums.BindingType; org.apache.chemistry.opencmis.client.api.SessionFactory; org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl; org.apache.chemistry.opencmis.client.api.Session; org.alfresco.service.ServiceRegistry; Map<String, String> parameter = new HashMap<String, String>(); // 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-/cmis/versions/1.1/atom"); parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); System.out.println(BindingType.ATOMPUB.value()); // set the alfresco object factory parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl"); // create session SessionFactory factory = SessionFactoryImpl.newInstance(); Session session = factory.getRepositories(parameter).get(0).createSession(); //I get error in the line below with error message - cannot find the method getServiceRegistry from Session. ServiceRegistry serviceRegistryFromSession = session.getServiceRegistry();
06-29-2020 02:14 PM
You are using a remote API, OpenCMIS, to access an Alfresco repository. As such, you should not expect to be able to get the Alfresco Service Registry, which is only available to code running in the local repository.
If you need to be able to call methods on the beans that are in the Alfresco Service Registry, you should be running your code in the local Alfresco process, like in a web script, an action, or a behavior.
If you want your code to run remotely, and do all the things that CMIS can do, you'll have to rely on what CMIS provides. If there are gaps, you can supplement those gaps by making calls to the Alfresco 5.2 Public REST API or to custom web scripts from your remote code.
07-02-2020 06:05 PM
Hello Jeff,
I saw your post (Java-OpenCMIS code example) in the past but I cannot locate it. Can you please direct me to that website?
I have a site (e.g. HelloSite) and in the docLibrary of that site, I have multiple folders and at the bottom-most folder, I have a few documents. I need to get the bytes and metadata of these documents. I will have to call in a recursive manner, which I can code. I have successfully coded it using Java-backed web service, but I need to code it Java Session/Open-CMIS API.
Can you please refer me to your site (code examples) where you have the Java-OpenCMIS code example of using Session, Sessionfactory, getRootFolder, getChildren, etc API?
Explore our Alfresco products with the links below. Use labels to filter content by product module.