use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.UserSessionManagementListType in project midpoint by Evolveum.
the class ClusterwideUserSessionManagerImpl method getLoggedInPrincipals.
@Override
@NotNull
public List<UserSessionManagementType> getLoggedInPrincipals(Task task, OperationResult result) {
List<UserSessionManagementType> loggedUsers = guiProfiledPrincipalManager.getLocalLoggedInPrincipals();
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.
clusterExecutionHelper.execute((client, node, result1) -> {
client.path(ClusterServiceConsts.EVENT_LIST_USER_SESSION);
Response response = client.get();
LOGGER.debug("Remote-node retrieval of user sessions finished on {} with status {}, {}", node.getNodeIdentifier(), response.getStatusInfo().getStatusCode(), response.getStatusInfo().getReasonPhrase());
if (response.hasEntity()) {
UserSessionManagementListType remoteSessionsWrapper = response.readEntity(UserSessionManagementListType.class);
List<UserSessionManagementType> remoteSessions = remoteSessionsWrapper.getSession();
for (UserSessionManagementType remoteSession : MiscUtil.emptyIfNull(remoteSessions)) {
UserSessionManagementType existingUser = usersMap.get(remoteSession.getFocus().getOid());
if (existingUser != null) {
existingUser.setActiveSessions(existingUser.getActiveSessions() + remoteSession.getActiveSessions());
existingUser.getNode().addAll(remoteSession.getNode());
} else {
usersMap.put(remoteSession.getFocus().getOid(), remoteSession);
}
}
}
response.close();
}, new ClusterExecutionOptions().tryNodesInTransition(), " list principals from remote nodes ", result);
return new ArrayList<>(usersMap.values());
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.UserSessionManagementListType in project midpoint by Evolveum.
the class ClusterRestController method listUserSession.
@GetMapping(ClusterServiceConsts.EVENT_LIST_USER_SESSION)
public ResponseEntity<?> listUserSession() {
Task task = initRequest();
OperationResult result = createSubresult(task, OPERATION_GET_LOCAL_SCHEDULER_INFORMATION);
ResponseEntity<?> response;
try {
checkNodeAuthentication();
List<UserSessionManagementType> principals = focusProfileService.getLocalLoggedInPrincipals();
UserSessionManagementListType list = new UserSessionManagementListType();
list.getSession().addAll(principals);
response = createResponse(HttpStatus.OK, list, result);
} catch (Throwable t) {
response = handleException(result, t);
}
result.computeStatus();
finishRequest(task, result);
return response;
}
Aggregations