Skip to content

Commit 8a4f474

Browse files
committed
Expose the text/uri-list also by content-negotiation
(but not by ?format=)
1 parent d760e7c commit 8a4f474

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

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

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@
1919

2020
package org.commonwl.view.workflow;
2121

22+
import java.io.File;
23+
import java.util.Optional;
24+
25+
import javax.servlet.http.HttpServletRequest;
26+
import javax.servlet.http.HttpServletResponse;
27+
2228
import org.commonwl.view.cwl.RDFService;
23-
import org.commonwl.view.git.GitType;
2429
import org.springframework.beans.factory.annotation.Autowired;
2530
import org.springframework.core.io.FileSystemResource;
2631
import org.springframework.http.MediaType;
2732
import org.springframework.web.bind.annotation.GetMapping;
2833
import org.springframework.web.bind.annotation.PathVariable;
34+
import org.springframework.web.bind.annotation.RequestParam;
2935
import org.springframework.web.bind.annotation.RestController;
3036
import org.springframework.web.servlet.HandlerMapping;
3137

32-
import javax.servlet.http.HttpServletRequest;
33-
import javax.servlet.http.HttpServletResponse;
34-
import java.io.File;
35-
3638
/**
3739
* Allows permalinks in URIs across our RDF to identify a
3840
* workflow or a workflow file
@@ -54,9 +56,32 @@ public WorkflowPermalinkController(WorkflowService workflowService,
5456
this.rdfService = rdfService;
5557
}
5658

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+
5780
/**
5881
* 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
6085
* @return A 302 redirect response to the viewer or 404
6186
*/
6287
@GetMapping(value = "/git/{commitid}/**",

0 commit comments

Comments
 (0)