cancel
Showing results for 
Search instead for 
Did you mean: 

When generating the document, I can't mark it as versionable so that the versioning actually version

marcog
Star Contributor
Star Contributor
Hi
 
When generating the document, I can't mark it as versionable so that the versioning actually versions it and doesn't overwrite it. To solve this, the parent folder of the upload folder must have a rule in the input to set the cm:versionable aspect valid for the subfolders as well. So to test this, if you import it WITHOUT the rule and it versions it, everything would be fine. But in the SDK environment without the rule, it doesn't work.
 
I'm using Alfresco ECM (community) 23.2 dockerized in Ubuntu 22.04. I'm importing files into Alfresco using CMIS (openCMIIS) with an external jar and I notice that the imported document does not have the cm:versionable aspect applied so when it needs to be versioned it's substituted. I tired to apply the aspect using this suggestion 
 
 
like this:
 
List<Object> aspects = doc.getProperty("cmis:secondaryObjectTypeIds").getValues();
if (!aspects.contains("P:cm:versionable")) {
aspects.add("P:cm:versionable");
HashMap<String, Object> props = new HashMap<String, Object>();
props.put("cmis:secondaryObjectTypeIds", aspects);
doc.updateProperties(props);
System.out.println("Added aspect");
} else {
System.out.println("Doc already had aspect");
}
HashMap<String, Object> props = new HashMap<String, Object>();
props.put("cm:versionable", true);
doc.updateProperties(props);
 
When I create the document testing the method and try this I get:
 
Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException: Type 'P:cm:versionable' is unknown!
 
on this line doc.updateProperties(props);
 
The syntax of the secondary Ids seems ok because I printed this:
 
Doc aspect: P:sys:localized
 
Is something special needed for cm:versionable?
 
As a workaround I defined a rule on the folder to apply this aspect but I would rather have this done with CMIS to avoid managing supporting rules.
 
1 ACCEPTED ANSWER

angelborroy
Community Manager Community Manager
Community Manager

Aspects VERSIONABLE, AUDITABLE and REFERENCEABLE are not CMIS-exposed:

https://github.com/Alfresco/alfresco-data-model/blob/5baba42306646cb5cfb11186d632b98fd5996298/src/ma...

Hyland Developer Evangelist

View answer in original post

1 REPLY 1

angelborroy
Community Manager Community Manager
Community Manager

Aspects VERSIONABLE, AUDITABLE and REFERENCEABLE are not CMIS-exposed:

https://github.com/Alfresco/alfresco-data-model/blob/5baba42306646cb5cfb11186d632b98fd5996298/src/ma...

Hyland Developer Evangelist