use of org.knime.core.internal.ReferencedFile in project knime-core by knime.
the class NativeNodeContainer method pushNodeDropDirURLsOntoStack.
/**
* Support old-style drop dir mechanism - replaced since 2.8 with relative mountpoints,
* e.g. knime://knime.workflow
*/
private void pushNodeDropDirURLsOntoStack(final FlowObjectStack st) {
ReferencedFile refDir = getNodeContainerDirectory();
ReferencedFile dropFolder = refDir == null ? null : new ReferencedFile(refDir, DROP_DIR_NAME);
if (dropFolder == null) {
return;
}
dropFolder.lock();
try {
File directory = dropFolder.getFile();
if (!directory.exists()) {
return;
}
String[] files = directory.list();
if (files != null) {
StringBuilder debug = new StringBuilder("Found " + files.length + " node local file(s) to " + getNameWithID() + ": ");
debug.append(Arrays.toString(Arrays.copyOf(files, Math.max(3, files.length))));
for (String f : files) {
File child = new File(directory, f);
try {
st.push(new FlowVariable(Scope.Local.getPrefix() + "(drop) " + f, // child.getAbsolutePath(), Scope.Local));
child.toURI().toURL().toString(), Scope.Local));
// } catch (Exception mue) {
} catch (MalformedURLException mue) {
LOGGER.warn("Unable to process drop file", mue);
}
}
}
} finally {
dropFolder.unlock();
}
}
use of org.knime.core.internal.ReferencedFile in project knime-core by knime.
the class FileWorkflowPersistor method loadNodeFile.
ReferencedFile loadNodeFile(final NodeSettingsRO settings, final ReferencedFile workflowDirRef) throws InvalidSettingsException {
String fileString = settings.getString("node_settings_file");
if (fileString == null) {
throw new InvalidSettingsException("Unable to read settings " + "file for node " + settings.getKey());
}
File workflowDir = workflowDirRef.getFile();
// fileString is something like "File Reader(#1)/settings.xml", thus
// it contains two levels of the hierarchy. We leave it here to the
// java.io.File implementation to resolve these levels
File fullFile = new File(workflowDir, fileString);
if (!fullFile.isFile() || !fullFile.canRead()) {
throw new InvalidSettingsException("Unable to read settings " + "file " + fullFile.getAbsolutePath());
}
Stack<String> children = new Stack<String>();
File workflowDirAbsolute = workflowDir.getAbsoluteFile();
while (!fullFile.getAbsoluteFile().equals(workflowDirAbsolute)) {
children.push(fullFile.getName());
fullFile = fullFile.getParentFile();
}
// create a ReferencedFile hierarchy for the settings file
ReferencedFile result = workflowDirRef;
while (!children.empty()) {
result = new ReferencedFile(result, children.pop());
}
return result;
}
use of org.knime.core.internal.ReferencedFile in project knime-core by knime.
the class NodeContainer method unsetDirty.
/**
* Called from persistor when node has been saved.
*/
void unsetDirty() {
final ReferencedFile ncDirectory = getNodeContainerDirectory();
assert ncDirectory != null : "NC directory must not be null at this point";
ncDirectory.setDirty(false);
getChangesTracker().ifPresent(ct -> ct.clearChanges());
}
Aggregations