CsarExporter { public CompletableFuture<String> writeCsarAndSaveManifestInProvenanceLayer(IRepository repository, DefinitionsChildId entryId, OutputStream out) throws IOException, RepositoryCorruptException, AccountabilityException, InterruptedException, ExecutionException { LocalDateTime start = LocalDateTime.now(); AccountabilityManager accountabilityManager = AccountabilityManagerFactory.getAccountabilityManager(); Map<String, Object> exportConfiguration = new HashMap<>(); exportConfiguration.put(CsarExportConfiguration.INCLUDE_HASHES.name(), null); exportConfiguration.put(CsarExportConfiguration.STORE_IMMUTABLY.name(), null); String manifestString = this.writeCsar(repository, entryId, out, exportConfiguration); String qNameWithComponentVersionOnly = VersionUtils.getQNameWithComponentVersionOnly(entryId); LOGGER.debug("Preparing CSAR export (provenance) lasted {}", Duration.between(LocalDateTime.now(), start).toString()); return accountabilityManager.storeFingerprint(qNameWithComponentVersionOnly, manifestString); }  static String getDefinitionsFileName(IRepository repository, DefinitionsChildId id); CompletableFuture<String> writeCsarAndSaveManifestInProvenanceLayer(IRepository repository, DefinitionsChildId entryId, OutputStream out); String writeCsar(IRepository repository, DefinitionsChildId entryId, OutputStream out, Map<String, Object> exportConfiguration); static final String PATH_TO_NAMESPACES_PROPERTIES; static final String PATH_TO_NAMESPACES_JSON; }
@Test @Disabled public void testPutCsarInBlockchainAndImmutableStorage() throws Exception { setRevisionTo("origin/plain"); CsarExporter exporter = new CsarExporter(); DefinitionsChildId id = new ServiceTemplateId("http: ByteArrayOutputStream os = new ByteArrayOutputStream(); CompletableFuture<String> future = exporter.writeCsarAndSaveManifestInProvenanceLayer(RepositoryFactory.getRepository(), id, os); String transactionHash = future.get(); assertNotNull(transactionHash); try (InputStream inputStream = new ByteArrayInputStream(os.toByteArray()); ZipInputStream zis = new ZipInputStream(inputStream)) { ManifestContents manifestContents = parseManifest(zis); assertNotNull(manifestContents); for (String section : manifestContents.getSectionNames()) { assertNotNull(manifestContents.getAttributesForSection(section).get(TOSCAMetaFileAttributes.IMMUTABLE_ADDRESS)); } } }