cancel
Showing results for 
Search instead for 
Did you mean: 

how can I enable versioning on files via opencmis ?

mmuller
Champ in-the-making
Champ in-the-making
I have alfresco 4 and i attempt use cmis to enable and disable versioning of files.
I use alfresco open cmis extensions.
When I try add versionable proporties to alfrescoDocument
   
Map<String, String> newDocProps = new HashMap<String, String>();
   newDocProps.put("cm:versionable", "true");
   document.updateProperties(newDocProps);

but I get this exception
Exception in thread "main" java.lang.IllegalArgumentException: Property 'cm:versionable' is neither an object type property nor an aspect property!
   at org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl.convertProperties(AlfrescoObjectFactoryImpl.java:181)
   at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.updateProperties(AbstractCmisObject.java:314)
   at org.alfresco.cmis.client.impl.AlfrescoDocumentImpl.updateProperties(AlfrescoDocumentImpl.java:72)
   at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.updateProperties(AbstractCmisObject.java:278)
   at espeo.sikposk.cmis.CmisTest.main(CmisTest.java:57)

But phrase "cm:versionable" is right when use alfrecso webscript and all works.
var nodeRef = args.nodeRef;
var node = search.findNode("workspace://SpacesStore/ae1203ff-f8b8-421e-9f69-5bec5111ec05");
node.addAspect("cm:versionable");

When i attempt add versionable to node using opencmis and aspect, sample is below
   AlfrescoDocument alfDoc = (AlfrescoDocument) document;
   alfDoc.addAspect("cm:versionable");

get this exception

Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Bad Request
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:423)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.read(AbstractAtomPubService.java:554)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getTypeDefinitionInternal(AbstractAtomPubService.java:821)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.RepositoryServiceImpl.getTypeDefinition(RepositoryServiceImpl.java:80)
   at org.apache.chemistry.opencmis.client.bindings.impl.RepositoryServiceImpl.getTypeDefinition(RepositoryServiceImpl.java:137)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.getTypeDefinition(SessionImpl.java:508)
   at org.alfresco.cmis.client.impl.AlfrescoAspectsImpl.addAspect(AlfrescoAspectsImpl.java:93)
   at org.alfresco.cmis.client.impl.AlfrescoDocumentImpl.addAspect(AlfrescoDocumentImpl.java:126)
   at espeo.sikposk.cmis.CmisTest.main(CmisTest.java:64)

question is, How can i enable versioning in alfresco node via cmis?

what I've done wrong?
7 REPLIES 7

mrogers
Star Contributor
Star Contributor
cm:versionable is an aspect, not a property.

Last I heard you need to use an alfresco extension to cmis to set aspects although the spec may have moved on since then.

mmuller
Champ in-the-making
Champ in-the-making
I've written that I had used open cmis alfresco extensions.

and I've tried add this as aspect and property.

I've written about it in my post.

aweber1nj
Champ in-the-making
Champ in-the-making
try

if (!alfDoc.hasAspect("P:cm:versionable")) {
    alfDoc.addAspect("P:cm:versionable");
}
I think Alfresco's extension uses the "P:" prefix to the namespace/name to indicate that it is a Policy (which Alfresco equates to an Aspect).

Let me know if that works.
-AJ

mmuller
Champ in-the-making
Champ in-the-making
I've tried to use:

if (!doc.hasAspect("P:cm:versionable")) {
  doc.addAspect("P:cm:versionable");
}   

but I've got the same error what in the previous post


log4j:WARN No appenders could be found for logger (org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubSpi).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Bad Request
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:423)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.read(AbstractAtomPubService.java:554)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getTypeDefinitionInternal(AbstractAtomPubService.java:821)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.RepositoryServiceImpl.getTypeDefinition(RepositoryServiceImpl.java:80)
   at org.apache.chemistry.opencmis.client.bindings.impl.RepositoryServiceImpl.getTypeDefinition(RepositoryServiceImpl.java:137)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.getTypeDefinition(SessionImpl.java:508)
   at org.alfresco.cmis.client.impl.AlfrescoAspectsImpl.addAspect(AlfrescoAspectsImpl.java:93)
   at org.alfresco.cmis.client.impl.AlfrescoDocumentImpl.addAspect(AlfrescoDocumentImpl.java:126)
   at espeo.sikposk.cmis.CMISTools.enableVersionable(CMISTools.java:409)
   at espeo.sikposk.cmis.CMISTools.enableVersionable(CMISTools.java:403)
   at espeo.sikposk.cmis.CmisTest.main(CmisTest.java:34)

aweber1nj
Champ in-the-making
Champ in-the-making
Your "info" indicates Alfresco 3.0.  Are you still using that?  I think CMIS needs Alfresco 3.3 and later.

Just want to cross that off the list of possible issues.

mmuller
Champ in-the-making
Champ in-the-making
I've written that I used to alfresco 4.0 D

This information is in my first post.

narithota
Champ in-the-making
Champ in-the-making
Is anybody got solution for this problem?