use of java.net.http.HttpClient in project jena by apache.
the class DSP method GET.
/**
* GET dataset.
* <p>
* If the remote end is a graph, the result is a dataset with that
* graph data in the default graph of the dataset.
*/
public DatasetGraph GET() {
ensureAcceptHeader(WebContent.defaultRDFAcceptHeader);
DatasetGraph dsg = DatasetGraphFactory.createTxnMem();
HttpClient hc = requestHttpClient(serviceEndpoint, serviceEndpoint);
HttpRDF.httpGetToStream(hc, serviceEndpoint, httpHeaders, StreamRDFLib.dataset(dsg));
return dsg;
}
use of java.net.http.HttpClient in project jena by apache.
the class DSP method PUT.
/**
* PUT a dataset
*/
public void PUT(DatasetGraph dataset) {
RDFFormat requestFmt = rdfFormat(HttpEnv.defaultQuadsFormat);
HttpClient hc = requestHttpClient(serviceEndpoint, serviceEndpoint);
HttpRDF.httpPutDataset(hc, serviceEndpoint, dataset, requestFmt, httpHeaders);
}
use of java.net.http.HttpClient in project jena by apache.
the class RDFParserBuilder method build.
/**
* Build an {@link RDFParser}. The parser takes it's configuration from this builder and can not then be changed.
* The source must be set.
* When a parser is used, it is takes the source and sends output to an {@link StreamRDF}.
* <p>
* Shortcuts:
* <ul>
* <li>{@link #parse(DatasetGraph)} - parse the source and output to a {@code DatasetGraph}
* <li>{@link #parse(Graph)} - parse the source and output to a {@code Graph}
* <li>{@link #parse(StreamRDF)} - parse the source and output to a {@code StreamRDF}
* </ul>
*
* @return RDFParser
*/
public RDFParser build() {
// Build what we can now - some things have to be built in the parser.
if (uri == null && path == null && stringToParse == null && inputStream == null && javaReader == null)
throw new RiotException("No source specified");
Context context = contextAcc.context();
// Setup the HTTP client.
HttpClient clientJDK = (httpClient != null) ? httpClient : HttpEnv.getDftHttpClient();
FactoryRDF factory$ = buildFactoryRDF();
ErrorHandler errorHandler$ = errorHandler;
if (errorHandler$ == null)
errorHandler$ = ErrorHandlerFactory.getDefaultErrorHandler();
// Select base for the parser.
// The order is baseURI > path > uri.
// baseURI or uri may be a filename or relative and need converting to a URI.
String parserBaseURI;
if (baseURI != null)
parserBaseURI = IRIs.toBase(baseURI);
else if (path != null)
parserBaseURI = IRILib.filenameToIRI(path.toString());
else if (uri != null)
parserBaseURI = IRIs.toBase(uri);
else
parserBaseURI = null;
StreamManager sMgr = streamManager;
if (sMgr == null)
sMgr = StreamManager.get(context);
// Can't build the profile here as it is Lang/conneg dependent.
return new RDFParser(uri, path, stringToParse, inputStream, javaReader, sMgr, appAcceptHeader, httpHeaders, clientJDK, hintLang, forceLang, parserBaseURI, strict, checking, canonicalValues, langTagForm, resolveURIs, resolver, factory$, errorHandler$, context);
}
use of java.net.http.HttpClient in project jena by apache.
the class GSP method POST.
// /**
// * Get a graph.
// * <p>
// * Synonym for {@link #GET()}.
// */
// public Graph getGraph() {
// // Synonym
// return GET();
// }
/**
* POST the contents of a file using the filename extension to determine the
* Content-Type to use if it is not already set.
* <p>
* This operation does not parse the file.
*/
public void POST(String file) {
validateGraphOperation();
String url = graphRequestURL();
String fileExtContentType = contentTypeFromFilename(file);
HttpClient hc = requestHttpClient(serviceEndpoint, url);
uploadTriples(hc, url, file, fileExtContentType, httpHeaders, Push.POST);
}
use of java.net.http.HttpClient in project jena by apache.
the class GSP method GET.
// Synonyms mirror the dataset names, so getGraph/getDataset
/**
* Get a graph
*/
public Graph GET() {
validateGraphOperation();
ensureAcceptHeader(WebContent.defaultGraphAcceptHeader);
String url = graphRequestURL();
Graph graph = GraphFactory.createDefaultGraph();
HttpClient hc = requestHttpClient(serviceEndpoint, url);
HttpRDF.httpGetToStream(hc, url, httpHeaders, StreamRDFLib.graph(graph));
return graph;
}
Aggregations