aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketGenerator.java
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-08-22 08:55:37 +0200
committersteckbrief <steckbrief@chefmail.de>2016-08-22 08:55:37 +0200
commit77d0c1110a8ae7a980f1c4420d719af803990da8 (patch)
tree20d3ce434f3c6d740141727d4c143ea5f027a646 /src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketGenerator.java
parent97100834a5bcb08f2fdf2eb6c580d3ceeb8b6b2f (diff)
parentf45ad10b1baaf09fd4a40d6b63d1cd093623eedc (diff)
Merge remote-tracking branch 'remotes/origin/filetransfer'
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketGenerator.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketGenerator.java46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketGenerator.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketGenerator.java
index 1eb44b5e..a93c37aa 100644
--- a/src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketGenerator.java
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/pubsub/PubSubPacketGenerator.java
@@ -4,10 +4,32 @@ import de.thedevstack.conversationsplus.xml.Element;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket;
/**
- * Created by tzur on 15.01.2016.
+ * Generates the IQ packets for Pubsub Subscription as defined in XEP-0060.
+ * @see <a href="http://xmpp.org/extensions/xep-0060.html">http://xmpp.org/extensions/xep-0060.html</a>
*/
public final class PubSubPacketGenerator {
+ /**
+ * Generates a pubsub publish packet.
+ * The attributes from and id are not set in here - this is added while sending the packet.
+ * <pre>
+ * <iq type='set'
+ * from='hamlet@denmark.lit/blogbot'
+ * to='pubsub.shakespeare.lit'
+ * id='publish1'>
+ * <pubsub xmlns='http://jabber.org/protocol/pubsub'>
+ * <publish node='princely_musings'>
+ * <item id='bnd81g37d61f49fgn581'>
+ * ...
+ * </item>
+ * </publish>
+ * </pubsub>
+ * </iq>
+ * </pre>
+ * @param nodeName the name of the publish node
+ * @param item the item element
+ * @return the generated PubSubPacket
+ */
public static PubSubPacket generatePubSubPublishPacket(String nodeName, Element item) {
final PubSubPacket pubsub = new PubSubPacket(IqPacket.TYPE.SET);
final Element publish = pubsub.addChild("publish");
@@ -16,6 +38,25 @@ public final class PubSubPacketGenerator {
return pubsub;
}
+ /**
+ * Generates a pubsub retrieve packet.
+ * The attributes from and id are not set in here - this is added while sending the packet.
+ * <pre>
+ * <iq type='get'
+ * from='romeo@montague.lit/home'
+ * to='juliet@capulet.lit'
+ * id='retrieve1'>
+ * <pubsub xmlns='http://jabber.org/protocol/pubsub'>
+ * <items node='urn:xmpp:avatar:data'>
+ * <item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'/>
+ * </items>
+ * </pubsub>
+ * </iq>
+ * </pre>
+ * @param nodeName
+ * @param item
+ * @return
+ */
public static PubSubPacket generatePubSubRetrievePacket(String nodeName, Element item) {
final PubSubPacket pubsub = new PubSubPacket(IqPacket.TYPE.GET);
final Element items = pubsub.addChild("items");
@@ -26,6 +67,9 @@ public final class PubSubPacketGenerator {
return pubsub;
}
+ /**
+ * Utility class - avoid instantiation
+ */
private PubSubPacketGenerator() {
// Avoid instantiation
}