Skip to content

Commit

Permalink
MID-6328 fix Logged in Users error
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Aug 12, 2020
1 parent fbfd5d0 commit 78dc2a8
Showing 1 changed file with 12 additions and 3 deletions.
Expand Up @@ -8,9 +8,9 @@
package com.evolveum.midpoint.model.impl.security;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.ws.rs.core.Response;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -64,8 +64,17 @@ public List<UserSessionManagementType> getLoggedInPrincipals(Task task, Operatio

List<UserSessionManagementType> loggedUsers = guiProfiledPrincipalManager.getLocalLoggedInPrincipals();

Map<String, UserSessionManagementType> usersMap = loggedUsers.stream()
.collect(Collectors.toMap(key -> key.getFocus().getOid(), value -> value));
Map<String, UserSessionManagementType> usersMap = new HashMap<>();
//fix for mid-6328
loggedUsers.forEach(loggedUser -> {
UserSessionManagementType addedUser = usersMap.get(loggedUser.getFocus().getOid());
if (addedUser != null) {
addedUser.setActiveSessions(addedUser.getActiveSessions() + loggedUser.getActiveSessions());
addedUser.getNode().addAll(loggedUser.getNode());
} else {
usersMap.put(loggedUser.getFocus().getOid(), loggedUser);
}
});

// We try to invoke this call also on nodes that are in transition. We want to get
// information as complete as realistically possible.
Expand Down

0 comments on commit 78dc2a8

Please sign in to comment.