Java Code Examples for org.jivesoftware.smack.util.StringUtils#isNotEmpty()

The following examples show how to use org.jivesoftware.smack.util.StringUtils#isNotEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FriendlyPingServer.java    From friendlyping with Apache License 2.0 6 votes vote down vote up
@Override
public void onMessage(String from, JsonObject jData) {
  if (jData.has("action")) {
    String action = jData.get("action").getAsString();
    if (action.equals(REGISTER_NEW_CLIENT)) {
      registerNewClient(jData);
    } else if (action.equals("ping_client")) {
      String toToken = jData.get("to").getAsString();
      String senderToken = jData.get("sender").getAsString();
      if (StringUtils.isNotEmpty(toToken) && StringUtils.isNotEmpty(senderToken)) {
        pingClient(toToken, senderToken);
      } else {
        logger.info("Unable to ping unless to and sender tokens are available.");
      }
    }
  } else {
    logger.info("No action found. Message received missing action.");
  }
}
 
Example 2
Source File: SpoilerElement.java    From Smack with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new SpoilerElement with a hint about a content and a language attribute.
 *
 * @param language language of the hint.
 * @param hint hint about the content.
 */
public SpoilerElement(String language, String hint) {
    if (StringUtils.isNotEmpty(language) && StringUtils.isNullOrEmpty(hint)) {
        throw new IllegalArgumentException("Hint cannot be null or empty if language is not empty.");
    }
    this.language = language;
    this.hint = hint;
}
 
Example 3
Source File: SignElementProvider.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public SignElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
    OpenPgpContentElementData data = parseOpenPgpContentElementData(parser, initialDepth);

    if (StringUtils.isNotEmpty(data.rpad)) {
        LOGGER.warning("Ignoring rpad in XEP-0373 <sign/> element");
    }

    return new SignElement(data.to, data.timestamp, data.payload);
}
 
Example 4
Source File: XmlEnvironment.java    From Smack with Apache License 2.0 5 votes vote down vote up
public String getEffectiveNamespace() {
    if (effectiveNamespaceDetermined) {
        return effectiveNamespace;
    }

    if (StringUtils.isNotEmpty(namespace)) {
        effectiveNamespace = namespace;
    } else if (next != null) {
        effectiveNamespace = next.getEffectiveNamespace();
    }

    effectiveNamespaceDetermined = true;
    return effectiveNamespace;
}
 
Example 5
Source File: XmlEnvironment.java    From Smack with Apache License 2.0 5 votes vote down vote up
public String getEffectiveLanguage() {
    if (effectiveLanguageDetermined) {
        return effectiveLanguage;
    }

    if (StringUtils.isNotEmpty(language)) {
        effectiveLanguage = language;
    } else if (next != null) {
        effectiveLanguage = next.getEffectiveLanguage();
    }

    effectiveLanguageDetermined = true;
    return effectiveLanguage;
}
 
Example 6
Source File: WorkgroupProperties.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) {
    if (StringUtils.isNotEmpty(getJid())) {
        buf.append("jid=\"" + getJid() + "\" ");
    }
    buf.setEmptyElement();
    return buf;
}
 
Example 7
Source File: GenericSettings.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) {
    buf.append('>');
    if (StringUtils.isNotEmpty(getQuery())) {
        buf.append("<query>" + getQuery() + "</query>");
    }
    return buf;
}
 
Example 8
Source File: SearchSettings.java    From Smack with Apache License 2.0 4 votes vote down vote up
public boolean hasForums() {
    return StringUtils.isNotEmpty(getForumsLocation());
}
 
Example 9
Source File: OfflineSettings.java    From Smack with Apache License 2.0 4 votes vote down vote up
public boolean isConfigured() {
    return StringUtils.isNotEmpty(getEmailAddress()) &&
           StringUtils.isNotEmpty(getSubject()) &&
           StringUtils.isNotEmpty(getOfflineText());
}
 
Example 10
Source File: OfflineSettings.java    From Smack with Apache License 2.0 4 votes vote down vote up
public boolean redirects() {
    return StringUtils.isNotEmpty(getRedirectURL());
}
 
Example 11
Source File: OfflineSettings.java    From Smack with Apache License 2.0 4 votes vote down vote up
public String getSubject() {
    if (!StringUtils.isNotEmpty(subject)) {
        return "";
    }
    return subject;
}
 
Example 12
Source File: OfflineSettings.java    From Smack with Apache License 2.0 4 votes vote down vote up
public String getEmailAddress() {
    if (!StringUtils.isNotEmpty(emailAddress)) {
        return "";
    }
    return emailAddress;
}
 
Example 13
Source File: OfflineSettings.java    From Smack with Apache License 2.0 4 votes vote down vote up
public String getOfflineText() {
    if (!StringUtils.isNotEmpty(offlineText)) {
        return "";
    }
    return offlineText;
}
 
