Skip to content

Commit 31cc5ff

Browse files
committed
Add support for adding workflows from generic Git URLs
1 parent 326f60e commit 31cc5ff

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

src/main/java/org/commonwl/view/PageController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class PageController {
3535
*/
3636
@GetMapping("/")
3737
public String homePage(Model model, @RequestParam(value = "url", required = false) String defaultURL) {
38-
model.addAttribute("workflowForm", new WorkflowForm(defaultURL));
38+
model.addAttribute("workflowForm", new WorkflowForm(defaultURL, "", ""));
3939
return "index";
4040
}
4141

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ private ModelAndView getWorkflow(GitDetails gitDetails, RedirectAttributes redir
444444
queued = workflowService.getQueuedWorkflow(gitDetails);
445445
if (queued == null) {
446446
// Validation
447-
WorkflowForm workflowForm = new WorkflowForm(gitDetails.getUrl());
447+
WorkflowForm workflowForm = new WorkflowForm(gitDetails.getUrl(), gitDetails.getBranch(), gitDetails.getPath());
448448
BeanPropertyBindingResult errors = new BeanPropertyBindingResult(workflowForm, "errors");
449449
workflowFormValidator.validateAndParse(workflowForm, errors);
450450
if (!errors.hasErrors()) {

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ public class WorkflowForm {
3232
public WorkflowForm() {}
3333

3434
public WorkflowForm(String url) {
35-
if (url != null) {
36-
this.url = trimTrailingSlashes(url);
37-
}
35+
setUrl(url);
36+
}
37+
38+
public WorkflowForm(String url, String branch, String path) {
39+
setUrl(url);
40+
this.branch = branch;
41+
this.path = path;
3842
}
3943

4044
public String getUrl() {

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,18 @@ public Page<Workflow> searchWorkflowsJson(Model model,
8888
/**
8989
* Create a new workflow from the given URL
9090
* @param url The URL of the workflow
91+
* @param branch The branch where the workflow can be found
92+
* @param path The path within the repository to the workflow file
9193
* @return Appropriate response code and optional JSON string with message
9294
*/
9395
@PostMapping(value = "/workflows", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
94-
public ResponseEntity<?> newWorkflowFromGithubURLJson(@RequestParam(value="url") String url,
95-
HttpServletResponse response) {
96+
public ResponseEntity<?> newWorkflowFromGitURLJson(@RequestParam(value="url") String url,
97+
@RequestParam(value="branch", required=false) String branch,
98+
@RequestParam(value="path", required=false) String path,
99+
HttpServletResponse response) {
96100

97-
// Run validator which checks the github URL is valid
98-
WorkflowForm workflowForm = new WorkflowForm(url);
101+
// Run validator which checks the URL is valid
102+
WorkflowForm workflowForm = new WorkflowForm(url, branch, path);
99103
BeanPropertyBindingResult errors = new BeanPropertyBindingResult(workflowForm, "errors");
100104
GitDetails gitInfo = workflowFormValidator.validateAndParse(workflowForm, errors);
101105

0 commit comments

Comments
 (0)