Friday, 18 March 2016

Repair Corrupted Version History For Alfresco Repository Node

If updating content is failing and in log files following error message can be found:
org.alfresco.service.cmr.version.VersionServiceException: The current 
implementation of the version service does not support the 
creation of branches.
Reason for this error is that current version for content does not point to latest version in version history list. Alfresco repository treats that as a branching case, which is not supported. Solution for this problem is to update current version value to point to latest version.

Option 1:

  1. Identify content that has corrupted version history (determine full path in alfresco repository)
  2. Create the javascript file to Company Home -> Data dictionary -> Scripts with below lines:
    // Path to node with broken version history
    var node = companyhome.childByNamePath("/Keenan/PCB/CMS/1442241086596_WHT_20140904_StudentTransportation_KA.pdf");
    if (node != null){
    // Version Label value for latest version (you can get this from alfresco explorer, click on details for content, in version history you will see all versions, select highest value
    node.properties.versionLabel="1.4";
    logger.log("version updated sucessfully");
    // Save changes
    node.save();
    }
  3. Navigate in alfresco repository to content identified in step 1
  4. Display details of content (click on "View Detail" icon for content)
  5. Expand "Version History" widget and identify latest version and its label
  6. Update javascript file from step 2
    1. update path value by replacing <your_site> and <path_to_content> containers accordingly (value identified in step 1)
    2. update version label container "V.v" with value identified in step 5
  7. Save updated script and confirm changes.
  8. On Scripts space click "Run Action" from actions menu
  9. Select "Execute Script" action and select javascript file updated in step 6
  10. Finish "Run Action" dialog
  11. Verify that issue is fixed by updating content identified in step 1
If not possible to determine latest version label using Details view of content, alternative solution is using node browser.
  1. In Node Browser navigate to content in question in workspace store
  2. Identify node uuid from properties
  3. Change store to version2store in Node Browser
  4. Search by noderef  for node uuid identified in step 2
  5. In Children list for displayed node, all versions are listed.
  6. Inspect all versions and identify lates version
  7. Identify version label for latest version and use it in javascript for repairing corrupted version history 

Option 2:

If previous procedure does not work or it is not possible to determine latest version label:
  1. Remove Versionable aspect
    1. Content's detail view, click on "Run Action" from actions menu
    2. Select "Remove Aspect" and select "Versionable"
    3. Finish "Run Action" Dialog
  2. In Node Browser verify that Versionable aspect is removed
  3. Verify that issue is fixed by updating content

Option 3:

If nothing else works
  1. Delete content 
  2. Upload it again


No comments:

Post a Comment