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();
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.
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?
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.