use of java.net.http.HttpClient in project jena by apache.
the class ExAuth03_UpdateExecutionPW method exampleUpdateAuthWithHttpClient.
// HttpClient
public static void exampleUpdateAuthWithHttpClient() {
System.out.println();
System.out.println("HttpClient + UpdateExecutionHTTP");
Authenticator authenticator = AuthLib.authenticator("u", "p");
HttpClient httpClient = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).authenticator(authenticator).build();
UpdateExecutionHTTP.service(dataURL).httpClient(httpClient).update("CLEAR ALL").execute();
}
use of java.net.http.HttpClient in project jena by apache.
the class AbstractTestWebappAuth_JDK method withAuthJDK.
public static UpdateExecutionHTTP withAuthJDK(UpdateExecutionHTTPBuilder builder, String user, String passwd) {
Authenticator authenticator = AuthLib.authenticator(user, passwd);
HttpClient hc = HttpClient.newBuilder().authenticator(authenticator).build();
return builder.httpClient(hc).build();
}
use of java.net.http.HttpClient in project jena by apache.
the class GSP method PUT.
// /**
// * PUT the contents of a file using the filename extension to determine the
// * Content-Type to use if it is not already set.
// * <p>
// * Synonym for {@link #PUT(String)}.
// * <p>
// * This operation does not parse the file.
// * <p>
// * If the data may have quads (named graphs), use {@link #putDataset(String)}.
// */
// public void putGraph(String file) {
// // Synonym
// PUT(file);
// }
/**
* PUT a graph.
*/
public void PUT(Graph graph) {
validateGraphOperation();
RDFFormat requestFmt = rdfFormat(HttpEnv.defaultTriplesFormat);
String url = graphRequestURL();
HttpClient hc = requestHttpClient(serviceEndpoint, url);
HttpRDF.httpPutGraph(hc, url, graph, requestFmt, httpHeaders);
}
use of java.net.http.HttpClient in project jena by apache.
the class GSP method DELETE.
// /**
// * Put a graph - replace the previous contents.
// * <p>
// * Synonym for {@link #PUT(Graph)}.
// */
// public void putGraph(Graph graph) {
// // Synonym
// PUT(graph);
// }
/**
* Delete a graph.
*/
public void DELETE() {
validateGraphOperation();
String url = graphRequestURL();
HttpClient hc = requestHttpClient(serviceEndpoint, url);
HttpRDF.httpDeleteGraph(hc, url);
}
use of java.net.http.HttpClient in project jena by apache.
the class GSP method POST.
// /**
// * Load the contents of a file into the target graph using the filename extension to determine the
// * Content-Type to use if it is not already set.
// * <p>
// * Synonym for {@link #POST(String)}.
// * <p>
// * This operation does not parse the file.
// * <p>
// * If the data may have quads (named graphs), use {@link #postDataset(String)}.
// *
// */
// public void postGraph(String file) {
// POST(file);
// }
/**
* POST a graph.
*/
public void POST(Graph graph) {
validateGraphOperation();
RDFFormat requestFmt = rdfFormat(HttpEnv.defaultTriplesFormat);
String url = graphRequestURL();
HttpClient hc = requestHttpClient(serviceEndpoint, url);
HttpRDF.httpPostGraph(hc, url, graph, requestFmt, httpHeaders);
}
Aggregations