Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,9 @@ protected void addCustomParams(JSONObject params)
params.put("labkeyFolderPath", getContainer().isWorkbook() ? getContainer().getParent().getPath() : getContainer().getPath());
}

private Path _getLogFile()
private FileLike _getLogFile()
{
var file = FileUtil.findUniqueFileName((FileUtil.makeLegalName(_jobName) + ".log"), getDataDirectoryFileObject());
return file.toNioPathForWrite();
return FileUtil.findUniqueFileName((FileUtil.makeLegalName(_jobName) + ".log"), getDataDirectoryFileObject());
}

@Override
Expand Down Expand Up @@ -342,9 +341,9 @@ public String getBaseNameForFileType(FileType fileType)
}

@Override
public File getDataDirectory()
public FileLike getDataDirectoryFileLike()
{
return _webserverJobDir.toNioPathForWrite().toFile();
return _webserverJobDir;
}

public FileLike getDataDirectoryFileObject()
Expand Down Expand Up @@ -397,13 +396,6 @@ public File getParametersFile()
return FileUtil.appendName(dir.toNioPathForWrite().toFile(),_folderPrefix + ".json");
}

@Nullable
@Override
public File getJobInfoFile()
{
return FileUtil.appendName(_webserverJobDir.toNioPathForWrite().toFile(), FileUtil.makeLegalName(_jobName) + ".job.json");
}

