use of org.pentaho.di.repository.AbstractRepository in project pentaho-kettle by pentaho.
the class RepositoryConnectController method createRepository.
public boolean createRepository(String id, Map<String, Object> items) {
try {
RepositoryMeta repositoryMeta = pluginRegistry.loadClass(RepositoryPluginType.class, id, RepositoryMeta.class);
repositoryMeta.populate(items, repositoriesMeta);
if (repositoryMeta.getName() != null) {
Repository repository = pluginRegistry.loadClass(RepositoryPluginType.class, repositoryMeta.getId(), Repository.class);
repository.init(repositoryMeta);
repositoriesMeta.addRepository(repositoryMeta);
repositoriesMeta.writeData();
if (!testRepository(repository)) {
return false;
}
((AbstractRepository) repository).create();
}
} catch (KettleException ke) {
log.logError("Unable to load repository type", ke);
return false;
}
return true;
}
use of org.pentaho.di.repository.AbstractRepository in project pentaho-kettle by pentaho.
the class RepositoryConnectController method testRepository.
private boolean testRepository(Repository repository) {
ExecutorService executorService = ExecutorUtil.getExecutor();
Future<Boolean> future = executorService.submit(() -> {
ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(Trans.class.getClassLoader());
return ((AbstractRepository) repository).test();
} finally {
Thread.currentThread().setContextClassLoader(currentClassLoader);
}
});
try {
return future.get();
} catch (InterruptedException | ExecutionException e) {
return false;
}
}
Aggregations