Source:
<code>public static String buildDockerImage(ArtifactTemplateId artifactTemplateId, IRepository repository) throws IOException { <START> TArtifactTemplate newDockerArtifactTemplate = repository.getElement(artifactTemplateId); <END> String fileLocation = Utils.findFileLocation(newDockerArtifactTemplate, repository); final String folder = fileLocation.substring(0, fileLocation.lastIndexOf("/")); final ZipInputStream zis = new ZipInputStream(new FileInputStream(fileLocation)); List<String> zipFiles = Utils.getFileListFromZip(zis, folder.concat("/")); String referencedFile = ""; if (zipFiles.contains("Dockerfile")) { final String dockerImageName = fileLocation.substring(fileLocation.lastIndexOf("/") + 1, fileLocation.lastIndexOf(".")); try { commandLineExecuter(folder, "docker", "build", "-t", dockerImageName, "."); commandLineExecuter(folder, "docker", "save", "-o", dockerImageName + ".tar", dockerImageName + ":latest"); referencedFile = dockerImageName + ".tar.gz"; final String compressedFile = Utils.compressTarFile(new File(folder + "/" + dockerImageName + ".tar")); if (compressedFile != null) { final File folderFile = new File(folder); Utils.deleteFilesInFolder(folderFile, "gz"); } } catch (Exception e) { throw new RuntimeException("Failed to build Docker image"); } } if (StringUtils.isNotBlank(referencedFile)) { TArtifactReference artifactReference = new TArtifactReference(); artifactReference.setReference("artifacttemplates/http%253A%252F%252Fopentosca.org%252Fartifacttemplates/" + artifactTemplateId.getQName().getLocalPart() + "/files/" + referencedFile); TArtifactTemplate.ArtifactReferences artifactReferences = new TArtifactTemplate.ArtifactReferences(); artifactReferences.getArtifactReference().add(artifactReference); newDockerArtifactTemplate.setArtifactReferences(artifactReferences); repository.setElement(artifactTemplateId, newDockerArtifactTemplate); } return referencedFile; }</code><technical_language>remove empty lines vars</technical_language>

Target:
public static String buildDockerImage(ArtifactTemplateId artifactTemplateId, IRepository repository) throws IOException { TArtifactTemplate newDockerArtifactTemplate = repository.getElement(artifactTemplateId); String fileLocation = Utils.findFileLocation(newDockerArtifactTemplate, repository); String folder = fileLocation.substring(0, fileLocation.lastIndexOf("/")); ZipInputStream zis = new ZipInputStream(new FileInputStream(fileLocation)); List<String> zipFiles = Utils.getFileListFromZip(zis, folder.concat("/")); StringBuilder referencedFile = new StringBuilder(); if (zipFiles.contains("Dockerfile")) { String dockerImageName = fileLocation.substring(fileLocation.lastIndexOf(File.pathSeparator) + 1, fileLocation.lastIndexOf(".")); try { commandLineExecutor(folder, "docker", "build", "-t", dockerImageName, "."); commandLineExecutor(folder, "docker", "save", "-o", dockerImageName + ".tar", dockerImageName + ":latest"); referencedFile.append(dockerImageName + ".tar.gz"); Utils.compressTarFile(new File(folder + File.pathSeparator + dockerImageName + ".tar")); File folderFile = new File(folder); Utils.deleteFilesInFolder(folderFile, "gz"); } catch (Exception e) { throw new RuntimeException("Failed to build Docker image"); } } if (StringUtils.isNotBlank(referencedFile)) { BackendUtils.synchronizeReferences(repository, artifactTemplateId); repository.setElement(artifactTemplateId, newDockerArtifactTemplate); } return referencedFile.toString(); }