@Override
public FileType.gzSupportLevel getGZPreference()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import org.labkey.api.writer.PrintWriters;
import org.labkey.sequenceanalysis.util.ScatterGatherUtils;
import org.labkey.sequenceanalysis.util.SequenceUtil;
import org.labkey.vfs.FileLike;
import org.labkey.vfs.FileSystemLike;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -408,9 +410,9 @@ public void intervalSerializeTest() throws Exception
{
VariantProcessingJob job1 = new VariantProcessingJob(){
@Override
public File getDataDirectory()
public FileLike getDataDirectoryFileLike()
{
return new File(System.getProperty("java.io.tmpdir"));
return FileSystemLike.wrapFile(new File(System.getProperty("java.io.tmpdir")));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.labkey.api.util.FileUtil;
import org.labkey.remoteapi.CommandException;
import org.labkey.remoteapi.Connection;
import org.labkey.remoteapi.query.Filter;
Expand Down Expand Up @@ -295,13 +296,22 @@ private void createIlluminaSampleSheet()
assertTextPresent(fileSearcher, prop_name + "," + prop_value);

File fileRoot = TestFileUtils.getDefaultFileRoot(getProjectName());
File importTemplate = new File(fileRoot, ILLUMINA_CSV);
File importTemplate = FileUtil.appendName(fileRoot, ILLUMINA_CSV);
if (importTemplate.exists())
importTemplate.delete();


//NOTE: use the text generated directly using JS
TestFileUtils.saveFile(importTemplate.getParentFile(), importTemplate.getName(), outputTable);
File tsvFile = FileUtil.appendName(importTemplate.getParentFile(), importTemplate.getName());

try
{
TestFileUtils.writeFile(tsvFile, outputTable);
}
catch (IOException e)
{
e.printStackTrace(System.err);
}
goToProjectHome();
}

Expand Down Expand Up @@ -330,7 +340,7 @@ private void importIlluminaTest() throws Exception
File fileRoot = TestFileUtils.getDefaultFileRoot(getProjectName());
for (String fn : Arrays.asList("Illumina-F.fastq.gz", "Illumina-R.fastq.gz", "SkipMe.fastq.gz"))
{
File target = new File(fileRoot, fn);
File target = FileUtil.appendName(fileRoot, fn);
if (target.exists())
{
target.delete();
Expand Down Expand Up @@ -749,7 +759,7 @@ private void alignmentImportPanelTest(boolean sequencePipelineEnabled) throws Ex
File fileRoot = TestFileUtils.getDefaultFileRoot(getProjectName());
log("file root: " + fileRoot.getPath());

File inputBam = new File(fileRoot, "test.bam");
File inputBam = FileUtil.appendName(fileRoot, "test.bam");
File inputBamIdx = new File(inputBam.getPath() + ".bai");
if (inputBam.exists())
{
Expand All @@ -763,8 +773,8 @@ private void alignmentImportPanelTest(boolean sequencePipelineEnabled) throws Ex
inputBamIdx.delete();
}

FileUtils.copyFile(new File(_sampleData, "test.bam"), inputBam);
FileUtils.copyFile(new File(_sampleData, "test.bam.bai"), inputBamIdx);
FileUtils.copyFile(FileUtil.appendName(_sampleData, "test.bam"), inputBam);
FileUtils.copyFile(FileUtil.appendName(_sampleData, "test.bam.bai"), inputBamIdx);

_helper.initiatePipelineJob(_alignmentImportPipelineName, List.of(inputBam.getName()), getProjectName());
waitForText("Job Name");
Expand Down
26 changes: 13 additions & 13 deletions Studies/src/org/labkey/studies/StudiesServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import org.labkey.api.util.Path;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.studies.query.StudiesTableCustomizer;
import org.labkey.vfs.FileLike;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
Expand All @@ -56,28 +56,28 @@ public void importFolderDefinition(Container container, User user, Module m, Pat
{
Resource root = m.getModuleResource(sourceFolderDirPath);
PipeRoot pipeRoot = PipelineService.get().findPipelineRoot(container);
java.nio.file.Path pipeRootPath = pipeRoot.getRootNioPath();
FileLike pipeRootPath = pipeRoot.getRootFileLike();

java.nio.file.Path folderXmlPath;
FileLike folderXmlPath;

if (root instanceof DirectoryResource && ((DirectoryResource)root).getDir().equals(pipeRootPath.toFile()))
if (root instanceof DirectoryResource dir && dir.getDir().equals(pipeRootPath.toNioPathForRead().toFile()))
{
// The pipeline root is already pointed at the folder definition, like it might be on a dev machine.
// No need to copy, especially since copying can cause infinite recursion when the paths are nested
folderXmlPath = pipeRootPath.resolve("folder.xml");
folderXmlPath = pipeRootPath.resolveChild("folder.xml");
}
else
{
java.nio.file.Path folderPath = pipeRootPath.resolve("moduleFolderImport");
folderXmlPath = folderPath.resolve("folder.xml");
if (Files.exists(folderPath))
FileLike folderPath = pipeRootPath.resolveChild("moduleFolderImport");
folderXmlPath = folderPath.resolveChild("folder.xml");
if (folderPath.exists())
{
FileUtil.deleteDir(folderPath);
}
copyResourceToPath(root, folderPath);
}

if (!Files.exists(folderXmlPath))
if (!folderXmlPath.exists())
{
throw new FileNotFoundException("Couldn't find an extracted " + folderXmlPath);
}
Expand All @@ -87,21 +87,21 @@ public void importFolderDefinition(Container container, User user, Module m, Pat
PipelineService.get().runFolderImportJob(container, user, null, folderXmlPath, "folder.xml", pipeRoot, options);
}

private void copyResourceToPath(Resource resource, java.nio.file.Path target) throws IOException
private void copyResourceToPath(Resource resource, FileLike target) throws IOException
{
if (resource.isCollection())
{
Files.createDirectory(target);
FileUtil.createDirectory(target);
for (Resource child : resource.list())
{
java.nio.file.Path childTarget = target.resolve(child.getName());
FileLike childTarget = target.resolveChild(child.getName());
copyResourceToPath(child, childTarget);
}
}
else
{
try (InputStream in = resource.getInputStream();
OutputStream out = Files.newOutputStream(target))
OutputStream out = target.openOutputStream())
{
FileUtil.copyData(in, out);
}
Expand Down