// Path: src/main/java/org/commonwl/view/util/StreamGobbler.java
// public class StreamGobbler extends Thread {
//     private final String lineSeparator = System.getProperty("line.separator");
// 
//     private InputStream is;
//     private String content = "";
// 
//     public StreamGobbler(InputStream is) {
//         this.is = is;
//     }
// 
//     public void run() {
//         try {
//             InputStreamReader isr = new InputStreamReader(is);
//             BufferedReader br = new BufferedReader(isr);
//             String line;
//             while ((line = br.readLine()) != null) {
//                 content += line + lineSeparator;
//             }
//         } catch (IOException ex) {
//             ex.printStackTrace();
//         }
//     }
// 
//     public String getContent() {
//         return content;
//     }
// }


import org.commonwl.view.util.StreamGobbler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);

            String line;
            if ((line = br.readLine()) != null) {
                cwlToolVersion = line.substring(line.indexOf(' ') + 1);
                return cwlToolVersion;
            } else {
                return "<error getting cwl version>";
            }
        } catch (IOException ex) {
            return "<error getting cwl version>";
        }
    }

    /**
     * Runs cwltool on a workflow with a given argument
     * @param argument The argument for cwltool
     * @param workflowUrl The url of the workflow
     * @return The standard output of cwltool
     * @throws CWLValidationException Errors from cwltool
     */
    private String runCwltoolOnWorkflow(String argument, String workflowUrl) throws CWLValidationException {
        try {
            // Run command
            String[] command = {"cwltool", "--non-strict", "--quiet", "--skip-schemas", argument, workflowUrl};
            ProcessBuilder cwlToolProcess = new ProcessBuilder(command);
            Process process = cwlToolProcess.start();

            // Read output from the process using threads
// Path: src/main/java/org/commonwl/view/util/StreamGobbler.java
// public class StreamGobbler extends Thread {
//     private final String lineSeparator = System.getProperty("line.separator");
// 
//     private InputStream is;
//     private String content = "";
// 
//     public StreamGobbler(InputStream is) {
//         this.is = is;
//     }
// 
//     public void run() {
//         try {
//             InputStreamReader isr = new InputStreamReader(is);
//             BufferedReader br = new BufferedReader(isr);
//             String line;
//             while ((line = br.readLine()) != null) {
//                 content += line + lineSeparator;
//             }
//         } catch (IOException ex) {
//             ex.printStackTrace();
//         }
//     }
// 
//     public String getContent() {
//         return content;
//     }
// }


// Path: src/main/java/org/commonwl/view/cwl/CWLTool.java
import org.commonwl.view.util.StreamGobbler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);

            String line;
            if ((line = br.readLine()) != null) {
                cwlToolVersion = line.substring(line.indexOf(' ') + 1);
                return cwlToolVersion;
            } else {
                return "<error getting cwl version>";
            }
        } catch (IOException ex) {
            return "<error getting cwl version>";
        }
    }

    /**
     * Runs cwltool on a workflow with a given argument
     * @param argument The argument for cwltool
     * @param workflowUrl The url of the workflow
     * @return The standard output of cwltool
     * @throws CWLValidationException Errors from cwltool
     */
    private String runCwltoolOnWorkflow(String argument, String workflowUrl) throws CWLValidationException {
        try {
            // Run command
            String[] command = {"cwltool", "--non-strict", "--quiet", "--skip-schemas", argument, workflowUrl};
            ProcessBuilder cwlToolProcess = new ProcessBuilder(command);
            Process process = cwlToolProcess.start();

            // Read output from the process using threads
            StreamGobbler inputGobbler = new StreamGobbler(process.getInputStream());