@Override
 public Classpage getClasspage(String collectionId, User user, String merge) {
   Classpage classpage = this.getCollectionRepository().getClasspageByGooruOid(collectionId, null);
   if (classpage != null && merge != null) {
     Map<String, Object> permissions = new HashMap<String, Object>();
     Boolean isMember = false;
     String status = NOTINVITED;
     InviteUser inviteUser = null;
     String mailId = null;
     UserGroup userGroup =
         this.getUserGroupService().findUserGroupByGroupCode(classpage.getClasspageCode());
     if (userGroup != null && !user.getGooruUId().equalsIgnoreCase(ANONYMOUS)) {
       isMember =
           this.getUserRepository()
                       .getUserGroupMemebrByGroupUid(userGroup.getPartyUid(), user.getPartyUid())
                   != null
               ? true
               : false;
       if (isMember) {
         status = ACTIVE;
       }
       if (user.getIdentities().size() > 0) {
         mailId = user.getIdentities().iterator().next().getExternalId();
       }
       inviteUser = this.getInviteRepository().findInviteUserById(mailId, collectionId);
       if (!isMember && inviteUser == null && classpage.getSharing().equalsIgnoreCase(PUBLIC)) {
         inviteUser =
             this.getInviteService().createInviteUserObj(mailId, collectionId, CLASS, user);
         this.getInviteRepository().save(inviteUser);
         this.getInviteRepository().flush();
       }
       if (inviteUser != null) {
         status = PENDING;
       }
     }
     if (merge.contains(PERMISSIONS)) {
       permissions.put(
           PERMISSIONS, this.getContentService().getContentPermission(collectionId, user));
     }
     permissions.put(STATUS, status);
     classpage.setMeta(permissions);
   }
   return classpage;
 }
  public ActionResponseDTO<Classpage> updateClasspage(
      Classpage newClasspage, String updateClasspageId, Boolean hasUnrestrictedContentAccess)
      throws Exception {
    Classpage classpage = this.getClasspage(updateClasspageId, null, null);
    Errors errors = validateUpdateClasspage(classpage, newClasspage);
    if (!errors.hasErrors()) {
      if (newClasspage.getVocabulary() != null) {
        classpage.setVocabulary(newClasspage.getVocabulary());
      }

      if (newClasspage.getTitle() != null) {
        classpage.setTitle(newClasspage.getTitle());
        UserGroup userGroup =
            this.getUserGroupService().findUserGroupByGroupCode(classpage.getClasspageCode());
        userGroup.setGroupName(newClasspage.getTitle());
        this.getUserRepository().save(userGroup);
      }
      if (newClasspage.getDescription() != null) {
        classpage.setDescription(newClasspage.getDescription());
      }
      if (newClasspage.getNarrationLink() != null) {
        classpage.setNarrationLink(newClasspage.getNarrationLink());
      }
      if (newClasspage.getEstimatedTime() != null) {
        classpage.setEstimatedTime(newClasspage.getEstimatedTime());
      }
      if (newClasspage.getNotes() != null) {
        classpage.setNotes(newClasspage.getNotes());
      }
      if (newClasspage.getGoals() != null) {
        classpage.setGoals(newClasspage.getGoals());
      }
      if (newClasspage.getKeyPoints() != null) {
        classpage.setGoals(newClasspage.getKeyPoints());
      }
      if (newClasspage.getLanguage() != null) {
        classpage.setLanguage(newClasspage.getLanguage());
      }
      if (newClasspage.getGrade() != null) {
        classpage.setGrade(newClasspage.getGrade());
      }
      if (newClasspage.getSharing() != null) {
        if (newClasspage.getSharing().equalsIgnoreCase(Sharing.PRIVATE.getSharing())
            || newClasspage.getSharing().equalsIgnoreCase(Sharing.PUBLIC.getSharing())
            || newClasspage.getSharing().equalsIgnoreCase(Sharing.ANYONEWITHLINK.getSharing())) {
          classpage.setSharing(newClasspage.getSharing());
        }
      }
      if (newClasspage.getLastUpdatedUserUid() != null) {
        classpage.setLastUpdatedUserUid(newClasspage.getLastUpdatedUserUid());
      }

      if (hasUnrestrictedContentAccess) {
        if (newClasspage.getCreator() != null && newClasspage.getCreator().getPartyUid() != null) {
          User user = userService.findByGooruId(newClasspage.getCreator().getPartyUid());
          classpage.setCreator(user);
        }

        if (newClasspage.getUser() != null && newClasspage.getUser().getPartyUid() != null) {
          User user = userService.findByGooruId(newClasspage.getUser().getPartyUid());
          classpage.setUser(user);
        }
      }

      this.getCollectionRepository().save(classpage);
    }
    return new ActionResponseDTO<Classpage>(classpage, errors);
  }