diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryController.java b/laboratory/src/org/labkey/laboratory/LaboratoryController.java index 31dedddc..0f85b4fe 100644 --- a/laboratory/src/org/labkey/laboratory/LaboratoryController.java +++ b/laboratory/src/org/labkey/laboratory/LaboratoryController.java @@ -89,6 +89,7 @@ import org.labkey.api.view.template.ClientDependency; import org.labkey.laboratory.assay.AssayHelper; import org.labkey.laboratory.query.WorkbookModel; +import org.labkey.vfs.FileLike; import org.springframework.validation.BindException; import org.springframework.validation.Errors; import org.springframework.web.servlet.ModelAndView; @@ -620,8 +621,8 @@ protected File getTargetFile(String filename) throws IOException try { - File targetDirectory = AssayFileWriter.ensureUploadDirectory(getContainer()); - return AssayFileWriter.findUniqueFileName(filename, targetDirectory); + FileLike targetDirectory = AssayFileWriter.ensureUploadDirectory(getContainer()); + return AssayFileWriter.findUniqueFileName(filename, targetDirectory).toNioPathForWrite().toFile(); } catch (ExperimentException e) { diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryServiceImpl.java b/laboratory/src/org/labkey/laboratory/LaboratoryServiceImpl.java index 731216b4..6e55124b 100644 --- a/laboratory/src/org/labkey/laboratory/LaboratoryServiceImpl.java +++ b/laboratory/src/org/labkey/laboratory/LaboratoryServiceImpl.java @@ -56,6 +56,7 @@ import org.labkey.laboratory.assay.AssayHelper; import org.labkey.laboratory.query.DefaultAssayCustomizer; import org.labkey.laboratory.query.LaboratoryTableCustomizer; +import org.labkey.vfs.FileLike; import java.io.File; import java.lang.reflect.InvocationTargetException; @@ -197,10 +198,10 @@ public Pair saveAssayBatch(List> resu try { - File targetDirectory = AssayFileWriter.ensureUploadDirectory(ctx.getContainer()); - File file = AssayFileWriter.findUniqueFileName(basename, targetDirectory); + FileLike targetDirectory = AssayFileWriter.ensureUploadDirectory(ctx.getContainer()); + FileLike file = AssayFileWriter.findUniqueFileName(basename, targetDirectory); - return this.saveAssayBatch(results, json, file, ctx, provider, protocol); + return this.saveAssayBatch(results, json, file.toNioPathForRead().toFile(), ctx, provider, protocol); } catch (ExperimentException e) { diff --git a/laboratory/src/org/labkey/laboratory/assay/AssayHelper.java b/laboratory/src/org/labkey/laboratory/assay/AssayHelper.java index 11367e31..528fe33a 100644 --- a/laboratory/src/org/labkey/laboratory/assay/AssayHelper.java +++ b/laboratory/src/org/labkey/laboratory/assay/AssayHelper.java @@ -29,6 +29,7 @@ import org.labkey.api.assay.AssayService; import org.labkey.api.cache.CacheManager; import org.labkey.api.collections.CaseInsensitiveHashMap; +import org.labkey.api.collections.CollectionUtils; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.RuntimeSQLException; @@ -58,6 +59,8 @@ import org.labkey.api.view.ViewContext; import org.labkey.laboratory.LaboratoryController; import org.labkey.laboratory.LaboratorySchema; +import org.labkey.vfs.FileLike; +import org.labkey.vfs.FileSystemLike; import java.beans.Introspector; import java.io.File; @@ -88,9 +91,8 @@ public static AssayHelper get() return _instance; } - public Map saveResultsFile(List> results, JSONObject json, File file, AssayProvider provider, ExpProtocol protocol) throws ExperimentException, ValidationException + public Map saveResultsFile(List> results, JSONObject json, File file, AssayProvider provider, ExpProtocol protocol) throws ExperimentException, ValidationException { - Map files = new HashMap(); //TODO: consider adding as input?? //files.put("RawInput", file); @@ -111,8 +113,8 @@ public Map saveResultsFile(List> results, JSON throw new ExperimentException(e.getMessage()); } - files.put(AssayDataCollector.PRIMARY_FILE, newFile); - + Map files = CollectionUtils.enforceValueClass(new HashMap<>(),FileLike.class); + files.put(AssayDataCollector.PRIMARY_FILE, FileSystemLike.wrapFile(newFile)); return files; } @@ -209,7 +211,7 @@ public Pair saveAssayBatch(List> resu }); } - Map uploadedFiles = saveResultsFile(results, json, file, provider, protocol); + Map uploadedFiles = saveResultsFile(results, json, file, provider, protocol); //TODO: see AssayRunAsyncContext AssayRunUploadContext uploadContext = new RunUploadContext<>(protocol, provider, name, comments, runProperties, batchProperties, ctx, uploadedFiles); @@ -243,10 +245,10 @@ private File getUniqueOutputName(File input, String extension) File parent = input.getParentFile(); String basename = FileUtil.getBaseName(input); int suffix = 1; - File newFile = new File(parent, basename + "." + extension); + File newFile = FileUtil.appendName(parent, basename + "." + extension); while (newFile.exists()) { - newFile = new File(parent, basename + "-" + suffix + "." + extension); + newFile = FileUtil.appendName(parent, basename + "-" + suffix + "." + extension); suffix++; } return newFile; diff --git a/laboratory/src/org/labkey/laboratory/assay/RunUploadContext.java b/laboratory/src/org/labkey/laboratory/assay/RunUploadContext.java index cc1dbc73..4ce1f0d5 100644 --- a/laboratory/src/org/labkey/laboratory/assay/RunUploadContext.java +++ b/laboratory/src/org/labkey/laboratory/assay/RunUploadContext.java @@ -22,6 +22,7 @@ import org.labkey.api.assay.AssayRunUploadContext; import org.labkey.api.assay.AssayService; import org.labkey.api.collections.CaseInsensitiveHashMap; +import org.labkey.api.collections.CollectionUtils; import org.labkey.api.data.Container; import org.labkey.api.exp.ExperimentException; import org.labkey.api.exp.api.ExpProtocol; @@ -32,8 +33,8 @@ import org.labkey.api.security.User; import org.labkey.api.view.ActionURL; import org.labkey.api.view.ViewContext; +import org.labkey.vfs.FileLike; -import java.io.File; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -53,9 +54,9 @@ public class RunUploadContext implements Ass private final ViewContext _ctx; private TransformResult _transformResult; - private final Map _uploadedData; + private final Map _uploadedData; - public RunUploadContext(ExpProtocol protocol, ProviderType providerType, String name, String comments, Map runProperties, Map batchProperties, ViewContext ctx, Map uploadedData) + public RunUploadContext(ExpProtocol protocol, ProviderType providerType, String name, String comments, Map runProperties, Map batchProperties, ViewContext ctx, Map uploadedData) { _protocol = protocol; _providerType = providerType; @@ -64,7 +65,8 @@ public RunUploadContext(ExpProtocol protocol, ProviderType providerType, String _runProperties = new CaseInsensitiveHashMap<>(runProperties); _batchProperties = new CaseInsensitiveHashMap<>(batchProperties); _ctx = ctx; - _uploadedData = uploadedData; + _uploadedData = CollectionUtils.checkValueClass(uploadedData, FileLike.class); + CollectionUtils.checkValueClass(_uploadedData, FileLike.class); } @Override @@ -154,7 +156,7 @@ public ActionURL getActionURL() @Override @NotNull - public Map getUploadedData() throws ExperimentException + public Map getUploadedData() throws ExperimentException { return _uploadedData; }