Search in sources :

Example 1 with InvalidFileProviderException

use of org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileProviderException in project pentaho-kettle by pentaho.

the class FileController method delete.

public Result delete(List<File> files) {
    try {
        FileProvider<File> fileProvider = providerService.get(files.get(0).getProvider());
        List<File> deletedFiles = fileProvider.delete(files);
        for (File file : deletedFiles) {
            fileCache.removeFile(fileProvider.getParent(file), file);
        }
        return Result.success("", deletedFiles);
    } catch (InvalidFileProviderException | FileException e) {
        return null;
    }
}
Also used : FileException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException) File(org.pentaho.di.plugins.fileopensave.api.providers.File) InvalidFileProviderException(org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileProviderException)

Example 2 with InvalidFileProviderException

use of org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileProviderException in project pentaho-kettle by pentaho.

the class FileController method add.

public Result add(File folder) {
    try {
        FileProvider<File> fileProvider = providerService.get(folder.getProvider());
        File newFile = fileProvider.add(folder);
        if (newFile != null) {
            fileCache.addFile(fileProvider.getParent(folder), newFile);
            return Result.success("", newFile);
        } else {
            return Result.error("Unable to create folder", folder);
        }
    } catch (FileExistsException fee) {
        return Result.fileCollision("", folder);
    } catch (FileException | InvalidFileProviderException fe) {
        return Result.error("", folder);
    }
}
Also used : FileException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException) File(org.pentaho.di.plugins.fileopensave.api.providers.File) InvalidFileProviderException(org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileProviderException) FileExistsException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileExistsException)

Example 3 with InvalidFileProviderException

use of org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileProviderException 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);
}
Also used : FileException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException) FileProvider(org.pentaho.di.plugins.fileopensave.api.providers.FileProvider) File(org.pentaho.di.plugins.fileopensave.api.providers.File) InvalidFileProviderException(org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileProviderException)

Example 4 with InvalidFileProviderException

use of org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileProviderException 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;
    }
}
Also used : FileException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException) File(org.pentaho.di.plugins.fileopensave.api.providers.File) InvalidFileProviderException(org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileProviderException)

Example 5 with InvalidFileProviderException

use of org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileProviderException 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);
}
Also used : FileException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException) FileProvider(org.pentaho.di.plugins.fileopensave.api.providers.FileProvider) File(org.pentaho.di.plugins.fileopensave.api.providers.File) InvalidFileProviderException(org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileProviderException)

Aggregations

InvalidFileProviderException (org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileProviderException)6 File (org.pentaho.di.plugins.fileopensave.api.providers.File)5 FileException (org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException)5 FileProvider (org.pentaho.di.plugins.fileopensave.api.providers.FileProvider)3 KettleException (org.pentaho.di.core.exception.KettleException)1 FileExistsException (org.pentaho.di.plugins.fileopensave.api.providers.exception.FileExistsException)1 FileOpenSaveDialog (org.pentaho.di.plugins.fileopensave.dialog.FileOpenSaveDialog)1 LocalFileProvider (org.pentaho.di.plugins.fileopensave.providers.local.LocalFileProvider)1 RepositoryFileProvider (org.pentaho.di.plugins.fileopensave.providers.repository.RepositoryFileProvider)1 VFSFileProvider (org.pentaho.di.plugins.fileopensave.providers.vfs.VFSFileProvider)1 FileDialogOperation (org.pentaho.di.ui.core.FileDialogOperation)1