use of org.pentaho.di.plugins.fileopensave.api.providers.FileProvider in project pentaho-kettle by pentaho.
the class FileController method copyFile.
public Result copyFile(File file, File destDir, String path, Boolean overwrite) {
try {
FileProvider<File> fileProvider = providerService.get(file.getProvider());
File newFile;
if (fileProvider.isSame(file, destDir)) {
newFile = fileProvider.copy(file, path, overwrite);
} else {
newFile = copyFileBetweenProviders(file, destDir, path, overwrite);
}
if (newFile != null) {
FileProvider newFileProvider = providerService.get(newFile.getProvider());
fileCache.addFile(newFileProvider.getParent(newFile), newFile);
return Result.success("Copy file complete", newFile);
}
} catch (InvalidFileProviderException | FileException e) {
return Result.error("Unable to copy file", file);
}
return Result.error("Unable to copy file", file);
}
use of org.pentaho.di.plugins.fileopensave.api.providers.FileProvider in project pentaho-kettle by pentaho.
the class FileControllerTest method setup.
@Before
public void setup() {
List<FileProvider> fileProviders = new ArrayList<>();
fileProviders.add(new TestFileProvider());
ProviderService providerService = new ProviderService(fileProviders);
fileController = new FileController(new FileCache(), providerService);
}
use of org.pentaho.di.plugins.fileopensave.api.providers.FileProvider in project pentaho-kettle by pentaho.
the class FileController method load.
public List<Tree> load(String filter, List<String> connectionTypes) {
List<Tree> trees = new ArrayList<>();
List<String> filters = Utils.isEmpty(filter) || filter.equalsIgnoreCase(ProviderFilterType.DEFAULT.toString()) ? Arrays.asList(ProviderFilterType.getDefaults()) : Arrays.asList(filter.split("[,]"));
// filter
if (filters.contains(ProviderFilterType.ALL_PROVIDERS.toString())) {
for (FileProvider fileProvider : providerService.get()) {
if (fileProvider.isAvailable()) {
trees.add(fileProvider.getTree(connectionTypes));
}
}
} else {
for (FileProvider fileProvider : providerService.get()) {
if (fileProvider.isAvailable() && filters.contains(fileProvider.getType())) {
trees.add(fileProvider.getTree(connectionTypes));
}
}
}
return trees;
}
use of org.pentaho.di.plugins.fileopensave.api.providers.FileProvider in project pentaho-kettle by pentaho.
the class FileController method moveFile.
public Result moveFile(File file, File destDir, String newPath, boolean overwrite) {
try {
FileProvider<File> fileProvider = providerService.get(file.getProvider());
File newFile;
if (fileProvider.isSame(file, destDir)) {
newFile = fileProvider.move(file, newPath, overwrite);
} else {
newFile = moveBetweenProviders(file, destDir, newPath, overwrite);
}
if (newFile != null) {
FileProvider newFileProvider = providerService.get(newFile.getProvider());
fileCache.move(fileProvider.getParent(file), file, newFileProvider.getParent(newFile), newFile);
return Result.success("Move file complete", newFile);
}
} catch (InvalidFileProviderException | FileException e) {
return Result.error("Unable to move file", file);
}
return Result.error("Unable to move file", file);
}
use of org.pentaho.di.plugins.fileopensave.api.providers.FileProvider in project pentaho-kettle by pentaho.
the class FileOpenSaveExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object o) throws KettleException {
FileDialogOperation fileDialogOperation = (FileDialogOperation) o;
final FileOpenSaveDialog fileOpenSaveDialog = new FileOpenSaveDialog(spoonSupplier.get().getShell(), WIDTH, HEIGHT, logChannelInterface);
resolveProvider(fileDialogOperation);
fileOpenSaveDialog.open(fileDialogOperation);
fileDialogOperation.setPath(null);
fileDialogOperation.setFilename(null);
fileDialogOperation.setConnection(null);
if (!Utils.isEmpty(fileOpenSaveDialog.getProvider())) {
try {
FileProvider fileProvider = providerService.get(fileOpenSaveDialog.getProvider());
fileProvider.setFileProperties(fileOpenSaveDialog, fileDialogOperation);
} catch (InvalidFileProviderException e) {
throw new KettleException(e);
}
}
}
Aggregations