use of won.protocol.agreement.IncompleteConversationDataException in project webofneeds by researchstudio-sat.
the class WonConversationUtils method getAgreementProtocolState.
public static AgreementProtocolState getAgreementProtocolState(URI connectionUri, LinkedDataSource linkedDataSource) {
URI atomUri = WonRelativeUriHelper.stripConnectionSuffix(connectionUri);
// allow each resource to be re-crawled once for each reason
Set<URI> recrawledForIncompleteness = new HashSet<>();
Set<URI> recrawledForFailedFetch = new HashSet<>();
while (true) {
// we leave the loop either with a runtime exception or with the result
try {
Dataset conversationDataset = WonLinkedDataUtils.getConversationAndAtomsDatasetUsingAtomUriAsWebId(connectionUri, linkedDataSource);
return AgreementProtocolState.of(conversationDataset);
} catch (IncompleteConversationDataException e) {
// we may have tried to crawl a conversation dataset of which messages
// were still in-flight. we allow one re-crawl attempt per exception before
// we throw the exception on:
refreshDataForConnection(connectionUri, atomUri, linkedDataSource);
if (!recrawl(recrawledForIncompleteness, connectionUri, atomUri, linkedDataSource, e.getMissingMessageUri(), e.getReferringMessageUri())) {
throw e;
}
} catch (LinkedDataFetchingException e) {
// we may have tried to crawl a conversation dataset of which messages
// were still in-flight. we allow one re-crawl attempt per exception before
// we throw the exception on:
refreshDataForConnection(connectionUri, atomUri, linkedDataSource);
if (!recrawl(recrawledForFailedFetch, connectionUri, atomUri, linkedDataSource, e.getResourceUri())) {
throw e;
}
}
}
}
Aggregations