mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 09:39:39 +02:00
Rename XMPPError to StanzaError
Fixes SMACK-769.
This commit is contained in:
parent
609f4243d9
commit
2efec89050
53 changed files with 205 additions and 208 deletions
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014 Florian Schmaus
|
||||
* Copyright © 2014-2018 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -21,8 +21,8 @@ import java.util.List;
|
|||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Nonza;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.packet.StanzaErrorTextElement;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
public class StreamManagement {
|
||||
|
@ -193,7 +193,7 @@ public class StreamManagement {
|
|||
public static class Failed implements Nonza {
|
||||
public static final String ELEMENT = "failed";
|
||||
|
||||
private final XMPPError.Condition condition;
|
||||
private final StanzaError.Condition condition;
|
||||
|
||||
private final List<StanzaErrorTextElement> textElements;
|
||||
|
||||
|
@ -202,7 +202,7 @@ public class StreamManagement {
|
|||
this(null, null);
|
||||
}
|
||||
|
||||
public Failed(XMPPError.Condition condition, List<StanzaErrorTextElement> textElements) {
|
||||
public Failed(StanzaError.Condition condition, List<StanzaErrorTextElement> textElements) {
|
||||
this.condition = condition;
|
||||
if (textElements == null) {
|
||||
this.textElements = Collections.emptyList();
|
||||
|
@ -211,7 +211,7 @@ public class StreamManagement {
|
|||
}
|
||||
}
|
||||
|
||||
public XMPPError.Condition getXMPPErrorCondition() {
|
||||
public StanzaError.Condition getXMPPErrorCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ public class StreamManagement {
|
|||
if (condition != null) {
|
||||
// TODO This should use StanzaError (formerly XMPPError) in Smack 4.3 (see SMACK-769)
|
||||
xml.append(condition.toString());
|
||||
xml.xmlnsAttribute(XMPPError.NAMESPACE);
|
||||
xml.xmlnsAttribute(StanzaError.NAMESPACE);
|
||||
}
|
||||
xml.append(textElements);
|
||||
xml.closeElement(ELEMENT);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014-2017 Florian Schmaus
|
||||
* Copyright © 2014-2018 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -21,8 +21,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.AbstractTextElement;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.packet.StanzaErrorTextElement;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.sm.packet.StreamManagement.AckAnswer;
|
||||
import org.jivesoftware.smack.sm.packet.StreamManagement.AckRequest;
|
||||
import org.jivesoftware.smack.sm.packet.StreamManagement.Enabled;
|
||||
|
@ -49,7 +49,7 @@ public class ParseStreamManagement {
|
|||
public static Failed failed(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
String name;
|
||||
XMPPError.Condition condition = null;
|
||||
StanzaError.Condition condition = null;
|
||||
List<StanzaErrorTextElement> textElements = new ArrayList<>(4);
|
||||
outerloop:
|
||||
while (true) {
|
||||
|
@ -58,14 +58,14 @@ public class ParseStreamManagement {
|
|||
case XmlPullParser.START_TAG:
|
||||
name = parser.getName();
|
||||
String namespace = parser.getNamespace();
|
||||
if (XMPPError.NAMESPACE.equals(namespace)) {
|
||||
if (StanzaError.NAMESPACE.equals(namespace)) {
|
||||
if (name.equals(AbstractTextElement.ELEMENT)) {
|
||||
String lang = ParserUtils.getXmlLang(parser);
|
||||
String text = parser.nextText();
|
||||
StanzaErrorTextElement stanzaErrorTextElement = new StanzaErrorTextElement(text, lang);
|
||||
textElements.add(stanzaErrorTextElement);
|
||||
} else {
|
||||
condition = XMPPError.Condition.fromString(name);
|
||||
condition = StanzaError.Condition.fromString(name);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2014 Vyacheslav Blinov, 2017 Florian Schmaus
|
||||
* Copyright 2014 Vyacheslav Blinov, 2017-2018 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -14,8 +14,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.jivesoftware.smack.sm.provider;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
|
@ -29,8 +27,8 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.packet.StanzaErrorTextElement;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.sm.packet.StreamManagement;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
|
@ -92,11 +90,11 @@ public class ParseStreamManagementTest {
|
|||
|
||||
@Test
|
||||
public void testParseFailedError() throws Exception {
|
||||
XMPPError.Condition errorCondition = XMPPError.Condition.unexpected_request;
|
||||
StanzaError.Condition errorCondition = StanzaError.Condition.unexpected_request;
|
||||
|
||||
String failedStanza = XMLBuilder.create("failed")
|
||||
.a("xmlns", "urn:xmpp:sm:3")
|
||||
.element(errorCondition.toString(), XMPPError.NAMESPACE)
|
||||
.element(errorCondition.toString(), StanzaError.NAMESPACE)
|
||||
.asString(outputProperties);
|
||||
|
||||
StreamManagement.Failed failedPacket = ParseStreamManagement.failed(
|
||||
|
@ -120,7 +118,7 @@ public class ParseStreamManagementTest {
|
|||
|
||||
StreamManagement.Failed failed = ParseStreamManagement.failed(parser);
|
||||
|
||||
assertEquals(XMPPError.Condition.item_not_found, failed.getXMPPErrorCondition());
|
||||
assertEquals(StanzaError.Condition.item_not_found, failed.getXMPPErrorCondition());
|
||||
|
||||
List<StanzaErrorTextElement> textElements = failed.getTextElements();
|
||||
assertEquals(1, textElements.size());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue