Search in sources :

Example 11 with RepositoriesMeta

use of org.pentaho.di.repository.RepositoriesMeta in project pentaho-kettle by pentaho.

the class ExecuteTransServlet method openRepository.

private Repository openRepository(String repositoryName, String user, String pass) throws KettleException {
    if (Utils.isEmpty(repositoryName)) {
        return null;
    }
    RepositoriesMeta repositoriesMeta = new RepositoriesMeta();
    repositoriesMeta.readData();
    RepositoryMeta repositoryMeta = repositoriesMeta.findRepository(repositoryName);
    if (repositoryMeta == null) {
        throw new KettleException("Unable to find repository: " + repositoryName);
    }
    PluginRegistry registry = PluginRegistry.getInstance();
    Repository repository = registry.loadClass(RepositoryPluginType.class, repositoryMeta, Repository.class);
    repository.init(repositoryMeta);
    repository.connect(user, pass);
    return repository;
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) RepositoriesMeta(org.pentaho.di.repository.RepositoriesMeta)

Example 12 with RepositoriesMeta

use of org.pentaho.di.repository.RepositoriesMeta in project pentaho-kettle by pentaho.

the class SlaveServerConfig method openRepository.

private void openRepository(String repositoryId) throws KettleException {
    try {
        RepositoriesMeta repositoriesMeta = new RepositoriesMeta();
        repositoriesMeta.readData();
        repositoryMeta = repositoriesMeta.findRepository(repositoryId);
        if (repositoryMeta == null) {
            throw new KettleException("Unable to find repository: " + repositoryId);
        }
        PluginRegistry registry = PluginRegistry.getInstance();
        repository = registry.loadClass(RepositoryPluginType.class, repositoryMeta, Repository.class);
        repository.init(repositoryMeta);
        repository.connect(repositoryUsername, repositoryPassword);
        // 
        if (repository.getMetaStore() != null) {
            metaStore.addMetaStore(0, repository.getMetaStore());
            metaStore.setActiveMetaStoreName(repository.getMetaStore().getName());
        }
        LogChannel.GENERAL.logBasic("Connected to repository '" + repository.getName() + "'");
    } catch (Exception e) {
        throw new KettleException("Unable to open repository connection", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository) RepositoryPluginType(org.pentaho.di.core.plugins.RepositoryPluginType) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) RepositoriesMeta(org.pentaho.di.repository.RepositoriesMeta) KettleException(org.pentaho.di.core.exception.KettleException) SocketException(java.net.SocketException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException)

Example 13 with RepositoriesMeta

use of org.pentaho.di.repository.RepositoriesMeta in project pentaho-kettle by pentaho.

the class JobEntryExportRepository method connectRep.

private void connectRep(LogChannelInterface log, String realrepName, String realusername, String realpassword) throws Exception {
    this.repsinfo = new RepositoriesMeta();
    this.repsinfo.getLog().setLogLevel(log.getLogLevel());
    try {
        this.repsinfo.readData();
    } catch (Exception e) {
        logError(BaseMessages.getString(PKG, "JobExportRepository.Error.NoRep"));
        throw new Exception(BaseMessages.getString(PKG, "JobExportRepository.Error.NoRep"));
    }
    this.repositoryMeta = this.repsinfo.findRepository(realrepName);
    if (this.repositoryMeta == null) {
        logError(BaseMessages.getString(PKG, "JobExportRepository.Error.NoRepSystem"));
        throw new Exception(BaseMessages.getString(PKG, "JobExportRepository.Error.NoRepSystem"));
    }
    this.repository = PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, this.repositoryMeta, Repository.class);
    this.repository.init(repositoryMeta);
    try {
        this.repository.connect(realusername, realpassword);
    } catch (Exception e) {
        logError(BaseMessages.getString(PKG, "JobExportRepository.Error.CanNotConnectRep"));
        throw new Exception(BaseMessages.getString(PKG, "JobExportRepository.Error.CanNotConnectRep"), e);
    }
}
Also used : Repository(org.pentaho.di.repository.Repository) RepositoryPluginType(org.pentaho.di.core.plugins.RepositoryPluginType) RepositoriesMeta(org.pentaho.di.repository.RepositoriesMeta) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException)

Example 14 with RepositoriesMeta

use of org.pentaho.di.repository.RepositoriesMeta in project pentaho-kettle by pentaho.

the class AbstractBaseCommandExecutor method loadRepositoryInfo.

public RepositoriesMeta loadRepositoryInfo(String loadingAvailableRepMsgTkn, String noRepsDefinedMsgTkn) throws KettleException {
    RepositoriesMeta repsinfo = new RepositoriesMeta();
    repsinfo.getLog().setLogLevel(getLog().getLogLevel());
    logDebug(loadingAvailableRepMsgTkn);
    try {
        repsinfo.readData();
    } catch (Exception e) {
        throw new KettleException(BaseMessages.getString(getPkgClazz(), noRepsDefinedMsgTkn), e);
    }
    return repsinfo;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoriesMeta(org.pentaho.di.repository.RepositoriesMeta) KettleException(org.pentaho.di.core.exception.KettleException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException)

Example 15 with RepositoriesMeta

use of org.pentaho.di.repository.RepositoriesMeta in project pentaho-kettle by pentaho.

the class AbstractBaseCommandExecutor method loadRepositoryConnection.

public RepositoryMeta loadRepositoryConnection(final String repoName, String loadingAvailableRepMsgTkn, String noRepsDefinedMsgTkn, String findingRepMsgTkn) throws KettleException {
    RepositoriesMeta repsinfo;
    if (Utils.isEmpty(repoName) || (repsinfo = loadRepositoryInfo(loadingAvailableRepMsgTkn, noRepsDefinedMsgTkn)) == null) {
        return null;
    }
    logDebug(findingRepMsgTkn, repoName);
    return repsinfo.findRepository(repoName);
}
Also used : RepositoriesMeta(org.pentaho.di.repository.RepositoriesMeta)

Aggregations

RepositoriesMeta (org.pentaho.di.repository.RepositoriesMeta)19 KettleException (org.pentaho.di.core.exception.KettleException)17 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)14 Repository (org.pentaho.di.repository.Repository)12 RepositoryPluginType (org.pentaho.di.core.plugins.RepositoryPluginType)8 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Test (org.junit.Test)2 Mockito.doAnswer (org.mockito.Mockito.doAnswer)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)2 KettleStepException (org.pentaho.di.core.exception.KettleStepException)2 KettleValueException (org.pentaho.di.core.exception.KettleValueException)2 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)2 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)2