2525import org .labkey .api .util .Path ;
2626import org .labkey .api .util .logging .LogHelper ;
2727import org .labkey .studies .query .StudiesTableCustomizer ;
28+ import org .labkey .vfs .FileLike ;
2829
2930import java .io .FileNotFoundException ;
3031import java .io .IOException ;
3132import java .io .InputStream ;
3233import java .io .OutputStream ;
33- import java .nio .file .Files ;
3434import java .sql .SQLException ;
3535import java .util .HashMap ;
3636import 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