Class SharedBagManager


  • public final class SharedBagManager
    extends java.lang.Object
    Singleton manager class for shared bags. Implements retrieving, adding and deleting bag shared between users.
    Author:
    Daniela Butano, Alex Kalderimis
    • Method Detail

      • getInstance

        public static SharedBagManager getInstance​(ProfileManager profileManager)
        Return the singleton SharedBagManager instance
        Parameters:
        profileManager - the profile manager
        Returns:
        the instance
      • getSharedBags

        public java.util.Map<java.lang.String,​InterMineBag> getSharedBags​(Profile profile)
        Return a map containing the bags that the user in input has access because shared by someone else
        Parameters:
        profile - the user profile
        Returns:
        a map from bag name to bag
      • getUsersWithAccessToBag

        public java.util.Set<java.lang.String> getUsersWithAccessToBag​(StorableBag bag)
        Return the users this bag is shared with. This set does not include the name of the owner of the bag, and it doesn't take global sharing into account.
        Parameters:
        bag - the bag the users share
        Returns:
        the list of users sharing the bag
      • inviteToShare

        public static SharingInvite inviteToShare​(InterMineBag bag,
                                                  java.lang.String userEmail)
        Generate an invitation to share a bag. The invitation is a record of the invitation to share a bag, and records the bag that is shared and whom it is meant to be shared with. This method generates a new invitation, stores it in the persistent data-store that the bag is stored in, and returns an object that represents that invitation.
        Parameters:
        bag - The list that we mean to share with someone.
        userEmail - An email address we are sending this invitation to.
        Returns:
        An invitation.
      • getSavedBag

        public SavedBag getSavedBag​(java.lang.String bagName,
                                    java.lang.String dateCreated)
        Perform a query to retrieve a bag's backing SavedBag
        Parameters:
        bagName - the bagName
        dateCreated - the date when the bag has been created
        Returns:
        the relevant SavedBag
      • shareBagWithUser

        public void shareBagWithUser​(java.lang.String bagName,
                                     java.lang.String dateCreated,
                                     java.lang.String userName)
                              throws UserNotFoundException,
                                     BagDoesNotExistException
        Share the bag given in input with user which userName is given in input To be used ONLY when deserialising the user-profile from XML.
        Parameters:
        bagName - the bag name to share
        dateCreated - the date when the bag has been created
        userName - the user which the bag is shared with
        Throws:
        UserNotFoundException - if the user does't exist
        BagDoesNotExistException - if the bag does't exist
      • unshareBagWithUser

        public void unshareBagWithUser​(InterMineBag bag,
                                       java.lang.String userName)
        Delete the sharing between the user and the bag given in input
        Parameters:
        bag - the bag shared
        userName - the user name sharing the bag
      • unshareBagWithAllUsers

        public void unshareBagWithAllUsers​(StorableBag bag)
        Delete the sharing between the bag and all the users sharing the bag. Method used when a bag is deleted.
        Parameters:
        bag - the bag that has been shared by users
      • removeAllInvitesBy

        public void removeAllInvitesBy​(java.lang.Integer userId)
        Removes all invitations to share resources that were issued by the user with the given id. This is used as part of the user deletion operation.
        Parameters:
        userId - An id of a user.
      • removeAllSharesInvolving

        public void removeAllSharesInvolving​(java.lang.Integer userId)
        Removes all shares from or to the user with the given id. This is used as part of the user deletion operation.
        Parameters:
        userId - A user id.
      • unshareAllBagsFromUser

        public void unshareAllBagsFromUser​(Profile owner,
                                           Profile recipient)
        Stop sharing all bags owned by the given user which have been shared with the given recipient.
        Parameters:
        owner - They what shared the bag.
        recipient - Them what got access.