Search in sources :

Example 21 with URIContent

use of org.knime.core.data.uri.URIContent 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) };
}
Also used : URIPortObject(org.knime.core.data.uri.URIPortObject) IURIPortObject(org.knime.core.data.uri.IURIPortObject) ArrayList(java.util.ArrayList) ZipFile(java.util.zip.ZipFile) File(java.io.File) URIPortObject(org.knime.core.data.uri.URIPortObject) IURIPortObject(org.knime.core.data.uri.IURIPortObject) PortObject(org.knime.core.node.port.PortObject) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) URIContent(org.knime.core.data.uri.URIContent)

Aggregations

URIContent (org.knime.core.data.uri.URIContent)21 File (java.io.File)13 ArrayList (java.util.ArrayList)13 IURIPortObject (org.knime.core.data.uri.IURIPortObject)13 IOException (java.io.IOException)11 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)10 URIPortObject (org.knime.core.data.uri.URIPortObject)6 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)6 PortObject (org.knime.core.node.port.PortObject)6 URI (java.net.URI)5 BufferedDataTable (org.knime.core.node.BufferedDataTable)4 FileStoreURIPortObject (com.genericworkflownodes.knime.base.data.port.FileStoreURIPortObject)3 IPrefixURIPortObject (com.genericworkflownodes.knime.base.data.port.IPrefixURIPortObject)2 PortObjectHandlerCell (com.genericworkflownodes.knime.base.data.port.PortObjectHandlerCell)2 NoBinaryAvailableException (com.genericworkflownodes.knime.custom.config.NoBinaryAvailableException)2 UnknownCommandGeneratorException (com.genericworkflownodes.knime.execution.UnknownCommandGeneratorException)2 UnknownToolExecutorException (com.genericworkflownodes.knime.execution.UnknownToolExecutorException)2 FileParameter (com.genericworkflownodes.knime.parameter.FileParameter)2 IFileParameter (com.genericworkflownodes.knime.parameter.IFileParameter)2 InvalidParameterValueException (com.genericworkflownodes.knime.parameter.InvalidParameterValueException)2