@Override
 public void classpageUserRemove(String code, List<String> mailIds, User apiCaller)
     throws Exception {
   UserGroup userGroup = this.getUserGroupService().findUserGroupByGroupCode(code);
   Classpage classpage = this.getCollectionRepository().getClasspageByCode(code);
   if (userGroup != null && classpage != null) {
     for (String mailId : mailIds) {
       Identity identity = this.getUserRepository().findByEmailIdOrUserName(mailId, true, false);
       if (identity != null) {
         UserGroupAssociation userGroupAssociation =
             this.getUserRepository()
                 .getUserGroupMemebrByGroupUid(
                     userGroup.getPartyUid(), identity.getUser().getPartyUid());
         if (userGroupAssociation != null) {
           this.getUserGroupRepository().remove(userGroupAssociation);
         }
         InviteUser inviteUser =
             this.getInviteRepository().findInviteUserById(mailId, classpage.getGooruOid());
         if (inviteUser != null) {
           this.getInviteRepository().remove(inviteUser);
         }
       }
     }
   }
 }
 @Override
 public List<Map<String, Object>> classpageUserJoin(
     String code, List<String> mailIds, User apiCaller) throws Exception {
   List<Map<String, Object>> classpageMember = new ArrayList<Map<String, Object>>();
   UserGroup userGroup = this.getUserGroupService().findUserGroupByGroupCode(code);
   Classpage classpage = this.getCollectionRepository().getClasspageByCode(code);
   if (userGroup != null && classpage != null) {
     for (String mailId : mailIds) {
       Identity identity = this.getUserRepository().findByEmailIdOrUserName(mailId, true, false);
       if (identity != null) {
         InviteUser inviteUser =
             this.getInviteRepository().findInviteUserById(mailId, classpage.getGooruOid());
         if (inviteUser != null) {
           inviteUser.setStatus(
               this.getCustomTableRepository().getCustomTableValue(INVITE_USER_STATUS, ACTIVE));
           inviteUser.setJoinedDate(new Date(System.currentTimeMillis()));
           this.getInviteRepository().save(inviteUser);
         }
         if (this.getUserRepository()
                 .getUserGroupMemebrByGroupUid(
                     userGroup.getPartyUid(), identity.getUser().getPartyUid())
             == null) {
           UserGroupAssociation groupAssociation = new UserGroupAssociation();
           groupAssociation.setIsGroupOwner(0);
           groupAssociation.setUser(identity.getUser());
           groupAssociation.setUserGroup(userGroup);
           this.getUserRepository().save(groupAssociation);
           classpageMember.add(setMemberResponse(groupAssociation, ACTIVE));
         }
       }
     }
   }
   return classpageMember;
 }
 private List<Map<String, Object>> getActiveMemberList(String code) {
   List<Map<String, Object>> activeList = new ArrayList<Map<String, Object>>();
   Classpage classpage = this.getCollectionRepository().getClasspageByCode(code);
   if (classpage == null) {
     throw new NotFoundException("Class not found!!!");
   }
   UserGroup userGroup = this.getUserGroupService().findUserGroupByGroupCode(code);
   List<UserGroupAssociation> userGroupAssociations =
       this.getUserGroupRepository().getUserGroupAssociationByGroup(userGroup.getPartyUid());
   for (UserGroupAssociation userGroupAssociation : userGroupAssociations) {
     if (userGroupAssociation.getIsGroupOwner() != 1) {
       activeList.add(this.setMemberResponse(userGroupAssociation, ACTIVE));
     }
   }
   return activeList;
 }
 @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);
  }