Skip to content

Commit 101e33f

Browse files
More FileLike
1 parent d64a27e commit 101e33f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Studies/src/org/labkey/studies/StudiesServiceImpl.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
import org.labkey.api.util.Path;
2626
import org.labkey.api.util.logging.LogHelper;
2727
import org.labkey.studies.query.StudiesTableCustomizer;
28+
import org.labkey.vfs.FileLike;
2829

2930
import java.io.FileNotFoundException;
3031
import java.io.IOException;
3132
import java.io.InputStream;
3233
import java.io.OutputStream;
33-
import java.nio.file.Files;
3434
import java.sql.SQLException;
3535
import java.util.HashMap;
3636
import java.util.List;
@@ -56,28 +56,28 @@ public void importFolderDefinition(Container container, User user, Module m, Pat
5656
{
5757
Resource root = m.getModuleResource(sourceFolderDirPath);
5858
PipeRoot pipeRoot = PipelineService.get().findPipelineRoot(container);
59-
java.nio.file.Path pipeRootPath = pipeRoot.getRootNioPath();
59+
FileLike pipeRootPath = pipeRoot.getRootFileLike();
6060

61-
java.nio.file.Path folderXmlPath;
61+
FileLike folderXmlPath;
6262

63-
if (root instanceof DirectoryResource && ((DirectoryResource)root).getDir().equals(pipeRootPath.toFile()))
63+
if (root instanceof DirectoryResource dir && dir.getDir().equals(pipeRootPath.toNioPathForRead().toFile()))
6464
{
6565
// The pipeline root is already pointed at the folder definition, like it might be on a dev machine.
6666
// No need to copy, especially since copying can cause infinite recursion when the paths are nested
67-
folderXmlPath = pipeRootPath.resolve("folder.xml");
67+
folderXmlPath = pipeRootPath.resolveChild("folder.xml");
6868
}
6969
else
7070
{
71-
java.nio.file.Path folderPath = pipeRootPath.resolve("moduleFolderImport");
72-
folderXmlPath = folderPath.resolve("folder.xml");
73-
if (Files.exists(folderPath))
71+
FileLike folderPath = pipeRootPath.resolveChild("moduleFolderImport");
72+
folderXmlPath = folderPath.resolveChild("folder.xml");
73+
if (folderPath.exists())
7474
{
7575
FileUtil.deleteDir(folderPath);
7676
}
7777
copyResourceToPath(root, folderPath);
7878
}
7979

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

90-
private void copyResourceToPath(Resource resource, java.nio.file.Path target) throws IOException
90+
private void copyResourceToPath(Resource resource, FileLike target) throws IOException
9191
{
9292
if (resource.isCollection())
9393
{
94-
Files.createDirectory(target);
94+
FileUtil.createDirectory(target);
9595
for (Resource child : resource.list())
9696
{
97-
java.nio.file.Path childTarget = target.resolve(child.getName());
97+
FileLike childTarget = target.resolveChild(child.getName());
9898
copyResourceToPath(child, childTarget);
9999
}
100100
}
101101
else
102102
{
103103
try (InputStream in = resource.getInputStream();
104-
OutputStream out = Files.newOutputStream(target))
104+
OutputStream out = target.openOutputStream())
105105
{
106106
FileUtil.copyData(in, out);
107107
}

0 commit comments

Comments
 (0)