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;
}