Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions ehr/src/org/labkey/ehr/EHRServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import org.labkey.api.query.FieldKey;
import org.labkey.api.query.QueryService;
import org.labkey.api.query.UserSchema;
import org.labkey.api.resource.DirectoryResource;
import org.labkey.api.resource.FileResource;
import org.labkey.api.resource.Resource;
import org.labkey.api.security.SecurableResource;
import org.labkey.api.security.SecurityPolicy;
Expand Down Expand Up @@ -866,16 +868,29 @@ public void importStudyDefinition(Container container, User user, Module m, Path
Resource root = m.getModuleResource(sourceStudyDirPath);
PipeRoot pipeRoot = PipelineService.get().findPipelineRoot(container);
java.nio.file.Path pipeRootPath = pipeRoot.getRootNioPath();
java.nio.file.Path studyPath = pipeRootPath.resolve("upgradeStudyImport");
if (Files.exists(studyPath))

java.nio.file.Path studyXmlPath;

if (root instanceof DirectoryResource && ((DirectoryResource)root).getDir().equals(pipeRootPath.toFile()))
{
// The pipeline root is already pointed at the study definition's folder, like it might be on a dev machine.
// No need to copy, especially since copying can cause infinite recursion when the paths are nested
studyXmlPath = pipeRootPath.resolve("study.xml");
}
else
{
FileUtil.deleteDir(studyPath);
java.nio.file.Path studyPath = pipeRootPath.resolve("moduleStudyImport");
studyXmlPath = studyPath.resolve("study.xml");
if (Files.exists(studyPath))
{
FileUtil.deleteDir(studyPath);
}
copyResourceToPath(root, studyPath);
}
copyResourceToPath(root, studyPath);
java.nio.file.Path studyXmlPath = studyPath.resolve("study.xml");

if (!Files.exists(studyXmlPath))
{
throw new FileNotFoundException("Couldn't find an extracted " + studyPath);
throw new FileNotFoundException("Couldn't find an extracted " + studyXmlPath);
}
ImportOptions options = new ImportOptions(container.getId(), user.getUserId());
options.setSkipQueryValidation(true);
Expand Down