use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.
the class JobEntryExportRepositoryDialog method displaydirectoryList.
private void displaydirectoryList() {
RepositoriesMeta repositoriesMeta = null;
RepositoryMeta repositoryMeta = null;
Repository repos = null;
try {
repositoriesMeta = new RepositoriesMeta();
repositoriesMeta.readData();
repositoryMeta = repositoriesMeta.findRepository(jobMeta.environmentSubstitute(wRepositoryname.getText()));
if (repositoryMeta == null) {
// Can not find repository
displayMsg(BaseMessages.getString(PKG, "JobExportRepository.Error.CanNotFindRep"), BaseMessages.getString(PKG, "JobExportRepository.Error.CanNotFindRepMsg", wRepositoryname.getText()), true);
}
repos = PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, repositoryMeta, Repository.class);
repos.init(repositoryMeta);
try {
repos.connect(jobMeta.environmentSubstitute(wUserName.getText()), jobMeta.environmentSubstitute(wPassword.getText()));
} catch (Exception e) {
displayMsg(BaseMessages.getString(PKG, "JobExportRepository.Error.CanNotConnect"), BaseMessages.getString(PKG, "JobExportRepository.Error.CanNotConnectMsg", wRepositoryname.getText()), true);
}
if (repos.isConnected()) {
try {
FileDialogOperation fileDialogOperation = new FileDialogOperation(FileDialogOperation.SELECT_FOLDER, FileDialogOperation.ORIGIN_SPOON);
fileDialogOperation.setTitle(BaseMessages.getString(PKG, "JobExportRepository.SelectDirectoryDialog.Title"));
fileDialogOperation.setFilter(null);
fileDialogOperation.setRepository(repos);
if (!Utils.isEmpty(wFoldername.getText())) {
fileDialogOperation.setStartDir(wFoldername.getText());
}
ExtensionPointHandler.callExtensionPoint(null, KettleExtensionPoint.SpoonOpenSaveRepository.id, fileDialogOperation);
if (fileDialogOperation.getRepositoryObject() != null) {
String path = ((RepositoryObject) fileDialogOperation.getRepositoryObject()).getRepositoryDirectory().getPath();
wFoldername.setText(path);
}
} catch (KettleException e) {
// Do Nothing
}
}
} catch (Exception e) {
displayMsg(BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "JobExportRepository.ErrorGettingFolderds.DialogMessage") + Const.CR + ":" + e.getMessage(), true);
} finally {
if (repos != null) {
repos.disconnect();
repos = null;
}
if (repositoryMeta != null) {
repositoryMeta = null;
}
repositoriesMeta.clear();
}
}
use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.
the class RepositoryConnectControllerTest method testEditConnectedRepository.
@Test
public void testEditConnectedRepository() throws Exception {
RepositoryMeta before = new TestRepositoryMeta(ID, "name1", PLUGIN_DESCRIPTION, "same");
RepositoryMeta edited = new TestRepositoryMeta(ID, "name2", PLUGIN_DESCRIPTION, "same");
when(pluginRegistry.loadClass(RepositoryPluginType.class, ID, Repository.class)).thenReturn(repository);
when(pluginRegistry.loadClass(RepositoryPluginType.class, ID, RepositoryMeta.class)).thenReturn(edited);
when(repositoriesMeta.nrRepositories()).thenReturn(1);
when(repositoriesMeta.getRepository(0)).thenReturn(before);
controller.setConnectedRepository(before.clone());
controller.setCurrentRepository(before);
when(repositoriesMeta.findRepository(anyString())).thenReturn(edited);
controller.updateRepository(ID, new HashMap<>());
assertEquals(edited, controller.getConnectedRepository());
}
use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.
the class RepositoryConnectController method reconnectToRepository.
public void reconnectToRepository(String repositoryName, String username, String password) throws KettleException {
final RepositoryMeta repositoryMeta = repositoriesMeta.findRepository(repositoryName);
if (repositoryMeta != null) {
currentRepository = repositoryMeta;
reconnectToRepository(username, password);
}
}
use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.
the class RepositorySpoonStartExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
if (!(object instanceof CommandLineOption[])) {
return;
}
CommandLineOption[] options = (CommandLineOption[]) object;
StringBuilder optionRepname = getCommandLineOption(options, "rep").getArgument();
StringBuilder optionFilename = getCommandLineOption(options, "file").getArgument();
StringBuilder optionUsername = getCommandLineOption(options, "user").getArgument();
StringBuilder optionPassword = getCommandLineOption(options, "pass").getArgument();
if (!Utils.isEmpty(optionRepname) && Utils.isEmpty(optionFilename)) {
RepositoryMeta repositoryMeta = repositoryConnectController.getRepositoryMetaByName(optionRepname.toString());
if (repositoryMeta != null && !Utils.isEmpty(optionUsername) && !Utils.isEmpty(optionPassword)) {
repositoryConnectController.connectToRepository(repositoryMeta, optionUsername.toString(), optionPassword.toString());
} else if (repositoryMeta != null) {
repositoryConnectController.connectToRepository(repositoryMeta, null, null);
}
if (!repositoryConnectController.isConnected()) {
String msg = BaseMessages.getString(PKG, "Repository.NoConnected.Message");
// "No repositories defined on this system."
log.logError(msg);
MessageBox mb = new MessageBox(getSpoon().getShell(), SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "Repository.NoConnected.Message", optionRepname.toString()));
mb.setText(BaseMessages.getString(PKG, "Repository.NoConnected.Message.Title"));
mb.open();
}
} else if (Utils.isEmpty(optionFilename)) {
RepositoryMeta repositoryMeta = repositoryConnectController.getDefaultRepositoryMeta();
if (repositoryMeta != null) {
if (repositoryMeta.getId().equals("KettleFileRepository")) {
repositoryConnectController.connectToRepository(repositoryMeta);
} else {
new RepositoryDialog(getSpoon().getShell(), repositoryConnectController).openLogin(repositoryMeta);
}
}
}
}
use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.
the class RequestLoginToRepositoryExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
ILoginCallback loginCallback = defaultLoginCallback;
if ((object instanceof ILoginCallback)) {
loginCallback = (ILoginCallback) object;
}
RepositoryMeta repositoryMeta = findRepositoryToConnect();
if (repositoryMeta != null) {
if (isKettleFileRepository(repositoryMeta)) {
repositoryConnectController.connectToRepository(repositoryMeta);
loginCallback.onSuccess(repositoryConnectController.getConnectedRepositoryInstance());
} else {
loginToRepository(repositoryMeta, loginCallback);
}
} else {
String errorMessage = BaseMessages.getString(PKG, "Repository.NoDefinedRepositoryToConnect");
KettleException exception = new KettleException(errorMessage);
loginCallback.onError(exception);
}
}
Aggregations