Uploaded image for project: 'Service Packs and Hot Fixes'
  1. Service Packs and Hot Fixes
  2. MNT-16583

Please add a getRootVersion method in Version2ServiceImpl.java as the existing way is not performant on nodes with 7000 versions

    Details

    • Type: Improvement
    • Status: Closed
    • Resolution: Won't Do
    • Affects Version/s: 5.1.1
    • Fix Version/s: None
    • Component/s: Versioning
    • Labels:
      None
    • Bug Priority:
      Category 3
    • ACT Numbers:

      00692425

    • Premier Customer:
      Yes

      Description

      Currently if you want to get the root version of a node (the very first initial version), you will have to do the following:

      VersionHistory versionHistory = this.serviceRegistry.getVersionService().getVersionHistory(nodeRef);
      versionHistory.getRootVersion();
      
      

      This creates a versionHistory object that traverses all versions just for getting to the root version! It becomes a performance hit to a customer on nodes of 7000 versions every time they want to get the root versions.

      We hope Alfresco could implement this better, perhapes add a getRootVersion method in Version2ServiceImpl.java so they can use it rather than going through this unperformant way.

      Here is a code suggestion to go into Version2ServiceImpl.java:

          public Version getRootVersion(NodeRef nodeRef) {
              NodeRef versionHistoryRef = getVersionHistoryNodeRef(nodeRef);
              if (versionHistoryRef != null) {
                  List<ChildAssociationRef> versionAssocs = getVersionAssocs(nodeRef, false);
                  return this.getVersion(versionAssocs.iterator().next().getChildRef());
              }
              return null;
          }
      
      

      The code suggestion assumes that the first entry is always the root version, if we are worried about out-of-order versions reported in MNT-226, we could add the following optional check and modify the comparator to accept List<ChildAssociationRef>:

               if (versionComparatorDesc != null)
               {
                   Collections.sort(versionAssocs, Collections.reverseOrder(versionComparatorDesc));
               }
      

      All in all, we should have a better way to get the root version and not make customers traverse through all versions just to get the root version.

        Attachments

          Issue Links

            Structure

              Activity

                People

                • Assignee:
                  closedissues Closed Issues
                  Reporter:
                  ctan Craig Tan [X] (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Structure Helper Panel