Custom Query On Open Fire via Smack

Hello,

I need some implementation ideas for this usecase.

I have a smack based client and the client wants to query for some information that’s available in ofmucconversationlog and ofmucroom tables in openfire.

To be specific , I want to do something like this:

select r.roomID, r.name, l.logTime from ofmucroom as r join ofmucconversationlog as l on r.roomID=l.roomID

where r.publicRoom = “1” order by logTime desc;

What is the easiest way to achieve this?

Hello,

I tried gathering information from questions that have already been raised on this topic. Now, I’m having an issue with IQ not getting processed. I get an “XMPPError: remote-server-not-found - cancel” response.

Let me walk through the setup""

In the client, I have created a customIQ, customIQProvider and a sender client as shown below:

In the server end, I have created a plugin to initialize a customIQHandler and add it to IQRouter.

Packets:

Sent

Received:

Any help will be greatly appreciated.

Client:

CustomIQ

public class CustomIQ extends IQ{

String token ;
public CustomIQ(String token){

super(“query”, “custom:iq:trendingpoolrequest”);
//this.token = token;
}

@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {

xml.append(">");
return xml;
}

}

CustomIQProvider

public class CustomIQProvider extends IQProvider {

private CustomIQ myIQ;
public CustomIQProvider(CustomIQ myIQ)

{

this.myIQ = myIQ;
}

@Override
public CustomIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {

return myIQ;
}

}

Client Code

CustomIQ myIQ = new CustomIQ(“trendingpoolrequest”);
myIQ. setType(IQ.Type.get); //or use instead SET
String jid = “user2”;
myIQ.setTo(jid);

CustomIQProvider provider = new CustomIQProvider(myIQ); //This will create a customIQ again. Possib

ProviderManager.addIQProvider( “query”,“myxmlns”,provider);

connection.sendStanza(myIQ);

CustomIQHandler

public class TrendingPoolRequestHandler extends IQHandler {

private IQHandlerInfo info;

public TrendingPoolRequestHandler(String moduleName) {

super(moduleName);

info= new IQHandlerInfo(“query”,“custom:iq:trendingpoolrequest”);

}

@Override

public IQ handleIQ(IQ packet) throws UnauthorizedException {

IQ result = IQ.createResultIQ(packet);

IQ.Type type = packet.getType();

if (type.equals(IQ.Type.get)) {

result.setChildElement(“query”, “custom:iq:trendingpoolrequest”);

}

else if(type.equals(IQ.Type.set))

{

result.setChildElement(“query”, “custom:iq:trendingpoolrequest”);

}

else{

result.setChildElement(packet.getChildElement().createCopy());

result.setError(PacketError.Condition.not_acceptable);

}

return result;

}

@Override

public IQHandlerInfo getInfo() {

// TODO Auto-generated method stub

return info;

}

}

Plugin

public class TrendingPoolPlugin implements Plugin {

private IQHandler trendingPoolRequestHandler;

public void initializePlugin(PluginManager manager, File pluginDirectory) {

trendingPoolRequestHandler = new TrendingPoolRequestHandler(“TrendingPoolRequestHandler”);

IQRouter iqRouter = XMPPServer.getInstance().getIQRouter();

iqRouter.addHandler(trendingPoolRequestHandler);

}

public void destroyPlugin() {

trendingPoolRequestHandler = null;

}

}

how to receive IQ?

in client part