Search in sources :

Example 1 with IncompleteConversationDataException

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;
            }
        }
    }
}
Also used : Dataset(org.apache.jena.query.Dataset) LinkedDataFetchingException(won.protocol.rest.LinkedDataFetchingException) IncompleteConversationDataException(won.protocol.agreement.IncompleteConversationDataException) URI(java.net.URI) HashSet(java.util.HashSet)

Aggregations

URI (java.net.URI)1 HashSet (java.util.HashSet)1 Dataset (org.apache.jena.query.Dataset)1 IncompleteConversationDataException (won.protocol.agreement.IncompleteConversationDataException)1 LinkedDataFetchingException (won.protocol.rest.LinkedDataFetchingException)1