Commit 8138364e authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed incorrect namespace returned in search results.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3449 b35dd754-fafc-0310-a699-88a17e54d16e
parent 6a4070d8
......@@ -44,9 +44,14 @@
Search Plugin Changelog
</h1>
<p><b>1.1.6</b> -- February 14, 2006</p>
<ul>
<li>Client Search - Fixed incorrect namespace returned in search resuslts.</li>
</ul>
<p><b>1.1.5</b> -- January 6, 2006</p>
<ul>
<li>Client Search - specific support for Miranda was replaced with a more general means to support non-dataform searches.</li>
<li>Client Search - Specific support for Miranda was replaced with a more general means to support non-dataform searches.</li>
</ul>
<p><b>1.1.4</b> -- December 15, 2005</p>
......@@ -54,53 +59,53 @@ Search Plugin Changelog
<li>Now requires Wildfire 2.4.0</li>
</ul>
<p><b>1.1.3</b> -- December 7, 2005</b></p>
<p><b>1.1.3</b> -- December 7, 2005</p>
<ul>
<li>Client Search - fixed issue where a null pointer exception could occur when a LDAP <searchFilter> is being used.
<li>Client Search - Fixed issue where a null pointer exception could occur when a LDAP <searchFilter> is being used.
</ul>
<p><b>1.1.2</b> -- June 30, 2005</b></p>
<p><b>1.1.2</b> -- June 30, 2005</p>
<ul>
<li>Admin Console - fixed possible null pointer exception when during a search.
<li>Admin Console - Fixed possible null pointer exception when during a search.
</ul>
<p><b>1.1.1</b> -- June 13, 2005</b></p>
<p><b>1.1.1</b> -- June 13, 2005</p>
<ul>
<li>Admin Console - added a fix to prevent all the checkboxes from becoming selected after a search.
<li>Admin Console - added the ability to toggle between having more or less search options.
<li>Admin Console - added a summary field that reports the number of users found after a search.
<li>Admin Console - added some additional localization for buttons and the results table header.
<li>Admin Console - Added a fix to prevent all the checkboxes from becoming selected after a search.
<li>Admin Console - Added the ability to toggle between having more or less search options.
<li>Admin Console - Added a summary field that reports the number of users found after a search.
<li>Admin Console - Added some additional localization for buttons and the results table header.
</ul>
<p><b>1.1</b> -- May 17, 2005</b></p>
<p><b>1.1</b> -- May 17, 2005</p>
<ul>
<li>Admin Console - added a page to allow the enabling/disabling of the search service and to change the service name.
<li>Admin Console - added a page to allow searching similiar to what is done on the client side.
<li>Client Search - added a hidden FORM_TYPE field per the JEP-0055 spec.
<li>Admin Console - Added a page to allow the enabling/disabling of the search service and to change the service name.
<li>Admin Console - Added a page to allow searching similiar to what is done on the client side.
<li>Client Search - Added a hidden FORM_TYPE field per the JEP-0055 spec.
<li>Some intenternal code refactoring.
</ul>
<p><b>1.0.6</b> -- April 12, 2005</b></p>
<p><b>1.0.6</b> -- April 12, 2005</p>
<ul>
<li>Client Search - changed the ui to use a single text field with multiple checkboxes to specify which fields are to be searched (thanks jfroehlich).</li>
<li>Client Search - Changed the ui to use a single text field with multiple checkboxes to specify which fields are to be searched (thanks jfroehlich).</li>
</ul>
<p><b>1.0.5</b> -- March 30, 2005</b></p>
<p><b>1.0.5</b> -- March 30, 2005</p>
<ul>
<li>Client Search - added basic support for non-data form searches to support the Miranda (thanks Baron Ng).</li>
<li>Client Search -Added basic support for non-data form searches to support the Miranda (thanks Baron Ng).</li>
</ul>
<p><b>1.0.4</b> -- March 22, 2005</b></p>
<p><b>1.0.4</b> -- March 22, 2005</p>
<ul>
<li>Client Search - added type and name attributes to the identity element when handling a disco#info query.</li>
<li>Client Search - added a check and appropriate response to a disco#items query.</li>
<li>Client Search - added a jid field when returning the search results.</li>
<li>Client Search - Added type and name attributes to the identity element when handling a disco#info query.</li>
<li>Client Search - Added a check and appropriate response to a disco#items query.</li>
<li>Client Search - Added a jid field when returning the search results.</li>
</ul>
<p><b>1.0.3</b> -- March 14, 2005</b></p>
<p><b>1.0.3</b> -- March 14, 2005</p>
<ul>
<li>Client Search - fixed incompatiblity issue with psi.</li>
<li>Client Search - fixed bug where a list of all the users in the system would be returned when using psi.</li>
<li>Client Search - Fixed incompatiblity issue with psi.</li>
<li>Client Search - Fixed bug where a list of all the users in the system would be returned when using psi.</li>
</ul>
<p><b>1.0.2</b> -- March 8, 2005</p>
......
......@@ -5,8 +5,8 @@
<name>Search</name>
<description>Provides support for Jabber Search (JEP-0055)</description>
<author>Ryan Graham</author>
<version>1.1.5</version>
<date>01/06/2006</date>
<version>1.1.6</version>
<date>02/14/2006</date>
<minServerVersion>2.4.0</minServerVersion>
<adminconsole>
......
......@@ -7,7 +7,6 @@
package org.jivesoftware.wildfire.plugin;
import org.dom4j.Attribute;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.QName;
......@@ -34,19 +33,7 @@ import org.xmpp.packet.JID;
import org.xmpp.packet.Packet;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.*;
/**
* Provides support for Jabber Search
......@@ -65,7 +52,6 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
public static final String PLUGIN_SEARCH_SERVICENAME = "plugin.search.serviceName";
public static final String PLUGIN_SEARCH_SERVICEENABLED = "plugin.search.serviceEnabled";
private XMPPServer server;
private UserManager userManager;
private ComponentManager componentManager;
private PluginManager pluginManager;
......@@ -88,8 +74,7 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
serviceName = JiveGlobals.getProperty("plugin.search.serviceName", "search");
serviceEnabled = JiveGlobals.getBooleanProperty("plugin.search.serviceEnabled", true);
server = XMPPServer.getInstance();
serverName = server.getServerInfo().getName();
serverName = XMPPServer.getInstance().getServerInfo().getName();
// See if the installed provider supports searching. If not, workaround
// by providing our own searching.
UserManager manager = UserManager.getInstance();
......@@ -185,7 +170,6 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
catch (Exception e) {
componentManager.getLog().error(e);
}
server = null;
userManager = null;
fieldLookup = null;
reverseFieldLookup = null;
......@@ -217,13 +201,12 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
try {
IQ replyPacket = IQ.createResultIQ(packet);
Element responseElement = DocumentHelper.createElement(QName.get(
"query", "http://jabber.org/protocol/disco#info"));
Element responseElement = replyPacket
.setChildElement("query", "http://jabber.org/protocol/disco#info");
responseElement.addElement("identity").addAttribute("category", "search")
.addAttribute("type", "text")
.addAttribute("name", "User Search");
responseElement.addElement("feature").addAttribute("var", "jabber:iq:search");
replyPacket.setChildElement(responseElement);
componentManager.sendPacket(this, replyPacket);
}
......@@ -234,10 +217,7 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
else if ("http://jabber.org/protocol/disco#items".equals(namespace)) {
try {
IQ replyPacket = IQ.createResultIQ(packet);
Element responseElement = DocumentHelper.createElement(QName.get(
"query", "http://jabber.org/protocol/disco#info"));
replyPacket.setChildElement(responseElement);
replyPacket.setChildElement("query", "http://jabber.org/protocol/disco#items");
componentManager.sendPacket(this, replyPacket);
}
catch (ComponentException e) {
......@@ -263,22 +243,18 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
}
private IQ replyDisabled(IQ packet) {
Element reply = DocumentHelper.createElement(QName.get("query", "jabber:iq:search"));
IQ replyPacket = IQ.createResultIQ(packet);
Element reply = replyPacket.setChildElement("query", "jabber:iq:search");
XDataFormImpl unavailableForm = new XDataFormImpl(DataForm.TYPE_CANCEL);
unavailableForm.setTitle("User Search");
unavailableForm.addInstruction("This service is unavailable.");
reply.add(unavailableForm.asXMLElement());
IQ replyPacket = IQ.createResultIQ(packet);
replyPacket.setChildElement("query", "jabber:iq:search");
replyPacket.setChildElement(reply.createCopy());
return replyPacket;
}
private IQ processGetPacket(IQ packet) {
IQ replyPacket = IQ.createResultIQ(packet);
replyPacket.setChildElement("query", "jabber:iq:search");
replyPacket.setChildElement(probeResult.createCopy());
return replyPacket;
......@@ -408,49 +384,39 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
searchResults.addItemFields(items);
}
Element reply = DocumentHelper.createElement(QName.get("query", "jabber:iq:search"));
reply.add(searchResults.asXMLElement());
IQ replyPacket = IQ.createResultIQ(packet);
replyPacket.setChildElement(reply);
Element reply = replyPacket.setChildElement("query", "jabber:iq:search");
reply.add(searchResults.asXMLElement());
return replyPacket;
}
private IQ replyNonDataFormResult(Set<User> users, IQ packet) {
Element replyQuery = DocumentHelper.createElement(QName.get("query", "jabber:iq:search"));
String serverName = XMPPServer.getInstance().getServerInfo().getName();
IQ replyPacket = IQ.createResultIQ(packet);
Element replyQuery = replyPacket.setChildElement("query", "jabber:iq:search");
for (User user : users) {
Element item = DocumentHelper.createElement("item");
Attribute jid = DocumentHelper.createAttribute(item, "jid", user.getUsername() + "@" + serverName);
item.add(jid);
Element item = replyQuery.addElement("item");
item.addAttribute("jid", user.getUsername() + "@" + serverName);
//return to the client the same fields that were submitted
for (String field : reverseFieldLookup.keySet()) {
if ("Username".equals(field)) {
Element element = DocumentHelper.createElement(reverseFieldLookup.get(field));
Element element = item.addElement(reverseFieldLookup.get(field));
element.addText(user.getUsername());
item.add(element);
}
if ("Name".equals(field)) {
Element element = DocumentHelper.createElement(reverseFieldLookup.get(field));
Element element = item.addElement(reverseFieldLookup.get(field));
element.addText(removeNull(user.getName()));
item.add(element);
}
if ("Email".equals(field)) {
Element element = DocumentHelper.createElement(reverseFieldLookup.get(field));
Element element = item.addElement(reverseFieldLookup.get(field));
element.addText(removeNull(user.getEmail()));
item.add(element);
}
}
replyQuery.add(item);
}
IQ replyPacket = IQ.createResultIQ(packet);
replyPacket.setChildElement(replyQuery);
return replyPacket;
}
......
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