@Override
 public ActionResponseDTO<Classpage> createClasspage(
     Classpage classpage, boolean addToUserClasspage, String assignmentId) throws Exception {
   Errors errors = validateClasspage(classpage);
   if (!errors.hasErrors()) {
     this.getCollectionRepository().save(classpage);
     if (assignmentId != null && !assignmentId.isEmpty()) {
       CollectionItem collectionItem = new CollectionItem();
       collectionItem.setItemType(ShelfType.AddedType.ADDED.getAddedType());
       collectionItem =
           this.createClasspageItem(
                   assignmentId,
                   classpage.getGooruOid(),
                   collectionItem,
                   classpage.getUser(),
                   CollectionType.CLASSPAGE.getCollectionType())
               .getModel();
       Set<CollectionItem> collectionItems = new TreeSet<CollectionItem>();
       collectionItems.add(collectionItem);
       classpage.setCollectionItems(collectionItems);
     }
     if (addToUserClasspage) {
       CollectionItem collectionItem = new CollectionItem();
       collectionItem.setItemType(ShelfType.AddedType.ADDED.getAddedType());
       this.createClasspageItem(
           classpage.getGooruOid(),
           null,
           collectionItem,
           classpage.getUser(),
           CollectionType.USER_CLASSPAGE.getCollectionType());
     }
     this.getCollectionRepository().save(classpage);
   }
   return new ActionResponseDTO<Classpage>(classpage, errors);
 }
 private String moveCollection(String collectionId, Collection targetCollection, User user) {
   CollectionItem sourceCollectionItem =
       getCollectionDao().getCollectionItemById(collectionId, user);
   rejectIfNull(sourceCollectionItem, GL0056, 404, COLLECTION);
   // need to put validation for collaborator
   CollectionItem collectionItem = new CollectionItem();
   if (sourceCollectionItem.getItemType() != null) {
     collectionItem.setItemType(sourceCollectionItem.getItemType());
   }
   String collectionType =
       getParentCollection(
           sourceCollectionItem.getContent().getContentId(),
           sourceCollectionItem.getContent().getContentType().getName(),
           collectionId,
           targetCollection);
   String contentType = null;
   if (collectionType.equalsIgnoreCase(LESSON)) {
     contentType = sourceCollectionItem.getContent().getContentType().getName();
   }
   createCollectionItem(collectionItem, targetCollection, sourceCollectionItem.getContent(), user);
   resetSequence(
       sourceCollectionItem.getCollection().getGooruOid(),
       sourceCollectionItem.getCollectionItemId(),
       user.getPartyUid(),
       COLLECTION);
   getCollectionDao().remove(sourceCollectionItem);
   getAsyncExecutor().deleteFromCache(V2_ORGANIZE_DATA + user.getPartyUid() + "*");
   return contentType;
 }
 @Override
 @Transactional(
     readOnly = false,
     propagation = Propagation.REQUIRED,
     rollbackFor = Exception.class)
 public ActionResponseDTO<CollectionItem> createResource(
     String collectionId, CollectionItem collectionItem, User user) {
   Resource resource = collectionItem.getResource();
   final Errors errors = validateResource(resource);
   if (!errors.hasErrors()) {
     Collection collection =
         getCollectionDao().getCollectionByType(collectionId, COLLECTION_TYPES);
     rejectIfNull(collection, GL0056, 404, COLLECTION);
     resource.setSharing(collection.getSharing());
     resource = getResourceBoService().createResource(resource, user);
     collectionItem.setItemType(ADDED);
     collectionItem = createCollectionItem(collectionItem, collection, resource, user);
     getCollectionEventLog()
         .collectionItemEventLog(
             collectionId, collectionItem, user.getPartyUid(), RESOURCE, collectionItem, ADD);
     updateCollectionMetaDataSummary(collection.getContentId(), RESOURCE, ADD);
     Map<String, Object> data =
         generateResourceMetaData(resource, collectionItem.getResource(), user);
     createContentMeta(resource, data);
   }
   return new ActionResponseDTO<CollectionItem>(collectionItem, errors);
 }
 @Override
 @Transactional(
     readOnly = false,
     propagation = Propagation.REQUIRED,
     rollbackFor = Exception.class)
 public void deleteCollection(
     String courseId, String unitId, String lessonId, String collectionId, User user) {
   CollectionItem collection =
       this.getCollectionDao().getCollectionItem(lessonId, collectionId, user.getPartyUid());
   rejectIfNull(collection, GL0056, 404, COLLECTION);
   reject(
       this.getOperationAuthorizer().hasUnrestrictedContentAccess(collectionId, user),
       GL0099,
       403,
       COLLECTION);
   Collection lesson = getCollectionDao().getCollectionByType(lessonId, LESSON_TYPE);
   rejectIfNull(lesson, GL0056, 404, LESSON);
   Collection course = getCollectionDao().getCollectionByType(courseId, COURSE_TYPE);
   rejectIfNull(course, GL0056, 404, COURSE);
   Collection unit = getCollectionDao().getCollectionByType(unitId, UNIT_TYPE);
   rejectIfNull(unit, GL0056, 404, UNIT);
   this.resetSequence(lessonId, collection.getCollectionItemId(), user.getPartyUid(), COLLECTION);
   this.deleteCollection(collectionId);
   this.updateContentMetaDataSummary(
       lesson.getContentId(), collection.getContent().getContentType().getName(), DELETE);
   collection.getContent().setIsDeleted((short) 1);
   this.getCollectionDao().save(collection);
   getCollectionEventLog()
       .collectionEventLog(courseId, unitId, lessonId, collection, user, null, DELETE);
 }
 protected void lessonCopyItems(String lessonId, Collection newLesson, User user) {
   List<CollectionItem> collectionItems =
       this.getCollectionDao().getCollectionItems(lessonId, false);
   for (CollectionItem sourceLessonItem : collectionItems) {
     getCollectionCopyService()
         .collectionCopy(newLesson, sourceLessonItem.getContent().getGooruOid(), user);
   }
 }
 private String getParentCollection(
     Long collectionId, String collectionType, String gooruOid, Collection targetCollection) {
   CollectionItem lesson = this.getCollectionDao().getParentCollection(collectionId);
   reject(
       !(lesson.getCollection().getGooruOid().equalsIgnoreCase(targetCollection.getGooruOid())),
       GL0111,
       404,
       lesson.getCollection().getCollectionType());
   if (lesson.getCollection().getCollectionType().equalsIgnoreCase(LESSON)) {
     updateContentMetaDataSummary(lesson.getCollection().getContentId(), collectionType, DELETE);
   }
   return targetCollection.getCollectionType();
 }
 @Override
 @Transactional(
     readOnly = false,
     propagation = Propagation.REQUIRED,
     rollbackFor = Exception.class)
 public CollectionItem addResource(String collectionId, String resourceId, User user) {
   Collection collection = getCollectionDao().getCollectionByType(collectionId, COLLECTION_TYPES);
   rejectIfNull(collection, GL0056, 404, COLLECTION);
   Resource resource = getResourceBoService().getResource(resourceId);
   rejectIfNull(resource, GL0056, 404, RESOURCE);
   reject(!resource.getContentType().getName().equalsIgnoreCase(QUESTION), GL0056, 404, RESOURCE);
   updateCollectionMetaDataSummary(collection.getContentId(), RESOURCE, ADD);
   CollectionItem collectionItem = new CollectionItem();
   getCollectionEventLog()
       .collectionItemEventLog(
           collectionId, collectionItem, user.getPartyUid(), RESOURCE, null, ADD);
   collectionItem.setItemType(ADDED);
   return createCollectionItem(collectionItem, collection, resource, user);
 }
 @Override
 @Transactional(
     readOnly = false,
     propagation = Propagation.REQUIRED,
     rollbackFor = Exception.class)
 public void updateQuestion(
     String collectionId, String collectionQuestionItemId, String data, User user) {
   final CollectionItem collectionItem =
       this.getCollectionDao().getCollectionItem(collectionQuestionItemId);
   rejectIfNull(collectionItem, GL0056, 404, _COLLECTION_ITEM);
   AssessmentQuestion newAssessmentQuestion =
       this.getQuestionService()
           .updateQuestion(collectionItem.getContent().getGooruOid(), data, user);
   Map<String, Object> metaData =
       generateQuestionMetaData(collectionItem.getContent(), newAssessmentQuestion, user);
   if (metaData != null && metaData.size() > 0) {
     ContentMeta contentMeta =
         this.getContentRepository().getContentMeta(collectionItem.getContent().getContentId());
     updateContentMeta(contentMeta, metaData);
   }
 }
 private Collection copyLesson(Collection lesson, Collection unit, User user) {
   Collection newLesson = new Collection();
   newLesson.setTitle(lesson.getTitle());
   newLesson.setCopiedCollectionId(lesson.getGooruOid());
   newLesson.setCollectionType(lesson.getCollectionType());
   newLesson.setDescription(lesson.getDescription());
   newLesson.setNotes(lesson.getNotes());
   newLesson.setLanguage(lesson.getLanguage());
   newLesson.setImagePath(lesson.getImagePath());
   newLesson.setGooruOid(UUID.randomUUID().toString());
   newLesson.setContentType(lesson.getContentType());
   newLesson.setLastModified(new Date(System.currentTimeMillis()));
   newLesson.setCreatedOn(new Date(System.currentTimeMillis()));
   newLesson.setIsRepresentative(0);
   newLesson.setSharing(lesson.getSharing());
   newLesson.setUser(user);
   newLesson.setOrganization(lesson.getOrganization());
   newLesson.setCreator(lesson.getCreator());
   newLesson.setUrl(lesson.getUrl());
   this.getCollectionDao().save(newLesson);
   // copy lesson items to collection
   lessonCopyItems(lesson.getGooruOid(), newLesson, user);
   copyContentTaxonomyCourse(lesson.getContentId(), newLesson);
   copyContentMetaAssoc(lesson.getContentId(), newLesson);
   copyContentClassification(lesson.getContentId(), newLesson);
   copyCollectionRepoStorage(lesson, newLesson);
   // copy content meta details
   ContentMeta contentMeta = this.getContentRepository().getContentMeta(lesson.getContentId());
   ContentMeta newContentMeta = new ContentMeta();
   if (contentMeta != null) {
     newContentMeta.setContent(newLesson);
     newContentMeta.setMetaData(contentMeta.getMetaData());
     this.getContentRepository().save(newContentMeta);
   }
   // associating the copied collection to lesson
   CollectionItem newCollectionItem = new CollectionItem();
   newCollectionItem.setItemType(ADDED);
   createCollectionItem(newCollectionItem, unit, newLesson, user);
   return newLesson;
 }
 @Override
 @Transactional(
     readOnly = false,
     propagation = Propagation.REQUIRED,
     rollbackFor = Exception.class)
 public void updateResource(
     String collectionId,
     String collectionResourceItemId,
     CollectionItem newCollectionItem,
     User user) {
   final CollectionItem collectionItem =
       this.getCollectionDao().getCollectionItem(collectionResourceItemId);
   rejectIfNull(collectionItem, GL0056, 404, _COLLECTION_ITEM);
   this.getResourceBoService()
       .updateResource(
           collectionItem.getContent().getGooruOid(), newCollectionItem.getResource(), user);
   Map<String, Object> data =
       generateResourceMetaData(
           collectionItem.getContent(), newCollectionItem.getResource(), user);
   if (data != null && data.size() > 0) {
     ContentMeta contentMeta =
         this.getContentRepository().getContentMeta(collectionItem.getContent().getContentId());
     updateContentMeta(contentMeta, data);
   }
 }
 @Override
 public ActionResponseDTO<Classpage> createClasspage(
     Classpage newClasspage, CollectionItem newCollectionItem, String gooruOid, User user)
     throws Exception {
   Errors errors = validateClasspage(newClasspage);
   if (!errors.hasErrors()) {
     this.getCollectionRepository().save(newClasspage);
     this.getUserGroupService()
         .createGroup(
             newClasspage.getTitle(), newClasspage.getClasspageCode(), "System", user, null);
     if (gooruOid != null && !gooruOid.isEmpty() && newCollectionItem != null) {
       CollectionItem collectionItem = new CollectionItem();
       collectionItem.setItemType(ShelfType.AddedType.ADDED.getAddedType());
       collectionItem.setPlannedEndDate(newCollectionItem.getPlannedEndDate());
       collectionItem.setNarration(newCollectionItem.getNarration());
       collectionItem =
           this.createCollectionItem(
                   gooruOid,
                   newClasspage.getGooruOid(),
                   collectionItem,
                   newClasspage.getUser(),
                   CollectionType.COLLECTION.getCollectionType(),
                   false)
               .getModel();
       Set<CollectionItem> collectionItems = new TreeSet<CollectionItem>();
       collectionItems.add(collectionItem);
       newClasspage.setCollectionItems(collectionItems);
       this.getCollectionRepository().save(newClasspage);
     }
   }
   return new ActionResponseDTO<Classpage>(newClasspage, errors);
 }
  public void saveOrUpdate(Object model) {
    if (model instanceof Annotation) {
      if (((Annotation) model).getResource() != null) {
        ((Content) model).setOrganization(((Annotation) model).getResource().getOrganization());
        ((Content) model)
            .setVersion(
                ((Content) model).getVersion() == null ? 1 : ((Content) model).getVersion() + 1);
      }

    } else if (model instanceof OrganizationWrapper
        && ((OrganizationWrapper) model).getOrganization() == null) {
      ((OrganizationWrapper) model).setOrganization(getCurrentUserPrimaryOrganization());
    }

    if (model instanceof Content) {
      ((Content) model).setLastModified(new Date(System.currentTimeMillis()));
      ((Content) model)
          .setVersion(
              ((Content) model).getVersion() == null ? 1 : ((Content) model).getVersion() + 1);
    }

    if (model instanceof CollectionItem) {
      ((CollectionItem) model)
          .getCollection()
          .setLastModified(new Date(System.currentTimeMillis()));
      ((CollectionItem) model)
          .getCollection()
          .setVersion(
              ((CollectionItem) model).getCollection().getVersion() == null
                  ? 1
                  : ((CollectionItem) model).getCollection().getVersion() + 1);
    }

    if (model instanceof User) {
      ((User) model).setLastModifiedOn(new Date(System.currentTimeMillis()));
    }

    getSession().saveOrUpdate(model);
  }
 @Override
 @Transactional(
     readOnly = false,
     propagation = Propagation.REQUIRED,
     rollbackFor = Exception.class)
 public CollectionItem addQuestion(String collectionId, String questionId, User user) {
   Collection collection = getCollectionDao().getCollectionByType(collectionId, COLLECTION_TYPES);
   rejectIfNull(collection, GL0056, 404, COLLECTION);
   AssessmentQuestion question = this.getQuestionService().getQuestion(questionId);
   rejectIfNull(question, GL0056, 404, QUESTION);
   AssessmentQuestion copyQuestion = this.getQuestionService().copyQuestion(question, user);
   CollectionItem collectionItem = new CollectionItem();
   getCollectionEventLog()
       .collectionItemEventLog(
           collectionId, collectionItem, user.getPartyUid(), QUESTION, null, ADD);
   collectionItem.setItemType(ADDED);
   collectionItem = createCollectionItem(collectionItem, collection, copyQuestion, user);
   updateCollectionMetaDataSummary(collection.getContentId(), QUESTION, ADD);
   Map<String, Object> metaData = generateQuestionMetaData(copyQuestion, copyQuestion, user);
   createContentMeta(copyQuestion, metaData);
   return collectionItem;
 }
 @Override
 @Transactional(
     readOnly = false,
     propagation = Propagation.REQUIRED,
     rollbackFor = Exception.class)
 public void deleteCollectionItem(String collectionId, String collectionItemId, String userUid) {
   CollectionItem collectionItem = this.getCollectionDao().getCollectionItem(collectionItemId);
   rejectIfNull(collectionItem, GL0056, 404, _COLLECTION_ITEM);
   Resource resource =
       this.getResourceBoService().getResource(collectionItem.getContent().getGooruOid());
   rejectIfNull(resource, GL0056, 404, RESOURCE);
   String contentType = resource.getContentType().getName();
   Long collectionContentId = collectionItem.getCollection().getContentId();
   this.resetSequence(
       collectionId, collectionItem.getCollectionItemId(), userUid, COLLECTION_ITEM);
   getCollectionEventLog()
       .collectionItemEventLog(collectionId, collectionItem, userUid, contentType, null, DELETE);
   if (contentType.equalsIgnoreCase(QUESTION)) {
     getCollectionDao().remove(resource);
   } else {
     getCollectionDao().remove(collectionItem);
   }
   updateCollectionMetaDataSummary(collectionContentId, RESOURCE, contentType);
 }
 private Errors validateClasspageItem(
     Classpage classpage, Resource resource, CollectionItem collectionItem) throws Exception {
   Map<String, String> itemType = new HashMap<String, String>();
   itemType.put(ADDED, COLLECTION_ITEM_TYPE);
   itemType.put(SUBSCRIBED, COLLECTION_ITEM_TYPE);
   final Errors errors = new BindException(collectionItem, COLLECTION_ITEM);
   if (collectionItem != null) {
     rejectIfNull(errors, classpage, COLLECTION, GL0056, generateErrorMessage(GL0056, CLASSPAGE));
     rejectIfNull(errors, resource, RESOURCE, GL0056, generateErrorMessage(GL0056, RESOURCE));
     rejectIfInvalidType(
         errors,
         collectionItem.getItemType(),
         ITEM_TYPE,
         GL0007,
         generateErrorMessage(GL0007, ITEM_TYPE),
         itemType);
   }
   return errors;
 }
 @Override
 @Transactional(
     readOnly = false,
     propagation = Propagation.REQUIRED,
     rollbackFor = Exception.class)
 public void updateCollection(
     String parentId, String collectionId, Collection newCollection, User user) {
   boolean hasUnrestrictedContentAccess =
       this.getOperationAuthorizer().hasUnrestrictedContentAccess(collectionId, user);
   // TO-Do add validation for collection type and collaborator validation
   Collection collection = getCollectionDao().getCollection(collectionId);
   if (newCollection.getSharing() != null
       && (newCollection.getSharing().equalsIgnoreCase(Sharing.PRIVATE.getSharing())
           || newCollection.getSharing().equalsIgnoreCase(Sharing.PUBLIC.getSharing())
           || newCollection.getSharing().equalsIgnoreCase(Sharing.ANYONEWITHLINK.getSharing()))) {
     if (!newCollection.getSharing().equalsIgnoreCase(PUBLIC)) {
       collection.setPublishStatusId(null);
     }
     if (!collection
             .getCollectionType()
             .equalsIgnoreCase(ResourceType.Type.ASSESSMENT_URL.getType())
         && newCollection.getSharing().equalsIgnoreCase(PUBLIC)
         && !userService.isContentAdmin(user)) {
       collection.setPublishStatusId(Constants.PUBLISH_PENDING_STATUS_ID);
       newCollection.setSharing(collection.getSharing());
     }
     if (collection
             .getCollectionType()
             .equalsIgnoreCase(ResourceType.Type.ASSESSMENT_URL.getType())
         || newCollection.getSharing().equalsIgnoreCase(PUBLIC)
             && userService.isContentAdmin(user)) {
       collection.setPublishStatusId(Constants.PUBLISH_REVIEWED_STATUS_ID);
     }
     collection.setSharing(newCollection.getSharing());
   }
   if (newCollection.getSettings() != null) {
     updateCollectionSettings(collection, newCollection);
   }
   if (newCollection.getLanguageObjective() != null) {
     collection.setLanguageObjective(newCollection.getLanguageObjective());
   }
   if (hasUnrestrictedContentAccess) {
     if (newCollection.getCreator() != null && newCollection.getCreator().getPartyUid() != null) {
       User creatorUser = getUserService().findByGooruId(newCollection.getCreator().getPartyUid());
       collection.setCreator(creatorUser);
     }
     if (newCollection.getUser() != null && newCollection.getUser().getPartyUid() != null) {
       User ownerUser = getUserService().findByGooruId(newCollection.getUser().getPartyUid());
       collection.setUser(ownerUser);
     }
     if (newCollection.getNetwork() != null) {
       collection.setNetwork(newCollection.getNetwork());
     }
   }
   if (newCollection.getPosition() != null) {
     CollectionItem parentCollectionItem =
         this.getCollectionDao().getCollectionItemById(collectionId, user);
     if (parentId == null) {
       parentId = parentCollectionItem.getCollection().getGooruOid();
     }
     Collection parentCollection =
         getCollectionDao().getCollectionByUser(parentId, user.getPartyUid());
     this.resetSequence(
         parentCollection,
         parentCollectionItem.getCollectionItemId(),
         newCollection.getPosition(),
         user.getPartyUid(),
         COLLECTION);
   }
   if (newCollection.getMediaFilename() != null) {
     String folderPath = Collection.buildResourceFolder(collection.getContentId());
     this.getGooruImageUtil()
         .imageUpload(newCollection.getMediaFilename(), folderPath, COLLECTION_IMAGE_DIMENSION);
     StringBuilder basePath = new StringBuilder(folderPath);
     basePath.append(File.separator).append(newCollection.getMediaFilename());
     collection.setImagePath(basePath.toString());
   }
   updateCollection(collection, newCollection, user);
   Map<String, Object> data = generateCollectionMetaData(collection, newCollection, user);
   if (data != null && data.size() > 0) {
     ContentMeta contentMeta =
         this.getContentRepository().getContentMeta(collection.getContentId());
     updateContentMeta(contentMeta, data);
   }
 }
  @Override
  public ActionResponseDTO<CollectionItem> createClasspageItem(
      String assignmentGooruOid,
      String classpageGooruOid,
      CollectionItem collectionItem,
      User user,
      String type)
      throws Exception {
    Classpage classpage = null;
    if (type != null && type.equalsIgnoreCase(CollectionType.USER_CLASSPAGE.getCollectionType())) {
      if (classpageGooruOid != null) {
        classpage = this.getClasspage(classpageGooruOid, null, null);
      } else {
        classpage =
            this.getCollectionRepository()
                .getUserShelfByClasspageGooruUid(
                    user.getGooruUId(), CollectionType.USER_CLASSPAGE.getCollectionType());
      }
      if (classpage == null) {
        classpage = new Classpage();
        classpage.setTitle(MY_CLASSPAGE);
        classpage.setCollectionType(CollectionType.USER_CLASSPAGE.getCollectionType());
        classpage.setClasspageCode(BaseUtil.base48Encode(7));
        classpage.setGooruOid(UUID.randomUUID().toString());
        ContentType contentType =
            (ContentType)
                this.getCollectionRepository().get(ContentType.class, ContentType.RESOURCE);
        classpage.setContentType(contentType);
        ResourceType resourceType =
            (ResourceType)
                this.getCollectionRepository()
                    .get(ResourceType.class, ResourceType.Type.CLASSPAGE.getType());
        classpage.setResourceType(resourceType);
        classpage.setLastModified(new Date(System.currentTimeMillis()));
        classpage.setCreatedOn(new Date(System.currentTimeMillis()));
        classpage.setSharing(Sharing.PRIVATE.getSharing());
        classpage.setUser(user);
        classpage.setOrganization(user.getPrimaryOrganization());
        classpage.setCreator(user);
        classpage.setDistinguish(Short.valueOf(ZERO));
        classpage.setRecordSource(NOT_ADDED);
        classpage.setIsFeatured(0);
        this.getCollectionRepository().save(classpage);
      }
      collectionItem.setItemType(ShelfType.AddedType.SUBSCRIBED.getAddedType());
    } else {
      classpage = this.getClasspage(classpageGooruOid, null, null);
      collectionItem.setItemType(ShelfType.AddedType.ADDED.getAddedType());
    }

    Collection collection =
        this.getCollectionRepository()
            .getCollectionByGooruOid(assignmentGooruOid, classpage.getUser().getGooruUId());
    Errors errors = validateClasspageItem(classpage, collection, collectionItem);
    if (collection != null) {
      if (!errors.hasErrors()) {
        collectionItem.setCollection(classpage);
        collectionItem.setResource(collection);
        int sequence =
            collectionItem.getCollection().getCollectionItems() != null
                ? collectionItem.getCollection().getCollectionItems().size() + 1
                : 1;
        collectionItem.setItemSequence(sequence);
        this.getCollectionRepository().save(collectionItem);
      }
    } else {
      throw new Exception("invalid assignmentId -" + assignmentGooruOid);
    }

    return new ActionResponseDTO<CollectionItem>(collectionItem, errors);
  }
 @Override
 @Transactional(
     readOnly = false,
     propagation = Propagation.REQUIRED,
     rollbackFor = Exception.class)
 public void updateCollectionItem(
     String collectionId,
     final String collectionItemId,
     CollectionItem newCollectionItem,
     User user) {
   final CollectionItem collectionItem =
       this.getCollectionDao().getCollectionItem(collectionItemId);
   rejectIfNull(collectionItem, GL0056, 404, _COLLECTION_ITEM);
   if (newCollectionItem.getNarration() != null) {
     collectionItem.setNarration(newCollectionItem.getNarration());
   }
   if (newCollectionItem.getStart() != null) {
     collectionItem.setStart(newCollectionItem.getStart());
   }
   if (newCollectionItem.getStop() != null) {
     collectionItem.setStop(newCollectionItem.getStop());
   }
   if (newCollectionItem.getPosition() != null) {
     Collection parentCollection =
         getCollectionDao().getCollectionByUser(collectionId, user.getPartyUid());
     this.resetSequence(
         parentCollection,
         collectionItem.getCollectionItemId(),
         newCollectionItem.getPosition(),
         user.getPartyUid(),
         COLLECTION_ITEM);
   }
   this.getCollectionDao().save(collectionItem);
 }