/** * Callback called when the visitor is done. * * @param code the completion code * @param message an optional error message */ public void onDone(CompletionCode code, String message) { synchronized (this) { completed = true; result = new Result(); result.code = code; result.message = message; notifyAll(); } }
private static void throwIfFatalVisitingError(VisitorControlHandler handler, RestUri restUri) throws RestApiException { final VisitorControlHandler.Result result = handler.getResult(); if (result.getCode() == VisitorControlHandler.CompletionCode.TIMEOUT) { if (! handler.hasVisitedAnyBuckets()) { throw new RestApiException(Response.createErrorResponse(500, "Timed out", restUri, RestUri.apiErrorCodes.TIME_OUT)); } // else: some progress has been made, let client continue with new token. } else if (result.getCode() != VisitorControlHandler.CompletionCode.SUCCESS) { throw new RestApiException(Response.createErrorResponse(400, result.toString(), RestUri.apiErrorCodes.VISITOR_ERROR)); } }