Search in sources :

Example 36 with DataForm

use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.

the class Node method getConfigurationForm.

/**
     * Returns a data form used by the owner to edit the node configuration.
     *
     * @return data form used by the owner to edit the node configuration.
     */
public DataForm getConfigurationForm() {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle(LocaleUtils.getLocalizedString("pubsub.form.conf.title"));
    List<String> params = new ArrayList<>();
    params.add(getNodeID());
    form.addInstruction(LocaleUtils.getLocalizedString("pubsub.form.conf.instruction", params));
    FormField formField = form.addField();
    formField.setVariable("FORM_TYPE");
    formField.setType(FormField.Type.hidden);
    formField.addValue("http://jabber.org/protocol/pubsub#node_config");
    // Add the form fields and configure them for edition
    addFormFields(form, true);
    return form;
}
Also used : DataForm(org.xmpp.forms.DataForm) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) FormField(org.xmpp.forms.FormField)

Example 37 with DataForm

use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.

the class Node method getMetadataForm.

/**
     * Returns a data form containing the node configuration that is going to be used for
     * service discovery.
     *
     * @return a data form with the node configuration.
     */
public DataForm getMetadataForm() {
    DataForm form = new DataForm(DataForm.Type.result);
    FormField formField = form.addField();
    formField.setVariable("FORM_TYPE");
    formField.setType(FormField.Type.hidden);
    formField.addValue("http://jabber.org/protocol/pubsub#meta-data");
    // Add the form fields
    addFormFields(form, true);
    return form;
}
Also used : DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 38 with DataForm

use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.

the class NodeSubscription method getConfigurationForm.

/**
     * Returns a data form with the subscription configuration. The data form can be used to
     * edit the subscription configuration.
     *
     * @return data form used by the subscriber to edit the subscription configuration.
     */
public DataForm getConfigurationForm() {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle(LocaleUtils.getLocalizedString("pubsub.form.subscription.title"));
    List<String> params = new ArrayList<>();
    params.add(node.getNodeID());
    form.addInstruction(LocaleUtils.getLocalizedString("pubsub.form.subscription.instruction", params));
    // Add the form fields and configure them for edition
    FormField formField = form.addField();
    formField.setVariable("FORM_TYPE");
    formField.setType(FormField.Type.hidden);
    formField.addValue("http://jabber.org/protocol/pubsub#subscribe_options");
    formField = form.addField();
    formField.setVariable("pubsub#deliver");
    formField.setType(FormField.Type.boolean_type);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.deliver"));
    formField.addValue(deliverNotifications);
    formField = form.addField();
    formField.setVariable("pubsub#digest");
    formField.setType(FormField.Type.boolean_type);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.digest"));
    formField.addValue(usingDigest);
    formField = form.addField();
    formField.setVariable("pubsub#digest_frequency");
    formField.setType(FormField.Type.text_single);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.digest_frequency"));
    formField.addValue(digestFrequency);
    formField = form.addField();
    formField.setVariable("pubsub#expire");
    formField.setType(FormField.Type.text_single);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.expire"));
    if (expire != null) {
        formField.addValue(XMPPDateTimeFormat.format(expire));
    }
    formField = form.addField();
    formField.setVariable("pubsub#include_body");
    formField.setType(FormField.Type.boolean_type);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.include_body"));
    formField.addValue(includingBody);
    formField = form.addField();
    formField.setVariable("pubsub#show-values");
    formField.setType(FormField.Type.list_multi);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.show-values"));
    formField.addOption(null, Presence.Show.away.name());
    formField.addOption(null, Presence.Show.chat.name());
    formField.addOption(null, Presence.Show.dnd.name());
    formField.addOption(null, "online");
    formField.addOption(null, Presence.Show.xa.name());
    for (String value : presenceStates) {
        formField.addValue(value);
    }
    if (node.isCollectionNode()) {
        formField = form.addField();
        formField.setVariable("pubsub#subscription_type");
        formField.setType(FormField.Type.list_single);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.subscription_type"));
        formField.addOption(null, Type.items.name());
        formField.addOption(null, Type.nodes.name());
        formField.addValue(type);
        formField = form.addField();
        formField.setVariable("pubsub#subscription_depth");
        formField.setType(FormField.Type.list_single);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.subscription_depth"));
        formField.addOption(null, "1");
        formField.addOption(null, "all");
        formField.addValue(depth == 1 ? "1" : "all");
    }
    if (!node.isCollectionNode() || type == Type.items) {
        formField = form.addField();
        formField.setVariable("x-pubsub#keywords");
        formField.setType(FormField.Type.text_single);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.keywords"));
        if (keyword != null) {
            formField.addValue(keyword);
        }
    }
    return form;
}
Also used : DataForm(org.xmpp.forms.DataForm) ArrayList(java.util.ArrayList) FormField(org.xmpp.forms.FormField)

Example 39 with DataForm

use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.

the class PendingSubscriptionsCommand method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle(LocaleUtils.getLocalizedString("pubsub.command.pending-subscriptions.title"));
    form.addInstruction(LocaleUtils.getLocalizedString("pubsub.command.pending-subscriptions.instruction"));
    FormField formField = form.addField();
    formField.setVariable("pubsub#node");
    formField.setType(FormField.Type.list_single);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.command.pending-subscriptions.node"));
    for (Node node : service.getNodes()) {
        if (!node.isCollectionNode() && node.isAdmin(data.getOwner())) {
            formField.addOption(null, node.getNodeID());
        }
    }
    // Add the form to the command
    command.add(form.getElement());
}
Also used : DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 40 with DataForm

