Quantcast
Channel: Alfresco Forums - Alfresco API
Viewing all articles
Browse latest Browse all 252

How to getProperties of a Document with OpenCmis

$
0
0

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:

org.apache.chemistry.opencmis
chemistry-opencmis-client-api
0.13.0

org.apache.chemistry.opencmis
chemistry-opencmis-client-impl
0.13.0

And this is the code:

Map properties = new HashMap();
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> 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");

org.alfresco.cmis.client
alfresco-opencmis-extension
0.3

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

5.1.x

Viewing all articles
Browse latest Browse all 252

Trending Articles