Package de.dlr.proseo.usermgr.rest
Class GroupManager
java.lang.Object
de.dlr.proseo.usermgr.rest.GroupManager
Service methods required to manage user group groups.
- Author:
- Dr. Thomas Bassler
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classException to indicate unmodified data to caller -
Field Summary
FieldsModifier and TypeFieldDescription(package private) GroupMemberRepositoryRepository for group members(package private) GroupRepositoryRepository for User group objects(package private) UserRepositoryRepository for User objects -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddGroupMember(Long id, String username) Add a member to the given user groupcountGroups(String mission) Count the groups matching the specified missioncreateGroup(RestGroup restGroup) Create a user group (optionally with direct authorities)voiddeleteGroupById(Long id) Delete a user group by IDgetGroupById(Long id) Get a user group by IDgetGroupMembers(Long id) Get all members of the given user groupGet user groups by mission and optionally by group namemodifyGroup(Long id, RestGroup restGroup) Update a user group by user group IDvoidremoveGroupMember(Long id, String username) Delete a member from the given user group(package private) static GrouptoModelGroup(RestGroup restGroup) Convert a user group from REST format to the prosEO data model format (including authorities)(package private) static RestGrouptoRestGroup(Group modelGroup) Convert a user group from prosEO data model format to REST format (including authorities)
-
Field Details
-
groupRepository
Repository for User group objects -
userRepository
Repository for User objects -
groupMemberRepository
Repository for group members
-
-
Constructor Details
-
GroupManager
public GroupManager()
-
-
Method Details
-
toModelGroup
Convert a user group from REST format to the prosEO data model format (including authorities)- Parameters:
restGroup- the REST user group to convert- Returns:
- the converted model user group
- Throws:
IllegalArgumentException- if an invalid authority value was given
-
toRestGroup
Convert a user group from prosEO data model format to REST format (including authorities)- Parameters:
modelGroup- the model user group to convert- Returns:
- the converted REST user
-
createGroup
Create a user group (optionally with direct authorities)- Parameters:
restGroup- a Json representation of the new user group- Returns:
- a Json representation of the user group after creation
- Throws:
IllegalArgumentException- if any of the input data was invalid
-
getGroups
public List<RestGroup> getGroups(String mission, String groupName, Integer recordFrom, Integer recordTo) throws jakarta.persistence.NoResultException, org.springframework.web.client.HttpClientErrorException Get user groups by mission and optionally by group name- Parameters:
mission- the mission codegroupName- the group name (optional)recordFrom- first record of filtered and ordered result to returnrecordTo- last record of filtered and ordered result to return- Returns:
- a list of Json objects representing the user groups authorized for the given mission
- Throws:
org.springframework.web.client.HttpClientErrorException- if the result list exceeds a configured maximumjakarta.persistence.NoResultException- if no groups matching the search criteria can be found
-
getGroupById
public RestGroup getGroupById(Long id) throws IllegalArgumentException, jakarta.persistence.NoResultException Get a user group by ID- Parameters:
id- the user group ID- Returns:
- a Json object corresponding to the user group found
- Throws:
IllegalArgumentException- if no user group ID was givenjakarta.persistence.NoResultException- if no user group with the given ID exists
-
deleteGroupById
public void deleteGroupById(Long id) throws jakarta.persistence.EntityNotFoundException, RuntimeException Delete a user group by ID- Parameters:
id- the ID of the user group to delete- Throws:
jakarta.persistence.EntityNotFoundException- if the user group to delete does not exist in the databaseRuntimeException- if the deletion was not performed as expected
-
modifyGroup
public RestGroup modifyGroup(Long id, RestGroup restGroup) throws jakarta.persistence.EntityNotFoundException, IllegalArgumentException, GroupManager.NotModifiedException Update a user group by user group ID- Parameters:
id- the ID of the user group to updaterestGroup- a Json object containing the modified (and unmodified) attributes- Returns:
- a response containing a Json object corresponding to the user group after modification
- Throws:
jakarta.persistence.EntityNotFoundException- if no user group with the given user group ID existsIllegalArgumentException- if any of the input data was invalidGroupManager.NotModifiedException- if the group data was not modified (input data same as database data)
-
getGroupMembers
Get all members of the given user group- Parameters:
id- the ID of the user group- Returns:
- a list of Json objects representing the users, which are members of the given group
- Throws:
jakarta.persistence.NoResultException- if the group has no members
-
addGroupMember
public List<RestUser> addGroupMember(Long id, String username) throws jakarta.persistence.EntityNotFoundException, IllegalArgumentException, GroupManager.NotModifiedException Add a member to the given user group- Parameters:
id- the ID of the group to updateusername- the name of the user to add- Returns:
- a Json object corresponding to the list of users after addition
- Throws:
jakarta.persistence.EntityNotFoundException- if no user group with the given ID or no user with the given name existsIllegalArgumentException- if any of the input data was invalidGroupManager.NotModifiedException- if the user is already a member of the group
-
removeGroupMember
public void removeGroupMember(Long id, String username) throws jakarta.persistence.EntityNotFoundException, RuntimeException, GroupManager.NotModifiedException Delete a member from the given user group- Parameters:
id- the group IDusername- the name of the user to remove- Throws:
jakarta.persistence.EntityNotFoundException- if the group did not existRuntimeException- if the deletion was unsuccessfulGroupManager.NotModifiedException- if the user is not a member of the group
-
countGroups
Count the groups matching the specified mission- Parameters:
mission- the mission code- Returns:
- the number of groups found as string
-