MCPcopy Create free account
hub / github.com/BombusMod/BombusMod / decodeError

Method decodeError

src/main/java/xmpp/XmppError.java:222–306  ·  view source on GitHub ↗
(JabberDataBlock error, String ns)

Source from the content-addressed store, hash-verified

220 }
221
222 private static XmppError decodeError(JabberDataBlock error, String ns) {
223 int errCond=NONE;
224 String text=error.getText();
225 if (text.length()==0) text=null;
226 Vector errChilds=error.getChildBlocks();
227 if (errChilds!=null) for (Enumeration e=errChilds.elements(); e.hasMoreElements();) {
228 JabberDataBlock child=(JabberDataBlock) e.nextElement();
229 String xmlns=child.getAttribute("xmlns");
230 if (xmlns!=null) if (!xmlns.equals(ns)) continue;
231
232 String tag=child.getTagName();
233 if (tag.equals("text")) text=child.getText();
234 if (tag.equals("bad-request")) errCond=BAD_REQUEST;
235 if (tag.equals("conflict")) errCond=CONFLICT;
236 if (tag.equals("feature-not-implemented")) errCond=FEATURE_NOT_IMPLEMENTED;
237 if (tag.equals("forbidden")) errCond=FORBIDDEN;
238 if (tag.equals("gone")) errCond=GONE;
239 if (tag.equals("internal-server-error")) errCond=INTERNAL_SERVER_ERROR;
240 if (tag.equals("item-not-found")) errCond=ITEM_NOT_FOUND;
241 if (tag.equals("jid-malformed")) errCond=JID_MALFORMED;
242 if (tag.equals("not-acceptable")) errCond=NOT_ACCEPTABLE;
243 if (tag.equals("not-allowed")) errCond=NOT_ALLOWED;
244 if (tag.equals("not-authorized")) errCond=NOT_AUTHORIZED;
245 if (tag.equals("payment-required")) errCond=PAYMENT_REQUIRED;
246 if (tag.equals("recipient-unavailable")) errCond=RECIPIENT_UNAVAILEBLE;
247 if (tag.equals("redirect")) errCond=REDIRECT;
248 if (tag.equals("registration-required")) errCond=REGISTRATION_REQUIRED;
249 if (tag.equals("remote-server-not-found")) errCond=REMOTE_SERVER_NOT_FOUND;
250 if (tag.equals("remote-server-timeout")) errCond=REMOTE_SERVER_TIMEOUT;
251 if (tag.equals("resource-constraint")) errCond=RESOURCE_CONSTRAINT;
252 if (tag.equals("service-unavailable")) errCond=SERVICE_UNAVAILABLE;
253 if (tag.equals("subscription-required")) errCond=SUBSCRIPTION_REQUIRED;
254 if (tag.equals("undefined-condition")) errCond=UNDEFINED_CONDITION;
255 if (tag.equals("unexpected-request")) errCond=UNEXPECTED_REQUEST;
256
257 //SASL conditions
258 if (tag.equals("aborted")) errCond=ABORTED;
259 if (tag.equals("incorrect-encoding")) errCond=INCORRECT_ENCODING;
260 if (tag.equals("invalid-authzid")) errCond=INVALID_AUTHZID;
261 if (tag.equals("invalid-mechanism")) errCond=INVALID_MECHANISM;
262 if (tag.equals("mechanism-too-weak")) errCond=MECHANISM_TOO_WEAK;
263 // already defined
264 //if (tag.equals("not-authorized")) errCond=NOT_AUTHORIZED;
265 if (tag.equals("temporary-auth-failure")) errCond=TEMPORARY_AUTH_FAILURE;
266
267 }
268
269 if (errCond==NONE) {
270 try {
271 int code=Integer.parseInt(error.getAttribute("code"));
272 switch (code) {
273 case 302: errCond=REDIRECT; break;
274 case 400: errCond=BAD_REQUEST; break;
275 case 401: errCond=NOT_AUTHORIZED; break;
276 case 402: errCond=PAYMENT_REQUIRED; break;
277 case 403: errCond=FORBIDDEN; break;
278 case 404: errCond=ITEM_NOT_FOUND; break;
279 case 405: errCond=NOT_ALLOWED; break;

Callers 3

decodeStanzaErrorMethod · 0.95
decodeStreamErrorMethod · 0.95
decodeSaslErrorMethod · 0.95

Calls 9

getAttributeMethod · 0.95
getTagNameMethod · 0.95
getTextMethod · 0.95
getChildBlocksMethod · 0.80
elementsMethod · 0.80
getTypeAttributeMethod · 0.80
getTextMethod · 0.65
equalsMethod · 0.45
getAttributeMethod · 0.45

Tested by

no test coverage detected