use of com.haulmont.cuba.security.entity.UserSessionEntity in project cuba by cuba-platform.
the class UserSessions method createUserSessionEntity.
protected UserSessionEntity createUserSessionEntity(UserSession session, long since, long lastUsedTs) {
UserSessionEntity use = metadata.create(UserSessionEntity.class);
use.setId(session.getId());
use.setLogin(session.getUser().getLoginLowerCase());
use.setUserName(session.getUser().getName());
use.setAddress(session.getAddress());
use.setClientInfo(session.getClientInfo());
use.setSince(new Date(since));
use.setLastUsedTs(new Date(lastUsedTs));
use.setSystem(session.isSystem());
return use;
}
use of com.haulmont.cuba.security.entity.UserSessionEntity in project cuba by cuba-platform.
the class SessionMessageWindow method send.
public void send() {
String text = messageField.getValue();
Set<UserSessionEntity> sessions = TO_ALL.equals(whomOptionsGroup.getValue()) ? allSessions : selectedSessions;
if (!sessions.isEmpty() && !StringUtils.isBlank(text)) {
List<UUID> sessionIds = new ArrayList<>(sessions.size());
for (UserSessionEntity session : sessions) {
sessionIds.add(session.getId());
}
uss.postMessage(sessionIds, text);
result = messages.formatMessage(getClass(), "messageWindow.report", sessions.size());
}
close();
}
use of com.haulmont.cuba.security.entity.UserSessionEntity in project cuba by cuba-platform.
the class UserSessionsDatasource method loadData.
@Override
protected void loadData(Map<String, Object> params) {
TimeSource timeSource = AppBeans.get(TimeSource.NAME);
updateTs = timeSource.currentTimestamp();
data.clear();
if (!AppBeans.get(Security.class).isEntityOpPermitted(UserSessionEntity.class, EntityOp.READ))
return;
UserSessionService uss = AppBeans.get(UserSessionService.NAME);
Collection<UserSessionEntity> userSessionList = uss.loadUserSessionEntities(createFilter(params));
for (UserSessionEntity entity : userSessionList) {
if (!sessionFilter.test(entity)) {
continue;
}
data.put(entity.getId(), entity);
}
}
Aggregations