本文整理汇总了Java中org.apache.jena.riot.web.HttpOp类的典型用法代码示例。如果您正苦于以下问题:Java HttpOp类的具体用法?Java HttpOp怎么用?Java HttpOp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpOp类属于org.apache.jena.riot.web包,在下文中一共展示了HttpOp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeJsonLd
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
private void writeJsonLd(final OutputStream output, final DatasetGraph graph, final IRI... profiles) {
final String profile = getCustomJsonLdProfile(profiles);
final RDFFormat format = nonNull(profile) && nonNull(cache) ? JSONLD_COMPACT_FLAT : getJsonLdProfile(profiles);
final WriterDatasetRIOT writer = RDFDataMgr.createDatasetWriter(format);
final PrefixMap pm = RiotLib.prefixMap(graph);
final String base = null;
final JsonLDWriteContext ctx = new JsonLDWriteContext();
if (nonNull(profile) && nonNull(cache)) {
LOGGER.debug("Setting JSON-LD context with profile: {}", profile);
final String c = cache.get(profile, p -> {
try (final TypedInputStream res = HttpOp.execHttpGet(profile)) {
return IOUtils.toString(res.getInputStream(), UTF_8);
} catch (final IOException | HttpException ex) {
LOGGER.warn("Error fetching profile {}: {}", p, ex.getMessage());
return null;
}
});
if (nonNull(c)) {
ctx.setJsonLDContext(c);
ctx.setJsonLDContextSubstitution("\"" + profile + "\"");
}
}
writer.write(output, graph, pm, base, ctx);
}
示例2: SparqlPersistance
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
@Inject
public SparqlPersistance(@Named("r2r.fusekiUrl") String sparqlQuery, SparqlPostClient sparqlClient) throws Exception {
this.sparqlQuery = new SparqlQueryClient(sparqlQuery + "/query");
this.sparqlClient = sparqlClient;
// putting this here for now
HttpParams params = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(params, 10000);
HttpConnectionParams.setSoTimeout(params, 40000);
PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
cm.setDefaultMaxPerRoute(20);
cm.setMaxTotal(200);
HttpOp.setDefaultHttpClient(new DefaultHttpClient(cm, params));
// make sure we have the latest model
// for some reason we need to do post to capture the prefixes
sparqlClient.post(R2ROntology.createR2ROntModel());
sparqlClient.update("CREATE GRAPH <" + R2R_DERIVED_GRAPH + ">");
// by loading these now, we make sure that we do not collide with calls to upsertAffiliation
knownAffiliations = loadAffiliations();
}
示例3: handle
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
@Override
public void handle(Patch patch) {
IndentedLineBuffer x = new IndentedLineBuffer() ;
RDFChanges scData = new RDFChangesWriteUpdate(x) ;
patch.play(scData);
x.flush();
String reqStr = x.asString() ;
updateEndpoints.forEach((ep)->{
try { HttpOp.execHttpPost(ep, WebContent.contentTypeSPARQLUpdate, reqStr) ; }
catch (HttpException ex) { DPS.LOG.warn("Failed to send to "+ep) ; }
}) ;
}
示例4: beforeClass
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() {
dftStdHttpClient = HttpOp.getDefaultHttpClient();
HttpOp.setDefaultHttpClient(HttpClients.createMinimal());
patchLogServer = patchLogServer();
server1 = fuseki1();
server2 = fuseki2();
URL_DPS = "http://localhost:"+D_PORT+"/";
conn1 = RDFConnectionFactory.connect("http://localhost:"+F1_PORT+ds1) ;
conn2 = RDFConnectionFactory.connect("http://localhost:"+F2_PORT+ds2) ;
}
示例5: afterClass
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
@AfterClass
public static void afterClass() {
server1.stop();
server2.stop();
patchLogServer.stop();
IO.close( ((CloseableHttpClient)HttpOp.getDefaultHttpClient()) );
HttpOp.setDefaultHttpClient(dftStdHttpClient);
}
示例6: if
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
/** 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) ;
}
示例7: fetchCommon
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
private RDFPatch fetchCommon(Id dsRef, String param, Object value, String valueLogStr) {
checkLink();
String url = remoteReceive;
url = createURL(url, DeltaConst.paramDatasource, dsRef.asParam());
url = appendURL(url, value.toString());
url = addToken(url);
final String s = url;
FmtLog.info(Delta.DELTA_HTTP_LOG, "Fetch request: %s %s=%s [%s]", dsRef, param, valueLogStr, url);
try {
return retry(()->{
// [NET] Network point
InputStream in = HttpOp.execHttpGet(s) ;
if ( in == null )
return null ;
RDFPatchReaderText pr = new RDFPatchReaderText(in) ;
RDFChangesCollector collector = new RDFChangesCollector();
pr.apply(collector);
return collector.getRDFPatch();
}, ()->true, ()->"Retry fetch patch.", ()->"Failed to fetch patch.");
}
catch ( HttpException ex) {
if ( ex.getResponseCode() == HttpSC.NOT_FOUND_404 )
return null ; //throw new DeltaNotFoundException(ex.getMessage());
throw ex;
}
}
示例8: buildHttpClient
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
public static HttpClient buildHttpClient(String serviceURI, String user, String password) {
if ( user == null )
return HttpOp.getDefaultHttpClient();
CredentialsProvider credsProvider = new BasicCredentialsProvider();
Credentials credentials = new UsernamePasswordCredentials(user, password);
credsProvider.setCredentials(AuthScope.ANY, credentials);
return HttpClients.custom()
.setDefaultCredentialsProvider(credsProvider)
.build();
// Example for scoped credentials
// See http://jena.staging.apache.org/documentation/query/http-auth.html
// CredentialsProvider credsProvider = new BasicCredentialsProvider();
// Credentials unscopedCredentials = new UsernamePasswordCredentials("user", "passwd");
// credsProvider.setCredentials(AuthScope.ANY, unscopedCredentials);
// Credentials scopedCredentials = new UsernamePasswordCredentials("user", "passwd");
// final String host = "http://example.com/sparql";
// final int port = 80;
// final String realm = "aRealm";
// final String schemeName = "DIGEST";
// AuthScope authscope = new AuthScope(host, port, realm, schemeName);
// credsProvider.setCredentials(authscope, scopedCredentials);
// return HttpClients.custom()
// .setDefaultCredentialsProvider(credsProvider)
// .build();
}
示例9: getExecution
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
public static QueryExecution getExecution(String epURL, String query) throws Exception {
try {
HttpOp.setUserAgent(CONSTANTS.USER_AGENT);
log.debug("INIT QueryExecution for {} with query {}",epURL,query.replaceAll("\n", ""));
return QueryExecutionFactory.sparqlService(epURL, query);
}
catch (Exception e) {
throw new Exception(e.getMessage());
}
}
示例10: test
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
@Test
public void test() {
QueryExecution ex = QueryExecutionFactory.sparqlService("http://localhost:8000/sparql", "SELECT * WHERE { ?s ?p ?o . }");
HttpOp.setUserAgent(CONSTANTS.USER_AGENT);
ResultSet res = ex.execSelect();
while (res.hasNext()){
System.out.println("nextS");
}
}
示例11: main
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
String MIMETYPE = "application/rdf-patch";
DatasetGraph dsg = DatasetGraphFactory.createTxnMem();
Operation patchOp = Operation.register("Patch", "Patch Service");
ActionService handler = new PatchApplyService();
String EP = "patch";
String DATASET = "ds";
FusekiServer server =
FusekiServer.create()
.setPort(2022)
.registerOperation(patchOp, MIMETYPE, handler)
.add(DATASET, dsg)
.addOperation(DATASET, EP, patchOp)
.build();
try {
server.start();
BasicHttpEntity entity = new BasicHttpEntity();
entity.setContent(IO.openFile("data1.rdfp"));
HttpOp.execHttpPost("http://localhost:2022/ds/patch", entity);
System.out.println();
try(RDFConnection rconn = RDFConnectionFactory.connect("http://localhost:2022/ds")) {
try(QueryExecution qExec = rconn.query("SELECT * {?s ?p ?o}")) {
//ResultSet rs = qExec.execSelect();
QueryExecUtils.executeQuery(qExec);
}
}
// RDFDataMgr.write(System.out, dsg, Lang.TRIG);
//
// String x = HttpOp.execHttpGetString("http://localhost:2022/ds/data", "text/turtle");
// System.out.println(x);
} finally {
System.out.println();
server.stop();
}
}
示例12: resetDefaultHttpClient
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
private static void resetDefaultHttpClient() {
setHttpClient(HttpOp.createDefaultHttpClient());
}
示例13: before
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
@Before
public void before() { HttpOp.setDefaultHttpClient(HttpClients.createMinimal()); }
示例14: after
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
@After
public void after() {
IO.close( ((CloseableHttpClient)HttpOp.getDefaultHttpClient()) );
}
示例15: cpatureHttpOp
import org.apache.jena.riot.web.HttpOp; //导入依赖的package包/类
@BeforeClass
public static void cpatureHttpOp() {
dftStdHttpClient = HttpOp.getDefaultHttpClient() ;
}