public void updateCollaborators(
     Resource resource,
     List<String> collaboratorsList,
     User apiCaller,
     String predicate,
     Set<Segment> collectionSegments,
     Set<AssessmentSegment> quizSegments) {
   if (collaboratorsList != null && collaboratorsList.size() > 0 && !collaboratorsList.isEmpty()) {
     List<User> userList = this.getUserRepository().findByIdentities(collaboratorsList);
     updateCollaborators(resource, userList, apiCaller, predicate, true);
     if (collectionSegments != null && collectionSegments.size() > 0) {
       for (Segment segment : collectionSegments) {
         for (ResourceInstance resourceInstance : segment.getResourceInstances()) {
           if (resourceInstance != null) {
             updateCollaborators(
                 resourceInstance.getResource(), userList, apiCaller, predicate, false);
           }
         }
       }
     } else if (quizSegments != null && quizSegments.size() > 0) {
       for (AssessmentSegment quizSegment : quizSegments) {
         for (AssessmentSegmentQuestionAssoc quizSegmentQuestionAssoc :
             quizSegment.getSegmentQuestions()) {
           if (quizSegmentQuestionAssoc != null) {
             updateCollaborators(
                 quizSegmentQuestionAssoc.getQuestion(), userList, apiCaller, predicate, false);
           }
         }
       }
     }
   }
 }
 public static void resetInstancesSequence(Segment segment) {
   if (segment == null || segment.getResourceInstances() == null) {
     return;
   }
   List<ResourceInstance> resourceInstances = new ArrayList<ResourceInstance>();
   resourceInstances.addAll(segment.getResourceInstances());
   Collections.sort(resourceInstances, new ResourceInstanceComparator());
   int sequence = 0;
   for (ResourceInstance resourceInstance : resourceInstances) {
     resourceInstance.setSequence(++sequence);
   }
   segment.getResourceInstances().clear();
   segment.getResourceInstances().addAll(resourceInstances);
 }