19
19
20
20
package org .commonwl .view .workflow ;
21
21
22
+ import java .io .File ;
23
+ import java .util .Optional ;
24
+
25
+ import javax .servlet .http .HttpServletRequest ;
26
+ import javax .servlet .http .HttpServletResponse ;
27
+
22
28
import org .commonwl .view .cwl .RDFService ;
23
- import org .commonwl .view .git .GitType ;
24
29
import org .springframework .beans .factory .annotation .Autowired ;
25
30
import org .springframework .core .io .FileSystemResource ;
26
31
import org .springframework .http .MediaType ;
27
32
import org .springframework .web .bind .annotation .GetMapping ;
28
33
import org .springframework .web .bind .annotation .PathVariable ;
34
+ import org .springframework .web .bind .annotation .RequestParam ;
29
35
import org .springframework .web .bind .annotation .RestController ;
30
36
import org .springframework .web .servlet .HandlerMapping ;
31
37
32
- import javax .servlet .http .HttpServletRequest ;
33
- import javax .servlet .http .HttpServletResponse ;
34
- import java .io .File ;
35
-
36
38
/**
37
39
* Allows permalinks in URIs across our RDF to identify a
38
40
* workflow or a workflow file
@@ -54,9 +56,32 @@ public WorkflowPermalinkController(WorkflowService workflowService,
54
56
this .rdfService = rdfService ;
55
57
}
56
58
59
+ /**
60
+ * Generate a URI list of all representations available
61
+ */
62
+ @ GetMapping (value = "/git/{commitid}/**" ,
63
+ produces = { "text/uri-list" })
64
+ public String uriList (@ PathVariable ("commitid" ) String commitId ,
65
+ @ RequestParam (name = "part" ) Optional <String > part , @ RequestParam (name = "format" ) Optional <String > format ,
66
+ HttpServletRequest request , HttpServletResponse response ) {
67
+ // A bit of a hack - reuse the representation of MultipleWorkflowsException,
68
+ // without setting the Location header or returning 300 Multiple Choices
69
+ Workflow workflow ;
70
+ try {
71
+ workflow = getWorkflow (commitId , request , part );
72
+ } catch (MultipleWorkflowsException ex ) {
73
+ // No problem, we can use its text/uri-list as-is
74
+ return ex .toString ();
75
+ }
76
+ // Return uri-list from a pretend MultipleWorkflowsException
77
+ return new MultipleWorkflowsException (workflow ).toString ();
78
+ }
79
+
57
80
/**
58
81
* Redirect to the viewer for a web browser or API call
59
- * @param commitId The commit ID of the workflow
82
+ *
83
+ * @param commitId
84
+ * The commit ID of the workflow
60
85
* @return A 302 redirect response to the viewer or 404
61
86
*/
62
87
@ GetMapping (value = "/git/{commitid}/**" ,
0 commit comments