// We fetch the relations of the target user
List<Relation> relations = RelationManager.getInstance().getRelations(sender.toBareJID(), target.toBareJID());
// Prepare the result packet
RelationDomWriter writer = new DefaultRelationDomWriter();
DOMDocument domDocument = new DOMDocument();
IQ result = IQ.createResultIQ(packet);
Element query = (Element) domDocument.appendChild(domDocument.createElementNS(NAMESPACE, NAME));
for (Relation relation : relations) {
writer.toElement(relation,query);
}
result.setChildElement((org.dom4j.Element) query);
// Return and send the result packet
return result;