cancel
Showing results for 
Search instead for 
Did you mean: 

cmis

sunitha
Champ in-the-making
Champ in-the-making
Hi ..

I am new to alfresco.I am trying to connect to the alfresco repository by using cmis api.
My program showing some errors at the atompub line..
could you people help me in regarding this area.
my source code..



import java.util.HashMap;
import java.util.Map;

import javax.xml.ws.BindingType;

import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;


public class Third {
   
   public static void main(String arg[]) throws Exception{
      
      
      Map<String, String> parameter = new HashMap<String, String>();

      // Set the user credentials
      parameter.put(SessionParameter.USER, "admin");
      parameter.put(SessionParameter.PASSWORD, "admin");

      // Specify the connection settings
      parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8070/alfresco/service/cmis");
      parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());

      // Set the alfresco object factory
      parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

      // Create a session
      SessionFactory factory = SessionFactoryImpl.newInstance();
      Session session = factory.getRepositories(parameter).get(0).createSession();
       System.out.println("Connected to repository:");
   }

}



Thanks,
Sunitha..
22 REPLIES 22

Can you put your CMIS code here?

I have resolved that problem by changing the web service url.
I am hiving one more doubt. Is it possible connect Alfresco5.0.d community with alfresco3.x web service url(http://<HOSTNAME>:<PORT>/alfresco/api)??
Because while trying the above scenario, I am getting Error: Unexpected document! Received: HTML document.

Please help me on this.

Thanks

gravitonian
Star Collaborator
Star Collaborator
Hi,

I have an All-in-One (AIO) 2.1 SDK project with some CMIS example code that might help: see https://github.com/gravitonian/all-in-one-it/blob/master/integration-test-runner/src/test/java/org/a...

If you are running with 4.2.c then you would need to use other URLs to connect, see:

{code}
// Use this URL for Alfresco versions older than 4.2.e Community and 4.2.0 Enterprise
parameters.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/cmisatom");
{code}

Also, if your are on 4.2.c you cannot use secondary types, so you need Alfresco CMIS extension:

{code}
// If you are using an Alfresco versions older than 4.2.e Community and 4.2.0 Enterprise
// then use this Alfresco specific factory for object creation
// to get Alfresco specific document and folder classes that can be used to manage aspects
parameters.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
{code}

In your pom.xml add the following so the AlfrescoObjectFactoryImpl can be found:

{code}
        <!–
            Use the Alfresco OpenCMIS library when your Alfresco server version is older than
            4.2.e Community or 4.2.0 Enterprise, These versions or newer can handle aspects
            via Secondary types, so no need for this library.

            Bring in Alfresco OpenCMIS extension so we can have an easier way of getting to
            aspect properties and managing aspects, which is otherwise through the CMIS Extension mechanism.
            For this to work the Object Factory has been changed via the Session property
            org.apache.chemistry.opencmis.objectfactory.classname–>
        <dependency>
            <groupId>org.alfresco.cmis.client</groupId>
            <artifactId>alfresco-opencmis-extension</artifactId>
            <version>0.4</version>
            <exclusions>

                <!– Exclude the OpenCMIS library so we do not end up with
                  multiple versions in for example WEB-INF/lib –>
                <exclusion>
                    <groupId>org.apache.chemistry.opencmis</groupId>
                    <artifactId>chemistry-opencmis-client-impl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
{code}