Skip to content

Commit 764e063

Browse files
committed
Redirect for any ?format=raw URI (not just workflow files)
This fixes #167 by looking up any matching commit ID
1 parent 8a4f474 commit 764e063

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,21 @@ public void goToViewer(@PathVariable("commitid") String commitId,
106106
public void goToRawUrl(@PathVariable("commitid") String commitId,
107107
HttpServletRequest request,
108108
HttpServletResponse response) {
109-
Workflow workflow = getWorkflow(commitId, request);
110-
if (workflow.getRetrievedFrom().getType() == GitType.GENERIC) {
109+
Optional<String> rawUrl = findRaw(commitId, request);
110+
if (!rawUrl.isPresent()) {
111111
throw new RepresentationNotFoundException();
112112
} else {
113-
response.setHeader("Location", workflow.getRetrievedFrom().getRawUrl(commitId));
113+
response.setHeader("Location", rawUrl.get());
114114
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
115115
}
116116
}
117117

118+
private Optional<String> findRaw(String commitId, HttpServletRequest request) {
119+
String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
120+
final String filepath = WorkflowController.extractPath(path, 3);
121+
return workflowService.findRawBaseForCommit(commitId).map(base -> base + filepath);
122+
}
123+
118124
/**
119125
* Get the RDF in Turtle format
120126
* @param commitId The commit ID of the workflow

0 commit comments

Comments
 (0)