Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmayworm2009-01-26 18:40:22 -0500
committermmayworm2009-01-26 18:40:22 -0500
commit15a38cfea47b79b4213c39f0a40049e039a62f87 (patch)
treeb91ba18acfddd18de3eeda9ee02622d58390757f /providers/bundles/org.eclipse.ecf.provider.xmpp
parent2ea8ba64a805fcbc75d8a59a71f974409a2546be (diff)
downloadorg.eclipse.ecf-15a38cfea47b79b4213c39f0a40049e039a62f87.tar.gz
org.eclipse.ecf-15a38cfea47b79b4213c39f0a40049e039a62f87.tar.xz
org.eclipse.ecf-15a38cfea47b79b4213c39f0a40049e039a62f87.zip
[bug:256696] adding user search API on HEAD
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.xmpp')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/Messages.java2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerPresenceHelper.java210
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/messages.properties4
3 files changed, 55 insertions, 161 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/Messages.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/Messages.java
index 86fc14c28..ceac3bc54 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/Messages.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/Messages.java
@@ -35,6 +35,7 @@ public class Messages extends NLS {
public static String XMPPContainer_UNEXPECTED_EVENT;
public static String XMPPContainer_UNEXPECTED_XMPP_MESSAGE;
public static String XMPPContainer_UNRECOGONIZED_CONTAINER_MESSAGE;
+ public static String XMPPContainer_UNRECOGONIZED_SEARCH_SERVICE;
public static String XMPPFileID_EXCEPTION_FILE_IDS_NOT_URLS;
public static String XMPPFileNamespace_EXCEPTION_FILEID_FILENAME_NOT_NULL;
public static String XMPPFileNamespace_EXCEPTION_FILEID_TARGETID_NOT_NULL;
@@ -50,6 +51,7 @@ public class Messages extends NLS {
public static String XMPPRoomNamespace_EXCEPTION_ID_CREAT;
public static String XMPPRoomNamespace_EXCEPTION_INVALID_ARGUMENTS;
public static String XMPPSNamespace_EXCEPTION_ID_CREATE;
+ public static String XMPPUserSearchManager_JOB;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerPresenceHelper.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerPresenceHelper.java
index ecc2760e5..b335391d6 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerPresenceHelper.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerPresenceHelper.java
@@ -437,7 +437,8 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
final IRosterEntry entry = createRosterEntry(newID, item);
if (itemType == RosterPacket.ItemType.NONE
|| itemType == RosterPacket.ItemType.REMOVE) {
- removeFromRoster(createIDFromName(item.getUser()));
+ removeItemFromRoster(roster.getItems(),
+ createIDFromName(item.getUser()));
remove = true;
} else {
remove = false;
@@ -459,24 +460,21 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
rosterManager.notifyRosterAdd(entry);
}
- private void removeFromRoster(XMPPID itemIDToRemove) {
+ private void removeItemFromRoster(Collection rosterItems,
+ XMPPID itemIDToRemove) {
boolean removed = false;
- Collection rosterItems = roster.getItems();
synchronized (rosterItems) {
for (final Iterator i = rosterItems.iterator(); i.hasNext();) {
final IRosterItem item = (IRosterItem) i.next();
if (item instanceof org.eclipse.ecf.presence.roster.RosterGroup) {
final org.eclipse.ecf.presence.roster.RosterGroup group = (org.eclipse.ecf.presence.roster.RosterGroup) item;
- boolean r = removeItemFromRosterGroup(group, itemIDToRemove);
- if (r)
- removed = true;
+ removed = removeItemFromRosterGroup(group, itemIDToRemove);
// If group is empty, remove it too
if (group.getEntries().size() == 0)
i.remove();
} else if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
- org.eclipse.ecf.presence.roster.RosterEntry entry = (org.eclipse.ecf.presence.roster.RosterEntry) item;
- XMPPID entryID = (XMPPID) entry.getUser().getID();
- if (entryID.equals(itemIDToRemove)) {
+ if (((org.eclipse.ecf.presence.roster.RosterEntry) item)
+ .getUser().getID().equals(itemIDToRemove)) {
i.remove();
removed = true;
}
@@ -496,8 +494,7 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
for (final Iterator i = group.getEntries().iterator(); i.hasNext();) {
final org.eclipse.ecf.presence.roster.RosterEntry entry = (org.eclipse.ecf.presence.roster.RosterEntry) i
.next();
- XMPPID entryID = (XMPPID) entry.getUser().getID();
- if (entryID.equals(itemIDToRemove)) {
+ if (entry.getUser().getID().equals(itemIDToRemove)) {
i.remove();
return true;
}
@@ -570,200 +567,93 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
private void updatePresence(XMPPID fromID, IPresence newPresence) {
final Collection rosterItems = roster.getItems();
- AdditionalClient newEntry = null;
+ List newEntrys = new ArrayList();
synchronized (rosterItems) {
for (final Iterator i = roster.getItems().iterator(); i.hasNext();) {
final IRosterItem item = (IRosterItem) i.next();
if (item instanceof IRosterGroup) {
- AdditionalClient newClient = updatePresenceInGroup(
+ AdditionalClientRosterEntry[] es = updatePresenceInGroup(
(IRosterGroup) item, fromID, newPresence);
- if (newClient != null)
- newEntry = newClient;
+ for (int j = 0; j < es.length; j++) {
+ newEntrys.add(es[j]);
+ }
} else if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
- AdditionalClient newClient = updatePresenceForMatchingEntry(
+ AdditionalClientRosterEntry entry = updatePresenceForMatchingEntry(
(org.eclipse.ecf.presence.roster.RosterEntry) item,
fromID, newPresence);
- if (newClient != null)
- newEntry = newClient;
+ if (entry != null)
+ newEntrys.add(entry);
}
}
}
- if (newEntry != null) {
- if (newEntry.add) {
- if (!rosterContainsEntry(fromID)) {
- IRosterEntry entry = new org.eclipse.ecf.presence.roster.RosterEntry(
- newEntry.parent, newEntry.user, newEntry.presence);
- rosterManager.notifyRosterUpdate(roster);
- fireSetRosterEntry(false, entry);
- }
- } else {
- // remove from roster as it's another client
- removeFromRoster(fromID);
+ AdditionalClientRosterEntry[] entrys = (AdditionalClientRosterEntry[]) newEntrys
+ .toArray(new AdditionalClientRosterEntry[] {});
+ IRosterEntry entry = null;
+ if (entrys.length > 0) {
+ for (int i = 0; i < entrys.length; i++) {
+ entry = new org.eclipse.ecf.presence.roster.RosterEntry(entrys[i].parent,entrys[i].user,entrys[i].presence);
+ //roster.addItem(entry);
}
+ rosterManager.notifyRosterUpdate(roster);
+ fireSetRosterEntry(false, entry);
}
}
- class AdditionalClient {
-
+ class AdditionalClientRosterEntry {
+
IRosterItem parent;
IUser user;
IPresence presence;
- boolean add;
-
- public AdditionalClient(IRosterItem parent, IUser user,
- IPresence presence, boolean add) {
+
+ public AdditionalClientRosterEntry(IRosterItem parent, IUser user, IPresence presence) {
this.parent = parent;
this.user = user;
this.presence = presence;
- this.add = add;
- }
-
- public AdditionalClient(IUser user) {
- this.user = user;
- this.add = false;
- }
- }
-
- private int countClientsInRosterGroup(
- org.eclipse.ecf.presence.roster.RosterGroup group, XMPPID oldID) {
- Collection groupItems = group.getEntries();
- int count = 0;
- for (final Iterator i = groupItems.iterator(); i.hasNext();) {
- final IRosterItem item = (IRosterItem) i.next();
- if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
- org.eclipse.ecf.presence.roster.RosterEntry entry = (org.eclipse.ecf.presence.roster.RosterEntry) item;
- XMPPID entryID = (XMPPID) entry.getUser().getID();
- if (entryID.getUsernameAtHost().equals(
- oldID.getUsernameAtHost()))
- count++;
- }
}
- return count;
}
-
- private int countClientsInRoster(XMPPID oldID) {
- Collection rosterItems = roster.getItems();
- int count = 0;
- synchronized (rosterItems) {
- for (final Iterator i = rosterItems.iterator(); i.hasNext();) {
- final IRosterItem item = (IRosterItem) i.next();
- if (item instanceof org.eclipse.ecf.presence.roster.RosterGroup) {
- final org.eclipse.ecf.presence.roster.RosterGroup group = (org.eclipse.ecf.presence.roster.RosterGroup) item;
- count += countClientsInRosterGroup(group, oldID);
- } else if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
- org.eclipse.ecf.presence.roster.RosterEntry entry = (org.eclipse.ecf.presence.roster.RosterEntry) item;
- XMPPID entryID = (XMPPID) entry.getUser().getID();
- if (entryID.getUsernameAtHost().equals(
- oldID.getUsernameAtHost())) {
- count++;
- }
- }
- }
- }
- return count;
- }
-
- private boolean rosterGroupContainsEntry(
- org.eclipse.ecf.presence.roster.RosterGroup group, XMPPID oldID) {
- Collection groupItems = group.getEntries();
- for (final Iterator i = groupItems.iterator(); i.hasNext();) {
- final IRosterItem item = (IRosterItem) i.next();
- if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
- org.eclipse.ecf.presence.roster.RosterEntry entry = (org.eclipse.ecf.presence.roster.RosterEntry) item;
- XMPPID entryID = (XMPPID) entry.getUser().getID();
- if (entryID.equals(oldID))
- return true;
- }
- }
- return false;
- }
-
- private boolean rosterContainsEntry(XMPPID oldID) {
- Collection rosterItems = roster.getItems();
- synchronized (rosterItems) {
- for (final Iterator i = rosterItems.iterator(); i.hasNext();) {
- final IRosterItem item = (IRosterItem) i.next();
- if (item instanceof org.eclipse.ecf.presence.roster.RosterGroup) {
- final org.eclipse.ecf.presence.roster.RosterGroup group = (org.eclipse.ecf.presence.roster.RosterGroup) item;
- if (rosterGroupContainsEntry(group, oldID))
- return true;
- } else if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
- org.eclipse.ecf.presence.roster.RosterEntry entry = (org.eclipse.ecf.presence.roster.RosterEntry) item;
- XMPPID entryID = (XMPPID) entry.getUser().getID();
- if (entryID.equals(oldID))
- return true;
- }
- }
- }
- return false;
- }
-
- private AdditionalClient removeEntryFromRoster(XMPPID oldID,
- org.eclipse.ecf.presence.roster.RosterEntry entry,
- IPresence newPresence, IUser user) {
- if (countClientsInRoster(oldID) > 1) {
- // remove this client from roster
- return new AdditionalClient(user);
- } else {
- // Last one, so we set resource to null and set presence to
- // unavailable
- oldID.setResourceName(null);
- entry.setPresence(newPresence);
- rosterManager.notifyRosterUpdate(entry);
- return null;
- }
- }
-
- private AdditionalClient updatePresenceForMatchingEntry(
+
+
+ private AdditionalClientRosterEntry updatePresenceForMatchingEntry(
org.eclipse.ecf.presence.roster.RosterEntry entry, XMPPID fromID,
IPresence newPresence) {
final IUser user = entry.getUser();
XMPPID oldID = (XMPPID) user.getID();
- if (newPresence.getType().equals(IPresence.Type.UNAVAILABLE)) {
- // This is an unavailable presence change
- if (oldID.equals(fromID))
- return removeEntryFromRoster(oldID, entry, newPresence, user);
- } else {
- // This is some other presence change
- // If the username/host part matches that means we either have to
- // update
- // the resource, or create a new client
- if (oldID.equals(fromID)) {
+ // If the username/host part matches that means we either have to update
+ // the resource, or create a new client
+ if (oldID.equals(fromID)) {
+ // set the new presence state
+ entry.setPresence(newPresence);
+ // and notify with roster update
+ rosterManager.notifyRosterUpdate(entry);
+ } else if (oldID.getUsernameAtHost().equals(fromID.getUsernameAtHost())) {
+ if (oldID.getResourceName() == null) {
+ oldID.setResourceName(fromID.getResourceName());
// set the new presence state
entry.setPresence(newPresence);
// and notify with roster update
rosterManager.notifyRosterUpdate(entry);
- } else if (oldID.getUsernameAtHost().equals(
- fromID.getUsernameAtHost())) {
- if (oldID.getResourceName() == null) {
- oldID.setResourceName(fromID.getResourceName());
- // set the new presence state
- entry.setPresence(newPresence);
- // and notify with roster update
- rosterManager.notifyRosterUpdate(entry);
- } else
- return new AdditionalClient(entry.getParent(), new User(
- fromID, user.getName()), newPresence, true);
+ } else if (fromID.getResourceName() != null && !newPresence.getType().equals(IPresence.Type.UNAVAILABLE)) {
+ return new AdditionalClientRosterEntry(entry.getParent(), new User(fromID, user.getName()), newPresence);
}
}
return null;
}
- private AdditionalClient updatePresenceInGroup(IRosterGroup group,
+ private AdditionalClientRosterEntry[] updatePresenceInGroup(IRosterGroup group,
XMPPID fromID, IPresence newPresence) {
+ List results = new ArrayList();
final Collection groupEntries = group.getEntries();
- AdditionalClient newEntry = null;
synchronized (groupEntries) {
for (final Iterator i = group.getEntries().iterator(); i.hasNext();) {
- AdditionalClient newClient = updatePresenceForMatchingEntry(
+ AdditionalClientRosterEntry newEntry = updatePresenceForMatchingEntry(
(org.eclipse.ecf.presence.roster.RosterEntry) i.next(),
fromID, newPresence);
- if (newClient != null)
- newEntry = newClient;
+ if (newEntry != null)
+ results.add(newEntry);
}
}
- return newEntry;
+ return (AdditionalClientRosterEntry[]) results.toArray(new AdditionalClientRosterEntry[] {});
}
protected void handleRoster(Roster roster) {
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/messages.properties b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/messages.properties
index 1a975121e..d288d99c1 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/messages.properties
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/messages.properties
@@ -22,7 +22,8 @@ XMPPIncomingFileTransfer_Status_Transfer_Completed_OK=Transfer Completed OK
XMPPContainer_EXCEPTION_INVALID_RESPONSE_FROM_SERVER=invalid connect response from server
XMPPIncomingFileTransfer_Status_Transfer_Exception=Transfer Exception
XMPPContainer_EXCEPTION_ADDING_SHARED_OBJECT=Exception adding shared object %1
-XMPPContainer_UNRECOGONIZED_CONTAINER_MESSAGE=got unrecognized container message...ignoring message
+XMPPContainer_UNRECOGONIZED_CONTAINER_MESSAGE=got unrecognized container message...ignoring message
+XMPPContainer_UNRECOGONIZED_SEARCH_SERVICE=Search Service not available on the server
XMPPContainer_UNEXPECTED_EVENT=processAsynch got unexpected event %1
XMPPContainer_EXCEPTION_HANDLING_ASYCH_EVENT=processAsynch exception processing event %1
XMPPFileID_EXCEPTION_FILE_IDS_NOT_URLS=XMPPFileIDs cannot be represented as URLs.
@@ -33,3 +34,4 @@ XMPPNamespace_EXCEPTION_ID_CREATE=XMPP ID creation exception
XMPPRoomNamespace_EXCEPTION_ID_CREAT=XMPP ID creation exception
XMPPRoomNamespace_EXCEPTION_INVALID_ARGUMENTS=XMPPRoomID constructor arguments invalid
XMPPSNamespace_EXCEPTION_ID_CREATE=XMPP ID creation exception
+XMPPUserSearchManager_JOB=User Search Job

Back to the top