Search in sources :

Example 1 with AccountabilityManager

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);
}
Also used : LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) AccountabilityManager(org.eclipse.winery.accountability.AccountabilityManager)

Example 2 with AccountabilityManager

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())));
}
Also used : DocumentBasedCsarEntry(org.eclipse.winery.repository.export.entries.DocumentBasedCsarEntry) CsarEntry(org.eclipse.winery.repository.export.entries.CsarEntry) XMLDefinitionsBasedCsarEntry(org.eclipse.winery.repository.export.entries.XMLDefinitionsBasedCsarEntry) RepositoryRefBasedCsarEntry(org.eclipse.winery.repository.export.entries.RepositoryRefBasedCsarEntry) DefinitionsBasedCsarEntry(org.eclipse.winery.repository.export.entries.DefinitionsBasedCsarEntry) HashMap(java.util.HashMap) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) AccountabilityManager(org.eclipse.winery.accountability.AccountabilityManager) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with AccountabilityManager

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;
}
Also used : AccountabilityManager(org.eclipse.winery.accountability.AccountabilityManager) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId)

Aggregations

AccountabilityManager (org.eclipse.winery.accountability.AccountabilityManager)3 HashMap (java.util.HashMap)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 LocalDateTime (java.time.LocalDateTime)1 Map (java.util.Map)1 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)1 CsarEntry (org.eclipse.winery.repository.export.entries.CsarEntry)1 DefinitionsBasedCsarEntry (org.eclipse.winery.repository.export.entries.DefinitionsBasedCsarEntry)1 DocumentBasedCsarEntry (org.eclipse.winery.repository.export.entries.DocumentBasedCsarEntry)1 RepositoryRefBasedCsarEntry (org.eclipse.winery.repository.export.entries.RepositoryRefBasedCsarEntry)1 XMLDefinitionsBasedCsarEntry (org.eclipse.winery.repository.export.entries.XMLDefinitionsBasedCsarEntry)1