Added userRoles attribute to UserGroupDto.
Change-Id: Ia410dda50f092508d7da4340486667d7ff502e04
diff --git a/full/Changes b/full/Changes
index a052996..8d9febb 100644
--- a/full/Changes
+++ b/full/Changes
@@ -8,7 +8,7 @@
- enabled custom implementation for email address retrieval (margaretha)
- removed old policy and deprecated code (margaretha)
- moved authentication related code to /full (margaretha)
- - removed spring config option in KustvaktServer (margaretha)
+ - added userRoles attribute to UserGroupDto. (margaretha)
version 0.59.10
20/02/2018
diff --git a/full/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java b/full/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
index e960ee1..72c856a 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
@@ -190,8 +190,6 @@
+ userId,
userId, e);
}
-
-
}
public UserGroup retrieveGroupByName (String groupName)
diff --git a/full/src/main/java/de/ids_mannheim/korap/dto/UserGroupDto.java b/full/src/main/java/de/ids_mannheim/korap/dto/UserGroupDto.java
index 6b3e8b6..82f05eb 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dto/UserGroupDto.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dto/UserGroupDto.java
@@ -2,6 +2,8 @@
import java.util.List;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
import de.ids_mannheim.korap.constant.GroupMemberStatus;
import lombok.Getter;
import lombok.Setter;
@@ -13,6 +15,10 @@
private int id;
private String name;
private String owner;
+
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<UserGroupMemberDto> members;
+
private GroupMemberStatus userMemberStatus;
+ private List<String> userRoles;
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java b/full/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java
index 273677b..0d61db3 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java
@@ -16,7 +16,8 @@
public class UserGroupConverter {
public UserGroupDto createUserGroupDto (UserGroup group,
- List<UserGroupMember> members, GroupMemberStatus userMemberStatus) {
+ List<UserGroupMember> members, GroupMemberStatus userMemberStatus,
+ List<Role> userRoles) {
UserGroupDto dto = new UserGroupDto();
dto.setId(group.getId());
@@ -24,6 +25,12 @@
dto.setOwner(group.getCreatedBy());
dto.setUserMemberStatus(userMemberStatus);
+ List<String> roles = new ArrayList<>(userRoles.size());
+ for (Role r : userRoles) {
+ roles.add(r.getName());
+ }
+ dto.setUserRoles(roles);
+
if (members != null) {
ArrayList<UserGroupMemberDto> memberDtos =
new ArrayList<>(members.size());
@@ -32,11 +39,11 @@
UserGroupMemberDto memberDto = new UserGroupMemberDto();
memberDto.setUserId(member.getUserId());
memberDto.setStatus(member.getStatus());
- List<String> roles = new ArrayList<>(member.getRoles().size());
+ List<String> memberRoles = new ArrayList<>(member.getRoles().size());
for (Role r : member.getRoles()) {
- roles.add(r.getName());
+ memberRoles.add(r.getName());
}
- memberDto.setRoles(roles);
+ memberDto.setRoles(memberRoles);
memberDtos.add(memberDto);
}
dto.setMembers(memberDtos);
diff --git a/full/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java b/full/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java
index 9c3e245..428d87c 100644
--- a/full/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java
@@ -78,12 +78,14 @@
UserGroupMember userAsMember;
List<UserGroupMember> members;
+ UserGroupDto groupDto;
for (UserGroup group : userGroups) {
members = retrieveMembers(group.getId(), username);
userAsMember =
groupMemberDao.retrieveMemberById(username, group.getId());
- dtos.add(converter.createUserGroupDto(group, members,
- userAsMember.getStatus()));
+ groupDto = converter.createUserGroupDto(group, members,
+ userAsMember.getStatus(), userAsMember.getRoles());
+ dtos.add(groupDto);
}
return dtos;
@@ -250,8 +252,10 @@
member.setUserId(username);
groupMemberDao.addMember(member);
- if (config.isMailEnabled() && userGroup.getStatus() != UserGroupStatus.HIDDEN) {
- mailService.sendMemberInvitationNotification(username,userGroup.getName(), createdBy);
+ if (config.isMailEnabled()
+ && userGroup.getStatus() != UserGroupStatus.HIDDEN) {
+ mailService.sendMemberInvitationNotification(username,
+ userGroup.getName(), createdBy);
}
}