Search code examples
javarestalfrescoalfresco-webscripts

Alfresco: change document content without changing the version


I've an Alfresco Community 6.2 version and I need to update the content of some documents without incrementing the version, from an external process. I've the following behaviour now:

The nodes to be modified have aspect cm:versionable and I cannot change that; If I update the content using REST API trough this PUT https://api-explorer.alfresco.com/alfresco/api/-default-/public/alfresco/versions/1/nodes/aaa/content?majorVersion=false a new minor version is being created.

I cannot remove the aspect because otherwise also the other previous versions of that node (manually created) will be removed, and I cannot afford that.

Is there a way? or some workaround using internal java API or CMIS something??

Thanks


Solution

  • You can simply update a node's content by using

    PUT ​/nodes​/{nodeId}​/content
    

    You can disable a node's autoversioning behavior by setting "cm:autoVersion"=false

    Alfresco's version behavior is a bit different as you may expect:

    • The main node is stored in workspace://SpacesStore
    • A version is implemented as a read only snapshot copy in workspace://version2Store by either checkout/checkin or by behavior
    • You can only update the main node's content and Alfresco is faking the main node as latest version (you can check that using the node browser)
    • when you remove the aspect you only modify the versioning behavior but you will not remove the snapshotted versions in workspace://version2Store
    • Versioning behavior is controlled by either alfresco-global.properties (e.g.version.store.enableAutoVersionOnUpdateProps=true) and/or by the aspect cm:versionable attached to a node
    • Alfresco Share, CMIS & REST will automatically add the versionable aspect on node creation having the following defaults (which can be modified in alfresco-global.properties):
      • cm:initialVersion=true: indicates that when the versionable aspect is applied, an initial snapshot of the node is taken at that point
      • cm:autoVersion=true: indicates that when ever a change is made to the content of a node, a new snapshot version will be created in the version store
      • cm:autoVersionOnUpdateProps=false: indicates that when ever a change is made to the properties of a node, a new snapshot version will be created