use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.UserSessionManagementType 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.UserSessionManagementType in project midpoint by Evolveum.
the class InternalsLoggedInUsersPanel method initLayout.
private void initLayout() {
MainObjectListPanel<F> table = new MainObjectListPanel(ID_TABLE, FocusType.class, null) {
@Override
protected void objectDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
if (WebComponentUtil.hasDetailsPage(object.getClass())) {
PageParameters parameters = new PageParameters();
parameters.add(OnePageParameterEncoder.PARAMETER, object.getOid());
getPageBase().navigateToNext(WebComponentUtil.getObjectDetailsPage(object.getClass()), parameters);
}
}
@Override
protected List<IColumn<SelectableBean<F>, String>> createDefaultColumns() {
return InternalsLoggedInUsersPanel.this.initColumns();
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return initInlineMenu();
}
@Override
protected UserProfileStorage.TableId getTableId() {
return null;
}
@Override
protected ISelectableDataProvider<UserSessionManagementType, SelectableBean<F>> createProvider() {
LoadableModel<List<UserSessionManagementType>> principals = new LoadableModel<List<UserSessionManagementType>>(true) {
@Override
protected List<UserSessionManagementType> load() {
return loadLoggedInPrincipals();
}
};
return new SelectableListDataProvider<SelectableBean<F>, UserSessionManagementType>(InternalsLoggedInUsersPanel.this, principals) {
@Override
protected SelectableBean<F> createObjectWrapper(UserSessionManagementType principal) {
SelectableBeanImpl<F> user = new SelectableBeanImpl<>((F) principal.getFocus());
user.setActiveSessions(principal.getActiveSessions());
user.setNodes(principal.getNode());
return user;
}
};
}
@Override
protected boolean isCreateNewObjectEnabled() {
return false;
}
@Override
protected List<Component> createToolbarButtonsList(String buttonId) {
return new ArrayList<>();
}
@Override
protected boolean enableSavePageSize() {
return false;
}
};
add(table);
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.UserSessionManagementType in project midpoint by Evolveum.
the class GuiProfiledPrincipalManagerImpl method getLocalLoggedInPrincipals.
@Override
public List<UserSessionManagementType> getLocalLoggedInPrincipals() {
String currentNodeId = taskManager.getNodeId();
if (sessionRegistry != null) {
List<Object> loggedInUsers = sessionRegistry.getAllPrincipals();
List<UserSessionManagementType> loggedPrincipals = new ArrayList<>();
for (Object principal : loggedInUsers) {
if (!(principal instanceof GuiProfiledPrincipal)) {
continue;
}
List<SessionInformation> sessionInfos = sessionRegistry.getAllSessions(principal, false);
if (sessionInfos == null || sessionInfos.isEmpty()) {
continue;
}
GuiProfiledPrincipal midPointPrincipal = (GuiProfiledPrincipal) principal;
UserSessionManagementType userSessionManagementType = new UserSessionManagementType();
userSessionManagementType.setFocus(midPointPrincipal.getFocus());
userSessionManagementType.setActiveSessions(sessionInfos.size());
userSessionManagementType.getNode().add(currentNodeId);
loggedPrincipals.add(userSessionManagementType);
}
return loggedPrincipals;
} else {
return emptyList();
}
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.UserSessionManagementType 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