use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.

the class DefaultNodeConfiguration method getConfigurationForm.

public DataForm getConfigurationForm() {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle(LocaleUtils.getLocalizedString("pubsub.form.default.title"));
    form.addInstruction(LocaleUtils.getLocalizedString("pubsub.form.default.instruction"));
    // Add the form fields and configure them for edition
    FormField formField = form.addField();
    formField.setVariable("FORM_TYPE");
    formField.setType(FormField.Type.hidden);
    formField.addValue("http://jabber.org/protocol/pubsub#node_config");
    formField = form.addField();
    formField.setVariable("pubsub#subscribe");
    formField.setType(FormField.Type.boolean_type);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.subscribe"));
    formField.addValue(subscriptionEnabled);
    formField = form.addField();
    formField.setVariable("pubsub#deliver_payloads");
    formField.setType(FormField.Type.boolean_type);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.deliver_payloads"));
    formField.addValue(deliverPayloads);
    formField = form.addField();
    formField.setVariable("pubsub#notify_config");
    formField.setType(FormField.Type.boolean_type);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.notify_config"));
    formField.addValue(notifyConfigChanges);
    formField = form.addField();
    formField.setVariable("pubsub#notify_delete");
    formField.setType(FormField.Type.boolean_type);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.notify_delete"));
    formField.addValue(notifyDelete);
    formField = form.addField();
    formField.setVariable("pubsub#notify_retract");
    formField.setType(FormField.Type.boolean_type);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.notify_retract"));
    formField.addValue(notifyRetract);
    formField = form.addField();
    formField.setVariable("pubsub#presence_based_delivery");
    formField.setType(FormField.Type.boolean_type);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.presence_based"));
    formField.addValue(presenceBasedDelivery);
    if (leaf) {
        formField = form.addField();
        formField.setVariable("pubsub#send_item_subscribe");
        formField.setType(FormField.Type.boolean_type);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.send_item_subscribe"));
        formField.addValue(sendItemSubscribe);
        formField = form.addField();
        formField.setVariable("pubsub#persist_items");
        formField.setType(FormField.Type.boolean_type);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.persist_items"));
        formField.addValue(persistPublishedItems);
        formField = form.addField();
        formField.setVariable("pubsub#max_items");
        formField.setType(FormField.Type.text_single);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.max_items"));
        formField.addValue(maxPublishedItems);
        formField = form.addField();
        formField.setVariable("pubsub#max_payload_size");
        formField.setType(FormField.Type.text_single);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.max_payload_size"));
        formField.addValue(maxPayloadSize);
    }
    formField = form.addField();
    formField.setVariable("pubsub#access_model");
    formField.setType(FormField.Type.list_single);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.access_model"));
    formField.addOption(null, AccessModel.authorize.getName());
    formField.addOption(null, AccessModel.open.getName());
    formField.addOption(null, AccessModel.presence.getName());
    formField.addOption(null, AccessModel.roster.getName());
    formField.addOption(null, AccessModel.whitelist.getName());
    formField.addValue(accessModel.getName());
    formField = form.addField();
    formField.setVariable("pubsub#publish_model");
    formField.setType(FormField.Type.list_single);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.publish_model"));
    formField.addOption(null, PublisherModel.publishers.getName());
    formField.addOption(null, PublisherModel.subscribers.getName());
    formField.addOption(null, PublisherModel.open.getName());
    formField.addValue(publisherModel.getName());
    formField = form.addField();
    formField.setVariable("pubsub#language");
    formField.setType(FormField.Type.text_single);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.language"));
    formField.addValue(language);
    formField = form.addField();
    formField.setVariable("pubsub#itemreply");
    formField.setType(FormField.Type.list_single);
    formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.itemreply"));
    if (replyPolicy != null) {
        formField.addValue(replyPolicy.name());
    }
    if (!leaf) {
        formField = form.addField();
        formField.setVariable("pubsub#leaf_node_association_policy");
        formField.setType(FormField.Type.list_single);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.leaf_node_association"));
        formField.addOption(null, CollectionNode.LeafNodeAssociationPolicy.all.name());
        formField.addOption(null, CollectionNode.LeafNodeAssociationPolicy.owners.name());
        formField.addOption(null, CollectionNode.LeafNodeAssociationPolicy.whitelist.name());
        formField.addValue(associationPolicy.name());
        formField = form.addField();
        formField.setVariable("pubsub#leaf_nodes_max");
        formField.setType(FormField.Type.text_single);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.leaf_nodes_max"));
        formField.addValue(maxLeafNodes);
    }
    return form;
}
Also used : DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Aggregations

DataForm (org.xmpp.forms.DataForm)81 FormField (org.xmpp.forms.FormField)67 Element (org.dom4j.Element)23 IQ (org.xmpp.packet.IQ)12 JID (org.xmpp.packet.JID)9 ArrayList (java.util.ArrayList)7 ClientSession (org.jivesoftware.openfire.session.ClientSession)6 HashMap (java.util.HashMap)4 List (java.util.List)4 Group (org.jivesoftware.openfire.group.Group)4 Date (java.util.Date)3 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)3 MUCRoom (org.jivesoftware.openfire.muc.MUCRoom)3 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)3 XStream (com.thoughtworks.xstream.XStream)2 ParseException (java.text.ParseException)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 PacketException (org.jivesoftware.openfire.PacketException)2 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)2