Example 14
Source File: OfflineSettings.java    From Smack with Apache License 2.0 4 votes vote down vote up
public String getRedirectURL() {
    if (!StringUtils.isNotEmpty(redirectURL)) {
        return "";
    }
    return redirectURL;
}
 
Example 15
Source File: FriendlyPingServer.java    From friendlyping with Apache License 2.0 4 votes vote down vote up
public boolean isValid() {
  return StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(registrationToken) &&
      StringUtils.isNotEmpty(profilePictureUrl);
}
 
Example 16
Source File: SearchSettings.java    From Smack with Apache License 2.0 4 votes vote down vote up
public boolean hasKB() {
    return StringUtils.isNotEmpty(getKbLocation());
}
 
Example 17
Source File: SearchSettings.java    From Smack with Apache License 2.0 4 votes vote down vote up
public boolean isSearchEnabled() {
    return StringUtils.isNotEmpty(getForumsLocation()) && StringUtils.isNotEmpty(getKbLocation());
}
 
Example 18
Source File: Configuration.java    From Smack with Apache License 2.0 4 votes vote down vote up
public static Configuration newConfiguration(String[] testPackages)
                throws IOException, KeyManagementException, NoSuchAlgorithmException {
    Properties properties = new Properties();

    File propertiesFile = findPropertiesFile();
    if (propertiesFile != null) {
        try (FileInputStream in = new FileInputStream(propertiesFile)) {
            properties.load(in);
        }
    }

    // Properties set via the system override the file properties
    Properties systemProperties = System.getProperties();
    for (Entry<Object, Object> entry : systemProperties.entrySet()) {
        String key = (String) entry.getKey();
        if (!key.startsWith(SINTTEST)) {
            continue;
        }
        key = key.substring(SINTTEST.length());
        String value = (String) entry.getValue();
        properties.put(key, value);
    }

    Builder builder = builder();
    builder.setService(properties.getProperty("service"));
    builder.setServiceTlsPin(properties.getProperty("serviceTlsPin"));
    builder.setSecurityMode(properties.getProperty("securityMode"));
    builder.setReplyTimeout(properties.getProperty("replyTimeout", "60000"));

    String adminAccountUsername = properties.getProperty("adminAccountUsername");
    String adminAccountPassword = properties.getProperty("adminAccountPassword");
    if (StringUtils.isNotEmpty(adminAccountUsername, adminAccountPassword)) {
        builder.setAdminAccountUsernameAndPassword(adminAccountUsername, adminAccountPassword);
    }

    String accountOneUsername = properties.getProperty("accountOneUsername");
    String accountOnePassword = properties.getProperty("accountOnePassword");
    String accountTwoUsername = properties.getProperty("accountTwoUsername");
    String accountTwoPassword = properties.getProperty("accountTwoPassword");
    String accountThreeUsername = properties.getProperty("accountThreeUsername");
    String accountThreePassword = properties.getProperty("accountThreePassword");
    if (accountOneUsername != null || accountOnePassword != null || accountTwoUsername != null
                    || accountTwoPassword != null || accountThreeUsername != null || accountThreePassword != null) {
        builder.setUsernamesAndPassword(accountOneUsername, accountOnePassword, accountTwoUsername,
                        accountTwoPassword, accountThreeUsername, accountThreePassword);
    }

    String debugString = properties.getProperty("debug");
    if (debugString != null) {
        LOGGER.warning("Usage of depreacted 'debug' option detected, please use 'debugger' instead");
        builder.setDebugger(debugString);
    }
    builder.setDebugger(properties.getProperty("debugger"));
    builder.setEnabledTests(properties.getProperty("enabledTests"));
    builder.setDisabledTests(properties.getProperty("disabledTests"));
    builder.setDefaultConnection(properties.getProperty("defaultConnection"));
    builder.setEnabledConnections(properties.getProperty("enabledConnections"));
    builder.setDisabledConnections(properties.getProperty("disabledConnections"));

    builder.addTestPackages(properties.getProperty("testPackages"));
    builder.addTestPackages(testPackages);

    builder.setVerbose(properties.getProperty("verbose"));

    builder.setDnsResolver(properties.getProperty("dnsResolver"));

    return builder.build();
}
 
Example 19
Source File: StanzaBuilder.java    From Smack with Apache License 2.0 4 votes vote down vote up
public final boolean willBuildStanzaWithId() {
    return stanzaIdSource != null || StringUtils.isNotEmpty(stanzaId);
}
 
Example 20
Source File: ValidateElement.java    From Smack with Apache License 2.0 2 votes vote down vote up
/**
 * The 'datatype' attribute specifies the datatype. This attribute is OPTIONAL, and when not specified, defaults to
 * "xs:string".
 *
 * @param datatype the data type of any value contained within the {@link FormField} element.
 */
private ValidateElement(String datatype) {
    this.datatype = StringUtils.isNotEmpty(datatype) ? datatype : null;
}