Skip to content

Commit a226747

Browse files
Resolve SequenceAnalysis pipeline paths through PipeRoot (#450)
2 parents 5d6730c + af5e3e7 commit a226747

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

‎SequenceAnalysis/src/org/labkey/sequenceanalysis/SequenceAnalysisController.java‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,13 @@ public ApiResponse execute(ValidateReadsetImportForm form, BindException errors)
10731073
FileLike base = root.getRootFileLike();
10741074

10751075
if (form.getPath() != null)
1076-
base = base.resolveFile(new Path(form.getPath()));
1076+
{
1077+
base = root.resolvePathToFileLike(form.getPath());
1078+
if (null == base)
1079+
{
1080+
throw new PipelineJobException("Invalid path: " + form.getPath());
1081+
}
1082+
}
10771083

10781084
for (String fileName : form.getFileNames())
10791085
{
@@ -1088,7 +1094,7 @@ public ApiResponse execute(ValidateReadsetImportForm form, BindException errors)
10881094
Map<String, Object> map = new HashMap<>();
10891095
map.put("fileName", fileName);
10901096
map.put("filePath", f.getPath());
1091-
map.put("relPath", FileUtil.relativePath(FileUtil.getAbsoluteCaseSensitiveFile(FileSystemLike.toFile(root.getRootFileLike())).getPath(), FileUtil.getAbsoluteCaseSensitiveFile(f).getPath()));
1097+
map.put("relPath", root.relativePath(f));
10921098
map.put("container", getContainer().getId());
10931099
map.put("containerPath", getContainer().getPath());
10941100
String basename = SequenceTaskHelper.getUnzippedBaseName(fileName);
@@ -1925,12 +1931,13 @@ else if (!d.getContainer().hasPermission(u, ReadPermission.class))
19251931
else if (o.has("relPath") || o.has("fileName"))
19261932
{
19271933
FileLike f;
1928-
if (o.opt("relPath") == null)
1934+
if (o.isNull("relPath"))
19291935
{
1930-
if (path != null)
1936+
if (StringUtils.isNotEmpty(path))
19311937
{
19321938
f = pr.resolvePathToFileLike(path);
1933-
f = f.resolveFile(Path.parse(o.getString("fileName")));
1939+
if (f != null)
1940+
f = f.resolveFile(Path.parse(o.getString("fileName")));
19341941
}
19351942
else
19361943
{
@@ -2231,7 +2238,12 @@ public Object execute(ImportFastaSequencesForm form, BindException errors) throw
22312238
return null;
22322239
}
22332240

2234-
FileLike baseDir = StringUtils.trimToNull(form.getPath()) == null ? root.getRootFileLike() : root.getRootFileLike().resolveFile(new Path(form.getPath()));
2241+
FileLike baseDir = StringUtils.trimToNull(form.getPath()) == null ? root.getRootFileLike() : root.resolvePathToFileLike(form.getPath());
2242+
if (baseDir == null)
2243+
{
2244+
errors.reject(ERROR_MSG, "Invalid path: " + form.getPath());
2245+
return null;
2246+
}
22352247

22362248
if (!baseDir.exists())
22372249
{

0 commit comments

Comments
 (0)