use of org.pentaho.di.connections.vfs.VFSConnectionDetails in project pentaho-kettle by pentaho.
the class ConnectionFileSystem method getUrl.
/**
* Creates a url for {@link ConnectionFileName}
*
* @param abstractFileName File name
* @param connectionDetails Connection details for the file name
* @return created url otherwise null
*/
public static String getUrl(AbstractFileName abstractFileName, ConnectionDetails connectionDetails) {
VFSConnectionDetails vfsConnectionDetails = (VFSConnectionDetails) connectionDetails;
String url = null;
if (vfsConnectionDetails != null) {
String domain = vfsConnectionDetails.getDomain();
if (!domain.equals("")) {
domain = "/" + domain;
}
url = vfsConnectionDetails.getType() + ":/" + domain + abstractFileName.getPath();
if (url.matches(DOMAIN_ROOT)) {
url += vfsConnectionDetails.getName();
}
}
return url;
}
use of org.pentaho.di.connections.vfs.VFSConnectionDetails in project pentaho-kettle by pentaho.
the class VFSFileProvider method getTree.
/**
* Filtered implementation
*
* @return Filter Tree
*/
@Override
public VFSTree getTree(List<String> connectionTypes) {
VFSTree vfsTree = new VFSTree(NAME);
List<ConnectionProvider<? extends ConnectionDetails>> providers = connectionManagerSupplier.get().getProvidersByType(VFSConnectionProvider.class);
for (ConnectionProvider<? extends ConnectionDetails> provider : providers) {
for (ConnectionDetails connectionDetails : provider.getConnectionDetails()) {
VFSConnectionDetails vfsConnectionDetails = (VFSConnectionDetails) connectionDetails;
VFSLocation vfsLocation = new VFSLocation();
vfsLocation.setName(connectionDetails.getName());
vfsLocation.setRoot(NAME);
vfsLocation.setHasChildren(true);
vfsLocation.setCanDelete(false);
vfsLocation.setPath(vfsConnectionDetails.getType() + "://" + vfsConnectionDetails.getDomain());
vfsLocation.setDomain(vfsConnectionDetails.getDomain());
vfsLocation.setConnection(connectionDetails.getName());
if (connectionTypes.isEmpty() || connectionTypes.contains(connectionDetails.getType())) {
vfsTree.addChild(vfsLocation);
}
}
}
return vfsTree;
}
use of org.pentaho.di.connections.vfs.VFSConnectionDetails 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;
}
use of org.pentaho.di.connections.vfs.VFSConnectionDetails in project pentaho-kettle by pentaho.
the class ConnectionFileSystem method createFile.
@Override
protected FileObject createFile(AbstractFileName abstractFileName) throws Exception {
String connectionName = ((ConnectionFileName) abstractFileName).getConnection();
VFSConnectionDetails connectionDetails = (VFSConnectionDetails) connectionManager.get().getConnectionDetails(connectionName);
String url = getUrl(abstractFileName, connectionDetails);
AbstractFileObject fileObject = null;
String domain = null;
if (url != null) {
domain = connectionDetails.getDomain();
Variables variables = new Variables();
variables.setVariable(CONNECTION, connectionName);
fileObject = (AbstractFileObject) KettleVFS.getFileObject(url, variables);
}
return new ConnectionFileObject(abstractFileName, this, fileObject, domain);
}
Aggregations