Ejemplo n.º 1
0
  @VisibleForTesting
  static DatabaseClient create(Configuration config, FileSystem fileSystem) {
    String url = config.getString("sonar.jdbc.url");
    DatabaseClient.Builder builder = newBuilderForUrl(url);

    String s = config.getString("sonar.jdbc.schema");
    if (!isEmpty(s)) {
      builder.setSchema(s);
    }
    s = config.getString("sonar.jdbc.username");
    if (!isEmpty(s)) {
      builder.setLogin(s);
    }
    s = config.getString("sonar.jdbc.password");
    if (!isEmpty(s)) {
      builder.setPassword(s);
    }
    s = config.getString("sonar.jdbc.rootUrl");
    if (!isEmpty(s)) {
      builder.setRootUrl(s);
    }
    s = config.getString("sonar.jdbc.rootUsername");
    if (!isEmpty(s)) {
      builder.setRootLogin(s);
    }
    s = config.getString("sonar.jdbc.rootPassword");
    if (!isEmpty(s)) {
      builder.setRootPassword(s);
    }
    s = config.getString("sonar.jdbc.driverFile");
    if (!isEmpty(s)) {
      builder.setDriverFile(new File(s));
    }
    s = config.getString("sonar.jdbc.driverMavenKey");
    if (!isEmpty(s)) {
      feedDriverMavenKey(fileSystem, builder, s);
    }

    String value = config.getString("orchestrator.keepDatabase", "false");
    boolean keepDatabase = StringUtils.isNotBlank(value) ? Boolean.valueOf(value) : false;
    if (keepDatabase) {
      builder.setDropAndCreate(false);
    }

    return builder.build();
  }
Ejemplo n.º 2
0
 public static DatabaseClient create(Configuration config) {
   return create(config, config.fileSystem());
 }