use of org.knime.core.data.uri.URIPortObject in project GenericKnimeNodes by genericworkflownodes.
the class MimeDirectoryImporterNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
// Create connection monitor
final ConnectionMonitor<? extends Connection> monitor = new ConnectionMonitor<>();
// Create output URI container
final List<URIContent> uris = new ArrayList<URIContent>();
try {
URI directoryUri;
if (m_connectionInformation != null) {
exec.setProgress("Connecting to " + m_connectionInformation.toURI());
// Generate URI to the directory
directoryUri = new URI(m_connectionInformation.toURI().toString() + NodeUtils.encodePath(m_configuration.getDirectory()));
} else {
// Create local URI
directoryUri = new File(m_configuration.getDirectory()).toURI();
}
// Create remote file for directory selection
final RemoteFile<? extends Connection> file = RemoteFileFactory.createRemoteFile(directoryUri, m_connectionInformation, monitor);
// List the selected directory
exec.setProgress("Retrieving list of files");
listDirectory(file, uris, true, exec, new MutableInteger(0), new MutableInteger(0));
} finally {
// Close connections
monitor.closeAll();
}
return new PortObject[] { new URIPortObject(uris) };
}
use of org.knime.core.data.uri.URIPortObject in project GenericKnimeNodes by genericworkflownodes.
the class MimeFileImporterNodeModel method execute.
@Override
protected PortObject[] execute(PortObject[] inObjects, ExecutionContext exec) throws Exception {
File file = new File(convertToURL(m_filename).toURI());
if (!file.exists()) {
throw new Exception("File does not exist: " + file.getAbsolutePath());
}
List<URIContent> uris = new ArrayList<URIContent>();
uris.add(new URIContent(file.toURI(), (m_file_extension.isActive() ? m_file_extension.getStringValue() : MIMETypeHelper.getMIMEtypeExtension(file.getAbsolutePath()))));
data = Helper.readFileSummary(file, 50);
return new PortObject[] { new URIPortObject(uris) };
}
Aggregations