|
36 | 36 | import org.labkey.vfs.FileLike; |
37 | 37 | import org.labkey.vfs.FileSystemLike; |
38 | 38 |
|
39 | | -import java.io.File; |
40 | 39 | import java.io.IOException; |
41 | 40 | import java.io.InputStream; |
42 | 41 | import java.net.URI; |
43 | 42 | import java.net.URLDecoder; |
| 43 | +import java.nio.charset.StandardCharsets; |
44 | 44 | import java.nio.file.Path; |
45 | 45 | import java.time.LocalDateTime; |
46 | 46 | import java.time.format.DateTimeFormatter; |
@@ -95,7 +95,11 @@ public RecordedActionSet run() |
95 | 95 | } |
96 | 96 |
|
97 | 97 | // guaranteed to only have a single file |
98 | | - assert support.getInputFiles().size() == 1; |
| 98 | + if (support.getInputFiles().size() != 1) |
| 99 | + { |
| 100 | + log.error("Expecting a single input file but received {}", support.getInputFiles().size()); |
| 101 | + return new RecordedActionSet(); |
| 102 | + } |
99 | 103 | FileLike dataFile = support.getInputFiles().getFirst(); |
100 | 104 |
|
101 | 105 | try |
@@ -131,7 +135,14 @@ public RecordedActionSet run() |
131 | 135 | } |
132 | 136 | else |
133 | 137 | { |
134 | | - sourceFile = FileSystemLike.wrapFile(new File(dataFilePath)); |
| 138 | + Path resolvedPath = Path.of(dataFilePath).toAbsolutePath().normalize(); |
| 139 | + if (!isUnderAnyPipelineRoot(resolvedPath)) |
| 140 | + { |
| 141 | + log.error("DataFile '{}' is not under a server-managed pipeline root", dataFilePath); |
| 142 | + row.remove(INPUT_DATA_FILE); |
| 143 | + continue; |
| 144 | + } |
| 145 | + sourceFile = FileSystemLike.wrapFile(resolvedPath.toFile()); |
135 | 146 | } |
136 | 147 |
|
137 | 148 | if (!sourceFile.exists()) |
@@ -169,22 +180,19 @@ public RecordedActionSet run() |
169 | 180 | FileLike d = FileUtil.getAbsoluteCaseSensitiveFile(destFile); |
170 | 181 | String url = d.toURI().toURL().toString(); |
171 | 182 |
|
172 | | - if (url != null) |
173 | | - { |
174 | | - dataInput.put(ExpDataTable.Column.Name.name(), data.getName()); |
175 | | - dataInput.put(ExpDataTable.Column.DataFileUrl.name(), data.getDataFileUrl()); |
| 183 | + dataInput.put(ExpDataTable.Column.Name.name(), data.getName()); |
| 184 | + dataInput.put(ExpDataTable.Column.DataFileUrl.name(), data.getDataFileUrl()); |
176 | 185 |
|
177 | | - // file data type for this run data field |
178 | | - String dataFileUrl = URLDecoder.decode(url, "UTF-8"); |
179 | | - row.replace(INPUT_DATA_FILE, dataFileUrl.replace("file:", "")); |
180 | | - } |
| 186 | + // file data type for this run data field, adjust the URL to be compatible |
| 187 | + String dataFileUrl = URLDecoder.decode(url, StandardCharsets.UTF_8); |
| 188 | + row.replace(INPUT_DATA_FILE, dataFileUrl.replace("file:", "")); |
181 | 189 | } |
182 | 190 | } |
183 | 191 | } |
184 | 192 |
|
185 | 193 | // create and save the run |
186 | 194 | AssayProvider provider = AssayService.get().getProvider(protocol); |
187 | | - if (provider != null) |
| 195 | + if (provider != null && !dataRows.isEmpty()) |
188 | 196 | { |
189 | 197 | AssayRunUploadContext.Factory<?,?> runFactory = provider.createRunUploadFactory(protocol, job.getUser(), container); |
190 | 198 |
|
@@ -275,6 +283,12 @@ private FileLike getTargetFolder(Container container, Logger log) throws IOExcep |
275 | 283 | return null; |
276 | 284 | } |
277 | 285 |
|
| 286 | + private boolean isUnderAnyPipelineRoot(Path resolvedPath) |
| 287 | + { |
| 288 | + return PipelineService.get().getAllPipelineRoots().values().stream() |
| 289 | + .anyMatch(pipeRoot -> pipeRoot.isUnderRoot(resolvedPath)); |
| 290 | + } |
| 291 | + |
278 | 292 | public static class Factory extends AbstractTaskFactory<AbstractTaskFactorySettings, Factory> |
279 | 293 | { |
280 | 294 | public Factory() |
|
0 commit comments