use of org.eclipse.winery.accountability.AccountabilityManager in project winery by eclipse.
the class CsarExporter method writeCsarAndSaveManifestInProvenanceLayer.
public CompletableFuture<String> writeCsarAndSaveManifestInProvenanceLayer(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(entryId, out, exportConfiguration);
String qNameWithComponentVersionOnly = VersionSupport.getQNameWithComponentVersionOnly(entryId);
LOGGER.debug("Preparing CSAR export (provenance) lasted {}", Duration.between(LocalDateTime.now(), start).toString());
return accountabilityManager.storeFingerprint(qNameWithComponentVersionOnly, manifestString);
}
use of org.eclipse.winery.accountability.AccountabilityManager in project winery by eclipse.
the class CsarExporter method immutablyStoreRefFiles.
/**
* Stores all files listed in the map in the immutable file storage, and updates the CsarContentProperties of each
* file to contain its address in the aforementioned storage.
*
* @param filesToStore a map of the CsarContentProperties of all files to be stored in the CSAR and their contents.
*/
private void immutablyStoreRefFiles(Map<CsarContentProperties, CsarEntry> filesToStore) throws AccountabilityException, ExecutionException, InterruptedException, IOException {
AccountabilityManager manager = AccountabilityManagerFactory.getAccountabilityManager();
Map<String, InputStream> filesMap = new HashMap<>();
for (Map.Entry<CsarContentProperties, CsarEntry> entry : filesToStore.entrySet()) {
filesMap.put(entry.getKey().getPathInsideCsar(), entry.getValue().getInputStream());
}
// store all files in immutable storage (already stored files will get their same old address)
Map<String, String> addressMap = manager.storeState(filesMap).get();
filesToStore.keySet().forEach((CsarContentProperties properties) -> properties.setImmutableAddress(addressMap.get(properties.getPathInsideCsar())));
}
use of org.eclipse.winery.accountability.AccountabilityManager in project winery by eclipse.
the class CsarImporter method isValid.
private boolean isValid(ImportMetaInformation metaInformation, Map<String, File> fileMap) throws ExecutionException, InterruptedException, AccountabilityException {
ServiceTemplateId entryServiceTemplate = metaInformation.entryServiceTemplate;
metaInformation.verificationMap = new HashMap<>();
if (Objects.nonNull(entryServiceTemplate)) {
AccountabilityManager accountabilityManager = AccountabilityManagerFactory.getAccountabilityManager();
String provenanceIdentifier = VersionSupport.getQNameWithComponentVersionOnly(entryServiceTemplate);
metaInformation.verificationMap = accountabilityManager.verify(provenanceIdentifier, "TOSCA-Metadata/TOSCA.meta", fileMap).exceptionally(e -> {
LOGGER.debug("accountabilityManager.verify completed exceptionally", e);
return null;
}).get();
return metaInformation.verificationMap.values().stream().allMatch(v -> v == ProvenanceVerification.VERIFIED);
}
return false;
}
Aggregations