use of org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException in project pentaho-kettle by pentaho.
the class VFSFileProvider method copy.
/**
* @param file
* @param toPath
* @param overwrite
* @return
* @throws FileException
*/
@Override
public VFSFile copy(VFSFile file, String toPath, boolean overwrite) throws FileException {
try {
FileObject fileObject = KettleVFS.getFileObject(file.getPath(), new Variables(), VFSHelper.getOpts(file.getPath(), file.getConnection()));
FileObject copyObject = KettleVFS.getFileObject(toPath, new Variables(), VFSHelper.getOpts(file.getPath(), file.getConnection()));
copyObject.copyFrom(fileObject, Selectors.SELECT_SELF);
if (file instanceof VFSDirectory) {
return VFSDirectory.create(copyObject.getParent().getPublicURIString(), fileObject, file.getConnection(), file.getDomain());
} else {
return VFSFile.create(copyObject.getParent().getPublicURIString(), fileObject, file.getConnection(), file.getDomain());
}
} catch (KettleFileException | FileSystemException e) {
throw new FileException();
}
}
use of org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException in project pentaho-kettle by pentaho.
the class FileController method rename.
public Result rename(File file, String newPath, boolean overwrite) {
try {
FileProvider<File> fileProvider = providerService.get(file.getProvider());
File newFile = fileProvider.rename(file, newPath, overwrite);
if (newFile != null) {
fileCache.move(fileProvider.getParent(file), file, fileProvider.getParent(newFile), newFile);
}
return Result.success("", newFile);
} catch (InvalidFileProviderException | FileException e) {
return null;
}
}
use of org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException 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);
}
Aggregations