@Override public CompletableFuture<List<ModelProvenanceElement>> getHistory(String processIdentifier) { CompletableFuture<AuthorizationInfo> authorizationTree = this.blockchain.getAuthorizationTree(processIdentifier); return this.blockchain .getProvenance(processIdentifier) .thenCombine(authorizationTree, this::enhanceHistoryElements); }
@Override public CompletableFuture<Map<String, ProvenanceVerification>> verify(String processIdentifier, String manifestId, Map<String, File> files) { Objects.requireNonNull(processIdentifier); Objects.requireNonNull(manifestId); Objects.requireNonNull(files); LOGGER.info("Verifying process id: " + processIdentifier); CompletableFuture<AuthorizationInfo> authorizationTree = this.blockchain.getAuthorizationTree(processIdentifier); return this.blockchain .getProvenance(processIdentifier) .thenCombine(authorizationTree, (provenanceElements, authorizationInfo) -> { // TODO: extract into one method and write test cases Map<String, ProvenanceVerification> map = null; try { if (authorizationInfo == null) { LOGGER.info(NO_AUTHORIZATION_DATA); map = new HashMap<>(); map.put(manifestId, NO_AUTHORIZATION_DATA_AVAILABLE); } else { map = this.validateBlockchainInput(provenanceElements, manifestId, files, authorizationInfo); } } catch (NoSuchAlgorithmException e) { LOGGER.error("Could not find the hashing algorithm.", e); } catch (IOException e) { LOGGER.error("Could not transform file to byte array.", e); } catch (SerializationException e) { LOGGER.error("Could not deserialize stored manifest file.", e); } return map; }); }
@Override public CompletableFuture<List<FileProvenanceElement>> getHistory(String processIdentifier, String fileId) { CompletableFuture<AuthorizationInfo> authorizationTree = this.blockchain.getAuthorizationTree(processIdentifier); return this.blockchain .getProvenance(processIdentifier) .thenCombine(authorizationTree, (provenanceElements, authorizationInfo) -> { List<FileProvenanceElement> result; if (authorizationInfo != null) { result = getHistoryOfSingleFile(provenanceElements, fileId, authorizationInfo); } else { LOGGER.info(NO_AUTHORIZATION_DATA); FileProvenanceElement historyElement = new FileProvenanceElement("", 0, NO_AUTHORIZATION_DATA); historyElement.setAuthorized(false); historyElement.setFileName(fileId); result = Collections.singletonList(historyElement); } return result; }); }