@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);
 }
 @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);
 }
 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 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);
 }
 @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);
   }
 }