Java Code Examples for org.apache.jena.riot.web.HttpOp#setDefaultHttpClient()
The following examples show how to use
org.apache.jena.riot.web.HttpOp#setDefaultHttpClient() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestDeltaFusekiGood.java From rdf-delta with Apache License 2.0 | 6 votes |
@BeforeClass public static void beforeClass() { try { dftStdHttpClient = HttpOp.getDefaultHttpClient(); HttpOp.setDefaultHttpClient(HttpClients.createMinimal()); deltaServer = deltaServer(CLEAN); // This needs testing. server1 = fuseki1(CLEAN); server2 = fuseki2(CLEAN); // Can not create! URL_DPS = "http://localhost:"+D_PORT+"/"; conn1 = RDFConnectionFactory.connect("http://localhost:"+F1_PORT+ds1) ; conn2 = RDFConnectionFactory.connect("http://localhost:"+F2_PORT+ds2) ; } catch (Throwable th) { th.printStackTrace(); } }
Example 2
Source File: SPARQLEndpointExecution.java From hypergraphql with Apache License 2.0 | 5 votes |
@Override public SPARQLExecutionResult call() { Map<String, Set<String>> resultSet = new HashMap<>(); markers.forEach(marker -> resultSet.put(marker, new HashSet<>())); Model unionModel = ModelFactory.createDefaultModel(); SPARQLServiceConverter converter = new SPARQLServiceConverter(schema); String sparqlQuery = converter.getSelectQuery(query, inputSubset, rootType); logger.info(sparqlQuery); CredentialsProvider credsProvider = new BasicCredentialsProvider(); Credentials credentials = new UsernamePasswordCredentials(this.sparqlEndpointService.getUser(), this.sparqlEndpointService.getPassword()); credsProvider.setCredentials(AuthScope.ANY, credentials); HttpClient httpclient = HttpClients.custom() .setDefaultCredentialsProvider(credsProvider) .build(); HttpOp.setDefaultHttpClient(httpclient); Query jenaQuery = QueryFactory.create(sparqlQuery); QueryEngineHTTP qEngine = QueryExecutionFactory.createServiceRequest(this.sparqlEndpointService.getUrl(), jenaQuery); qEngine.setClient(httpclient); ResultSet results = qEngine.execSelect(); results.forEachRemaining(solution -> { markers.stream().filter(solution::contains).forEach(marker -> resultSet.get(marker).add(solution.get(marker).asResource().getURI())); unionModel.add(this.sparqlEndpointService.getModelFromResults(query, solution, schema)); }); SPARQLExecutionResult sparqlExecutionResult = new SPARQLExecutionResult(resultSet, unionModel); logger.info(sparqlExecutionResult); return sparqlExecutionResult; }
Example 3
Source File: TestDeltaFusekiGood.java From rdf-delta with Apache License 2.0 | 5 votes |
@AfterClass public static void afterClass() { if ( server1 != null ) server1.stop(); if ( server2 != null ) server2.stop(); deltaServer.stop(); IO.close( ((CloseableHttpClient)HttpOp.getDefaultHttpClient()) ); HttpOp.setDefaultHttpClient(dftStdHttpClient); }
Example 4
Source File: Setup.java From rdf-delta with Apache License 2.0 | 5 votes |
/** Set the HttpClient - close the old one if appropriate */ /*package*/ static void setHttpClient(HttpClient newHttpClient) { HttpClient hc = HttpOp.getDefaultHttpClient() ; if ( hc instanceof CloseableHttpClient ) IO.close((CloseableHttpClient)hc) ; HttpOp.setDefaultHttpClient(newHttpClient) ; }
Example 5
Source File: SPARQLEndpointExecution.java From hypergraphql with Apache License 2.0 | 4 votes |
@Override public SPARQLExecutionResult call() { Map<String, Set<String>> resultSet = new HashMap<>(); markers.forEach(marker -> resultSet.put(marker, new HashSet<>())); Model unionModel = ModelFactory.createDefaultModel(); SPARQLServiceConverter converter = new SPARQLServiceConverter(schema); String sparqlQuery = converter.getSelectQuery(query, inputSubset, rootType); logger.debug(sparqlQuery); CredentialsProvider credsProvider = new BasicCredentialsProvider(); Credentials credentials = new UsernamePasswordCredentials(this.sparqlEndpointService.getUser(), this.sparqlEndpointService.getPassword()); credsProvider.setCredentials(AuthScope.ANY, credentials); HttpClient httpclient = HttpClients.custom() .setDefaultCredentialsProvider(credsProvider) .build(); HttpOp.setDefaultHttpClient(httpclient); ARQ.init(); Query jenaQuery = QueryFactory.create(sparqlQuery); QueryEngineHTTP qEngine = QueryExecutionFactory.createServiceRequest(this.sparqlEndpointService.getUrl(), jenaQuery); qEngine.setClient(httpclient); //qEngine.setSelectContentType(ResultsFormat.FMT_RS_XML.getSymbol()); ResultSet results = qEngine.execSelect(); results.forEachRemaining(solution -> { markers.stream().filter(solution::contains).forEach(marker -> resultSet.get(marker).add(solution.get(marker).asResource().getURI())); unionModel.add(this.sparqlEndpointService.getModelFromResults(query, solution, schema)); }); SPARQLExecutionResult sparqlExecutionResult = new SPARQLExecutionResult(resultSet, unionModel); logger.debug("Result: {}", sparqlExecutionResult); return sparqlExecutionResult; }
Example 6
Source File: TestDeltaFusekiBad.java From rdf-delta with Apache License 2.0 | 4 votes |
@Before public void before() { HttpOp.setDefaultHttpClient(HttpClients.createMinimal()); }
Example 7
Source File: TestDeltaFusekiBad.java From rdf-delta with Apache License 2.0 | 4 votes |
@AfterClass public static void resetHttpOp() { HttpOp.setDefaultHttpClient(dftStdHttpClient) ; }