diff --git a/api/src/org/labkey/api/exp/XarSource.java b/api/src/org/labkey/api/exp/XarSource.java index 38ec6ec1868..1d0853be740 100644 --- a/api/src/org/labkey/api/exp/XarSource.java +++ b/api/src/org/labkey/api/exp/XarSource.java @@ -84,6 +84,8 @@ public XarSource(PipelineJob job) public abstract Path getRootPath(); + public Path getJobRootPath() { return getRootPath(); } + /** * Should be true if this was uploaded XML that was not part of a full XAR */ diff --git a/api/src/org/labkey/api/util/NetworkDrive.java b/api/src/org/labkey/api/util/NetworkDrive.java index 557ae5f64f8..e4f2fb1876c 100644 --- a/api/src/org/labkey/api/util/NetworkDrive.java +++ b/api/src/org/labkey/api/util/NetworkDrive.java @@ -149,8 +149,12 @@ public static boolean exists(java.nio.file.Path p) return false; if (Files.exists(p)) return true; - ensureDrive(p.toString()); - return Files.exists(p); + if (FileUtil.FILE_SCHEME.equals(p.toUri().getScheme())) + { + ensureDrive(p.toString()); + return Files.exists(p); + } + return false; } public static void ensureDrive(FileLike f) diff --git a/core/src/org/labkey/core/security/SecurityController.java b/core/src/org/labkey/core/security/SecurityController.java index 677c0044ceb..4275dcc55c5 100644 --- a/core/src/org/labkey/core/security/SecurityController.java +++ b/core/src/org/labkey/core/security/SecurityController.java @@ -1822,7 +1822,7 @@ public void setMailPrefix(String mailPrefix) public @NotNull User getUser(boolean throwIfNull) { if (throwIfNull && null == _user) - throw new IllegalStateException("User not found"); + throw new NotFoundException("User not found"); return _user; } diff --git a/experiment/src/org/labkey/experiment/ExpDataIterators.java b/experiment/src/org/labkey/experiment/ExpDataIterators.java index 72a945d88da..7ea0d7e342e 100644 --- a/experiment/src/org/labkey/experiment/ExpDataIterators.java +++ b/experiment/src/org/labkey/experiment/ExpDataIterators.java @@ -2961,7 +2961,12 @@ private TypeData createSampleHeaderRow(ExpSampleTypeImpl sampleType, Container c ColumnInfo colInfo = getColumnInfo(i); String name = colInfo.getName(); String lcName = name.toLowerCase(); - if (validFields.contains(name)) + if (_typeColIndex != null && _typeColIndex == i) // Issue 52355: assure we have some data in the row by including the type + { + fieldIndexes.add(i); + header.add(_typeColName); + } + else if (validFields.contains(name)) { fieldIndexes.add(i); header.add(_tsvWriter.quoteValue(name)); diff --git a/experiment/src/org/labkey/experiment/XarReader.java b/experiment/src/org/labkey/experiment/XarReader.java index 62ffa397eab..e7744f755f8 100644 --- a/experiment/src/org/labkey/experiment/XarReader.java +++ b/experiment/src/org/labkey/experiment/XarReader.java @@ -1109,7 +1109,7 @@ private void loadExperimentRun(ExperimentRunType a, List startingMa vals.setProtocolLSID(protocol.getLSID()); vals.setComments(trimString(a.getComments())); - vals.setFilePathRoot(FileUtil.getAbsolutePath(_xarSource.getRootPath())); // FileUtil.getAbsolutePath(runContext.getContainer(), _job.getPipeRoot().getRootNioPath())); + vals.setFilePathRoot(FileUtil.getAbsolutePath(_xarSource.getJobRootPath())); vals.setContainer(getContainer()); String workflowTaskLSID = a.getWorkflowTaskLSID(); diff --git a/experiment/src/org/labkey/experiment/pipeline/MoveRunsTask.java b/experiment/src/org/labkey/experiment/pipeline/MoveRunsTask.java index 1a5e8af2faa..e36410dc529 100644 --- a/experiment/src/org/labkey/experiment/pipeline/MoveRunsTask.java +++ b/experiment/src/org/labkey/experiment/pipeline/MoveRunsTask.java @@ -220,6 +220,15 @@ public Path getRootPath() return FileUtil.stringToPath(_sourceContainer, _root); } + @Override + public Path getJobRootPath() + { + var pipelineJob = getXarContext().getJob(); + return pipelineJob != null + ? pipelineJob.getPipeRoot().getRootFileLike().toNioPathForRead() + : super.getJobRootPath(); + } + @Override public boolean shouldIgnoreDataFiles() { diff --git a/filecontent/src/org/labkey/filecontent/FileContentServiceImpl.java b/filecontent/src/org/labkey/filecontent/FileContentServiceImpl.java index 1f85566955e..6be418bc831 100644 --- a/filecontent/src/org/labkey/filecontent/FileContentServiceImpl.java +++ b/filecontent/src/org/labkey/filecontent/FileContentServiceImpl.java @@ -80,6 +80,7 @@ import org.labkey.api.util.FileUtil; import org.labkey.api.util.GUID; import org.labkey.api.util.HtmlString; +import org.labkey.api.util.NetworkDrive; import org.labkey.api.util.PageFlowUtil; import org.labkey.api.util.Path; import org.labkey.api.util.TestContext; @@ -339,7 +340,7 @@ public java.nio.file.Path getDefaultRootPath(Container c, boolean createDir) try { - if (createDir && !Files.exists(fileRootPath)) + if (createDir && !NetworkDrive.exists(fileRootPath)) FileUtil.createDirectories(fileRootPath); } catch (IOException e) @@ -602,7 +603,7 @@ public void setIsUseDefaultRoot(Container c, boolean useDefaultRoot) try { - if (root == null || !root.exists()) + if (!NetworkDrive.exists(root)) { File configuredRoot = root; root = getDefaultRoot(); @@ -621,7 +622,7 @@ public void setIsUseDefaultRoot(Container c, boolean useDefaultRoot) _problematicFileRootMessage = null; } - if (!root.exists()) + if (!NetworkDrive.exists(root)) { if (FileUtil.mkdirs(root)) { @@ -658,7 +659,7 @@ public String getProblematicFileRootMessage() root = root.getParentFile(); } File defaultRoot = new File(root, "files"); - if (!defaultRoot.exists()) + if (!NetworkDrive.exists(defaultRoot)) FileUtil.mkdirs(defaultRoot); return defaultRoot; @@ -670,7 +671,7 @@ public void setSiteDefaultRoot(File root, User user) if (root == null) throw new IllegalArgumentException("Invalid site root: specified root is null"); - if (!root.exists()) + if (!NetworkDrive.exists(root)) throw new IllegalArgumentException("Invalid site root: " + root.getAbsolutePath() + " does not exist"); File prevRoot = getSiteDefaultRoot(); @@ -764,7 +765,7 @@ public java.nio.file.Path getMappedDirectory(Container c, boolean create) throws return null; } - if (!Files.exists(root)) + if (!NetworkDrive.exists(root)) { if (create) throw new MissingRootDirectoryException(c.isRoot() ? c : c.getProject(), root); @@ -862,7 +863,7 @@ public void containerMoved(Container c, Container oldParent, User user) if (!FileUtil.hasCloudScheme(srcParent)) { File src = new File(srcParent.toFile(), c.getName()); - if (src.exists()) + if (NetworkDrive.exists(src)) { if (!FileUtil.hasCloudScheme(dest)) { @@ -873,7 +874,7 @@ public void containerMoved(Container c, Container oldParent, User user) { // local -> cloud; source starts under @files File filesSrc = FileUtil.appendName(src, FILES_LINK); - if (filesSrc.exists()) + if (NetworkDrive.exists(filesSrc)) moveFileRoot(filesSrc.toPath(), dest, user, c); FileUtil.deleteDir(src); // moveFileRoot will delete @files, but we need to delete its parent } @@ -935,10 +936,10 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) File parentDir = locationFile.getParentFile(); File oldLocation = new File(parentDir, oldValue); File newLocation = new File(parentDir, newValue); - if (newLocation.exists()) + if (NetworkDrive.exists(newLocation)) moveToDeleted(newLocation); - if (oldLocation.exists()) + if (NetworkDrive.exists(oldLocation)) { oldLocation.renameTo(newLocation); fireFileMoveEvent(oldLocation, newLocation, evt.user, evt.container); @@ -972,18 +973,18 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) */ private static boolean moveToDeleted(File fileToMove) throws IOException { - if (!fileToMove.exists()) + if (!NetworkDrive.exists(fileToMove)) return false; File parent = fileToMove.getParentFile(); File deletedDir = new File(parent, ".deleted"); - if (!deletedDir.exists()) + if (!NetworkDrive.exists(deletedDir)) if (!FileUtil.mkdir(deletedDir)) return false; File newLocation = new File(deletedDir, fileToMove.getName()); - if (newLocation.exists()) + if (NetworkDrive.exists(newLocation)) FileUtil.deleteDir(newLocation); return fileToMove.renameTo(newLocation); @@ -1093,7 +1094,7 @@ public QueryUpdateService getFilePropsUpdateService(TableInfo tinfo, Container c public boolean isValidProjectRoot(String root) { File f = new File(root); - return f.exists() && f.isDirectory(); + return NetworkDrive.exists(f) && f.isDirectory(); } @Override @@ -1131,7 +1132,7 @@ public void moveFileRoot(File prev, File dest, @Nullable User user, @Nullable Co // If it exists, try deleting the target directory, which will only succeed if it's empty, but would // enable using renameTo() method. Don't delete if it's a symbolic link, since it wouldn't be recreated // in the same way. - if (dest.exists() && !Files.isSymbolicLink(dest.toPath())) + if (NetworkDrive.exists(dest) && !Files.isSymbolicLink(dest.toPath())) doRename = dest.delete(); if (doRename && !prev.renameTo(dest)) @@ -1292,7 +1293,7 @@ public Set> getNodes(boolean isShowOverridesOnly, @Nullable try { java.nio.file.Path assayFilesRoot = getFileRootPath(c, ContentType.assayfiles); - if (assayFilesRoot != null && Files.exists(assayFilesRoot)) + if (NetworkDrive.exists(assayFilesRoot)) { Map node = createFileSetNode(c, ASSAY_FILES, assayFilesRoot); node.put("default", false); @@ -1646,7 +1647,7 @@ public File getMoveTargetFile(String absoluteFilePath, @NotNull Container source return null; File file = new File(absoluteFilePath); - if (!file.exists()) + if (!NetworkDrive.exists(file)) { _log.warn("File '" + absoluteFilePath + "' not found and cannot be moved"); return null; @@ -1779,7 +1780,7 @@ private File getTestRoot() File siteRoot = svc.getSiteDefaultRoot(); File testRoot = new File(siteRoot, FILE_ROOT_SUFFIX); testRoot.mkdirs(); - Assert.assertTrue("Unable to create test file root", testRoot.exists()); + Assert.assertTrue("Unable to create test file root", NetworkDrive.exists(testRoot)); return testRoot; } @@ -1843,7 +1844,7 @@ public void testFolderMove() throws Exception _log, false); - Assert.assertTrue("File not found: " + childFile.getPath(), childFile.exists()); + Assert.assertTrue("File not found: " + childFile.getPath(), NetworkDrive.exists(childFile)); ContainerManager.move(subsubfolder, subfolder2, TestContext.get().getUser()); Container movedSubfolder = ContainerManager.getChild(subfolder2, subsubfolder.getName()); @@ -1852,7 +1853,7 @@ public void testFolderMove() throws Exception assertPathsEqual("SubSubfolder has incorrect root", _expectedPaths.get(movedSubfolder), svc.getFileRoot(movedSubfolder)); File expectedFile = new File(svc.getFileRoot(movedSubfolder, ContentType.files), TXT_FILE); - Assert.assertTrue("File was not moved, expected: " + expectedFile.getPath(), expectedFile.exists()); + Assert.assertTrue("File was not moved, expected: " + expectedFile.getPath(), NetworkDrive.exists(expectedFile)); ExpData movedData = ExperimentService.get().getExpData(data.getRowId()); Assert.assertNotNull(movedData); @@ -1938,7 +1939,7 @@ public void cleanup() deleteContainerAndFiles(svc, ContainerManager.getForPath(PROJECT2)); File testRoot = getTestRoot(); - if (testRoot.exists()) + if (NetworkDrive.exists(testRoot)) { FileUtil.deleteDir(testRoot); } @@ -1951,7 +1952,7 @@ private void deleteContainerAndFiles(FileContentService svc, @Nullable Container ContainerManager.deleteAll(c, TestContext.get().getUser()); File file1 = svc.getFileRoot(c); - if (file1 != null && file1.exists()) + if (NetworkDrive.exists(file1)) { FileUtil.deleteDir(file1); } diff --git a/pipeline/src/org/labkey/pipeline/mule/EPipelineQueueImpl.java b/pipeline/src/org/labkey/pipeline/mule/EPipelineQueueImpl.java index 95d2ee78278..ecd93f7eee1 100644 --- a/pipeline/src/org/labkey/pipeline/mule/EPipelineQueueImpl.java +++ b/pipeline/src/org/labkey/pipeline/mule/EPipelineQueueImpl.java @@ -128,6 +128,7 @@ public boolean cancelJob(User user, Container c, PipelineStatusFile statusFile) if (cancelRemoteExecutionEngineJob(statusFile, job)) return true; } + PipelineJobService.get().cancelForJob(statusFile.getJobId()); return false; }