|
24 | 24 | import org.commonwl.view.git.GitDetails; |
25 | 25 | import org.commonwl.view.graphviz.GraphVizService; |
26 | 26 | import org.eclipse.jgit.api.errors.GitAPIException; |
| 27 | +import org.eclipse.jgit.api.errors.TransportException; |
27 | 28 | import org.slf4j.Logger; |
28 | 29 | import org.slf4j.LoggerFactory; |
29 | 30 | import org.springframework.beans.factory.annotation.Autowired; |
|
45 | 46 | import javax.validation.Valid; |
46 | 47 | import java.io.File; |
47 | 48 | import java.io.IOException; |
| 49 | +import java.util.List; |
48 | 50 |
|
49 | 51 | @Controller |
50 | 52 | public class WorkflowController { |
@@ -119,7 +121,14 @@ public ModelAndView createWorkflow(@Valid WorkflowForm workflowForm, BindingResu |
119 | 121 | Workflow workflow = workflowService.getWorkflow(gitInfo); |
120 | 122 | if (workflow == null) { |
121 | 123 | try { |
122 | | - workflow = workflowService.createQueuedWorkflow(gitInfo).getTempRepresentation(); |
| 124 | + if (gitInfo.getPath().endsWith(".cwl")) { |
| 125 | + workflow = workflowService.createQueuedWorkflow(gitInfo).getTempRepresentation(); |
| 126 | + } else { |
| 127 | + return new ModelAndView("redirect:" + gitInfo.getInternalUrl()); |
| 128 | + } |
| 129 | + } catch (TransportException ex) { |
| 130 | + bindingResult.rejectValue("url", "git.sshError"); |
| 131 | + return new ModelAndView("index"); |
123 | 132 | } catch (GitAPIException ex) { |
124 | 133 | bindingResult.rejectValue("url", "git.retrievalError"); |
125 | 134 | logger.error("Git API Error", ex); |
@@ -449,10 +458,24 @@ private ModelAndView getWorkflow(GitDetails gitDetails, RedirectAttributes redir |
449 | 458 | workflowFormValidator.validateAndParse(workflowForm, errors); |
450 | 459 | if (!errors.hasErrors()) { |
451 | 460 | try { |
452 | | - queued = workflowService.createQueuedWorkflow(gitDetails); |
| 461 | + if (gitDetails.getPath().endsWith(".cwl")) { |
| 462 | + queued = workflowService.createQueuedWorkflow(gitDetails); |
| 463 | + } else { |
| 464 | + List<WorkflowOverview> workflowOverviews = workflowService.getWorkflowsFromDirectory(gitDetails); |
| 465 | + if (workflowOverviews.size() > 1) { |
| 466 | + return new ModelAndView("selectworkflow", "workflowOverviews", workflowOverviews) |
| 467 | + .addObject("gitDetails", gitDetails); |
| 468 | + } else if (workflowOverviews.size() == 1) { |
| 469 | + return new ModelAndView("redirect:" + gitDetails.getInternalUrl() + |
| 470 | + "/" + workflowOverviews.get(0).getFileName()); |
| 471 | + } else { |
| 472 | + errors.rejectValue("url", "url.noWorkflowsInDirectory", "No workflow files were found in the given directory"); |
| 473 | + } |
| 474 | + } |
| 475 | + } catch (TransportException ex) { |
| 476 | + errors.rejectValue("url", "git.sshError", "SSH URLs are not supported, please provide a HTTPS URL for the repository or submodules"); |
453 | 477 | } catch (GitAPIException ex) { |
454 | 478 | errors.rejectValue("url", "git.retrievalError", "The workflow could not be retrieved from the Git repository using the details given"); |
455 | | - logger.error("Git API Error", ex); |
456 | 479 | } catch (WorkflowNotFoundException ex) { |
457 | 480 | errors.rejectValue("url", "git.pathTraversal", "The path given did not resolve to a location within the repository"); |
458 | 481 | } catch (IOException ex) { |
|
0 commit comments