Source:
public VersionTypeValidation validateWorkflowSet(Set<SourceFile> sourcefiles, String primaryDescriptorFilePath) { List<DescriptorLanguage.FileType> fileTypes = new ArrayList<>(Collections.singletonList(DescriptorLanguage.FileType.DOCKSTORE_CWL)); Set<SourceFile> filteredSourcefiles = filterSourcefiles(sourcefiles, fileTypes); Optional<SourceFile> mainDescriptor = filteredSourcefiles.stream().filter((sourceFile -> Objects.equals(sourceFile.getPath(), primaryDescriptorFilePath))).findFirst(); boolean isValid = true; String validationMessage = null; Map<String, String> validationMessageObject = new HashMap<>(); if (mainDescriptor.isPresent()) { Yaml yaml = new Yaml(); String content = mainDescriptor.get().getContent(); if (content == null || content.isEmpty()) { isValid = false; validationMessage = "Primary descriptor is empty."; } else if (!content.contains("class: Workflow")) { isValid = false; validationMessage = "A CWL workflow requires class: Workflow."; if (content.contains("class: CommandLineTool") || content.contains("class: ExpressionTool")) { validationMessage += " This file contains class: CommandLineTool or ExpressionTool. Did you mean to register a tool?"; } } else if (!this.isValidCwl(content, yaml)) { isValid = false; validationMessage = "Invalid CWL version."; } } else { validationMessage = "Primary CWL descriptor is not present."; isValid = false; } validationMessageObject.put(primaryDescriptorFilePath, validationMessage); return new VersionTypeValidation(isValid, validationMessageObject); }

Target:
public VersionTypeValidation validateWorkflowSet(Set<SourceFile> sourcefiles, String primaryDescriptorFilePath) { List<DescriptorLanguage.FileType> fileTypes = new ArrayList<>(Collections.singletonList(DescriptorLanguage.FileType.DOCKSTORE_CWL)); Set<SourceFile> filteredSourcefiles = filterSourcefiles(sourcefiles, fileTypes); Optional<SourceFile> mainDescriptor = filteredSourcefiles.stream().filter((sourceFile -> Objects.equals(sourceFile.getPath(), primaryDescriptorFilePath))).findFirst(); boolean isValid = true; StringBuilder validationMessage = new StringBuilder(); Map<String, String> validationMessageObject = new HashMap<>(); if (mainDescriptor.isPresent()) { Yaml yaml = new Yaml(); String content = mainDescriptor.get().getContent(); if (content == null || content.isEmpty()) { isValid = false; validationMessage.append("Primary descriptor is empty."); } else if (!content.contains("class: Workflow")) { isValid = false; validationMessage.append("A CWL workflow requires 'class: Workflow'."); if (content.contains("class: CommandLineTool") || content.contains("class: ExpressionTool")) { String cwlClass = content.contains("class: CommandLineTool") ? "CommandLineTool" : "ExpressionTool"; validationMessage.append(" This file contains 'class: ").append(cwlClass).append("'. Did you mean to register a tool?"); } } else if (!this.isValidCwl(content, yaml)) { isValid = false; validationMessage.append("Invalid CWL version."); } } else { validationMessage.append("Primary CWL descriptor is not present."); isValid = false; } validationMessageObject.put(primaryDescriptorFilePath, validationMessage.toString()); return new VersionTypeValidation(isValid, validationMessageObject); }