Fixed administrative user group retrieval.
Now returns groups with empty members.
Change-Id: I4702ab23c7c48d35ecc3c4d8fa47414861e29f10
diff --git a/Changes b/Changes
index c13cf0f..dee7d5e 100644
--- a/Changes
+++ b/Changes
@@ -25,6 +25,7 @@
- Added role names to user-group list
- Added not-timeExceeded to the totalResult constraints.
- Replace EDIT_VC occurrences with CREATE_VC, and removed it.
+- Fixed administrative user group retrieval to return groups with empty members.
# version 0.74.1-SNAPSHOT
diff --git a/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java b/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
index 6c7914a..2545122 100644
--- a/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
+++ b/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
@@ -210,6 +210,14 @@
}
}
+ /** If fetchMembers=true, this method doesn't return groups with empty
+ * members.
+ *
+ * @param groupName
+ * @param fetchMembers
+ * @return
+ * @throws KustvaktException
+ */
public UserGroup retrieveGroupByName (String groupName,
boolean fetchMembers) throws KustvaktException {
ParameterChecker.checkStringValue(groupName, "groupName");
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 e059583..6362d25 100644
--- a/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java
+++ b/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java
@@ -367,9 +367,12 @@
public UserGroupDto searchByName (String groupName)
throws KustvaktException {
- UserGroup userGroup = userGroupDao.retrieveGroupByName(groupName, true);
+ UserGroup userGroup = userGroupDao.retrieveGroupByName(groupName, false);
+ List<UserGroupMember> members = groupMemberDao
+ .retrieveMemberByGroupId(userGroup.getId());
+
UserGroupDto groupDto = converter.createUserGroupDto(userGroup,
- userGroup.getMembers());
+ members);
return groupDto;
}
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/usergroup/UserGroupControllerAdminTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/usergroup/UserGroupControllerAdminTest.java
index 13fa68a..6ea1d0a 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/usergroup/UserGroupControllerAdminTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/usergroup/UserGroupControllerAdminTest.java
@@ -14,6 +14,7 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.service.UserGroupService;
import de.ids_mannheim.korap.utils.JsonUtils;
+import de.ids_mannheim.korap.web.controller.vc.VirtualCorpusTestBase;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.MediaType;
@@ -23,7 +24,7 @@
/**
* @author margaretha
*/
-public class UserGroupControllerAdminTest extends UserGroupTestBase {
+public class UserGroupControllerAdminTest extends VirtualCorpusTestBase {
private String testUser = "group-admin";
@@ -179,6 +180,23 @@
}
@Test
+ public void testRetrieveHiddenGroupEmptyMember() throws KustvaktException {
+ createDoryGroup();
+ createPublishedVC("dory", "dory-published");
+
+ JsonNode node = listHiddenGroup();
+ assertEquals(2, node.size());
+
+ String name = node.at("/1/name").asText();
+ JsonNode groupNode = retrieveGroup(name);
+
+ assertEquals(name, groupNode.at("/name").asText());
+
+ deleteVC("dory-published", "dory", "dory");
+ deleteGroupByName(doryGroupName, "dory");
+ }
+
+ @Test
public void testUserGroupAdmin ()
throws KustvaktException {
String groupName = "admin-test-group";