コード例 #1
0
 @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;
 }
コード例 #2
0
 public User updateNewCollaborators(
     Collection collection,
     List<String> collaboratorsList,
     User apiCaller,
     String predicate,
     String collaboratorOperation) {
   List<User> userList = null;
   if (collaboratorsList != null && collaboratorsList.size() > 0 && !collaboratorsList.isEmpty()) {
     userList = this.getUserRepository().findByIdentities(collaboratorsList);
     if (collaboratorOperation.equals(DELETE)) {
       deleteCollaborators(collection, userList, apiCaller, predicate);
     } else {
       addNewCollaborators(collection, userList, apiCaller, predicate, false);
     }
   }
   if (userList.size() > 0) {
     User user = userList.get(0);
     user.setEmailId(user.getIdentities().iterator().next().getExternalId());
     return user;
   }
   return null;
 }