private static boolean isFuseki(HttpOptions request, HttpClient httpClient, HttpContext httpContext) { try { HttpResponse response = httpClient.execute(request); // Fuseki does not send "Server" in release mode. // (best practice). // All we can do is try for the "Fuseki-Request-ID" String reqId = safeGetHeader(response, "Fuseki-Request-ID"); if ( reqId != null ) return true; // If returning "Server" String serverIdent = safeGetHeader(response, "Server"); if ( serverIdent != null ) { Log.debug(ARQ.getHttpRequestLogger(), "Server: "+serverIdent); boolean isFuseki = serverIdent.startsWith("Apache Jena Fuseki"); if ( !isFuseki ) isFuseki = serverIdent.toLowerCase().contains("fuseki"); return isFuseki; } return false; } catch (IOException ex) { throw new HttpException("Failed to check for a Fuseki server", ex); } }
private static void expectQuery(Runnable action, int expected) { try { action.run(); throw new HttpException("action completed"); } catch (QueryExceptionHTTP ex) { if ( ex.getResponseCode() != expected ) throw ex; } }
private static boolean isFuseki(HttpOptions request, HttpClient httpClient, HttpContext httpContext) { try { HttpResponse response = httpClient.execute(request); // Fuseki does not send "Server" in release mode. // (best practice). // All we can do is try for the "Fuseki-Request-ID" String reqId = safeGetHeader(response, "Fuseki-Request-ID"); if ( reqId != null ) return true; // If returning "Server" String serverIdent = safeGetHeader(response, "Server"); if ( serverIdent != null ) { Log.debug(ARQ.getHttpRequestLogger(), "Server: "+serverIdent); boolean isFuseki = serverIdent.startsWith("Apache Jena Fuseki"); if ( !isFuseki ) isFuseki = serverIdent.toLowerCase().contains("fuseki"); return isFuseki; } return false; } catch (IOException ex) { throw new HttpException("Failed to check for a Fuseki server", ex); } }
private static void expectQuery(Runnable action, int expected) { try { action.run(); throw new HttpException("action completed"); } catch (QueryExceptionHTTP ex) { if ( ex.getResponseCode() != expected ) throw ex; } }
throw new HttpException(statusLine.getStatusCode(), statusLine.getReasonPhrase(), contentPayload); throw new HttpException(ex);
throw new HttpException(statusLine.getStatusCode(), statusLine.getReasonPhrase()); handler.handle(baseURI, response); } catch (IOException ex) { throw new HttpException(ex);
public static RuntimeException makeHumanFriendly(Exception e) { RuntimeException result; if(e instanceof HttpException) { HttpException x = (HttpException)e; result = new HttpException(x.getResponse(), e); } else if(e instanceof QueryExceptionHTTP) { QueryExceptionHTTP x = (QueryExceptionHTTP)e; result = new QueryExceptionHTTP(x.getResponseMessage() + " " + x.getMessage(), e); } else { result = new RuntimeException(e); } return result; } }
LOG.warn("Failed to login against " + login.getLoginFormURL() + " to obtain authentication for access to " + target.toString()); throw new HttpException(response.getStatusLine().getStatusCode(), "Login attempt failed - " + response.getStatusLine().getReasonPhrase()); throw new HttpException("UTF-8 encoding not supported on your platform", e); } catch (IOException e) { throw new HttpException("Error making login request", e);
public void sync() { try { checkDeltaConnection(); PatchLogInfo logInfo = getPatchLogInfo(); sync(logInfo); } catch (HttpException ex) { if ( ex.getResponseCode() == -1 ) throw new HttpException(HttpSC.SERVICE_UNAVAILABLE_503, HttpSC.getMessage(HttpSC.SERVICE_UNAVAILABLE_503), ex.getMessage()); throw ex; } }