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

common-workflow-language / cwlviewer / #1996

13 May 2026 05:15PM UTC coverage: 70.773% (+0.4%) from 70.334%
#1996

Pull #751

github

kinow
Avoid string concatenations in log calls
Pull Request #751: Bump org.springframework.boot:spring-boot-starter-parent from 3.1.4 to 4.1.0-RC1

122 of 194 new or added lines in 32 files covered. (62.89%)

54 existing lines in 5 files now uncovered.

1712 of 2419 relevant lines covered (70.77%)

0.71 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 org.apache.jena.query.QueryException;
23
import org.commonwl.view.git.GitDetails;
24
import org.commonwl.view.git.GitLicenseException;
25
import org.commonwl.view.git.GitSemaphore;
26
import org.commonwl.view.git.GitService;
27
import org.commonwl.view.researchobject.ROBundleFactory;
28
import org.commonwl.view.util.FileUtils;
29
import org.commonwl.view.workflow.QueuedWorkflow;
30
import org.commonwl.view.workflow.QueuedWorkflowRepository;
31
import org.commonwl.view.workflow.Workflow;
32
import org.commonwl.view.workflow.WorkflowRepository;
33
import org.eclipse.jgit.api.Git;
34
import org.slf4j.Logger;
35
import org.slf4j.LoggerFactory;
36
import org.springframework.beans.factory.annotation.Autowired;
37
import org.springframework.scheduling.annotation.Async;
38
import org.springframework.scheduling.annotation.EnableAsync;
39
import org.springframework.stereotype.Component;
40

41
import java.io.IOException;
42
import java.nio.file.Path;
43
import java.util.Date;
44

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

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

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

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

UNCOV
80
  @Async
×
NEW
81
  public void createWorkflowFromQueued(QueuedWorkflow queuedWorkflow) throws IOException {
×
UNCOV
82

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

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

102
      workflowRepository.save(newWorkflow);
×
103

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

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

×
110
    } catch (QueryException ex) {
×
NEW
111
      logger.error("Jena query exception for workflow {}", queuedWorkflow.getId(), ex);
×
112
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
113
      queuedWorkflow.setMessage("An error occurred when executing a query on the SPARQL store");
×
114
      FileUtils.deleteGitRepository(repo);
×
115
    } catch (CWLValidationException | GitLicenseException ex) {
×
116
      String message = ex.getMessage();
×
NEW
117
      logger.error("Workflow {} from {} : {}", queuedWorkflow.getId(), gitInfo.toSummary(), message, ex);
×
118
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
119
      queuedWorkflow.setMessage(message);
×
120
      FileUtils.deleteGitRepository(repo);
×
121
    } catch (Exception ex) {
NEW
122
      logger.error("Unexpected error processing workflow {} from {} : {}",
×
NEW
123
          queuedWorkflow.getId(), gitInfo.toSummary(), ex.getMessage(), ex);
×
124
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
125
      queuedWorkflow.setMessage(
UNCOV
126
          "Whoops! Cwltool ran successfully, but an unexpected "
×
UNCOV
127
              + "error occurred in CWLViewer!\n"
×
128
              + ex.getMessage()
129
              + "\nHelp us by reporting it at https://github.com/common-workflow-language/cwlviewer/issues/new/choose\n");
130
      FileUtils.deleteGitRepository(repo);
×
131
    } finally {
132
      gitSemaphore.release(repoUrl);
×
133
      FileUtils.deleteTemporaryGitRepository(repo);
134
      queuedWorkflowRepository.save(queuedWorkflow);
×
UNCOV
135
    }
×
136
  }
×
137
}
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