Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-jams
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-jams
Commits
57bcc03c
Commit
57bcc03c
authored
4 years ago
by
William Enright
Committed by
Larbi Gharib
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixed deletion of group memberships not working when deleting a group
Change-Id: I16d4c9963b7bc40eead3e076a938ddb1b0638ad0
parent
3a075fd0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jams-server/src/main/java/net/jami/jams/server/servlets/api/admin/group/GroupServlet.java
+31
-4
31 additions, 4 deletions
...mi/jams/server/servlets/api/admin/group/GroupServlet.java
with
31 additions
and
4 deletions
jams-server/src/main/java/net/jami/jams/server/servlets/api/admin/group/GroupServlet.java
+
31
−
4
View file @
57bcc03c
...
...
@@ -98,9 +98,9 @@ public class GroupServlet extends HttpServlet {
// if the username sent isn't already part of the group members, then we add it
if
(!
targetGroup
.
getGroupMembers
().
contains
(
groupMembers
))
{
// otherwise remove the group from the user's memberships.
AddUserToGroupFlow
.
addUserToGroup
(
name
,
req
.
getParameter
(
"groupMembers"
));
}
else
{
// otherwise remove the group from the user's memberships.
statementList
=
new
StatementList
();
st
=
new
StatementElement
(
"username"
,
"="
,
groupMembers
,
""
);
statementList
.
addStatement
(
st
);
...
...
@@ -169,10 +169,37 @@ public class GroupServlet extends HttpServlet {
if
(
dataStore
.
getGroupDao
().
deleteObject
(
constraint
))
{
// if deletion was successful, cascade the deletion onto the users
List
<
UserProfile
>
validProfiles
=
dataStore
.
getUserProfileDao
().
getObjects
(
null
).
stream
().
filter
(
profile
->
profile
.
getGroupMemberships
().
remove
(
Long
.
parseLong
(
req
.
getParameter
(
"groupName"
)))).
collect
(
Collectors
.
toList
());
profile
.
getGroupMemberships
().
remove
(
req
.
getParameter
(
"groupName"
))).
collect
(
Collectors
.
toList
());
validProfiles
.
parallelStream
().
forEach
(
profile
->
{
StatementList
statementList
=
new
StatementList
();
StatementElement
st
=
new
StatementElement
(
"username"
,
"="
,
profile
.
getUsername
(),
""
);
statementList
.
addStatement
(
st
);
UserGroupMapping
mapping
=
dataStore
.
getUserGroupMappingsDao
().
getObjects
(
statementList
).
get
(
0
);
mapping
.
removeGroup
(
req
.
getParameter
(
"groupName"
));
StatementList
update
=
new
StatementList
();
StatementElement
st0
=
new
StatementElement
(
"groups"
,
"="
,
mapping
.
getGroups
(),
""
);
update
.
addStatement
(
st0
);
StatementList
constraint2
=
new
StatementList
();
StatementElement
st1
=
new
StatementElement
(
"username"
,
"="
,
mapping
.
getUsername
(),
""
);
constraint2
.
addStatement
(
st1
);
// update user mappings
dataStore
.
getUserGroupMappingsDao
().
updateObject
(
update
,
constraint2
);
// then update the profile itself
dataStore
.
updateUserProfile
(
profile
);
});
validProfiles
.
forEach
(
profile
->
dataStore
.
updateUserProfile
(
profile
));
resp
.
setStatus
(
200
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment