Ad-Hoc Commands: 'type' attribute is optional

Fixes SMACK-741
This commit is contained in:
Florian Schmaus 2016-11-23 17:55:16 +01:00
parent 1b1e88c4c3
commit d6ebb884e7
1 changed files with 8 additions and 2 deletions

View File

@ -95,8 +95,14 @@ public class AdHocCommandDataProvider extends IQProvider<AdHocCommandData> {
adHocCommandData.setForm(dataFormProvider.parse(parser)); adHocCommandData.setForm(dataFormProvider.parse(parser));
} }
else if (parser.getName().equals("note")) { else if (parser.getName().equals("note")) {
AdHocCommandNote.Type type = AdHocCommandNote.Type.valueOf( String typeString = parser.getAttributeValue("", "type");
parser.getAttributeValue("", "type")); AdHocCommandNote.Type type;
if (typeString != null) {
type = AdHocCommandNote.Type.valueOf(typeString);
} else {
// Type is optional and 'info' if not present.
type = AdHocCommandNote.Type.info;
}
String value = parser.nextText(); String value = parser.nextText();
adHocCommandData.addNote(new AdHocCommandNote(type, value)); adHocCommandData.addNote(new AdHocCommandNote(type, value));
} }