Incentive for a user search method

Hi Folk,

I am proposing an incentive (USD 50) for implementation of a method for retrieving users from a Wildfire server using the Smack library. Let me know if you need further information. The first one to post a working solution will receive the incentive via Paypal. Hope this does not go against the spirit of the forum.

Regards,

Klaus.

Hi,

may one use the Wildfire search service and do a lame search ‘’*’’?

May one extend the xmpp protocoll and write a Wildfire plugin to do this without search?

LG

Hi,

On client side only Smack should be used (i.e. no extra library). If necessary you are free to use raw XMPP packets to extend the protocol. On the server side, Wildfilre and any other plugin that seems reasonable can be used.

Here is what I thought Smack could be used for this purpose. Obviously it does not work. So you also wellcome to just fix this:

ReportedData getUserAccounts(Map attributes){

UserSearchManager search = new UserSearchManager(getXMPPConnection());

Form searchForm=null;

Form answerForm =null;

try {

searchForm = search.getSearchForm(“search.”+getXMPPConnection().getServiceName());

answerForm = searchForm.createAnswerForm();

Iterator it=attributes.keySet().iterator();

while(it.hasNext()){

String next=(String)it.next();

String value=(String)attributes.get(next);

answerForm.setAnswer(next, value);

}

return search.getSearchResults(answerForm,“search.”+getXMPPConnection().getServiceName ());

} catch (Exception e) {

log.debug(e,e);

}

return null;

}

Regards,

Klaus.

Hi,

try it with this code. I did enable DEBUG as I did not write any code to parse the result so one needs the debug window to check that all users are retrieved.

( Surround your code with like " your code " to display it as code. )

LG

import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smackx.Form;
import org.jivesoftware.smackx.search.UserSearchManager; public class SmackSearch
{
     public static final String SERVER="jabber-server.example.com";
     public static void main(String args[]) throws Exception
     {
           SmackSearch ss = new SmackSearch();
           ss.start();
     };
     private void start() throws Exception
     {
          XMPPConnection.DEBUG_ENABLED=true;
          XMPPConnection con = new XMPPConnection(SERVER);
          XMPPConnection.DEBUG_ENABLED=true;
         con.login("test", "test");
         UserSearchManager search = new UserSearchManager(con);
         Form searchForm = search.getSearchForm("search."+ SERVER);
         Form answerForm = searchForm.createAnswerForm();
         answerForm.setAnswer("Username", true);
         answerForm.setAnswer("search", "*");
         search.getSearchResults(answerForm, "search."+ SERVER);              };
};

Thanks this solves my problem! Few additional questions if your permit:

  1. I could only search the fields “Username” and “Email”. Where can I find a more accurate list of thinks I can search for?

  2. How do I search many fields simultaneously?

  3. How do I extend Widlfire to allow searching on none standard fields?

  4. Can I specify the max number of rows to be returned by the server?

Thanks so much.

LG.

Klaus.

Hi,

(1) as you may have seen in the debug window you can - using Wildfire - search for Username, Name and Email. I didn’'t evalute the list and just specified Username, this may fail for other servers.

(3) Wildfire stores the vcard as a CLOB or VARCHAR as it is and does as far as I know not extract some fields into seperate columns with indexes so one can not easy search for the fields. I did not look at the search source code but I bet that the jiveUser table is accessed and not the vcard. upd: checked, it is the jiveUser table So one could either read all vcards and sort them manually or write a plugin which intercepts all vcard updates and adds relevant fields to a table with indexes. And then one may modify the Wildifre search engine to query the new table and not jiveUser.

upd: (2) + (4)

(2) According to http://www.jabber.org/jeps/jep-0055.html it is possible. It seems to be impossible to do this using this code and to be honest if one can just search for three things it would be nearly useless to search for more than one value.

Anyhow you can set true for Email to match also the email address using the same value, but this makes little sense.

(4) no, there’'s no option to limit the result set

LG

Hi Klaus,

I did ask Gato in the Wednesday Live Chat for a more complex search method. Currently this is not possible and there are yet no plans to do this. It should not be a very big issue to add new columns to the VCard table and extract some VCard fields into the columns I did name dyn*.

So the jivevcard table could like this (while here are also some other new tables displayed which would require a very huge database schema change, maybe for Wildfire 5.0 using foreign keys):

LG