@SuppressWarnings("unchecked")
 private void updateCollectionMetaDataSummary(Long collectionId, String type, String action) {
   ContentMeta lessonContentMeta = this.getContentRepository().getContentMeta(collectionId);
   if (lessonContentMeta != null) {
     Map<String, Object> metaData =
         JsonDeserializer.deserialize(
             lessonContentMeta.getMetaData(), new TypeReference<Map<String, Object>>() {});
     Map<String, Object> summary = (Map<String, Object>) metaData.get(SUMMARY);
     if (summary != null && summary.size() > 0) {
       int resourceCount = ((Number) summary.get(MetaConstants.RESOURCE_COUNT)).intValue();
       int questionCount = ((Number) summary.get(MetaConstants.QUESTION_COUNT)).intValue();
       if (type.equalsIgnoreCase(RESOURCE)) {
         summary.put(
             MetaConstants.RESOURCE_COUNT,
             action.equalsIgnoreCase(ADD) ? (resourceCount + 1) : (resourceCount - 1));
       }
       if (type.equalsIgnoreCase(QUESTION)) {
         summary.put(
             MetaConstants.QUESTION_COUNT,
             action.equalsIgnoreCase(ADD) ? (questionCount + 1) : (questionCount - 1));
       }
       metaData.put(SUMMARY, summary);
       updateContentMeta(lessonContentMeta, 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;
 }