AnsweredAssumed Answered

How to getProperties of a Document with OpenCmis

Question asked by moveax0 on May 19, 2016
Latest reply on May 30, 2016 by moveax0
Hi

I have some problem to get all the properties of a Document with OpenCmis and Atom Binding

This is our environment

Alfresco Version: Community - 5.1.0

Pom:

<dependency>
   <groupId>org.apache.chemistry.opencmis</groupId>
   <artifactId>chemistry-opencmis-client-api</artifactId>
   <version>0.13.0</version>
</dependency>

<dependency>
   <groupId>org.apache.chemistry.opencmis</groupId>
   <artifactId>chemistry-opencmis-client-impl</artifactId>
   <version>0.13.0</version>
</dependency>

And this is the code:

Map<String, String> properties = new HashMap<String, String>();
properties.put(SessionParameter.USER, user);
properties.put(SessionParameter.PASSWORD, password);
properties.put(SessionParameter.ATOMPUB_URL, "http://{host}:{port}/alfresco/api/-default-/public/cmis/versions/1.1/atom");
properties.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
SessionFactory factory = SessionFactoryImpl.newInstance();
session = factory.getRepositories(properties).get(0).createSession();

String="ObjectId";
ObjectId id = session.createObjectId(idObject);
CmisObject object = session.getObject(id);
Document document = (Document) object;
List<Property<?>> properties = document.getProperties();

If I run the code I obtain this error:
java.lang.ClassCastException: org.apache.chemistry.opencmis.client.runtime.FolderImpl cannot be cast to org.apache.chemistry.opencmis.client.api.Document

After some Google search I have try to add this parameter to the SessionFactory and add alfresco-opencmis-extension dependency to pom:
properties.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

<dependency>
   <groupId>org.alfresco.cmis.client</groupId>
   <artifactId>alfresco-opencmis-extension</artifactId>
   <version>0.3</version>
</dependency>

The exception is changed and It becomes:
java.lang.NoClassDefFoundError: org/apache/chemistry/opencmis/client/api/TransientCmisObject

Do you have any idea Where is the problem?

Is there an how to that explains how to retrieve the Document properties?

Thank in advance

Outcomes