Tabnine Logo
StanzaError$Builder
Code IndexAdd Tabnine to your IDE (free)

How to use
StanzaError$Builder
in
org.jivesoftware.smack.packet

Best Java code snippets using org.jivesoftware.smack.packet.StanzaError$Builder (Showing top 20 results out of 315)

origin: igniterealtime/Smack

} else {
  StanzaError.Builder builder = PacketParserUtils.parseError(parser);
  throw new XMPPException.XMPPErrorException(null, builder.build());
origin: igniterealtime/Smack

StanzaError.Builder xmppError = StanzaError.getBuilder().setCondition(StanzaError.Condition.internal_server_error).setDescriptiveEnText(e.getMessage());
return respondError(response, xmppError);
origin: igniterealtime/Smack

builder.setType(StanzaError.Type.fromString(parser.getAttributeValue("", "type")));
builder.setErrorGenerator(parser.getAttributeValue("", "by"));
        break;
      default:
        builder.setCondition(StanzaError.Condition.fromString(name));
        if (!parser.isEmptyElementTag()) {
          builder.setConditionText(parser.nextText());
builder.setExtensions(extensions).setDescriptiveTexts(descriptiveTexts);
return builder;
origin: org.igniterealtime.smack/smack-core

builder.setType(StanzaError.Type.fromString(parser.getAttributeValue("", "type")));
builder.setErrorGenerator(parser.getAttributeValue("", "by"));
        break;
      default:
        builder.setCondition(StanzaError.Condition.fromString(name));
        if (!parser.isEmptyElementTag()) {
          builder.setConditionText(parser.nextText());
builder.setExtensions(extensions).setDescriptiveTexts(descriptiveTexts);
return builder;
origin: org.igniterealtime.smack/smack-core

public static Builder getBuilder(Condition condition) {
  return getBuilder().setCondition(condition);
}
origin: org.igniterealtime.smack/smack-core

public static Builder getBuilder() {
  return new Builder();
}
origin: org.igniterealtime.smack/smack-core

public static Builder getBuilder(StanzaError xmppError) {
  return getBuilder().copyFrom(xmppError);
}
origin: org.igniterealtime.smack/smack-core

/**
 * Creates a new XMPPErrorException with the given builder.
 *
 * @param xmppErrorBuilder
 * @deprecated Use {@link #XMPPErrorException(Stanza, StanzaError)} instead.
 */
@Deprecated
public XMPPErrorException(StanzaError.Builder xmppErrorBuilder) {
  this(null, xmppErrorBuilder.build());
}
origin: org.igniterealtime.smack/smack-core

public static StanzaError.Builder from(Condition condition, String descriptiveText) {
  StanzaError.Builder builder = getBuilder().setCondition(condition);
  if (descriptiveText != null) {
    Map<String, String> descriptiveTexts = new HashMap<>();
    descriptiveTexts.put("en", descriptiveText);
    builder.setDescriptiveTexts(descriptiveTexts);
  }
  return builder;
}
origin: org.igniterealtime.smack/smack-core

public Builder copyFrom(StanzaError xmppError) {
  setCondition(xmppError.getCondition());
  setType(xmppError.getType());
  setConditionText(xmppError.getConditionText());
  setErrorGenerator(xmppError.getErrorGenerator());
  setStanza(xmppError.getStanza());
  setDescriptiveTexts(xmppError.descriptiveTexts);
  setTextNamespace(xmppError.textNamespace);
  setExtensions(xmppError.extensions);
  return this;
}
origin: org.igniterealtime.smack/smack-core

/**
 * Sets the error for this stanza.
 *
 * @param xmppErrorBuilder the error to associate with this stanza.
 */
public void setError(StanzaError.Builder xmppErrorBuilder) {
  if (xmppErrorBuilder == null) {
    return;
  }
  xmppErrorBuilder.setStanza(this);
  error = xmppErrorBuilder.build();
}
origin: igniterealtime/Smack

/**
 * Complete and send an error. Complete all the null fields in an IQ error
 * response, using the session information we have or some info from the
 * incoming packet.
 *
 * @param iq
 *            The Jingle stanza we are responding to
 * @param jingleError
 *            the IQ stanza we want to complete and send
 */
public IQ createJingleError(IQ iq, JingleError jingleError) {
  IQ errorPacket = null;
  if (jingleError != null) {
    // TODO This is wrong according to XEP-166 ยง 10, but this jingle implementation is deprecated anyways
    StanzaError.Builder builder = StanzaError.getBuilder(StanzaError.Condition.undefined_condition);
    builder.addExtension(jingleError);
    errorPacket = IQ.createErrorResponse(iq, builder);
    //            errorPacket.addExtension(jingleError);
    // NO! Let the normal state machinery do all of the sending.
    // getConnection().sendStanza(perror);
    LOGGER.severe("Error sent: " + errorPacket.toXML(null));
  }
  return errorPacket;
}
origin: igniterealtime/Smack

/**
 * Test creating a error response based on an IQ request.
 * @throws XmppStringprepException
 */
@Test
public void testGeneratingValidErrorResponse() throws XmppStringprepException {
  final StanzaError.Builder error = StanzaError.getBuilder(StanzaError.Condition.bad_request);
  final IQ request = new TestIQ(ELEMENT, NAMESPACE);
  request.setType(IQ.Type.set);
  request.setFrom(JidCreate.from("sender@test/Smack"));
  request.setTo(JidCreate.from("receiver@test/Smack"));
  final IQ result = IQ.createErrorResponse(request, error);
  assertEquals(IQ.Type.error, result.getType());
  assertNotNull(result.getStanzaId());
  assertEquals(request.getStanzaId(), result.getStanzaId());
  assertEquals(request.getFrom(), result.getTo());
  assertEquals(error.build().toXML(), result.getError().toXML());
  // TODO this test was never valid
  // assertEquals(CHILD_ELEMENT, result.getChildElementXML());
}
origin: igniterealtime/Smack

@Test
public void ensureNoEmptyLangInDescriptiveText() throws Exception {
  final String text = "Dummy descriptive text";
  Map<String, String> texts = new HashMap<>();
  texts.put("", text);
  StanzaError error = StanzaError
      .getBuilder(StanzaError.Condition.internal_server_error)
      .setDescriptiveTexts(texts)
      .build();
  final String errorXml = XMLBuilder
      .create(StanzaError.ERROR).a("type", "cancel").up()
      .element("internal-server-error", StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE).up()
      .element("text", StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE).t(text).up()
      .asString();
  XmlUnitUtils.assertSimilar(errorXml, error.toXML(StreamOpen.CLIENT_NAMESPACE));
}
origin: igniterealtime/Smack

/**
 * Cancels the SOCKS5 Bytestream request by sending an error to the initiator and building a
 * XMPP exception.
 * @throws XMPPErrorException
 * @throws NotConnectedException
 * @throws InterruptedException
 */
private void cancelRequest() throws XMPPErrorException, NotConnectedException, InterruptedException {
  String errorMessage = "Could not establish socket with any provided host";
  StanzaError.Builder error = StanzaError.from(StanzaError.Condition.item_not_found, errorMessage);
  IQ errorIQ = IQ.createErrorResponse(this.bytestreamRequest, error);
  this.manager.getConnection().sendStanza(errorIQ);
  throw new XMPPErrorException(errorIQ, error.build());
}
origin: igniterealtime/Smack

public static Builder getBuilder() {
  return new Builder();
}
origin: igniterealtime/Smack

public static Builder getBuilder(StanzaError xmppError) {
  return getBuilder().copyFrom(xmppError);
}
origin: igniterealtime/Smack

public static Builder getBuilder(Condition condition) {
  return getBuilder().setCondition(condition);
}
origin: igniterealtime/Smack

/**
 * Responds an error with an specific condition.
 *
 * @param response the response to send.
 * @param condition the condition of the error.
 * @param specificCondition the adhoc command error condition.
 * @throws NotConnectedException
 */
private static IQ respondError(AdHocCommandData response, StanzaError.Condition condition,
    AdHocCommand.SpecificErrorCondition specificCondition) {
  StanzaError.Builder error = StanzaError.getBuilder(condition).addExtension(new AdHocCommandData.SpecificError(specificCondition));
  return respondError(response, error);
}
origin: igniterealtime/Smack

  @Test
  public void ensureNoNullLangInParsedDescriptiveTexts() throws Exception {
    final String text = "Dummy descriptive text";
    final String errorXml = XMLBuilder
      .create(StanzaError.ERROR).a("type", "cancel").up()
      .element("internal-server-error", StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE).up()
      .element("text", StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE).t(text).up()
      .asString();
    XmlPullParser parser = TestUtils.getParser(errorXml);
    StanzaError error = PacketParserUtils.parseError(parser).build();
    assertEquals(text, error.getDescriptiveText());
  }
}
org.jivesoftware.smack.packetStanzaError$Builder

Most used methods

  • build
  • setCondition
  • setDescriptiveTexts
  • <init>
  • addExtension
  • copyFrom
  • setConditionText
  • setErrorGenerator
  • setExtensions
  • setStanza
  • setTextNamespace
  • setType
  • setTextNamespace,
  • setType,
  • setDescriptiveEnText

Popular in Java

  • Start an intent from android
  • onRequestPermissionsResult (Fragment)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • onCreateOptionsMenu (Activity)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Runner (org.openjdk.jmh.runner)
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now