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

common-workflow-language / cwlviewer / #1998

13 May 2026 06:03PM UTC coverage: 70.05% (-0.3%) from 70.334%
#1998

Pull #751

github

kinow
Remove custom implementations with native queries, now Hibernate + JPA works!
Pull Request #751: Bump org.springframework.boot:spring-boot-starter-parent from 3.1.4 to 4.1.0-RC1

117 of 194 new or added lines in 30 files covered. (60.31%)

20 existing lines in 4 files now uncovered.

1691 of 2414 relevant lines covered (70.05%)

0.7 hits per line

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

0.0
/src/main/java/org/commonwl/view/cwl/CWLToolRunner.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.cwl;
21

22
import java.io.IOException;
23
import java.nio.file.Path;
24
import java.util.Date;
25
import org.apache.jena.query.QueryException;
26
import org.commonwl.view.git.GitDetails;
27
import org.commonwl.view.git.GitLicenseException;
28
import org.commonwl.view.git.GitSemaphore;
29
import org.commonwl.view.git.GitService;
30
import org.commonwl.view.researchobject.ROBundleFactory;
31
import org.commonwl.view.util.FileUtils;
32
import org.commonwl.view.workflow.QueuedWorkflow;
33
import org.commonwl.view.workflow.QueuedWorkflowRepository;
34
import org.commonwl.view.workflow.Workflow;
35
import org.commonwl.view.workflow.WorkflowRepository;
36
import org.eclipse.jgit.api.Git;
37
import org.eclipse.jgit.errors.MissingObjectException;
38
import org.eclipse.jgit.errors.TransportException;
39
import org.slf4j.Logger;
40
import org.slf4j.LoggerFactory;
41
import org.springframework.beans.factory.annotation.Autowired;
42
import org.springframework.scheduling.annotation.Async;
43
import org.springframework.scheduling.annotation.EnableAsync;
44
import org.springframework.stereotype.Component;
45

