@RequestMapping(value = "/user/currentUserList.do", method = RequestMethod.GET)
public ModelAndView list(HttpSession session, HttpServletRequest request) throws Exception {
User user = (User) getUser();
ZeroView view = new ZeroView(getMessages(), request.getLocale());
logFunction("user-current-list");
log.debug("currentUserList");
if (user.checkAuthorisation(UserModule.AUTH_CURRENT_USERS)) {
List<UserSession> userList = new ArrayList();
for (Object obj : sessionRegistry.getAllPrincipals()) {
log.debug(obj.getClass().getName() + " " + obj.toString());
if (obj instanceof String) {
for (SessionInformation si : sessionRegistry.getAllSessions((String) obj, false)) {
userList.add(new UserSession(userDao.getUser((String) obj), si));
}
}
}
log.debug(userList.size());
view.addWidget(new SimpleWidget(ZeroView.DIV_CONTENT, "user_current_users"));
HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("CURRENTUSERLIST");
if (userListComponent == null) {
DefaultTableModelColumn usernameColumn = new DefaultTableModelColumn("base.user.table.username", "user.username");
usernameColumn.setStyleClass("emphasize");
/* usernameColumn.addClickListener(new TableClickListener() {
public void fireClicked(TableClickEvent event) {
log.debug("fireClicked: " + event.getWidget().getModel().getData(event.getColumn(), event.getRow()));
}
});*/
DefaultTableModel<UserSession> model = new DefaultTableModel<UserSession>(userList, getMessages(), request.getLocale());
model.setSelectable(true);
model.addColumn(usernameColumn);
model.addColumn(new DefaultTableModelColumn("base.user.table.firstname", "user.person.firstname"));
model.addColumn(new DefaultTableModelColumn("base.user.table.lastname", "user.person.lastname"));
model.addColumn(new DefaultTableModelColumn("base.user.table.email", "user.person.email"));
model.addColumn(new DefaultTableModelColumn("base.user.table.phone", "user.person.phone"));
model.addColumn(new DefaultTableModelColumn("base.user.label.usergroupkey", "user.userGroup.groupKey"));
model.addColumn(new DefaultTableModelColumn("base.user.label.usergroupkey", "session.lastRequest"));
model.setSort(1);
userListComponent = new HtmlTableWidget("CURRENTUSERLIST", model, request.getLocale());
getWidgetManager(session).register(userListComponent);
} else {
((DefaultTableModel<UserSession>) userListComponent.getModel()).setCollection(userList);
}
view.addWidget(userListComponent);
}
return new ModelAndView(view, null);
}