Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions flow/enginesrc/org/labkey/flow/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.labkey.flow.persist.AnalysisSerializer;
import org.labkey.flow.persist.AttributeSet;
import org.labkey.flow.persist.ObjectType;
import org.labkey.vfs.FileLike;
import org.w3c.dom.Document;

import javax.xml.transform.OutputKeys;
Expand All @@ -51,6 +52,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
Expand Down Expand Up @@ -383,7 +385,7 @@ private static ExternalAnalysis readTsvAnalysisResults(File analysisResultsFile,
if (analysisResultsFile.getName().endsWith(".zip"))
{
// NOTE: Duplicated code in AnalysisScriptController
File statisticsFile;
FileLike statisticsFile;
java.util.zip.ZipFile zipFile;
try
{
Expand All @@ -409,12 +411,13 @@ private static ExternalAnalysis readTsvAnalysisResults(File analysisResultsFile,
// UNDONE: instead of unzipping into temp dir, make zip VirtualFile impl readable.
try
{
File tmpDir = FileUtil.createTempDirectory("flow").toFile();
tmpDir.deleteOnExit();
FileLike tmpDirFileLike = FileUtil.createTempDirectoryFileLike("flow");
Path tmpDirFilePath = tmpDirFileLike.toNioPathForWrite();
tmpDirFilePath.toFile().deleteOnExit();

ZipUtil.unzipToDirectory(analysisResultsFile, tmpDir);
statisticsFile = new File(tmpDir, zipEntry.getName());
rootDir = new FileSystemFile(statisticsFile.getParentFile());
ZipUtil.unzipToDirectory(analysisResultsFile.toPath(), tmpDirFilePath);
statisticsFile = tmpDirFileLike.resolveChild(zipEntry.getName());
rootDir = new FileSystemFile(statisticsFile.getParent().toNioPathForRead());
}
catch (IOException ioe)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.labkey.api.util.DateUtil;
import org.labkey.api.util.JunitUtil;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.XmlBeansUtil;
import org.labkey.flow.analysis.data.NumberArray;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Expand All @@ -32,7 +33,6 @@

import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
Expand Down Expand Up @@ -131,9 +131,7 @@ public CompensationMatrix(InputStream is) throws Exception
public CompensationMatrix(String name, String str) throws Exception
{
this(name);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true);
DocumentBuilder db = dbf.newDocumentBuilder();
DocumentBuilder db = XmlBeansUtil.DOCUMENT_BUILDER_FACTORY.newDocumentBuilder();
try (var rdr = new StringReader(str))
{
Document doc = db.parse(new InputSource(rdr));
Expand Down Expand Up @@ -556,7 +554,7 @@ public Document toXML()
Document doc;
try
{
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
doc = XmlBeansUtil.DOCUMENT_BUILDER_FACTORY.newDocumentBuilder().newDocument();
}
catch (ParserConfigurationException e)
{
Expand Down
16 changes: 9 additions & 7 deletions flow/enginesrc/org/labkey/flow/persist/AnalysisSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.labkey.flow.analysis.web.GraphSpec;
import org.labkey.flow.analysis.web.StatisticSpec;
import org.labkey.flow.analysis.web.SubsetSpec;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -253,7 +254,7 @@ public void error(String msg, Throwable t)
}
}

public static File extractArchive(File file, File tempDir)
public static File extractArchive(File file, FileLike tempDir)
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method signature is inconsistent - it accepts a File parameter but returns a File while using FileLike for tempDir. Consider updating the return type to FileLike or the input parameter to FileLike for API consistency.

Copilot uses AI. Check for mistakes.
throws IOException
{
File statisticsFile = null;
Expand All @@ -271,13 +272,13 @@ else if (file.getName().endsWith(".zip"))

ZipFile zipFile = new ZipFile(file);

File importDir;
FileLike importDir;
String zipBaseName = FileUtil.getBaseName(file);
ZipEntry zipEntry = zipFile.getEntry(AnalysisSerializer.STATISTICS_FILENAME);
if (zipEntry != null)
{
// Create extra directory under tempDir to extract into.
importDir = new File(tempDir, zipBaseName);
importDir = tempDir.resolveChild(zipBaseName);
}
else
{
Expand All @@ -288,12 +289,13 @@ else if (file.getName().endsWith(".zip"))
if (zipEntry == null)
throw new IOException("Couldn't find '" + AnalysisSerializer.STATISTICS_FILENAME + "' or '" + zipBaseName + "/" + AnalysisSerializer.STATISTICS_FILENAME + "' in the zip archive.");

//File importDir = File.createTempFile(zipBaseName, null, tempDir);
if (importDir.exists() && !FileUtil.deleteDir(importDir))
if (importDir.exists() && !FileUtil.deleteDir(importDir.toNioPathForWrite()))
throw new IOException("Could not delete the directory \"" + importDir + "\"");

ZipUtil.unzipToDirectory(file, importDir);
statisticsFile = new File(importDir, zipEntry.getName());
ZipUtil.unzipToDirectory(file.toPath(), importDir.toNioPathForWrite());
FileLike statisticsFileLike = importDir.resolveChild(zipEntry.getName());
if (statisticsFileLike.exists())
statisticsFile = statisticsFileLike.toNioPathForRead().toFile();
}

if (statisticsFile == null)
Expand Down
5 changes: 3 additions & 2 deletions flow/src/org/labkey/flow/controllers/WorkspaceData.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.labkey.flow.data.FlowProtocol;
import org.labkey.flow.persist.AnalysisSerializer;
import org.labkey.flow.persist.AttributeCache;
import org.labkey.vfs.FileLike;
import org.springframework.validation.Errors;

import java.io.File;
Expand Down Expand Up @@ -206,8 +207,8 @@ public void validate(User user, Container container, Errors errors) throws Excep
else if (path.endsWith(".zip"))
{
// Extract external analysis zip into pipeline
File tempDir = pipeRoot.resolvePath(PipelineService.UNZIP_DIR);
if (tempDir.exists() && !FileUtil.deleteDir(tempDir))
FileLike tempDir = pipeRoot.resolvePathToFileLike(PipelineService.UNZIP_DIR);
if (tempDir != null && tempDir.exists() && !FileUtil.deleteDir(tempDir.toNioPathForWrite()))
throw new IOException("Failed to delete temp directory");

String originalPath = path;
Expand Down
6 changes: 2 additions & 4 deletions protein/src/org/labkey/protein/ProteinServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.labkey.api.security.User;
import org.labkey.api.util.DeadlockPreventingException;
import org.labkey.api.util.HtmlString;
import org.labkey.api.util.XmlBeansUtil;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.api.view.ActionURL;
import org.labkey.api.view.JspView;
Expand All @@ -60,7 +61,6 @@
import org.xml.sax.SAXException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.BufferedReader;
import java.io.IOException;
Expand Down Expand Up @@ -314,9 +314,7 @@ public List<ProteinFeature> load(@NotNull String accession, @Nullable Object arg
}
}

DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
DocumentBuilder db = XmlBeansUtil.DOCUMENT_BUILDER_FACTORY.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(response.toString()));

Expand Down