Java 类com.beust.jcommander.Strings 实例源码

项目:solr-cmd-utils    文件:ElasticWriter.java   
void procesBuffer() {
    try {
        StringBuilder bulkRequest = new StringBuilder();
        for (Document document : buffer) {
            Map<String, Object> jsonDocument = mapToJson(document);
            if (jsonDocument.isEmpty()) {
                continue;
            }
            String id;
            if (Strings.isStringEmpty(idField)) {
                id = UUID.randomUUID().toString();
            } else {
                id = document.getFieldValue(idField);
            }
            String index = ElasticHelper.getIndexFromUrl(location);
            String type = ElasticHelper.getTypeFromUrl(location);
            String bulkMethod = createBulkMethod("index", index, type, id);
            String json = gson.toJson(jsonDocument);
            bulkRequest.append(bulkMethod).append(" \n");
            bulkRequest.append(json).append(" \n");
        }

        String bulkUrl = ElasticHelper.getBulkUrl(location);
        HTTPHelper.post(bulkUrl, bulkRequest.toString());
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }

}
项目:incubator-slider    文件:RegistryRetriever.java   
protected String getConfigurationURL(boolean external) throws FileNotFoundException {
  String confURL = external ? externalConfigurationURL: internalConfigurationURL;
  if (Strings.isStringEmpty(confURL)) {
    throw new FileNotFoundException("No configuration URL");
  }
  return confURL;
}
项目:incubator-slider    文件:RegistryRetriever.java   
protected String getExportURL(boolean external) throws FileNotFoundException {
  String confURL = external ? externalExportsURL: internalExportsURL;
  if (Strings.isStringEmpty(confURL)) {
    throw new FileNotFoundException("No configuration URL");
  }
  return confURL;
}
项目:halyard    文件:DCOSAccountValidator.java   
private void validateClusters(final ConfigProblemSetBuilder problems, final DCOSAccount account) {
  final NodeIterator children = account.getParent().getChildren();

  Node n = children.getNext();
  Set<String> definedClusters = new HashSet<>();
  while (n != null) {
    if (n instanceof DCOSCluster) {
      definedClusters.add(((DCOSCluster) n).getName());
    }
    n = children.getNext();
  }

  final Set<String> accountClusters = account.getClusters().stream().map(c -> c.getName())
      .collect(Collectors.toSet());
  accountClusters.removeAll(definedClusters);
  accountClusters.forEach(c -> problems.addProblem(ERROR, "Cluster \"" + c.toString() + "\" not defined for provider")
      .setRemediation("Add cluster to the provider or remove from the account")
      .setOptions(Lists.newArrayList(definedClusters)));

  Set<List<String>> credentials = new HashSet<>();
  account.getClusters().forEach(c -> {
    final List<String> key = Lists.newArrayList(c.getName(), c.getUid());
    if (credentials.contains(key)) {
      problems.addProblem(ERROR,
          "Account contains duplicate credentials for cluster \"" + c.getName() + "\" and user id \"" + c.getUid()
              + "\".").setRemediation("Remove the duplicate credentials");
    } else {
      credentials.add(key);
    }

    // TODO(willgorman) once we have the clouddriver-dcos module pulled in we can just validate whether or not
    // we can connect without a password
    if (Strings.isStringEmpty(c.getPassword()) && Strings.isStringEmpty(c.getServiceKeyFile())) {
      problems.addProblem(WARNING,
          "Account has no password or service key.  Unless the cluster has security disabled this may be an error")
          .setRemediation("Add a password or service key.");
    }

    if (!Strings.isStringEmpty(c.getPassword()) && !Strings.isStringEmpty(c.getServiceKeyFile())) {
      problems.addProblem(ERROR, "Account has both a password and service key")
          .setRemediation("Remove either the password or service key.");
    }

    if (!Strings.isStringEmpty(c.getServiceKeyFile())) {
      String resolvedServiceKey = ValidatingFileReader.contents(problems, c.getServiceKeyFile());

      if (Strings.isStringEmpty(resolvedServiceKey)) {
        problems.addProblem(ERROR, "The supplied service key file does not exist or is empty.")
          .setRemediation("Supply a valid service key file.");
      }
    }
  });
}
项目:checklistbank    文件:ZooKeeperConfiguration.java   
public boolean isConfigured() {
  return !Strings.isStringEmpty(namespace) && !Strings.isStringEmpty(connectionString);
}
项目:incubator-slider    文件:RegistryRetriever.java   
/**
 * Does a bonded registry retriever have a configuration?
 * @param external flag to indicate that it is the external entries to fetch
 * @return true if there is a URL to the configurations defined
 */
public boolean hasConfigurations(boolean external) {
  return !Strings.isStringEmpty(
      external ? externalConfigurationURL : internalConfigurationURL);
}