|
37 | 37 |
|
38 | 38 | import javax.servlet.http.HttpServletRequest;
|
39 | 39 | import javax.servlet.http.HttpServletResponse;
|
40 |
| -import java.util.Collections; |
41 |
| -import java.util.Map; |
| 40 | +import java.util.*; |
42 | 41 |
|
43 | 42 | import static org.commonwl.view.cwl.CWLToolStatus.SUCCESS;
|
44 | 43 |
|
@@ -121,6 +120,27 @@ public ResponseEntity<?> newWorkflowFromGitURLJson(@RequestParam(value="url") St
|
121 | 120 | if (queued == null) {
|
122 | 121 | try {
|
123 | 122 | queued = workflowService.createQueuedWorkflow(gitInfo);
|
| 123 | + if (queued.getWorkflowList() != null) { |
| 124 | + if (queued.getWorkflowList().size() == 1) { |
| 125 | + // Parse the packed workflow within automatically if there is only one |
| 126 | + gitInfo.setPackedId(queued.getWorkflowList().get(0).getFileName()); |
| 127 | + queued = workflowService.getQueuedWorkflow(gitInfo); |
| 128 | + if (queued == null) { |
| 129 | + queued = workflowService.createQueuedWorkflow(gitInfo); |
| 130 | + } |
| 131 | + } else { |
| 132 | + // Error with alternatives suggested |
| 133 | + List<String> workflowUris = new ArrayList<>(); |
| 134 | + for (WorkflowOverview overview : queued.getWorkflowList()) { |
| 135 | + workflowUris.add(overview.getFileName()); |
| 136 | + } |
| 137 | + Map<String, Object> responseMap = new HashMap<>(); |
| 138 | + responseMap.put("message", "This workflow file is packed and contains multiple workflow " + |
| 139 | + "descriptions. Please choose one to add"); |
| 140 | + responseMap.put("workflows", workflowUris); |
| 141 | + return new ResponseEntity<Map>(responseMap, HttpStatus.UNPROCESSABLE_ENTITY); |
| 142 | + } |
| 143 | + } |
124 | 144 | } catch (CWLValidationException ex) {
|
125 | 145 | Map<String, String> message = Collections.singletonMap("message", "Error:" + ex.getMessage());
|
126 | 146 | return new ResponseEntity<Map>(message, HttpStatus.BAD_REQUEST);
|
|
0 commit comments