Package org.intermine.api.bag
Class SharedBagManager
- java.lang.Object
-
- org.intermine.api.bag.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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BAG_INVITES
The name of the table to persist offers to share a bag with others.protected ProfileManager
profileManager
static java.lang.String
SHARED_BAGS
the table nameprotected ObjectStoreWriterInterMineImpl
uosw
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptInvitation(SharingInvite invitation, Profile accepter)
Accept this invitation.static SharedBagManager
getInstance(ProfileManager profileManager)
Return the singleton SharedBagManager instanceSavedBag
getSavedBag(java.lang.String bagName, java.lang.String dateCreated)
Perform a query to retrieve a bag's backing SavedBagjava.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 elsejava.util.Set<java.lang.String>
getUsersWithAccessToBag(StorableBag bag)
Return the users this bag is shared with.static SharingInvite
inviteToShare(InterMineBag bag, java.lang.String userEmail)
Generate an invitation to share a bag.static void
rejectInvitation(SharingInvite invitation)
Reject this invitation.void
removeAllInvitesBy(java.lang.Integer userId)
Removes all invitations to share resources that were issued by the user with the given id.void
removeAllSharesInvolving(java.lang.Integer userId)
Removes all shares from or to the user with the given id.void
resolveInvitation(SharingInvite invitation, Profile accepter, boolean accepted)
Either reject or accept an invitation to share a list.void
shareBagWithUser(java.lang.String bagName, java.lang.String dateCreated, java.lang.String userName)
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.void
shareBagWithUser(InterMineBag bag, java.lang.String userName)
Share the bag given in input with user which userName is given in inputvoid
unshareAllBagsFromUser(Profile owner, Profile recipient)
Stop sharing all bags owned by the given user which have been shared with the given recipient.void
unshareBagWithAllUsers(StorableBag bag)
Delete the sharing between the bag and all the users sharing the bag.void
unshareBagWithUser(InterMineBag bag, java.lang.String userName)
Delete the sharing between the user and the bag given in input
-
-
-
Field Detail
-
SHARED_BAGS
public static final java.lang.String SHARED_BAGS
the table name- See Also:
- Constant Field Values
-
BAG_INVITES
public static final java.lang.String BAG_INVITES
The name of the table to persist offers to share a bag with others.- See Also:
- Constant Field Values
-
uosw
protected ObjectStoreWriterInterMineImpl uosw
-
profileManager
protected ProfileManager profileManager
-
-
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.
-
resolveInvitation
public void resolveInvitation(SharingInvite invitation, Profile accepter, boolean accepted) throws UserNotFoundException, UserAlreadyShareBagException, SharingInvite.NotFoundException
Either reject or accept an invitation to share a list.- Parameters:
invitation
- The invitation in question.accepter
- The user who is deciding what to do.accepted
- Whether to accept or reject this invitation.- Throws:
UserNotFoundException
- If we can't find the accepter or the inviter.UserAlreadyShareBagException
- If this user already has access to this resource.SharingInvite.NotFoundException
- If the resource itself does not exist.
-
rejectInvitation
public static void rejectInvitation(SharingInvite invitation) throws UserNotFoundException, UserAlreadyShareBagException, SharingInvite.NotFoundException
Reject this invitation. After this method is called, the invitation will be marked as resolved (declined), and will not be able to be used again.- Parameters:
invitation
- The invitation.- Throws:
UserNotFoundException
- If we can't find the accepter or the inviter.UserAlreadyShareBagException
- If this user already has access to this resource.SharingInvite.NotFoundException
- If the resource itself does not exist.
-
acceptInvitation
public void acceptInvitation(SharingInvite invitation, Profile accepter) throws UserNotFoundException, UserAlreadyShareBagException, SharingInvite.NotFoundException
Accept this invitation. When this method returns, the user who accepted this invitation will have access to the resource it grants access to.- Parameters:
invitation
- The invitation.accepter
- The user accepting the invitation.- Throws:
UserNotFoundException
- If we can't find the accepter or the inviter.UserAlreadyShareBagException
- If this user already has access to this resource.SharingInvite.NotFoundException
- If the resource itself does not exist.
-
shareBagWithUser
public void shareBagWithUser(InterMineBag bag, java.lang.String userName) throws UserNotFoundException, UserAlreadyShareBagException
Share the bag given in input with user which userName is given in input- Parameters:
bag
- the bag to shareuserName
- the user which the bag is shared with- Throws:
UserNotFoundException
- if the user doesn't existUserAlreadyShareBagException
- if the user already shares the list
-
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 bagNamedateCreated
- 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 sharedateCreated
- the date when the bag has been createduserName
- the user which the bag is shared with- Throws:
UserNotFoundException
- if the user does't existBagDoesNotExistException
- 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 shareduserName
- 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.
-
-