mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-21 13:52:06 +01:00
[pubsub] FormNode(Provider) should not fail if there is no DataForm
Error IQ respones may not contain a data form, e.g. <iq type="error" id="6LXNC-48" from="pubsub.openfire.xmpp.test" to="anno@openfire.xmpp.test/5dsi4g084a"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <configure node="fdp/submitted/spot_report"/> </pubsub> <error code="403" type="auth"> <forbidden xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/> </error> </iq> Also FormNode's toXML() already handled the case where submitForm was 'null'. Only the constructor threw a IAE if submitForm was 'null'. Fixes SMACK-910. Closes: https://github.com/igniterealtime/Smack/pull/471
This commit is contained in:
parent
f39e433121
commit
0d73c21945
2 changed files with 7 additions and 9 deletions
|
@ -38,11 +38,7 @@ public class FormNode extends NodeExtension {
|
||||||
* @param submitForm The form
|
* @param submitForm The form
|
||||||
*/
|
*/
|
||||||
public FormNode(FormNodeType formType, DataForm submitForm) {
|
public FormNode(FormNodeType formType, DataForm submitForm) {
|
||||||
super(formType.getNodeElement());
|
this(formType, null, submitForm);
|
||||||
|
|
||||||
if (submitForm == null)
|
|
||||||
throw new IllegalArgumentException("Submit form cannot be null");
|
|
||||||
configForm = submitForm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,9 +51,6 @@ public class FormNode extends NodeExtension {
|
||||||
*/
|
*/
|
||||||
public FormNode(FormNodeType formType, String nodeId, DataForm submitForm) {
|
public FormNode(FormNodeType formType, String nodeId, DataForm submitForm) {
|
||||||
super(formType.getNodeElement(), nodeId);
|
super(formType.getNodeElement(), nodeId);
|
||||||
|
|
||||||
if (submitForm == null)
|
|
||||||
throw new IllegalArgumentException("Submit form cannot be null");
|
|
||||||
configForm = submitForm;
|
configForm = submitForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,11 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||||
public class FormNodeProvider extends EmbeddedExtensionProvider<FormNode> {
|
public class FormNodeProvider extends EmbeddedExtensionProvider<FormNode> {
|
||||||
@Override
|
@Override
|
||||||
protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) {
|
protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) {
|
||||||
return new FormNode(FormNodeType.valueOfFromElementName(currentElement, currentNamespace), attributeMap.get("node"), (DataForm) content.iterator().next());
|
DataForm dataForm = null;
|
||||||
|
if (!content.isEmpty()) {
|
||||||
|
dataForm = (DataForm) content.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new FormNode(FormNodeType.valueOfFromElementName(currentElement, currentNamespace), attributeMap.get("node"), dataForm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue