How to getProperties of a Document with OpenCmis
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2016 07:47 AM
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
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
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2016 09:10 AM
I am using 5.0.d, so do not know if this helps…
I see a slight difference in my code. It works.
I remember getting the same error. Now I could not say how it is gone. Sorry.
It looks like the combination of these - 1. the URL, 2. the opencmis libraries (versions) and 3. the SessionParameters used on the SessionFactory - matters a lot. They are very sensitive.
Here is the code (that works for me)
I use opencmis libraries
<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>
Please post the answer when you figure out the exact issue or any more details…
I see a slight difference in my code. It works.
I remember getting the same error. Now I could not say how it is gone. Sorry.
It looks like the combination of these - 1. the URL, 2. the opencmis libraries (versions) and 3. the SessionParameters used on the SessionFactory - matters a lot. They are very sensitive.
Here is the code (that works for me)
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();List<Repository> repositories = factory.getRepositories(properties);Respository cmisRepository = repositories.get(0);properties.put(SessionParameter.REPOSITORY_ID, cmisRepository.getId());cmisSession = factory.createSession(properties);….
I use opencmis libraries
<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>
Please post the answer when you figure out the exact issue or any more details…
Gnanasekaran Sakthivel
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2016 11:06 AM
Thank you for the response.
I have solved. It was a Pom configuration problem. Alfresco 5.0d works well with the library that we have used
I have solved. It was a Pom configuration problem. Alfresco 5.0d works well with the library that we have used
