for (Iterator<Item> iter = sessions.iterator(); iter.hasNext();) {
IMSessionItems.Item item = iter.next();
if (item.getResource().startsWith(IMConfig.RESOURCE)) {
ConnectedUsersListEntry entry = (ConnectedUsersListEntry)sessionItemsCache.get(item.getUsername());
if (entry != null && !item.getUsername().equals(currentUsername)) {
entries.add(entry);
if (log.isDebug()) log.debug("loading item from cache: "+item.getUsername());
} else {
Identity identity = ManagerFactory.getManager().findIdentityByName(item.getUsername());
if (identity != null) {
identity = (Identity) DBFactory.getInstance().loadObject(identity);
try {
ImPrefsManager ipm = ImPrefsManager.getInstance();
ImPreferences imPrefs = ipm.loadOrCreatePropertiesFor(identity);
if ( (imPrefs != null) ) {
entry = new ConnectedUsersListEntry(item.getUsername(), identity.getUser().getPreferences().getLanguage());
entry.setName(identity.getUser().getProperty(UserConstants.LASTNAME, null));
entry.setPrename(identity.getUser().getProperty(UserConstants.FIRSTNAME, null));
entry.setShowAwarenessMessage(imPrefs.isAwarenessVisible());
entry.setShowOnlineTime(imPrefs.isOnlineTimeVisible());
entry.setAwarenessMessage(item.getPresenceMsg());
entry.setInstantMessagingStatus(item.getPresenceStatus());
entry.setLastActivity(item.getLastActivity());
entry.setOnlineTime(item.getLoginTime());
entry.setJabberId(InstantMessagingModule.getAdapter().getUserJid(item.getUsername()));
entry.setVisibleToOthers(imPrefs.isVisibleToOthers());
entry.setResource(item.getResource());
entries.add(entry);
//put in cache. Sync. is done by cache
sessionItemsCache.put(item.getUsername(), entry);
}