• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

common-workflow-language / cwlviewer / #1997

13 May 2026 05:20PM UTC coverage: 70.25% (-0.08%) from 70.334%
#1997

Pull #751

github

kinow
Undo code deletion, but replace string concatenation by log+parameters
Pull Request #751: Bump org.springframework.boot:spring-boot-starter-parent from 3.1.4 to 4.1.0-RC1

119 of 196 new or added lines in 32 files covered. (60.71%)

20 existing lines in 4 files now uncovered.

1712 of 2437 relevant lines covered (70.25%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.0
/src/main/java/org/commonwl/view/workflow/WorkflowFormValidator.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *   http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
package org.commonwl.view.workflow;
21

22
import java.net.URI;
23
import java.util.List;
24
import org.apache.commons.lang.StringUtils;
25
import org.commonwl.view.git.GitDetails;
26
import org.commonwl.view.validation.GenericGitUrlValidator;
27
import org.commonwl.view.validation.GitHubUrlValidator;
28
import org.commonwl.view.validation.GitLabUrlValidator;
29
import org.commonwl.view.validation.GitUrlValidator;
30
import org.springframework.stereotype.Component;
31
import org.springframework.validation.Errors;
32
import org.springframework.validation.ValidationUtils;
33

34
/** Runs validation on the workflow form from the main page */
35
@Component
36
public class WorkflowFormValidator {
1✔
37

38
  /**
39
   * Validates a WorkflowForm to ensure the URL is not empty and links to a cwl file
40
   *
41
   * @param form The given WorkflowForm
42
   * @param e Any errors from validation
43
   */
44
  public GitDetails validateAndParse(WorkflowForm form, Errors e) {
45

46
    ValidationUtils.rejectIfEmptyOrWhitespace(e, "url", "url.emptyOrWhitespace");
1✔
47

48
    if (e.hasErrors()) {
1✔
49
      return null;
1✔
50
    }
51

52
    List<GitUrlValidator> handlers =
1✔
53
        List.of(new GitHubUrlValidator(), new GitLabUrlValidator(), new GenericGitUrlValidator());
1✔
54

55
    for (GitUrlValidator handler : handlers) {
1✔
56
      if (handler.supports(form.getUrl())) {
1✔
57
        handler.validate(form, e);
1✔
58

59
        GitDetails details = handler.parse(form.getUrl(), form);
1✔
60
        if (details != null) {
1✔
61
          attachPackedId(details, form);
1✔
62
          return details;
1✔
63
        }
64
      }
65
    }
1✔
66

67
    ValidationUtils.rejectIfEmptyOrWhitespace(e, "branch", "branch.emptyOrWhitespace");
1✔
68
    return null;
1✔
69
  }
70

71
  /**
72
   * Attaches a packed workflow ID into the Git details.
73
   *
74
   * <p>If no workflow is packed in the request, it searches for the information about the workflow
75
   * in the URL.
76
   *
77
   * @param details Git details
78
   * @param form Workflow form
79
   */
80
  private void attachPackedId(GitDetails details, WorkflowForm form) {
81
    if (isNotEmptyOrWhitespace(form.getPackedId())) {
1✔
NEW
82
      details.setPackedId(form.getPackedId());
×
NEW
83
      return;
×
84
    }
85

86
    URI uri = URI.create(form.getUrl());
1✔
87

88
    String fragment = uri.getFragment();
1✔
89

90
    if (isNotEmptyOrWhitespace(fragment)) {
1✔
91
      details.setPackedId(fragment);
1✔
92
    }
93
  }
1✔
94

95
  /**
96
   * Checks if a string is empty or whitespace
97
   *
98
   * @param str The string to be checked
99
   * @return Whether the string is empty or whitespace
100
   */
101
  private boolean isNotEmptyOrWhitespace(String str) {
102
    return (str != null && !str.isEmpty() && !StringUtils.isWhitespace(str));
1✔
103
  }
104
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc