cancel
Showing results for 
Search instead for 
Did you mean: 

In process open cmis in alfresco 4 documentation?

jpearson
Champ in-the-making
Champ in-the-making
In the Alfresco 4.0.a release notes(http://wiki.alfresco.com/wiki/Alfresco_Community_4.0.a#CMIS) it mentions "Access to OpenCMIS Client API within Repository (in-process)". I assume that this means that we can create a bean with an open cmis session already initialized with the current credentials. I cant seem to find any documentation on this. I don't need help with the open cmis api, thats all over the net, but just how to create a java bean with an open cmis session. Can any one point me to the docs for this feature? My google skills are failing me on this…
7 REPLIES 7

fmui
Champ in-the-making
Champ in-the-making
There is not much documentation, but Alfresco 4 ships with sample code.

Have a look at:
http://<host>/alfresco/service/cmissamples
http://<host>/alfresco/service/cmis-browser-app/connections

In order to connect to the local Alfresco server from JavaScript use this snippet:
var cmisConnection = cmis.getConnection()
var cmisSession = cmisConnection.getSession()
The returned session object is an OpenCMIS session to the local Alfresco repository for the current user.

You were talking about a Java bean. Do you want use the OpenCMIS API from Java or JavaScript?

Florian

jpearson
Champ in-the-making
Champ in-the-making
Thanks for your reply but I have already used open cmis. What I am looking for is information on how to use cmis on an in process alfresco extension written in java. So for example you know how its possible to create an alfresco extension in java and you can create a java bean that has say the nodeService as a property and spring will set its value when it creates the object the bean describes. That is what I mean by "in process". At least that my interpretation. So from the release notes that I linked to above it sounds like its possible to use opencmis calls instead of node service for in process alfresco extensions. I suppose I could just create the open cmis connection myself but then I need to decide what user/pass to authenticate with, it sounds like I can create a java bean that would set it as a property for me(sort of like I described with node service).

So for example if I have a services-context.xml like this how could I add in an open cmis Session property.
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

    <bean id="documentEventHandler" class="com.foobar.eventhandler.DocumentEventHandler"
          init-method="registerEventHandlers">
       
        <property name="policyComponent">
            <ref bean="policyComponent"/>
        </property>
       
        <property name="nodeService">
            <ref bean="nodeService"/>
        </property>
       
    </bean>
</beans>

fmui
Champ in-the-making
Champ in-the-making
It is not possible to create a bean. Each OpenCMIS session is bound to a user and a bean isn't.
You can, however, create a session for each user that bypasses the network and inherits the user credentials:
parameters.put(SessionParameter.BINDING_TYPE, BindingType.LOCAL.value());
parameters.put(SessionParameter.LOCAL_FACTORY, "org.alfresco.opencmis.AlfrescoLocalCmisServiceFactory");
parameters.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
But you have to make sure that you the use the session object only for the user it has been created for.

Florian

jpearson
Champ in-the-making
Champ in-the-making
Thanks, I will try that out.

jpearson
Champ in-the-making
Champ in-the-making
Just as an update. I tried what was posted above and it works but there was one gotcha. I am using policies to trigger my code when content is updated or created. In the case of content being just created OpenCMIS does not see it (I presume because the transaction has not been committed yet). Node service on the other hand can see the content so I am using node service. If any one wants to elaborate on this feel free. For now though I will just use node service. Big thanks to every one for the help.

plastiko
Champ in-the-making
Champ in-the-making
In order to connect to the local Alfresco server from JavaScript use this snippet:
var cmisConnection = cmis.getConnection()
var cmisSession = cmisConnection.getSession()
The returned session object is an OpenCMIS session to the local Alfresco repository for the current user.

You were talking about a Java bean. Do you want use the OpenCMIS API from Java or JavaScript?

Florian

Hi Florian, I'm writing Java code running in Share (my jar will be put in /tomcat/webapps/share/WEB-INF/lib) and i need to obtain a valid CMIS Session for the current user. Is it possible to obtain in Java something like the cmis javascript object?

Tnx

Samuele

acurs
Champ in-the-making
Champ in-the-making
plastiko,
You might want to take a look to http://ecmarchitect.com/archives/2012/01/09/1509
The code has some examples of the OpenCMIS API, look at the CMISExampleBase.java it implements a getSession method….

Also you should take a look to the webinar where it explains: http://ecmarchitect.com/archives/2012/01/25/1526
and http://ecmarchitect.com/archives/2012/01/27/1534

cheers