46
/** Replace an existing workflow with the one given by cwltool */
47
@Component
48
@EnableAsync
49
public class CWLToolRunner {
50

51
  private final Logger logger = LoggerFactory.getLogger(this.getClass());
×
52

53
  private final WorkflowRepository workflowRepository;
54
  private final QueuedWorkflowRepository queuedWorkflowRepository;
55
  private final CWLService cwlService;
56
  private final ROBundleFactory roBundleFactory;
57
  private final String cwlToolVersion;
58
  private final GitSemaphore gitSemaphore;
59
  private final GitService gitService;
60

61
  @Autowired
62
  public CWLToolRunner(
63
      WorkflowRepository workflowRepository,
64
      QueuedWorkflowRepository queuedWorkflowRepository,
65
      CWLService cwlService,
66
      CWLTool cwlTool,
67
      ROBundleFactory roBundleFactory,
68
      GitSemaphore gitSemaphore,
69
      GitService gitService) {
×
70
    this.workflowRepository = workflowRepository;
×
71
    this.queuedWorkflowRepository = queuedWorkflowRepository;
×
72
    this.cwlService = cwlService;
×
73
    this.cwlToolVersion = cwlTool.getVersion();
×
74
    this.roBundleFactory = roBundleFactory;
×
75
    this.gitSemaphore = gitSemaphore;
×
76
    this.gitService = gitService;
×
77
  }
×
78

79
  @Async
80
  public void createWorkflowFromQueued(QueuedWorkflow queuedWorkflow) throws IOException {
81

82
    Workflow tempWorkflow = queuedWorkflow.getTempRepresentation();
×
83
    GitDetails gitInfo = tempWorkflow.getRetrievedFrom();
×
84
    final String repoUrl = gitInfo.getRepoUrl();
×
85
    // Parse using cwltool and replace in database
86
    Git repo = null;
×
87
    try {
88
      boolean safeToAccess = gitSemaphore.acquire(repoUrl);
×
89
      repo = gitService.getRepository(gitInfo, safeToAccess);
×
90
      Path localPath = repo.getRepository().getWorkTree().toPath();
×
91
      Path workflowFile = localPath.resolve(gitInfo.getPath()).normalize().toAbsolutePath();
×
92
      Workflow newWorkflow =
×
93
          cwlService.parseWorkflowWithCwltool(tempWorkflow, workflowFile, localPath);
×
94

95
      // Success
96
      newWorkflow.setRetrievedFrom(tempWorkflow.getRetrievedFrom());
×
97
      newWorkflow.setRetrievedOn(new Date());
×
98
      newWorkflow.setLastCommit(tempWorkflow.getLastCommit());
×
99
      newWorkflow.setCwltoolVersion(cwlToolVersion);
×
100

101
      workflowRepository.save(newWorkflow);
×
102

103
      // Generate RO bundle
104
      roBundleFactory.createWorkflowRO(newWorkflow);
×
105

106
      // Mark success on queue
107
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.SUCCESS);
×
108

109
    } catch (QueryException ex) {
×
NEW
110
      logger.error("Jena query exception for workflow {}", queuedWorkflow.getId(), ex);
×
111
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
112
      queuedWorkflow.setMessage("An error occurred when executing a query on the SPARQL store");
×
113
      FileUtils.deleteGitRepository(repo);
×
114
    } catch (CWLValidationException | GitLicenseException ex) {
×
115
      String message = ex.getMessage();
×
116
      logger.error(
×
NEW
117
          "Workflow {} from {} : {}", queuedWorkflow.getId(), gitInfo.toSummary(), message, ex);
×
UNCOV
118
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
119
      queuedWorkflow.setMessage(message);
×
120
      FileUtils.deleteGitRepository(repo);
×
121
    } catch (TransportException ex) {
×
122
      String message = ex.getMessage();
×
123
      logger.error(
×
124
          "Workflow retrieval error while processing {} from {} : {}",
NEW
125
          queuedWorkflow.getId(),
×
NEW
126
          gitInfo.toSummary(),
×
127
          message,
128
          ex);
129
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
130
      if (message.contains(
×
131
          "Authentication is required but no CredentialsProvider has been registered")) {
132
        queuedWorkflow.setMessage(
×
133
            "Unable to retrieve the Git repository: it may be private, misnamed, or removed. "
134
                + message);
135
      } else {
136
        queuedWorkflow.setMessage(message);
×
137
      }
138
      FileUtils.deleteGitRepository(repo);
×
139
    } catch (MissingObjectException ex) {
×
140
      String message = ex.getMessage();
×
141
      logger.error(
×
142
          "Workflow retrieval error while processing {} from {} : {}",
NEW
143
          queuedWorkflow.getId(),
×
NEW
144
          gitInfo.toSummary(),
×
145
          message,
146
          ex);
147
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
148
      queuedWorkflow.setMessage("Unable to retrieve a needed Git object: " + message);
×
149
      FileUtils.deleteGitRepository(repo);
×
150
    } catch (Exception ex) {
×
151
      logger.error(
×
152
          "Unexpected error processing workflow {} from {} : {}",
NEW
153
          queuedWorkflow.getId(),
×
NEW
154
          gitInfo.toSummary(),
×
NEW
155
          ex.getMessage(),
×
156
          ex);
157
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
158
      queuedWorkflow.setMessage(
×
159
          "Whoops! Cwltool ran successfully, but an unexpected "
160
              + "error occurred in CWLViewer!\n"
161
              + ex.getMessage()
×
162
              + "\nHelp us by reporting it at https://github.com/common-workflow-language/cwlviewer/issues/new/choose\n");
163
      FileUtils.deleteGitRepository(repo);
×
164
    } finally {
165
      gitSemaphore.release(repoUrl);
×
166
      FileUtils.deleteTemporaryGitRepository(repo);
×
167
      queuedWorkflowRepository.save(queuedWorkflow);
×
168
    }
169
  }
×
170
}
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