Klasse GroupManager

java.lang.Object
de.dlr.proseo.usermgr.rest.GroupManager

@Component @Transactional(isolation=REPEATABLE_READ) public class GroupManager extends Object
Service methods required to manage user group groups.
Autor:
Dr. Thomas Bassler
  • Felddetails

    • groupRepository

      @Autowired GroupRepository groupRepository
      Repository for User group objects
    • userRepository

      @Autowired UserRepository userRepository
      Repository for User objects
    • groupMemberRepository

      @Autowired GroupMemberRepository groupMemberRepository
      Repository for group members
  • Konstruktordetails

    • GroupManager

      public GroupManager()
  • Methodendetails

    • toModelGroup

      static Group toModelGroup(RestGroup restGroup) throws IllegalArgumentException
      Convert a user group from REST format to the prosEO data model format (including authorities)
      Parameter:
      restGroup - the REST user group to convert
      Gibt zurück:
      the converted model user group
      Löst aus:
      IllegalArgumentException - if an invalid authority value was given
    • toRestGroup

      static RestGroup toRestGroup(Group modelGroup)
      Convert a user group from prosEO data model format to REST format (including authorities)
      Parameter:
      modelGroup - the model user group to convert
      Gibt zurück:
      the converted REST user
    • createGroup

      public RestGroup createGroup(RestGroup restGroup) throws IllegalArgumentException
      Create a user group (optionally with direct authorities)
      Parameter:
      restGroup - a Json representation of the new user group
      Gibt zurück:
      a Json representation of the user group after creation
      Löst aus:
      IllegalArgumentException - if any of the input data was invalid
    • getGroups

      public List<RestGroup> getGroups(String mission, String groupName, Integer recordFrom, Integer recordTo) throws javax.persistence.NoResultException, org.springframework.web.client.HttpClientErrorException
      Get user groups by mission and optionally by group name
      Parameter:
      mission - the mission code
      groupName - the group name (optional)
      recordFrom - first record of filtered and ordered result to return
      recordTo - last record of filtered and ordered result to return
      Gibt zurück:
      a list of Json objects representing the user groups authorized for the given mission
      Löst aus:
      org.springframework.web.client.HttpClientErrorException - if the result list exceeds a configured maximum
      javax.persistence.NoResultException - if no groups matching the search criteria can be found
    • getGroupById

      public RestGroup getGroupById(Long id) throws IllegalArgumentException, javax.persistence.NoResultException
      Get a user group by ID
      Parameter:
      id - the user group ID
      Gibt zurück:
      a Json object corresponding to the user group found
      Löst aus:
      IllegalArgumentException - if no user group ID was given
      javax.persistence.NoResultException - if no user group with the given ID exists
    • deleteGroupById

      public void deleteGroupById(Long id) throws javax.persistence.EntityNotFoundException, RuntimeException
      Delete a user group by ID
      Parameter:
      id - the ID of the user group to delete
      Löst aus:
      javax.persistence.EntityNotFoundException - if the user group to delete does not exist in the database
      RuntimeException - if the deletion was not performed as expected
    • modifyGroup

      public RestGroup modifyGroup(Long id, RestGroup restGroup) throws javax.persistence.EntityNotFoundException, IllegalArgumentException, GroupManager.NotModifiedException
      Update a user group by user group ID
      Parameter:
      id - the ID of the user group to update
      restGroup - a Json object containing the modified (and unmodified) attributes
      Gibt zurück:
      a response containing a Json object corresponding to the user group after modification
      Löst aus:
      javax.persistence.EntityNotFoundException - if no user group with the given user group ID exists
      IllegalArgumentException - if any of the input data was invalid
      GroupManager.NotModifiedException - if the group data was not modified (input data same as database data)
    • getGroupMembers

      public List<RestUser> getGroupMembers(Long id)
      Get all members of the given user group
      Parameter:
      id - the ID of the user group
      Gibt zurück:
      a list of Json objects representing the users, which are members of the given group
      Löst aus:
      javax.persistence.NoResultException - if the group has no members
    • addGroupMember

      public List<RestUser> addGroupMember(Long id, String username) throws javax.persistence.EntityNotFoundException, IllegalArgumentException, GroupManager.NotModifiedException
      Add a member to the given user group
      Parameter:
      id - the ID of the group to update
      username - the name of the user to add
      Gibt zurück:
      a Json object corresponding to the list of users after addition
      Löst aus:
      javax.persistence.EntityNotFoundException - if no user group with the given ID or no user with the given name exists
      IllegalArgumentException - if any of the input data was invalid
      GroupManager.NotModifiedException - if the user is already a member of the group
    • removeGroupMember

      public void removeGroupMember(Long id, String username) throws javax.persistence.EntityNotFoundException, RuntimeException, GroupManager.NotModifiedException
      Delete a member from the given user group
      Parameter:
      id - the group ID
      username - the name of the user to remove
      Löst aus:
      javax.persistence.EntityNotFoundException - if the group did not exist
      RuntimeException - if the deletion was unsuccessful
      GroupManager.NotModifiedException - if the user is not a member of the group
    • countGroups

      public String countGroups(String mission)
      Count the groups matching the specified mission
      Parameter:
      mission - the mission code
      Gibt zurück:
      the number of groups found as string