Skip to content

Commit a3e4796

Browse files
committed
Fix behaviour with single workflow in a packed file
1 parent c3b72ea commit a3e4796

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

src/main/java/org/commonwl/view/workflow/WorkflowController.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,9 @@ private ModelAndView getWorkflow(GitDetails gitDetails, RedirectAttributes redir
467467
queued = workflowService.getQueuedWorkflow(gitDetails);
468468
if (queued == null) {
469469
// Validation
470-
WorkflowForm workflowForm = new WorkflowForm(gitDetails.getUrl(), gitDetails.getBranch(), gitDetails.getPath());
470+
String packedPart = (gitDetails.getPackedId() == null) ? "" : "#" + gitDetails.getPackedId();
471+
WorkflowForm workflowForm = new WorkflowForm(gitDetails.getUrl(), gitDetails.getBranch(),
472+
gitDetails.getPath() + packedPart);
471473
BeanPropertyBindingResult errors = new BeanPropertyBindingResult(workflowForm, "errors");
472474
workflowFormValidator.validateAndParse(workflowForm, errors);
473475
if (!errors.hasErrors()) {
@@ -476,6 +478,10 @@ private ModelAndView getWorkflow(GitDetails gitDetails, RedirectAttributes redir
476478
queued = workflowService.createQueuedWorkflow(gitDetails);
477479
if (queued.getWorkflowList() != null) {
478480
// Packed workflow listing
481+
if (queued.getWorkflowList().size() == 1) {
482+
gitDetails.setPackedId(queued.getWorkflowList().get(0).getFileName());
483+
return new ModelAndView("redirect:" + gitDetails.getInternalUrl());
484+
}
479485
return new ModelAndView("selectworkflow", "workflowOverviews", queued.getWorkflowList())
480486
.addObject("gitDetails", gitDetails);
481487
}

src/main/java/org/commonwl/view/workflow/WorkflowService.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,25 @@ public QueuedWorkflow createQueuedWorkflow(GitDetails gitInfo)
309309
File workflowFile = new File(pathToWorkflowFile.toString());
310310

311311
// Handling of packed workflows
312-
String packedWorkflowId = null;
313-
if (cwlService.isPacked(workflowFile)) {
314-
List<WorkflowOverview> overviews = cwlService.getWorkflowOverviewsFromPacked(workflowFile);
315-
if (overviews.size() == 0) {
316-
throw new IOException("No workflow was found within the packed CWL file");
317-
} else {
318-
// Dummy queued workflow object to return the list
319-
QueuedWorkflow overviewList = new QueuedWorkflow();
320-
overviewList.setWorkflowList(overviews);
321-
return overviewList;
312+
String packedWorkflowId = gitInfo.getPackedId();
313+
if (packedWorkflowId == null) {
314+
if (cwlService.isPacked(workflowFile)) {
315+
List<WorkflowOverview> overviews = cwlService.getWorkflowOverviewsFromPacked(workflowFile);
316+
if (overviews.size() == 0) {
317+
throw new IOException("No workflow was found within the packed CWL file");
318+
} else {
319+
// Dummy queued workflow object to return the list
320+
QueuedWorkflow overviewList = new QueuedWorkflow();
321+
overviewList.setWorkflowList(overviews);
322+
return overviewList;
323+
}
322324
}
325+
} else {
326+
// Packed ID specified but was not found
327+
if (!cwlService.isPacked(workflowFile)) {
328+
throw new WorkflowNotFoundException();
329+
}
330+
323331
}
324332

325333
Workflow basicModel = cwlService.parseWorkflowNative(workflowFile, packedWorkflowId);

0 commit comments

Comments
 (0)