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