Creating child nodes

Hi

Using Smack 3.2.1.

I want to create a node on a pub sub service, and then create child nodes of that node. I am trying this:

private void createNodes() {

String leafNodeName = null;

String rootNodeName = null;

ArrayList children = new ArrayList();

try {

rootNodeName = properties.getProperty(“rootNode”);

ConfigureForm form = new ConfigureForm(FormType.submit);

Iterator iterator = getPubSubNodeNames().iterator();

while (iterator.hasNext()) {

leafNodeName = iterator.next();

children.add(leafNodeName);

}

form.setChildren(children);

Node node = (Node) pubSubManager.createNode(rootNodeName, form);

When I try this:

form.setChildren(children);

I get to Form.java here:

public void setAnswer(String variable, List values) {

if (!isSubmitType()) {

throw new IllegalStateException("Cannot set an answer if the form is not of type " +

““submit””);

}

FormField field = getField(variable);

if (field != null) {

// Check that the field can accept a collection of values

if (!FormField.TYPE_JID_MULTI.equals(field.getType())

&& !FormField.TYPE_LIST_MULTI.equals(field.getType())

&& !FormField.TYPE_LIST_SINGLE.equals(field.getType())

&& !FormField.TYPE_HIDDEN.equals(field.getType())) {

throw new IllegalArgumentException(“This field only accept list of values.”);

And the IllegalArgumentException is thrown.

The debug values are:

values ArrayList (id=37)

[exampleNodeAAAAA]

field FormField (id=59)

description null

label null

options ArrayList (id=62)

required false

type “text-multi” (id=63)

values ArrayList (id=64)

variable “pubsub#children” (id=65)

I have looked through the test code for an example of what I should be doing, but I don’t see one.

Any ideas please?

Many thanks

Nathan

You may be running into a bug related to collection nodes. The pubsub API does not fully support collections. Actually, it does not specifically support collections at all, it just so happens that much of the functionality is common with leaf nodes.

Thus, you will not find any test code related to collections as this is not officially supported.

Sorry, but that is currently earmarked for a future release.

You are welcome to provide a patch for your specific issue though and post it back here.