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;
}
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;
}
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;
}
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());
}
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;
}
Aggregations