// Not null, and not addressed to itself
if (to != null && !to.getBareJID().equals(sessionContext.getInitiatingEntity().getBareJID())) {
return ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.BAD_FORMAT, null, "can only view your data", null);
}
XMLElement queryElement = stanza.getFirstInnerElement();
XMLElement x = queryElement.getFirstInnerElement();
if (x == null) {
return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.NOT_ACCEPTABLE, stanza, StanzaErrorType.MODIFY, "query's child element missing", null, null);
}
// No persistancy Manager
if (persistenceManager == null) {
return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.INTERNAL_SERVER_ERROR, stanza, StanzaErrorType.WAIT, "internal storage inaccessible", null, null);
}
String queryKey = getKey(x);
String privateDataXML = persistenceManager.getPrivateData(from, queryKey);
StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(stanza.getTo(), stanza.getFrom(), IQStanzaType.RESULT, stanza.getID());
if (privateDataXML == null) {
stanzaBuilder.startInnerElement(x.getName());
for (Attribute a : x.getAttributes()) {
stanzaBuilder.addAttribute(a);
}
stanzaBuilder.endInnerElement();
} else {
stanzaBuilder.addText(privateDataXML);