コード例 #1
0
  public Repository connectRepository(
      RepositoriesMeta repositoriesMeta, String repositoryName, String username, String password)
      throws KettleException {
    RepositoryMeta repositoryMeta = repositoriesMeta.findRepository(repositoryName);
    if (repositoryMeta == null) {
      log.logBasic("I couldn't find the repository with name '" + repositoryName + "'");
      return null;
    }

    Repository rep =
        PluginRegistry.getInstance()
            .loadClass(RepositoryPluginType.class, repositoryMeta, Repository.class);
    rep.init(repositoryMeta);

    try {
      rep.connect(username, password);
      log.logBasic("Connected to " + repositoryName + " as " + username);
      setRepository(rep);
      return rep;
    } catch (Exception e) {
      log.logBasic("Unable to connect to the repository with name '" + repositoryName + "'");
      return null;
    }
  }