Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-8296

MergingResourceProvider purges the last item if existing item is overlaid and has sling:orderBefore property set

    XMLWordPrintableJSON

    Details

      Description

      The MergingResourceProvider has a logic which tends to purge the last element on the merged list if one of the overlaid nodes is from the original node and has a "sling:orderBefore" property.

      Example:

      /libs resource has

      create, edit, delete, update, rollout

      /apps overlaid resource has

      move, create (sling:orderBefore=edit)

      The orderBefore property in the /apps resource is added to ensure that the overlaid node is not pushed to the end.

      Excepted Merged Resource /mnt/overlay

      create, edit, delete, update, rollout, move

      Actual Response

      create, edit, delete, update, rollout

      This is due to a logical issue in the following lines of code in MergingResourceProvider. 

      When the _sling:_orderBefore is set, even though childPositionInCandidateList is actually not -1, this logic is not triggered and the first block executes, which adds the overlaid existing node create twice and removes the last element move in the previous example.

      // either reorder because of explicit reording property
      if (orderBeforeIndex > -1) {
          candidates.add(orderBeforeIndex, holder);
          candidates.remove(candidates.size() - 1);
      } else {
          // or reorder because overlaid resource has a different order
          if (childPositionInCandidateList != -1 && previousChildPositionInCandidateList != -1) {
              candidates.remove(childPositionInCandidateList);
              if (childPositionInCandidateList < previousChildPositionInCandidateList) {
                  previousChildPositionInCandidateList--;
              }
              if(previousChildPositionInCandidateList+1 > candidates.size()){
                  candidates.add(holder);
              } else {
                  candidates.add(previousChildPositionInCandidateList + 1, holder);
              }
              previousChildPositionInCandidateList++;
          }
      }
      
      

       

        Attachments

          Activity

            People

            • Assignee:
              cziegeler Carsten Ziegeler
              Reporter:
              bhagwath Janaki Ratnakar Bhagwath
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: