Class VosManagerBlImpl

java.lang.Object
cz.metacentrum.perun.core.blImpl.VosManagerBlImpl
All Implemented Interfaces:
VosManagerBl

public class VosManagerBlImpl extends Object implements VosManagerBl
VosManager business logic
Author:
Michal Prochazka michalp@ics.muni.cz, Slavek Licehammer glory@ics.muni.cz
  • Field Details

    • A_MEMBER_DEF_MEMBER_ORGANIZATIONS

      public static final String A_MEMBER_DEF_MEMBER_ORGANIZATIONS
      See Also:
    • A_MEMBER_DEF_MEMBER_ORGANIZATIONS_HISTORY

      public static final String A_MEMBER_DEF_MEMBER_ORGANIZATIONS_HISTORY
      See Also:
  • Constructor Details

    • VosManagerBlImpl

      public VosManagerBlImpl(VosManagerImplApi vosManagerImpl)
      Constructor.
  • Method Details

    • addMemberVo

      public void addMemberVo(PerunSession sess, Vo vo, Vo memberVo) throws RelationExistsException
      Description copied from interface: VosManagerBl
      Adds new relationship between vo and a member vo. If user is member in both vos, updates memberOrganizations list attribute. If user is member only in member vo, creates member in parent vo and sets memberOrganizations list attribute.
      Specified by:
      addMemberVo in interface VosManagerBl
      Parameters:
      sess - session
      vo - vo
      memberVo - new member of the vo
      Throws:
      RelationExistsException - if member vo is already member of the vo
    • checkVoExists

      public void checkVoExists(PerunSession sess, Vo vo) throws VoNotExistsException
      Specified by:
      checkVoExists in interface VosManagerBl
      Throws:
      VoNotExistsException
    • convertSponsoredUsers

      public void convertSponsoredUsers(PerunSession sess, Vo vo)
      Description copied from interface: VosManagerBl
      For the given vo, creates sponsored members for each sponsored user who is a member of the given vo. Original sponsors of the users will be set to the sponsored members.
      Specified by:
      convertSponsoredUsers in interface VosManagerBl
      Parameters:
      sess - session
      vo - vo where members will be converted
    • convertSponsoredUsersWithNewSponsor

      public void convertSponsoredUsersWithNewSponsor(PerunSession sess, Vo vo, User newSponsor)
      Description copied from interface: VosManagerBl
      For the given vo, creates sponsored members for each sponsored user who is a member of the given vo. The sponsored members will be sponsored by the given user, not by its original sponsors.
      Specified by:
      convertSponsoredUsersWithNewSponsor in interface VosManagerBl
      Parameters:
      sess - session
      vo - vo where members will be converted
      newSponsor - user, who will be set as a sponsor to the sponsored members
    • createMemberCandidates

      public List<MemberCandidate> createMemberCandidates(PerunSession sess, List<RichUser> users, Vo vo, Group group, List<Candidate> candidates, List<String> attrNames)
      Creates MemberCandidates for given RichUsers, vo, group and candidates. If the given group is not null then to all members who are in this group is assigned the sourceGroupId of the given group. The given group can be null.
      Parameters:
      sess - session
      users - users
      group - group
      candidates - candidates
      attrNames - names of attributes that will be returned
      Returns:
      list of MemberCandidates for given RichUsers, group and candidates
      Throws:
      InternalErrorException - internal error
    • createVo

      public Vo createVo(PerunSession sess, Vo vo) throws VoExistsException
      Description copied from interface: VosManagerBl
      Create new VO.
      Specified by:
      createVo in interface VosManagerBl
      vo - vo object with prefilled voShortName and voName
      Returns:
      newly created VO
      Throws:
      VoExistsException
    • deleteVo

      public void deleteVo(PerunSession sess, Vo vo, boolean forceDelete)
      Description copied from interface: VosManagerBl
      Delete VO.
      Specified by:
      deleteVo in interface VosManagerBl
      forceDelete - force the deletion of the VO, regardless there are any existing entities associated with the VO (they will be deleted)
    • deleteVo

      public void deleteVo(PerunSession sess, Vo vo)
      Description copied from interface: VosManagerBl
      Delete VO.
      Specified by:
      deleteVo in interface VosManagerBl
    • findCandidates

      public List<Candidate> findCandidates(PerunSession sess, Vo vo, String searchString, int maxNumOfResults)
      Description copied from interface: VosManagerBl
      Finds users, who can join the Vo.
      Specified by:
      findCandidates in interface VosManagerBl
      searchString - depends on the extSource of the VO, could by part of the name, email or something like that.
      maxNumOfResults - limit the maximum number of returned entries
      Returns:
      list of candidates who match the searchString
    • findCandidates

      public List<Candidate> findCandidates(PerunSession sess, Vo vo, String searchString, int maxNumOfResults, List<ExtSource> extSources, boolean filterExistingMembers)
    • findCandidates

      public List<Candidate> findCandidates(PerunSession sess, Vo vo, String searchString)
      Description copied from interface: VosManagerBl
      Finds users, who can join the Vo.
      Specified by:
      findCandidates in interface VosManagerBl
      vo - vo to be used
      searchString - depends on the extSource of the VO, could by part of the name, email or something like that.
      Returns:
      list of candidates who match the searchString
    • findCandidates

      public List<Candidate> findCandidates(PerunSession sess, Group group, String searchString)
      Description copied from interface: VosManagerBl
      Finds users, who can join the group in Vo.
      Specified by:
      findCandidates in interface VosManagerBl
      group - group to be used
      searchString - depends on the extSource of the Group, could by part of the name, email or something like that.
      Returns:
      list of candidates who match the searchString
    • findCandidates

      public List<Candidate> findCandidates(PerunSession sess, Group group, String searchString, List<ExtSource> extSources, boolean filterExistingMembers)
    • getAdminGroups

      public List<Group> getAdminGroups(PerunSession perunSession, Vo vo, String role)
      Description copied from interface: VosManagerBl
      Get list of group administrators of the given VO.

      Supported roles: VOOBSERVER, TOPGROUPCREATOR, VOADMIN

      Specified by:
      getAdminGroups in interface VosManagerBl
      Returns:
      List of groups, who are administrators of the Vo with supported role. Returns empty list if there is no VO group admin.
    • getAdminGroups

      @Deprecated public List<Group> getAdminGroups(PerunSession sess, Vo vo)
      Deprecated.
      Description copied from interface: VosManagerBl
      Get list of group administrators of the given VO.
      Specified by:
      getAdminGroups in interface VosManagerBl
      Returns:
      List of groups, who are administrators of the Vo. Returns empty list if there is no VO group admin.
    • getAdmins

      public List<User> getAdmins(PerunSession perunSession, Vo vo, String role, boolean onlyDirectAdmins)
      Description copied from interface: VosManagerBl
      Get list of user administrators of specific vo for specific role. If some group is administrator of the VO, all VALID members are included in the list.

      If onlyDirectAdmins is true, return only direct users of the group for supported role.

      Supported roles: VOOBSERVER, TOPGROUPCREATOR, VOADMIN

      Specified by:
      getAdmins in interface VosManagerBl
      role - supported role
      onlyDirectAdmins - if true, get only direct user administrators (if false, get both direct and indirect)
      Returns:
      list of all user administrators of the given vo for supported role
    • getAdmins

      @Deprecated public List<User> getAdmins(PerunSession sess, Vo vo)
      Deprecated.
      Description copied from interface: VosManagerBl
      Get list of Vo administrators. If some group is administrator of the VO, all members are included in the list.
      Specified by:
      getAdmins in interface VosManagerBl
      Returns:
      List of users, who are administrators of the Vo. Returns empty list if there is no VO admin.
    • getBanById

      public BanOnVo getBanById(PerunSession sess, int banId) throws BanNotExistsException
      Description copied from interface: VosManagerBl
      Get ban by its id.
      Specified by:
      getBanById in interface VosManagerBl
      Parameters:
      sess - session
      banId - ban id
      Returns:
      ban object
      Throws:
      BanNotExistsException - if ban with given id is not found
    • getBanForMember

      public Optional<BanOnVo> getBanForMember(PerunSession sess, int memberId)
      Description copied from interface: VosManagerBl
      Get ban for given member, if it exists.
      Specified by:
      getBanForMember in interface VosManagerBl
      Parameters:
      sess - session
      memberId - member id
      Returns:
      ban object, or null if there is no ban for given member
    • getBansForUser

      public List<BanOnVo> getBansForUser(PerunSession sess, int userId)
      Description copied from interface: VosManagerBl
      Gets all bans for given user
      Specified by:
      getBansForUser in interface VosManagerBl
      Parameters:
      sess - session
      userId - id of user
      Returns:
      list of bans for given user
    • getBansForVo

      public List<BanOnVo> getBansForVo(PerunSession sess, int voId)
      Description copied from interface: VosManagerBl
      Get list of all bans for vo with given id.
      Specified by:
      getBansForVo in interface VosManagerBl
      Parameters:
      sess - session
      voId - vo id
      Returns:
      list of bans for given vo
    • getCompleteCandidates

      public List<MemberCandidate> getCompleteCandidates(PerunSession sess, Vo vo, List<String> attrNames, String searchString)
      Description copied from interface: VosManagerBl
      Finds MemberCandidates who can join the Vo.
      Specified by:
      getCompleteCandidates in interface VosManagerBl
      Parameters:
      sess - session
      vo - vo to be used
      attrNames - name of attributes to be searched
      searchString - depends on the extSource of the Vo, could by part of the name, email or something like that.
      Returns:
      list of memberCandidates who match the searchString
    • getCompleteCandidates

      public List<MemberCandidate> getCompleteCandidates(PerunSession sess, Vo vo, Group group, List<String> attrNames, String searchString, List<ExtSource> extSources)
      Description copied from interface: VosManagerBl
      Finds MemberCandidates who can join the Group. If the given vo is not null, it searches only users who belong to this Vo or who have ues in any of given extSources.
      Specified by:
      getCompleteCandidates in interface VosManagerBl
      Parameters:
      sess - session
      vo - vo if vo is null, users are searched in whole perun, otherwise users are searched in members of given vo and in users with ues in any of given extSources
      group - group to be used
      attrNames - name of attributes to be searched
      searchString - depends on the extSource of the Vo, could by part of the name, email or something like that.
      extSources - extSources used to find candidates and possibly users
      Returns:
      list of memberCandidates who match the searchString
    • getDirectAdmins

      @Deprecated public List<User> getDirectAdmins(PerunSession sess, Vo vo)
      Deprecated.
      Description copied from interface: VosManagerBl
      Gets list of direct user administrators of the VO. 'Direct' means, there aren't included users, who are members of group administrators, in the returned list.
      Specified by:
      getDirectAdmins in interface VosManagerBl
    • getDirectRichAdmins

      @Deprecated public List<RichUser> getDirectRichAdmins(PerunSession sess, Vo vo)
      Deprecated.
      Description copied from interface: VosManagerBl
      Get list of Vo administrators directly assigned to VO like RichUsers without attributes.
      Specified by:
      getDirectRichAdmins in interface VosManagerBl
      Returns:
      List of users, who are administrators of the Vo. Returns empty list if there is no VO admin.
    • getDirectRichAdminsWithSpecificAttributes

      @Deprecated public List<RichUser> getDirectRichAdminsWithSpecificAttributes(PerunSession perunSession, Vo vo, List<String> specificAttributes)
      Deprecated.
      Description copied from interface: VosManagerBl
      Get list of Vo administrators, which are directly assigned (not by group membership) with specific attributes. From list of specificAttributes get all Users Attributes and find those for every RichAdmin (only, other attributes are not searched)
      Specified by:
      getDirectRichAdminsWithSpecificAttributes in interface VosManagerBl
      Returns:
      list of RichUsers with specific attributes.
    • getEnrichedBansForUser

      public List<EnrichedBanOnVo> getEnrichedBansForUser(PerunSession sess, int userId, List<String> attrNames) throws AttributeNotExistsException
      Description copied from interface: VosManagerBl
      Get all Enriched Bans for given User
      Specified by:
      getEnrichedBansForUser in interface VosManagerBl
      Parameters:
      sess - sesion
      userId - User ID
      attrNames - List of attributes, returns all attributes if null or empty
      Returns:
      List of Enriched Bans
      Throws:
      AttributeNotExistsException
    • getEnrichedBansForVo

      public List<EnrichedBanOnVo> getEnrichedBansForVo(PerunSession sess, Vo vo, List<String> attrNames) throws AttributeNotExistsException
      Description copied from interface: VosManagerBl
      Get all Enriched Bans for given VO and attribute names
      Specified by:
      getEnrichedBansForVo in interface VosManagerBl
      Parameters:
      sess - sesion
      vo - VO
      attrNames - List of attributes, returns all attributes if null or empty
      Returns:
      list of enriched bans
      Throws:
      AttributeNotExistsException
    • getEnrichedVoById

      public EnrichedVo getEnrichedVoById(PerunSession sess, int id) throws VoNotExistsException
      Description copied from interface: VosManagerBl
      Finds existing vo by and id and returns corresponding EnrichedVo
      Specified by:
      getEnrichedVoById in interface VosManagerBl
      Returns:
      EnrichedVO object of requested VO, which contains its member and parent VOs
      Throws:
      VoNotExistsException
    • getEnrichedVos

      public List<EnrichedVo> getEnrichedVos(PerunSession sess)
      Description copied from interface: VosManagerBl
      Get list of all EnrichedVos
      Specified by:
      getEnrichedVos in interface VosManagerBl
      Returns:
      List of EnrichedVos or empty list
    • getMemberVos

      public List<Vo> getMemberVos(PerunSession sess, int voId)
      Description copied from interface: VosManagerBl
      Gets all member organizations of the given vo.
      Specified by:
      getMemberVos in interface VosManagerBl
      Parameters:
      sess - session
      voId - vo id
      Returns:
      list of member vos
    • getParentVos

      public List<Vo> getParentVos(PerunSession sess, int memberVoId)
      Description copied from interface: VosManagerBl
      Gets all organizations where given vo is direct member.
      Specified by:
      getParentVos in interface VosManagerBl
      Parameters:
      sess - session
      memberVoId - member vo id
      Returns:
      list of direct parent vos
    • getPerunBl

      public PerunBl getPerunBl()
      Gets the perunBl.
      Returns:
      The perunBl.
    • getRichAdmins

      public List<RichUser> getRichAdmins(PerunSession perunSession, Vo vo, String role, List<String> specificAttributes, boolean allUserAttributes, boolean onlyDirectAdmins) throws UserNotExistsException
      Description copied from interface: VosManagerBl
      Get list of richUser administrators of specific vo for specific role. If some group is administrator of the VO, all VALID members are included in the list.

      Supported roles: VOOBSERVER, TOPGROUPCREATOR, VOADMIN

      If "onlyDirectAdmins" is "true", return only direct users of the vo for supported role with specific attributes. If "allUserAttributes" is "true", do not specify attributes through list and return them all in objects richUser . Ignoring list of specific attributes.

      Specified by:
      getRichAdmins in interface VosManagerBl
      specificAttributes - list of specified attributes which are needed in object richUser
      allUserAttributes - if true, get all possible user attributes and ignore list of specificAttributes (if false, get only specific attributes)
      onlyDirectAdmins - if true, get only direct user administrators (if false, get both direct and indirect)
      Returns:
      list of RichUser administrators for the vo and supported role with attributes
      Throws:
      UserNotExistsException
    • getRichAdmins

      @Deprecated public List<RichUser> getRichAdmins(PerunSession perunSession, Vo vo)
      Deprecated.
      Description copied from interface: VosManagerBl
      Get list of Vo administrators like RichUsers without attributes.
      Specified by:
      getRichAdmins in interface VosManagerBl
      Returns:
      List of users, who are administrators of the Vo. Returns empty list if there is no VO admin.
    • getRichAdminsWithAttributes

      @Deprecated public List<RichUser> getRichAdminsWithAttributes(PerunSession perunSession, Vo vo) throws UserNotExistsException
      Deprecated.
      Description copied from interface: VosManagerBl
      Get list of Vo administrators like RichUsers with attributes.
      Specified by:
      getRichAdminsWithAttributes in interface VosManagerBl
      Returns:
      List of users, who are administrators of the Vo. Returns empty list if there is no VO admin.
      Throws:
      UserNotExistsException
    • getRichAdminsWithSpecificAttributes

      @Deprecated public List<RichUser> getRichAdminsWithSpecificAttributes(PerunSession perunSession, Vo vo, List<String> specificAttributes)
      Deprecated.
      Description copied from interface: VosManagerBl
      Get list of Vo administrators with specific attributes. From list of specificAttributes get all Users Attributes and find those for every RichAdmin (only, other attributes are not searched)
      Specified by:
      getRichAdminsWithSpecificAttributes in interface VosManagerBl
      Returns:
      list of RichUsers with specific attributes.
    • getVoById

      public Vo getVoById(PerunSession sess, int id) throws VoNotExistsException
      Description copied from interface: VosManagerBl
      Finds existing VO by id.
      Specified by:
      getVoById in interface VosManagerBl
      Returns:
      VO with requested id or throws if the VO with specified id doesn't exist
      Throws:
      VoNotExistsException
    • getVoByShortName

      public Vo getVoByShortName(PerunSession sess, String shortName) throws VoNotExistsException
      Description copied from interface: VosManagerBl
      Find existing VO by short name (short name is unique).
      Specified by:
      getVoByShortName in interface VosManagerBl
      shortName - short name of VO which you find (for example "KZCU")
      Returns:
      VO with requested shortName or throws if the VO with specified shortName doesn't exist
      Throws:
      VoNotExistsException
    • getVoMembersCountsByStatus

      public Map<Status,Integer> getVoMembersCountsByStatus(PerunSession sess, Vo vo)
      Description copied from interface: VosManagerBl
      Returns number of vo members by their status.
      Specified by:
      getVoMembersCountsByStatus in interface VosManagerBl
      Parameters:
      sess - perun session
      vo - vo of members
      Returns:
      map of status in vo to number of vo members with the status
    • getVos

      public List<Vo> getVos(PerunSession sess)
      Description copied from interface: VosManagerBl
      Get list of all Vos.
      Specified by:
      getVos in interface VosManagerBl
      Returns:
      List of VOs or empty ArrayList
    • getVosByIds

      public List<Vo> getVosByIds(PerunSession sess, List<Integer> ids)
      Description copied from interface: VosManagerBl
      Finds existing VOs by ids.
      Specified by:
      getVosByIds in interface VosManagerBl
      Returns:
      VOs with requested ids
    • getVosByPerunBean

      public List<Vo> getVosByPerunBean(PerunSession sess, Group group) throws VoNotExistsException
      Description copied from interface: VosManagerBl
      Returns list of vos connected with a group
      Specified by:
      getVosByPerunBean in interface VosManagerBl
      Returns:
      list of vos connected with group
      Throws:
      VoNotExistsException
    • getVosByPerunBean

      public List<Vo> getVosByPerunBean(PerunSession sess, Member member)
      Description copied from interface: VosManagerBl
      Returns list of vos connected with a member
      Specified by:
      getVosByPerunBean in interface VosManagerBl
      Returns:
      list of vos connected with member
    • getVosByPerunBean

      public List<Vo> getVosByPerunBean(PerunSession sess, Resource resource) throws VoNotExistsException
      Description copied from interface: VosManagerBl
      Returns list of vos connected with a resource
      Specified by:
      getVosByPerunBean in interface VosManagerBl
      Returns:
      list of vos connected with resource
      Throws:
      VoNotExistsException
    • getVosByPerunBean

      public List<Vo> getVosByPerunBean(PerunSession sess, User user)
      Description copied from interface: VosManagerBl
      Returns list of vos connected with a user
      Specified by:
      getVosByPerunBean in interface VosManagerBl
      Returns:
      list of vos connected with user
    • getVosByPerunBean

      public List<Vo> getVosByPerunBean(PerunSession sess, Host host)
      Description copied from interface: VosManagerBl
      Returns list of vos connected with a host
      Specified by:
      getVosByPerunBean in interface VosManagerBl
      Returns:
      list of vos connected with host
    • getVosByPerunBean

      public List<Vo> getVosByPerunBean(PerunSession sess, Facility facility)
      Description copied from interface: VosManagerBl
      Returns list of vos connected with a facility
      Specified by:
      getVosByPerunBean in interface VosManagerBl
      Returns:
      list of vos connected with facility
    • getVosCount

      public int getVosCount(PerunSession sess)
      Description copied from interface: VosManagerBl
      Get count of all vos.
      Specified by:
      getVosCount in interface VosManagerBl
      Returns:
      count of all vos
    • handleGroupLostVoRole

      public void handleGroupLostVoRole(PerunSession sess, Group group, Vo vo, String role)
      Description copied from interface: VosManagerBl
      Handles a group that lost a role.
      Specified by:
      handleGroupLostVoRole in interface VosManagerBl
      Parameters:
      sess - perun session
      group - group
      vo - virtual organization
      role - role of group in VO
    • handleUserLostVoRole

      public void handleUserLostVoRole(PerunSession sess, User user, Vo vo, String role)
      Description copied from interface: VosManagerBl
      Handles a user that lost a role.
      Specified by:
      handleUserLostVoRole in interface VosManagerBl
      Parameters:
      sess - perun session
      user - user
      vo - virtual organization
      role - role of user in VO
    • isMemberBanned

      public boolean isMemberBanned(PerunSession sess, int memberId)
      Description copied from interface: VosManagerBl
      Information if there is a ban for member with given id.
      Specified by:
      isMemberBanned in interface VosManagerBl
      Parameters:
      sess - session
      memberId - member id
      Returns:
      true, if member with given id is banned, false otherwise
    • isUserInRoleForVo

      public boolean isUserInRoleForVo(PerunSession session, User user, String role, Vo vo, boolean checkGroups)
      Description copied from interface: VosManagerBl
      Check whether a user is in a role for a given VO, possibly checking also user's groups.
      Specified by:
      isUserInRoleForVo in interface VosManagerBl
      Parameters:
      session - session
      user - user
      role - role
      vo - virtual organization
      checkGroups - check also groups of the user whether they have the role
      Returns:
      true if user is directly in role for the vo, or if "checkGroups" flag is set and at least one of the groups is in the role
    • removeBan

      public void removeBan(PerunSession sess, int banId) throws BanNotExistsException
      Description copied from interface: VosManagerBl
      Removes ban with given id.
      Specified by:
      removeBan in interface VosManagerBl
      Parameters:
      sess - session
      banId - ban id
      Throws:
      BanNotExistsException - if there is no ban with given id
    • removeBanForMember

      public void removeBanForMember(PerunSession sess, int memberId) throws BanNotExistsException
      Description copied from interface: VosManagerBl
      Removes ban for member with given id.
      Specified by:
      removeBanForMember in interface VosManagerBl
      Parameters:
      sess - session
      memberId - member id
      Throws:
      BanNotExistsException - if there is no ban for member with given id
    • removeMemberVo

      public void removeMemberVo(PerunSession sess, Vo vo, Vo memberVo) throws RelationNotExistsException
      Description copied from interface: VosManagerBl
      Removes member vo from given vo. Updates memberOrganizations list attribute for those members of parent vo who came from the member vo.
      Specified by:
      removeMemberVo in interface VosManagerBl
      Parameters:
      sess - session
      vo - vo
      memberVo - vo to be removed
      Throws:
      RelationNotExistsException - if member vo is not a member of the vo
    • setBan

      Description copied from interface: VosManagerBl
      Set given ban.
      Specified by:
      setBan in interface VosManagerBl
      Parameters:
      sess - session
      banOnVo - ban information, memberId, voId, validity and description are needed
      Returns:
      created ban object
      Throws:
      MemberNotExistsException
      BanAlreadyExistsException
    • setPerunBl

      public void setPerunBl(PerunBl perunBl)
      Sets the perunBl for this instance.
      Parameters:
      perunBl - The perunBl.
    • updateBan

      public BanOnVo updateBan(PerunSession sess, BanOnVo banOnVo)
      Description copied from interface: VosManagerBl
      Update ban information. Only description and validity are updated.
      Specified by:
      updateBan in interface VosManagerBl
      Parameters:
      sess - session
      banOnVo - updated ban
      Returns:
      updated ban object
    • updateVo

      public Vo updateVo(PerunSession sess, Vo vo)
      Description copied from interface: VosManagerBl
      Updates VO.
      Specified by:
      updateVo in interface VosManagerBl
      Returns:
      returns updated VO
    • usesEmbeddedGroupRegistrations

      public boolean usesEmbeddedGroupRegistrations(PerunSession sess, Vo vo)
      Description copied from interface: VosManagerBl
      Returns true, if the given vo uses EMBEDDED_GROUP_APPLICATION item in its form.
      Specified by:
      usesEmbeddedGroupRegistrations in interface VosManagerBl
      Parameters:
      sess - session
      vo - vo
      Returns:
      true, if the given vo uses EMBEDDED_GROUP_APPLICATION item in its form, false otherwise.