1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-12 05:51:08 +01:00

Make XMPPError imutable and add stanza reference

This commit is contained in:
Florian Schmaus 2015-12-08 08:22:50 +01:00
parent 83eda4c58d
commit 45feaecdf7
30 changed files with 308 additions and 94 deletions

View file

@ -444,8 +444,7 @@ public final class InBandBytestreamManager implements BytestreamManager {
* @throws InterruptedException
*/
protected void replyRejectPacket(IQ request) throws NotConnectedException, InterruptedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
IQ error = IQ.createErrorResponse(request, xmppError);
IQ error = IQ.createErrorResponse(request, XMPPError.Condition.not_acceptable);
this.connection.sendStanza(error);
}
@ -458,8 +457,7 @@ public final class InBandBytestreamManager implements BytestreamManager {
* @throws InterruptedException
*/
protected void replyResourceConstraintPacket(IQ request) throws NotConnectedException, InterruptedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.resource_constraint);
IQ error = IQ.createErrorResponse(request, xmppError);
IQ error = IQ.createErrorResponse(request, XMPPError.Condition.resource_constraint);
this.connection.sendStanza(error);
}
@ -472,8 +470,7 @@ public final class InBandBytestreamManager implements BytestreamManager {
* @throws InterruptedException
*/
protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException, InterruptedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.item_not_found);
IQ error = IQ.createErrorResponse(request, xmppError);
IQ error = IQ.createErrorResponse(request, XMPPError.Condition.item_not_found);
this.connection.sendStanza(error);
}

View file

@ -457,8 +457,8 @@ public class InBandBytestreamSession implements BytestreamSession {
* check if sequence was not used already (see XEP-0047 Section 2.2)
*/
if (data.getSeq() <= this.lastSequence) {
IQ unexpectedRequest = IQ.createErrorResponse((IQ) packet, new XMPPError(
XMPPError.Condition.unexpected_request));
IQ unexpectedRequest = IQ.createErrorResponse((IQ) packet,
XMPPError.Condition.unexpected_request);
connection.sendStanza(unexpectedRequest);
return;
@ -467,8 +467,8 @@ public class InBandBytestreamSession implements BytestreamSession {
// check if encoded data is valid (see XEP-0047 Section 2.2)
if (data.getDecodedData() == null) {
// data is invalid; respond with bad-request error
IQ badRequest = IQ.createErrorResponse((IQ) packet, new XMPPError(
XMPPError.Condition.bad_request));
IQ badRequest = IQ.createErrorResponse((IQ) packet,
XMPPError.Condition.bad_request);
connection.sendStanza(badRequest);
return;
}

View file

@ -691,7 +691,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
* @throws InterruptedException
*/
protected void replyRejectPacket(IQ packet) throws NotConnectedException, InterruptedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
XMPPError.Builder xmppError = XMPPError.getBuilder(XMPPError.Condition.not_acceptable);
IQ errorIQ = IQ.createErrorResponse(packet, xmppError);
connection().sendStanza(errorIQ);
}

View file

@ -283,10 +283,10 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
*/
private void cancelRequest() throws XMPPErrorException, NotConnectedException, InterruptedException {
String errorMessage = "Could not establish socket with any provided host";
XMPPError error = XMPPError.from(XMPPError.Condition.item_not_found, errorMessage);
XMPPError.Builder error = XMPPError.from(XMPPError.Condition.item_not_found, errorMessage);
IQ errorIQ = IQ.createErrorResponse(this.bytestreamRequest, error);
this.manager.getConnection().sendStanza(errorIQ);
throw new XMPPErrorException(errorMessage, error);
throw new XMPPErrorException(error);
}
/**