Package cz.metacentrum.perun.core.impl
Class MembersManagerImpl
java.lang.Object
cz.metacentrum.perun.core.impl.MembersManagerImpl
- All Implemented Interfaces:
MembersManagerImplApi
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final ResultSetExtractor
<List<AssignedMember>> AssignedMember extractor that also sets correctly all member group statues.static final ResultSetExtractor
<List<Member>> Member extractor that also sets correctly all member group statues. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSponsor
(PerunSession session, Member sponsoredMember, User sponsor) Adds another sponsoring user for a sponsored member.void
addSponsor
(PerunSession session, Member sponsoredMember, User sponsor, LocalDate validityTo) Adds another sponsoring user for a sponsored member.void
checkMemberExists
(PerunSession sess, Member member) Check if member exists in underlaying data source.createMember
(PerunSession sess, Vo vo, User user) Creates member entry in the database.createSponsoredMember
(PerunSession session, Vo vo, User sponsored, User sponsor, LocalDate validityTo) Creates a new member in given Vo with flag "sponsored", and linked to its sponsoring user.void
deleteAllSponsors
(PerunSession session, Member sponsoredMember) Delete all existing sponsorships for defined member.void
deleteMember
(PerunSession sess, Member member) Deletes only member data appropriated by member id.void
deleteSponsorLinks
(PerunSession sess, Member sponsoredMember) Deletes all links to sponsors, even those marked as inactive.findMembers
(PerunSession sess, Vo vo, String searchString, boolean onlySponsored) Return list of members by specific string.getAllMembers
(PerunSession sess) Get all members from all vos.Return all loaded namespaces rules.getAvailableSponsorsForMember
(PerunSession sess, Member member) Returns all available sponsors for given member.getMemberById
(PerunSession sess, int id) Returns member by his id.getMemberByUserExtSource
(PerunSession sess, Vo vo, UserExtSource userExtSource) Find member of this Vo by his login in external sourcegetMemberByUserId
(PerunSession sess, Vo vo, int userId) Returns member by his user id and vo.getMembersByIds
(PerunSession perunSession, List<Integer> ids) Gets members by their ids.getMembersByUser
(PerunSession sess, User user) Return all VO Members of the User.getMembersByUsers
(PerunSession sess, List<User> users, Vo vo) Convert list of users into the list of members.getMembersByUsersIds
(PerunSession sess, List<Integer> usersIds, Vo vo) Convert list of users' ids into the list of members.getMembersByUserWithStatus
(PerunSession sess, User user, Status status) Return all VO Members of the User, which have specified Status in their VO.int
getMembersCount
(PerunSession sess, Vo vo) Returns all members from the VO (with every status).int
getMembersCount
(PerunSession sess, Vo vo, Status status) Returns number of Vo members with defined status.getMembersPage
(PerunSession sess, Vo vo, MembersPageQuery query) Get page of members from the given vogetMembersPage
(PerunSession sess, Vo vo, MembersPageQuery query, String policy) Get page of members from the given voint
getMemberVoId
(PerunSession sess, Member member) Get member's VO idgetNamespaceRules
(String namespace) Get NamespaceRules for the namespace from the LoginNamespacesRulesConfigContainergetSponsoredMembers
(PerunSession sess, User sponsor) Gets members sponsored by the given user in all vos.getSponsoredMembers
(PerunSession sess, Vo vo) Gets list of sponsored members of a VO.getSponsoredMembers
(PerunSession sess, Vo vo, User sponsor) Gets members sponsored by the given user.getSponsoredRichMembers
(PerunSession sess, Vo vo) Get list of rich members that are sponsored in the VO.getSponsorship
(PerunSession sess, Member sponsoredMember, User sponsor) For the given member and user returns their sponsorship relation object.getSponsorshipsExpiringInRange
(PerunSession sess, LocalDate from, LocalDate to) Returns sponsorship, which have validityTo in range [from, to).getUnifiedMemberGroupStatus
(PerunSession sess, Member member, Resource resource) Returns unified result of MemberGroupStatus for specified member and resource.getUnifiedMemberGroupStatus
(PerunSession sess, User user, Facility facility) Returns unified result of MemberGroupStatus for specified user and facility.void
Load all namespaces rules for login-namespacesboolean
memberExists
(PerunSession sess, Member member) Check if member exists in underlaying data source.void
moveMembersApplications
(PerunSession sess, Member sourceMember, Member targetMember) Move all applications from one member to another member.void
rejectAllMemberOpenApplications
(PerunSession sess, Member member) Reject all member applications which are not Approved or already rejected Reserved login/passwords are also deleted.void
removeSponsor
(PerunSession session, Member sponsoredMember, User sponsor) Removes a sponsoring user.void
setLoginNamespacesRulesConfigLoader
(LoginNamespacesRulesConfigLoader loginNamespacesRulesConfigLoader) Set Login-namespaces rules config loader propertysetSponsorshipForMember
(PerunSession session, Member sponsoredMember, User sponsor, LocalDate validityTo) Set member to be sponsored by sponsor.void
setStatus
(PerunSession sess, Member member, Status status) Set status of the member to specified status.boolean
someAvailableSponsorExistsForMember
(PerunSession sess, Member member) Checks if some vo sponsor who does not already sponsor given member exists.storePasswordResetRequest
(PerunSession sess, User user, String namespace, String mail, LocalDateTime validityTo) Store information about password reset request.unsetSponsorshipForMember
(PerunSession session, Member sponsoredMember) Unset member to not be sponsored by anybody from now.void
updateSponsorshipValidity
(PerunSession sess, Member sponsoredMember, User sponsor, LocalDate newValidity) Update the sponsorship of given member for given sponsor.
-
Field Details
-
A_D_MEMBER_MAIL
- See Also:
-
A_D_USER_PREFERRED_MAIL
- See Also:
-
MEMBERS_WITH_GROUP_STATUSES_SET_EXTRACTOR
Member extractor that also sets correctly all member group statues.Use with `groupsMembersMappingSelectQuery`
-
ASSIGNED_MEMBERS_WITH_GROUP_STATUSES_SET_EXTRACTOR
public static final ResultSetExtractor<List<AssignedMember>> ASSIGNED_MEMBERS_WITH_GROUP_STATUSES_SET_EXTRACTORAssignedMember extractor that also sets correctly all member group statues.Use with `groupsAssignedMembersMappingSelectQuery`
-
-
Constructor Details
-
MembersManagerImpl
Constructor
-
-
Method Details
-
addSponsor
public void addSponsor(PerunSession session, Member sponsoredMember, User sponsor) throws AlreadySponsorException Description copied from interface:MembersManagerImplApi
Adds another sponsoring user for a sponsored member.- Specified by:
addSponsor
in interfaceMembersManagerImplApi
- Parameters:
session
- perun sessionsponsoredMember
- member which is sponsoredsponsor
- sponsoring user- Throws:
AlreadySponsorException
- if member was already sponsored before this call
-
addSponsor
public void addSponsor(PerunSession session, Member sponsoredMember, User sponsor, LocalDate validityTo) throws AlreadySponsorException Description copied from interface:MembersManagerImplApi
Adds another sponsoring user for a sponsored member.- Specified by:
addSponsor
in interfaceMembersManagerImplApi
- Parameters:
session
- perun sessionsponsoredMember
- member which is sponsoredsponsor
- sponsoring uservalidityTo
- time, when the sponsorship will expire- Throws:
AlreadySponsorException
- if member was already sponsored before this call
-
checkMemberExists
Description copied from interface:MembersManagerImplApi
Check if member exists in underlaying data source.- Specified by:
checkMemberExists
in interfaceMembersManagerImplApi
- Parameters:
sess
-member
-- Throws:
MemberNotExistsException
-
createMember
Description copied from interface:MembersManagerImplApi
Creates member entry in the database. Created member is in invalid state.- Specified by:
createMember
in interfaceMembersManagerImplApi
- Parameters:
sess
-vo
- Vouser
- User- Returns:
- created member with id filled
- Throws:
AlreadyMemberException
-
createSponsoredMember
public Member createSponsoredMember(PerunSession session, Vo vo, User sponsored, User sponsor, LocalDate validityTo) throws AlreadyMemberException, AlreadySponsorException Description copied from interface:MembersManagerImplApi
Creates a new member in given Vo with flag "sponsored", and linked to its sponsoring user.- Specified by:
createSponsoredMember
in interfaceMembersManagerImplApi
- Parameters:
session
- PerunSessionvo
- vo where newly created member will be sponsoredsponsored
- user for which the new membership will be created (and also sponsored)sponsor
- sponsor of new membershipvalidityTo
- time, when the sponsorship will expire- Returns:
- sponsored member
- Throws:
AlreadyMemberException
- if user has already a membership in the voAlreadySponsorException
- if member is already sponsored by the sponsor
-
deleteAllSponsors
Description copied from interface:MembersManagerImplApi
Delete all existing sponsorships for defined member. This method will delete them, not just marked.- Specified by:
deleteAllSponsors
in interfaceMembersManagerImplApi
- Parameters:
session
- perun sessionsponsoredMember
- member which is sponsored
-
deleteMember
Description copied from interface:MembersManagerImplApi
Deletes only member data appropriated by member id.- Specified by:
deleteMember
in interfaceMembersManagerImplApi
- Parameters:
sess
-member
-- Throws:
MemberAlreadyRemovedException
- if there are 0 rows affected by removing from DB
-
deleteSponsorLinks
Description copied from interface:MembersManagerImplApi
Deletes all links to sponsors, even those marked as inactive.- Specified by:
deleteSponsorLinks
in interfaceMembersManagerImplApi
- Parameters:
sess
- perun sessionsponsoredMember
- member which is sponsored
-
findMembers
public List<Member> findMembers(PerunSession sess, Vo vo, String searchString, boolean onlySponsored) Description copied from interface:MembersManagerImplApi
Return list of members by specific string. Looking for searchString in user name, member and user id, user uuid, member, users and userExtSource attributes specified by perun.properties. All searches are case insensitive. If parameter onlySponsored is true, it will return only sponsored members by searchString. If vo is null, looking for any members in whole Perun. If vo is not null, looking only in specific VO.- Specified by:
findMembers
in interfaceMembersManagerImplApi
- Parameters:
sess
-vo
- for which searching will be filtered, if null there is no filter for vosearchString
- it will be looking for this search string in the specific parameters in DBonlySponsored
- it will return only sponsored members in vo- Returns:
- all members from specific VO by specific string
-
getAllMembers
Description copied from interface:MembersManagerImplApi
Get all members from all vos.- Specified by:
getAllMembers
in interfaceMembersManagerImplApi
- Parameters:
sess
- session- Returns:
- list of all members from all Vos.
-
getAllNamespacesRules
Description copied from interface:MembersManagerImplApi
Return all loaded namespaces rules.- Specified by:
getAllNamespacesRules
in interfaceMembersManagerImplApi
- Returns:
- all namespaces rules
-
getMemberById
Description copied from interface:MembersManagerImplApi
Returns member by his id.- Specified by:
getMemberById
in interfaceMembersManagerImplApi
- Parameters:
sess
-id
-- Returns:
- member
- Throws:
MemberNotExistsException
-
getMemberByUserExtSource
public Member getMemberByUserExtSource(PerunSession sess, Vo vo, UserExtSource userExtSource) throws MemberNotExistsException Description copied from interface:MembersManagerImplApi
Find member of this Vo by his login in external source- Specified by:
getMemberByUserExtSource
in interfaceMembersManagerImplApi
- Parameters:
sess
-vo
-userExtSource
-- Returns:
- selected user or throws MemberNotExistsException in case the requested member doesn't exists in this Vo
- Throws:
MemberNotExistsException
-
getMemberByUserId
public Member getMemberByUserId(PerunSession sess, Vo vo, int userId) throws MemberNotExistsException Description copied from interface:MembersManagerImplApi
Returns member by his user id and vo.- Specified by:
getMemberByUserId
in interfaceMembersManagerImplApi
- Parameters:
sess
-vo
-userId
-- Returns:
- member
- Throws:
MemberNotExistsException
-
getMemberVoId
Description copied from interface:MembersManagerImplApi
Get member's VO id- Specified by:
getMemberVoId
in interfaceMembersManagerImplApi
- Parameters:
sess
-member
-- Returns:
- VO id
-
getMembersByIds
Description copied from interface:MembersManagerImplApi
Gets members by their ids. Silently skips non-existing members.- Specified by:
getMembersByIds
in interfaceMembersManagerImplApi
- Parameters:
perunSession
-ids
-- Returns:
- list of members with specified ids
-
getMembersByUser
Description copied from interface:MembersManagerImplApi
Return all VO Members of the User.- Specified by:
getMembersByUser
in interfaceMembersManagerImplApi
- Parameters:
sess
-user
-- Returns:
- List of Members
-
getMembersByUserWithStatus
Description copied from interface:MembersManagerImplApi
Return all VO Members of the User, which have specified Status in their VO.- Specified by:
getMembersByUserWithStatus
in interfaceMembersManagerImplApi
- Parameters:
sess
-user
-status
-- Returns:
- List of Members
-
getMembersByUsers
Description copied from interface:MembersManagerImplApi
Convert list of users into the list of members.- Specified by:
getMembersByUsers
in interfaceMembersManagerImplApi
- Parameters:
sess
-users
-vo
-- Returns:
- list of members
-
getMembersByUsersIds
Description copied from interface:MembersManagerImplApi
Convert list of users' ids into the list of members.- Specified by:
getMembersByUsersIds
in interfaceMembersManagerImplApi
- Parameters:
sess
-usersIds
-vo
-- Returns:
- list of members
-
getMembersCount
Description copied from interface:MembersManagerImplApi
Returns all members from the VO (with every status).- Specified by:
getMembersCount
in interfaceMembersManagerImplApi
- Parameters:
sess
-vo
-- Returns:
- number of members
-
getMembersCount
Description copied from interface:MembersManagerImplApi
Returns number of Vo members with defined status.- Specified by:
getMembersCount
in interfaceMembersManagerImplApi
- Parameters:
sess
-vo
-status
-- Returns:
- number of members
-
getMembersPage
public Paginated<Member> getMembersPage(PerunSession sess, Vo vo, MembersPageQuery query, String policy) throws PolicyNotExistsException Description copied from interface:MembersManagerImplApi
Get page of members from the given vo- Specified by:
getMembersPage
in interfaceMembersManagerImplApi
- Parameters:
sess
- sessionvo
- voquery
- query with page informationpolicy
- policy to replace the default one (`filter_getMembersPage-policy`)- Returns:
- page of requested rich members
- Throws:
PolicyNotExistsException
-
getMembersPage
public Paginated<Member> getMembersPage(PerunSession sess, Vo vo, MembersPageQuery query) throws PolicyNotExistsException Description copied from interface:MembersManagerImplApi
Get page of members from the given vo- Specified by:
getMembersPage
in interfaceMembersManagerImplApi
- Parameters:
sess
- sessionvo
- voquery
- query with page information- Returns:
- page of requested rich members
- Throws:
PolicyNotExistsException
-
getNamespaceRules
Description copied from interface:MembersManagerImplApi
Get NamespaceRules for the namespace from the LoginNamespacesRulesConfigContainer- Specified by:
getNamespaceRules
in interfaceMembersManagerImplApi
- Parameters:
namespace
- for which will be the rules fetched- Returns:
- NamespaceRules for the namespace
- Throws:
NamespaceRulesNotExistsException
- of there are no rules for the namespace
-
getSponsoredMembers
Description copied from interface:MembersManagerImplApi
Gets members sponsored by the given user.- Specified by:
getSponsoredMembers
in interfaceMembersManagerImplApi
- Parameters:
sess
- perun sessionvo
- virtual organizationsponsor
- sponsoring user- Returns:
- list of members sponsored by the given user
-
getSponsoredMembers
Description copied from interface:MembersManagerImplApi
Gets members sponsored by the given user in all vos.- Specified by:
getSponsoredMembers
in interfaceMembersManagerImplApi
- Parameters:
sess
- perun sessionsponsor
- sponsoring user- Returns:
- list of members sponsored by the given user
-
getSponsoredMembers
Description copied from interface:MembersManagerImplApi
Gets list of sponsored members of a VO.- Specified by:
getSponsoredMembers
in interfaceMembersManagerImplApi
- Parameters:
sess
- sessionvo
- virtual organization from which are the sponsored members chosen- Returns:
- list of members from given vo who are sponsored
-
getSponsoredRichMembers
Description copied from interface:MembersManagerImplApi
Get list of rich members that are sponsored in the VO.- Specified by:
getSponsoredRichMembers
in interfaceMembersManagerImplApi
- Parameters:
sess
-vo
-- Returns:
- list of rich members which are sponsored in the given VO
-
getSponsorship
public Sponsorship getSponsorship(PerunSession sess, Member sponsoredMember, User sponsor) throws SponsorshipDoesNotExistException Description copied from interface:MembersManagerImplApi
For the given member and user returns their sponsorship relation object. If there is no such relation, the SponsorshipDoesNotExistException is thrown.- Specified by:
getSponsorship
in interfaceMembersManagerImplApi
- Parameters:
sess
- sessionsponsoredMember
- sponsored membersponsor
- sponsor- Returns:
- Sponsorship object
- Throws:
SponsorshipDoesNotExistException
- if there is no sponsorship relation between the given member and user
-
getSponsorshipsExpiringInRange
public List<Sponsorship> getSponsorshipsExpiringInRange(PerunSession sess, LocalDate from, LocalDate to) Description copied from interface:MembersManagerImplApi
Returns sponsorship, which have validityTo in range [from, to). (from is inclusive, to is exclusive).- Specified by:
getSponsorshipsExpiringInRange
in interfaceMembersManagerImplApi
- Parameters:
sess
- sessionfrom
- lower validityTo bound (inclusive), use LocalDate.MIN if you don't want to specify the lower boundto
- upper validityTo bound (exclusive), use LocalDate.MAX, if you don't want to specify the upper bound- Returns:
- list of sponsorships which have validityTo set in the given range
-
getUnifiedMemberGroupStatus
public MemberGroupStatus getUnifiedMemberGroupStatus(PerunSession sess, Member member, Resource resource) Description copied from interface:MembersManagerImplApi
Returns unified result of MemberGroupStatus for specified member and resource.If member is VALID in at least one group assigned to the resource, result is VALID. If member is not VALID in any of groups assigned to the resource, result is EXPIRED. If member is not assigned to the resource at all, result is NULL.
MemberGroupStatus is never related to the members status in a VO as a whole!
- Specified by:
getUnifiedMemberGroupStatus
in interfaceMembersManagerImplApi
- Parameters:
sess
- PerunSessionmember
- Member to get unified MemberGroupStatusresource
- Resource to get unified MemberGroupStatus- Returns:
- MemberGroupStatus for member unified through all his groups assigned to the resource.
-
getUnifiedMemberGroupStatus
public MemberGroupStatus getUnifiedMemberGroupStatus(PerunSession sess, User user, Facility facility) Description copied from interface:MembersManagerImplApi
Returns unified result of MemberGroupStatus for specified user and facility.If user is VALID in at least one group assigned to at least one resource on facility, result is VALID. If user is not VALID in any of groups assigned to any of resources, result is EXPIRED. If user is not assigned to the facility at all, result is NULL.
MemberGroupStatus is never related to the members status in any VO!
- Specified by:
getUnifiedMemberGroupStatus
in interfaceMembersManagerImplApi
- Parameters:
sess
- PerunSessionuser
- User to get unified MemberGroupStatusfacility
- Facility to get unified MemberGroupStatus- Returns:
- MemberGroupStatus for user unified throught all his groups assigned to any of resources of facility.
-
initialize
public void initialize()Load all namespaces rules for login-namespaces -
memberExists
Description copied from interface:MembersManagerImplApi
Check if member exists in underlaying data source.- Specified by:
memberExists
in interfaceMembersManagerImplApi
- Parameters:
sess
-member
-- Returns:
- true if member exists in underlaying data source, false otherwise
-
moveMembersApplications
Description copied from interface:MembersManagerImplApi
Move all applications from one member to another member.- Specified by:
moveMembersApplications
in interfaceMembersManagerImplApi
- Parameters:
sess
-sourceMember
- for which move applications fromtargetMember
- for which move applications to
-
rejectAllMemberOpenApplications
Description copied from interface:MembersManagerImplApi
Reject all member applications which are not Approved or already rejected Reserved login/passwords are also deleted. User is not notified about the rejection.- Specified by:
rejectAllMemberOpenApplications
in interfaceMembersManagerImplApi
- Parameters:
sess
- perunSessionmember
- which applications will be removed
-
removeSponsor
Description copied from interface:MembersManagerImplApi
Removes a sponsoring user. In fact marks the link as inactive.- Specified by:
removeSponsor
in interfaceMembersManagerImplApi
- Parameters:
session
- perun sessionsponsoredMember
- member which is sponsoredsponsor
- sponsoring user
-
setLoginNamespacesRulesConfigLoader
public void setLoginNamespacesRulesConfigLoader(LoginNamespacesRulesConfigLoader loginNamespacesRulesConfigLoader) Description copied from interface:MembersManagerImplApi
Set Login-namespaces rules config loader property- Specified by:
setLoginNamespacesRulesConfigLoader
in interfaceMembersManagerImplApi
- Parameters:
loginNamespacesRulesConfigLoader
- to set
-
setSponsorshipForMember
public Member setSponsorshipForMember(PerunSession session, Member sponsoredMember, User sponsor, LocalDate validityTo) throws AlreadySponsorException Description copied from interface:MembersManagerImplApi
Set member to be sponsored by sponsor. Set flag and sponsorship.- Specified by:
setSponsorshipForMember
in interfaceMembersManagerImplApi
- Parameters:
session
- perun session.sponsoredMember
- member who should be sponsored from nowsponsor
- user which will be a sponsor for member- Returns:
- sponsored member
- Throws:
AlreadySponsorException
- if member was already sponsored before this call
-
setStatus
Description copied from interface:MembersManagerImplApi
Set status of the member to specified status.- Specified by:
setStatus
in interfaceMembersManagerImplApi
- Parameters:
sess
-member
-status
- new status
-
storePasswordResetRequest
public UUID storePasswordResetRequest(PerunSession sess, User user, String namespace, String mail, LocalDateTime validityTo) Description copied from interface:MembersManagerImplApi
Store information about password reset request.- Specified by:
storePasswordResetRequest
in interfaceMembersManagerImplApi
- Parameters:
sess
- PerunSessionuser
- User to reset password fornamespace
- namespace to reset password inmail
- mail address used to send request tovalidityTo
- time till request is valid- Returns:
- request's UUID to be used for validation
-
unsetSponsorshipForMember
Description copied from interface:MembersManagerImplApi
Unset member to not be sponsored by anybody from now. Unset flag and remove all sponsorships.- Specified by:
unsetSponsorshipForMember
in interfaceMembersManagerImplApi
- Parameters:
session
-sponsoredMember
- member whou shouldn't be sponsored from now- Returns:
- member which is not sponsored any more
-
updateSponsorshipValidity
public void updateSponsorshipValidity(PerunSession sess, Member sponsoredMember, User sponsor, LocalDate newValidity) throws SponsorshipDoesNotExistException Description copied from interface:MembersManagerImplApi
Update the sponsorship of given member for given sponsor.- Specified by:
updateSponsorshipValidity
in interfaceMembersManagerImplApi
- Parameters:
sess
- sessionsponsoredMember
- sponsored membersponsor
- sponsornewValidity
- new validity, can be set to null never expire- Throws:
SponsorshipDoesNotExistException
- if the given user is not sponsor of the given member
-
someAvailableSponsorExistsForMember
Description copied from interface:MembersManagerImplApi
Checks if some vo sponsor who does not already sponsor given member exists.- Specified by:
someAvailableSponsorExistsForMember
in interfaceMembersManagerImplApi
- Parameters:
sess
- perun sessionmember
- member- Returns:
- true if available sponsor exists, false otherwise
-
getAvailableSponsorsForMember
Description copied from interface:MembersManagerImplApi
Returns all available sponsors for given member.- Specified by:
getAvailableSponsorsForMember
in interfaceMembersManagerImplApi
- Parameters:
sess
- perun sessionmember
- member- Returns:
- list of available sponsors
-