From 83cdf7f294389dd2a16b2489faf7109fbd9fbc53 Mon Sep 17 00:00:00 2001 From: margaretha Date: Wed, 23 Oct 2024 10:50:29 +0200 Subject: [PATCH] Changed memberUsername to member in the member-role-addition web-service Removed user-privileges from user-group list response. Change-Id: Icc58cc4ba46cc1e58697d4fcbb5d0a65aaeac54f --- Changes | 4 ++++ .../de/ids_mannheim/korap/dto/UserGroupDto.java | 3 --- .../korap/dto/converter/UserGroupConverter.java | 6 +----- .../korap/service/UserGroupService.java | 13 ++++++------- .../korap/web/controller/UserGroupController.java | 8 ++++++-- .../web/controller/usergroup/UserGroupTestBase.java | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Changes b/Changes index 050dfc74..639a5fe6 100644 --- a/Changes +++ b/Changes @@ -20,6 +20,10 @@ - Deprecate VC access deletion. - Change default port to 8089. - Disallow scope all for non super clients. +- Changed memberUsername to member in the new member-role-addition web-service. +- Removed user-privileges from user-group list response. +- + # version 0.74.1-SNAPSHOT diff --git a/src/main/java/de/ids_mannheim/korap/dto/UserGroupDto.java b/src/main/java/de/ids_mannheim/korap/dto/UserGroupDto.java index b5501d49..7803c532 100644 --- a/src/main/java/de/ids_mannheim/korap/dto/UserGroupDto.java +++ b/src/main/java/de/ids_mannheim/korap/dto/UserGroupDto.java @@ -28,7 +28,4 @@ public class UserGroupDto { @JsonInclude(JsonInclude.Include.NON_EMPTY) private List members; - - @JsonInclude(JsonInclude.Include.NON_NULL) - private List userPrivileges; } diff --git a/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java b/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java index 3ffa646b..7fbaa101 100644 --- a/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java +++ b/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java @@ -27,7 +27,7 @@ public class UserGroupConverter { public UserGroupDto createUserGroupDto (UserGroup group, - List members, Set roleSet) { + List members) { UserGroupDto dto = new UserGroupDto(); dto.setId(group.getId()); @@ -36,10 +36,6 @@ public UserGroupDto createUserGroupDto (UserGroup group, dto.setStatus(group.getStatus()); dto.setOwner(group.getCreatedBy()); - if (roleSet != null) { - dto.setUserPrivileges(createPrivilegeList(roleSet)); - } - if (members != null) { ArrayList memberDtos = new ArrayList<>( members.size()); diff --git a/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java b/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java index 11e9c125..f73a9ecc 100644 --- a/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java +++ b/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java @@ -93,10 +93,9 @@ public List retrieveUserGroupDto (String username) UserGroupDto groupDto; for (UserGroup group : userGroups) { members = retrieveMembers(group.getId(), username); - userAsMember = groupMemberDao.retrieveMemberById(username, - group.getId()); - groupDto = converter.createUserGroupDto(group, members, - userAsMember.getRoles()); +// userAsMember = groupMemberDao.retrieveMemberById(username, +// group.getId()); + groupDto = converter.createUserGroupDto(group, members); dtos.add(groupDto); } @@ -141,7 +140,7 @@ public UserGroupDto retrieveHiddenUserGroupByQueryName (String queryName) .retrieveHiddenGroupByQueryName(queryName); List members = groupMemberDao .retrieveMemberByGroupId(group.getId()); - return converter.createUserGroupDto(group, members, null); + return converter.createUserGroupDto(group, members); } public List retrieveUserGroupByStatus (String username, @@ -156,7 +155,7 @@ public List retrieveUserGroupByStatus (String username, UserGroupDto groupDto; for (UserGroup group : userGroups) { members = groupMemberDao.retrieveMemberByGroupId(group.getId()); - groupDto = converter.createUserGroupDto(group, members, null); + groupDto = converter.createUserGroupDto(group, members); dtos.add(groupDto); } return dtos; @@ -373,7 +372,7 @@ public UserGroupDto searchByName (String groupName) throws KustvaktException { UserGroup userGroup = userGroupDao.retrieveGroupByName(groupName, true); UserGroupDto groupDto = converter.createUserGroupDto(userGroup, - userGroup.getMembers(), null); + userGroup.getMembers()); return groupDto; } diff --git a/src/main/java/de/ids_mannheim/korap/web/controller/UserGroupController.java b/src/main/java/de/ids_mannheim/korap/web/controller/UserGroupController.java index a968946a..dd39ffc9 100644 --- a/src/main/java/de/ids_mannheim/korap/web/controller/UserGroupController.java +++ b/src/main/java/de/ids_mannheim/korap/web/controller/UserGroupController.java @@ -277,7 +277,7 @@ public Response addMemberRoles (@Context SecurityContext securityContext, @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response addAdminRole (@Context SecurityContext securityContext, @PathParam("groupName") String groupName, - @FormParam("memberUsername") String memberUsername) { + @FormParam("member") String memberUsername) { TokenContext context = (TokenContext) securityContext .getUserPrincipal(); try { @@ -311,7 +311,8 @@ public Response addAdminRole (@Context SecurityContext securityContext, @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response deleteMemberRoles (@Context SecurityContext securityContext, @PathParam("groupName") String groupName, - @FormParam("memberUsername") String memberUsername, + @FormParam("memberUsername") String memberUsername, // DEPRECATED + @FormParam("member") String member, @FormParam("roleId") List roleIds, @FormParam("role") List roles) { TokenContext context = (TokenContext) securityContext @@ -326,6 +327,9 @@ public Response deleteMemberRoles (@Context SecurityContext securityContext, + " removed in API v1.1.")); } else { + memberUsername = (member!=null && !member.isEmpty()) + ? member : memberUsername; + service.deleteMemberRoles(context.getUsername(), groupName, memberUsername, roles); } diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/usergroup/UserGroupTestBase.java b/src/test/java/de/ids_mannheim/korap/web/controller/usergroup/UserGroupTestBase.java index 630ee660..82568c01 100644 --- a/src/test/java/de/ids_mannheim/korap/web/controller/usergroup/UserGroupTestBase.java +++ b/src/test/java/de/ids_mannheim/korap/web/controller/usergroup/UserGroupTestBase.java @@ -90,7 +90,7 @@ protected void testAddMember (String groupName, String username, protected Response addAdminRole (String groupName, String memberName, String addedBy) throws KustvaktException { Form form = new Form(); - form.param("memberUsername", memberName); + form.param("member", memberName); form.param("role", PredefinedRole.GROUP_ADMIN.name()); Response response = target().path(API_VERSION).path("group")