Skip to content

Commit 177c311

Browse files
committed
REST API support for generic git URLs
1 parent 2fcc09e commit 177c311

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

src/main/java/org/commonwl/view/git/GitDetails.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919

2020
package org.commonwl.view.git;
2121

22+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
23+
2224
import java.io.Serializable;
2325
import java.net.URI;
2426
import java.net.URISyntaxException;
2527

2628
/**
2729
* Represents all the parameters necessary to access a file/directory with Git
2830
*/
31+
@JsonIgnoreProperties(value = {"internalUrl"})
2932
public class GitDetails implements Serializable {
3033

3134
private String repoUrl;

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

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ public ResponseEntity<?> newWorkflowFromGithubURLJson(@RequestParam(value="url")
149149
@GetMapping(value = {"/workflows/{domain}.com/{owner}/{repoName}/tree/{branch}/**",
150150
"/workflows/{domain}.com/{owner}/{repoName}/blob/{branch}/**"},
151151
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
152-
public Workflow getWorkflowByGithubDetailsJson(@PathVariable("domain") String domain,
153-
@PathVariable("owner") String owner,
154-
@PathVariable("repoName") String repoName,
155-
@PathVariable("branch") String branch,
156-
HttpServletRequest request) {
152+
public Workflow getWorkflowJson(@PathVariable("domain") String domain,
153+
@PathVariable("owner") String owner,
154+
@PathVariable("repoName") String repoName,
155+
@PathVariable("branch") String branch,
156+
HttpServletRequest request) {
157157
// The wildcard end of the URL is the path
158158
String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
159159
path = WorkflowController.extractPath(path, 7);
@@ -170,6 +170,30 @@ public Workflow getWorkflowByGithubDetailsJson(@PathVariable("domain") String do
170170
}
171171
}
172172

173+
/**
174+
* Get JSON representation of a workflow from generic git details
175+
* @param branch The branch of the repository
176+
* @return The JSON representation of the workflow
177+
*/
178+
@GetMapping(value="/workflows/**/*.git/{branch}/**",
179+
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
180+
public Workflow getWorkflowJsonGeneric(@PathVariable("branch") String branch,
181+
HttpServletRequest request) {
182+
// The wildcard end of the URL is the path
183+
String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
184+
185+
// Construct a GitDetails object to search for in the database
186+
GitDetails gitDetails = WorkflowController.getGitDetails(11, path, branch);
187+
188+
// Get workflow
189+
Workflow workflowModel = workflowService.getWorkflow(gitDetails);
190+
if (workflowModel == null) {
191+
throw new WorkflowNotFoundException();
192+
} else {
193+
return workflowModel;
194+
}
195+
}
196+
173197
/**
174198
* Query progress of a queued workflow
175199
* @param queueID The queued workflow ID to check

src/main/resources/templates/workflow.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ <h4 id="modalTitle">Dot File Source:</h4>
9797
</textarea>
9898
<a id="download-link-dot" href="" download="workflow.dot"></a>
9999
<button id="download-dot" class="btn btn-primary" type="button">Download dot File</button>
100-
<a th:href="@{'/workflows/' + ${workflow.id} + '/graph/xdot'}" href="#" download="graph.dot" class="btn btn-primary" type="button">Download xdot File</a>
100+
<a th:href="@{${workflow.getVisualisationXdot()}}" href="#" download="graph.dot" class="btn btn-primary" type="button">Download xdot File</a>
101101
</div>
102102
</div>
103103
</div>

0 commit comments

Comments
 (0)