@Override public synchronized void storeCSAR(Csar csar, String yaml) { Path csarDirectoryPath = rootPath.resolve(csar.getName()).resolve(csar.getVersion()); String realName = csar.getName().concat("-").concat(csar.getVersion()).concat("." + CSAR_EXTENSION); createCSARDirectory(csarDirectoryPath, realName); Path csarExpandedDirectoryPath = csarDirectoryPath.resolve(EXPANDED); try { Files.createDirectories(csarExpandedDirectoryPath); Path targetPath = csarExpandedDirectoryPath.resolve(csar.getYamlFilePath()); try (BufferedWriter writer = Files.newBufferedWriter(targetPath)) { writer.write(yaml); } } catch (IOException e) { throw new CSARDirectoryCreationFailureException( "Error while trying to create the CSAR directory <" + csarDirectoryPath.toString() + ">. " + e.getMessage(), e); } }
private ParsingResult toParsingResult(ParsingException exception) { ParsingResult<Csar> failedResult = new ParsingResult<>(); failedResult.setContext(ArchiveParserUtil.toParsingContext(exception.getFileName(), exception.getParsingErrors())); if (StringUtils.isNotBlank(EditionContextManager.getCsar().getYamlFilePath())) { failedResult.getContext().setFileName(EditionContextManager.getCsar().getYamlFilePath()); } return failedResult; } }
private void saveYamlAndZipFile() throws IOException { // Update the yaml in the archive Csar csar = EditionContextManager.getCsar(); Path targetPath = EditionContextManager.get().getLocalGitPath().resolve(csar.getYamlFilePath()); String yaml = exportService.getYaml(csar, EditionContextManager.getTopology()); try (BufferedWriter writer = Files.newBufferedWriter(targetPath)) { writer.write(yaml); } // Update the archive zip for download repositoryService.updateArchiveZip(EditionContextManager.getCsar().getName(), EditionContextManager.getCsar().getVersion()); }
if (csar.getYamlFilePath() == null) { csar.setYamlFilePath("topology.yml"); Files.write(topologyPath.resolve(csar.getYamlFilePath()), yaml.getBytes(Charset.forName("UTF-8"))); archiveRepositry.storeCSAR(csar, topologyPath);
@Override public void process(Csar csar, Topology topology, DeleteFileOperation operation) { // Topology topology = EditionContextManager.get().getTopology(); if (csar.getYamlFilePath().equals(operation.getPath())) { throw new InvalidPathException("Topology yaml file cannot be removed."); } TreeNode target = FileProcessorHelper.getFileTreeNode(operation.getPath()); target.getParent().getChildren().remove(target); for (NodeTemplate nodeTemplate : safe(topology.getNodeTemplates()).values()) { for (DeploymentArtifact artifact : safe(nodeTemplate.getArtifacts()).values()) { resetRemovedArtifact(artifact, operation.getPath()); } cleanupInterfaces(nodeTemplate.getInterfaces(), operation.getPath()); for (RelationshipTemplate relationshipTemplate : safe(nodeTemplate.getRelationships()).values()) { cleanupInterfaces(relationshipTemplate.getInterfaces(), operation.getPath()); } } }
if (csar.getYamlFilePath().equals(operation.getPath())) {