Commit 0b7353ac authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Anonymous sessions appear now first than non-anonymous sessions in the session summary page.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8729 b35dd754-fafc-0310-a699-88a17e54d16e
parent 645e23d7
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
package org.jivesoftware.openfire; package org.jivesoftware.openfire;
import org.jivesoftware.openfire.session.Session; import org.jivesoftware.openfire.session.ClientSession;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
...@@ -196,7 +196,7 @@ public class SessionResultFilter { ...@@ -196,7 +196,7 @@ public class SessionResultFilter {
* *
* @return a comparator that sorts Sessions matching the sort order for this filter. * @return a comparator that sorts Sessions matching the sort order for this filter.
*/ */
public Comparator<Session> getSortComparator() { public Comparator<ClientSession> getSortComparator() {
return new SessionComparator(); return new SessionComparator();
} }
...@@ -205,11 +205,9 @@ public class SessionResultFilter { ...@@ -205,11 +205,9 @@ public class SessionResultFilter {
* *
* @author Iain Shigeoka * @author Iain Shigeoka
*/ */
private class SessionComparator implements Comparator { private class SessionComparator implements Comparator<ClientSession> {
public int compare(Object o1, Object o2) { public int compare(ClientSession lhs, ClientSession rhs) {
Session lhs = (Session)o1;
Session rhs = (Session)o2;
int comparison; int comparison;
switch (sortField) { switch (sortField) {
case SessionResultFilter.SORT_CREATION_DATE: case SessionResultFilter.SORT_CREATION_DATE:
...@@ -226,8 +224,9 @@ public class SessionResultFilter { ...@@ -226,8 +224,9 @@ public class SessionResultFilter {
break; break;
case SessionResultFilter.SORT_USER: case SessionResultFilter.SORT_USER:
// sort first by name, then by resource // sort first by name, then by resource
comparison = compareString(lhs.getAddress().getNode(), String lUsername = lhs.isAnonymousUser() ? "" : lhs.getAddress().getNode();
rhs.getAddress().getNode()); String rUsername = rhs.isAnonymousUser() ? "" : rhs.getAddress().getNode();
comparison = compareString(lUsername, rUsername);
if (comparison == 0) { if (comparison == 0) {
comparison = compareString(lhs.getAddress().getResource(), comparison = compareString(lhs.getAddress().getResource(),
rhs.getAddress().getResource()); rhs.getAddress().getResource());
......
...@@ -64,6 +64,15 @@ public interface ClientSession extends Session { ...@@ -64,6 +64,15 @@ public interface ClientSession extends Session {
*/ */
public String getUsername() throws UserNotFoundException; public String getUsername() throws UserNotFoundException;
/**
* Returns true if the authetnicated user is an anonymous user or if
* the use has not authenticated yet.
*
* @return true if the authetnicated user is an anonymous user or if
* the use has not authenticated yet.
*/
boolean isAnonymousUser();
/** /**
* Flag indicating if this session has been initialized once coming * Flag indicating if this session has been initialized once coming
* online. Session initialization occurs after the session receives * online. Session initialization occurs after the session receives
......
...@@ -536,6 +536,10 @@ public class LocalClientSession extends LocalSession implements ClientSession { ...@@ -536,6 +536,10 @@ public class LocalClientSession extends LocalSession implements ClientSession {
return authToken; return authToken;
} }
public boolean isAnonymousUser() {
return authToken == null || authToken.isAnonymous();
}
/** /**
* Flag indicating if this session has been initialized once coming * Flag indicating if this session has been initialized once coming
* online. Session initialization occurs after the session receives * online. Session initialization occurs after the session receives
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment