Search in sources :

Example 1 with VFSFile

use of org.pentaho.di.plugins.fileopensave.providers.vfs.model.VFSFile in project pentaho-kettle by pentaho.

the class VFSFileProvider method getRoot.

/**
 * @param file
 * @return
 */
private List<VFSFile> getRoot(VFSFile file) throws FileException {
    if (this.roots.containsKey(file.getConnection())) {
        return this.roots.get(file.getConnection());
    }
    List<VFSFile> files = new ArrayList<>();
    VFSConnectionDetails vfsConnectionDetails = (VFSConnectionDetails) ConnectionManager.getInstance().getConnectionDetails(file.getConnection());
    @SuppressWarnings("unchecked") VFSConnectionProvider<VFSConnectionDetails> vfsConnectionProvider = (VFSConnectionProvider<VFSConnectionDetails>) ConnectionManager.getInstance().getConnectionProvider(vfsConnectionDetails.getType());
    List<VFSRoot> vfsRoots = vfsConnectionProvider.getLocations(vfsConnectionDetails);
    if (vfsRoots.isEmpty()) {
        throw new FileNotFoundException(file.getPath(), file.getProvider());
    }
    String scheme = vfsConnectionProvider.getProtocol(vfsConnectionDetails);
    for (VFSRoot root : vfsRoots) {
        VFSDirectory vfsDirectory = new VFSDirectory();
        vfsDirectory.setName(root.getName());
        vfsDirectory.setDate(root.getModifiedDate());
        vfsDirectory.setHasChildren(true);
        vfsDirectory.setCanAddChildren(true);
        vfsDirectory.setParent(scheme + "://");
        vfsDirectory.setDomain(vfsConnectionDetails.getDomain());
        vfsDirectory.setConnection(vfsConnectionDetails.getName());
        vfsDirectory.setPath(scheme + "://" + root.getName());
        vfsDirectory.setRoot(NAME);
        files.add(vfsDirectory);
    }
    this.roots.put(file.getConnection(), files);
    return files;
}
Also used : VFSFile(org.pentaho.di.plugins.fileopensave.providers.vfs.model.VFSFile) VFSDirectory(org.pentaho.di.plugins.fileopensave.providers.vfs.model.VFSDirectory) VFSConnectionProvider(org.pentaho.di.connections.vfs.VFSConnectionProvider) VFSRoot(org.pentaho.di.connections.vfs.VFSRoot) ArrayList(java.util.ArrayList) FileNotFoundException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileNotFoundException) VFSConnectionDetails(org.pentaho.di.connections.vfs.VFSConnectionDetails)

Example 2 with VFSFile

use of org.pentaho.di.plugins.fileopensave.providers.vfs.model.VFSFile in project pentaho-kettle by pentaho.

the class VFSFileProvider method getParent.

/**
 * @param file
 * @return
 */
@Override
public VFSFile getParent(VFSFile file) {
    VFSFile vfsFile = new VFSFile();
    vfsFile.setConnection(file.getConnection());
    vfsFile.setPath(file.getParent());
    return vfsFile;
}
Also used : VFSFile(org.pentaho.di.plugins.fileopensave.providers.vfs.model.VFSFile)

Example 3 with VFSFile

use of org.pentaho.di.plugins.fileopensave.providers.vfs.model.VFSFile in project pentaho-kettle by pentaho.

the class VFSFileProvider method isSame.

/**
 * @param file1
 * @param file2
 * @return
 */
@Override
public boolean isSame(org.pentaho.di.plugins.fileopensave.api.providers.File file1, org.pentaho.di.plugins.fileopensave.api.providers.File file2) {
    if (file1 instanceof VFSFile && file2 instanceof VFSFile) {
        VFSFile vfsFile1 = (VFSFile) file1;
        VFSFile vfsFile2 = (VFSFile) file2;
        return vfsFile1.getConnection().equals(vfsFile2.getConnection());
    }
    return false;
}
Also used : VFSFile(org.pentaho.di.plugins.fileopensave.providers.vfs.model.VFSFile)

Aggregations

VFSFile (org.pentaho.di.plugins.fileopensave.providers.vfs.model.VFSFile)3 ArrayList (java.util.ArrayList)1 VFSConnectionDetails (org.pentaho.di.connections.vfs.VFSConnectionDetails)1 VFSConnectionProvider (org.pentaho.di.connections.vfs.VFSConnectionProvider)1 VFSRoot (org.pentaho.di.connections.vfs.VFSRoot)1 FileNotFoundException (org.pentaho.di.plugins.fileopensave.api.providers.exception.FileNotFoundException)1 VFSDirectory (org.pentaho.di.plugins.fileopensave.providers.vfs.model.VFSDirectory)1