cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco 5.0 with cmis 1.0 aspects fail

ephesoft
Champ in-the-making
Champ in-the-making
Hi,

I am trying to use Alfresco 5.0 community version for cmis 1.0 with Service URL as: http://servernameSmiley Tongueort/alfresco/api/-default-/public/cmis/versions/1.0/atom.

I am using Alfresco Extension jar version 0.3:
   sessionParameters.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

But the aspect fails with exception of no aspect property defined. I simply moved from Alfresco 4.2 version to 5.0 version with no other change, but aspects fail with following exception:

Caused by: java.lang.IllegalArgumentException: Property 'cm:description' is not valid for this type or one of the secondary types!

I tried to use this with opencmis chemistry jar version 0.6.0 and with version 0.10.0. Same error occured on both.

Is it taht Alfresco 5.0 with cmis 1.0 does not support aspects?
5 REPLIES 5

jm_pascal
Star Contributor
Star Contributor
Aloah,

Have you tested with latest version of Alfresco OpenCMIS Extension (1.0) ?

See at https://artifacts.alfresco.com/nexus/#nexus-search;quick~alfresco-opencmis-extension

ephesoft
Champ in-the-making
Champ in-the-making
Thanks for the help.

Now, we are using Alfresco extension jar version 1.0 and openmcmis version 0.10.0 versions.
But now the code fails with exception:

Caused by: org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Document is not the latest version!
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:458)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.put(AbstractAtomPubService.java:653)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.put(AbstractAtomPubService.java:640)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.updateProperties(ObjectServiceImpl.java:333)
   at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.updateProperties(AbstractCmisObject.java:343)
   at org.alfresco.cmis.client.impl.AlfrescoDocumentImpl.updateProperties(AlfrescoDocumentImpl.java:64)
   at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.updateProperties(AbstractCmisObject.java:307)


the code is:
org.apache.chemistry.opencmis.client.api.Document doc = targetFolder.createDocument(propertiesDocument, contentStream,
               VersioningState.MAJOR);

   AlfrescoDocument alfrescoDoc = (AlfrescoDocument) doc;
      alfrescoDoc.addAspect("P:cm:taggable");
      
           Map<String, Object> properties = new HashMap<String, Object>();
           properties.put("cm:description", "My taggable document");
           alfrescoDoc.updateProperties(properties);

It fails on the last line.

Please help.

jm_pascal
Star Contributor
Star Contributor
The error is explicit : Document is not the latest version!

It means the document you try to update is not the latest version. You need to retrieve the latest version before trying to update it.
When you execute alfrescoDoc.addAspect("P:cm:taggable"); The document has changed.

ephesoft
Champ in-the-making
Champ in-the-making
Thanks for the help, it worked.

Another thing is we are trying to provide backward compatibility with Alfresco version 3.x and 4.2 for cmis 1.0. This code with opencmis jars version 0.10.0 and alfresco extension 1.0.

We used Alreco 4.2c commuinity version with url:

http://<servername>:<port>/alfresco/cmisatom
http://<servername>:<port>/alfresco/service/cmis
http://<servername>:<port>/alfresco/api/-default-/public/cmis/versions/1.0/atom

It gives following exception:

java.lang.IllegalArgumentException: Property 'cm:description' is neither an object type property nor an aspect property!
   at org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl.convertProperties(AlfrescoObjectFactoryImpl.java:196)
   at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.updateProperties(AbstractCmisObject.java:343)
   at org.alfresco.cmis.client.impl.AlfrescoDocumentImpl.updateProperties(AlfrescoDocumentImpl.java:64)
   at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.updateProperties(AbstractCmisObject.java:307)

jm_pascal
Star Contributor
Star Contributor
Be aware that Alfresco 3.X has different version of OpenCMIS than 5.X and CMIS features coverage might have changed (+ bugfix)

Furthermore
http://:/alfresco/cmisatom ==> Available since Alfresco 4.X
http://:/alfresco/service/cmis ==> Available since Alfresco 3.4 and removed from Alfresco 5.X
http://:/alfresco/api/-default-/public/cmis/versions/1.0/atom ==> Available since Alfresco 4.2.X