public static String executeHTTPPostRequest(String serviceURL, String contentType, String acceptContentType, Map<String, String> formParameters) throws ClientProtocolException, IOException { // Prepare the message body parameters List<NameValuePair> formParams = new ArrayList<>(); for (Map.Entry<String, String> stringStringEntry : formParameters.entrySet()) { formParams.add(new BasicNameValuePair(stringStringEntry.getKey(), stringStringEntry.getValue())); } return executeHTTPPostRequest(serviceURL, contentType, acceptContentType, new UrlEncodedFormEntity(formParams, "UTF-8")); }
/** * Invokes a SPARQL query on the given Triple Store URL and returns the JSON * object containing the result. The content type of the result is * application/sparql-results+json. * * @param query * : SPARQL query * @param tripleStoreUrl * : SPARQL endpoint address of the triple store * @param acceptContentType * : The accept context type in the header * @param contextType * : * @return * @throws ClientProtocolException * @throws IOException * @throws JSONException */ public static String invokeSparqlQuery(String query, String tripleStoreUrl, String acceptContentType, String contextType) throws ClientProtocolException, IOException, JSONException { Map<String, String> formParams = new HashMap<>(); formParams.put("query", query); formParams.put("queryLn", "SPARQL"); String response = HTTPUtil.executeHTTPPostRequest(tripleStoreUrl, contextType, acceptContentType, formParams); if (response == null || response.isEmpty()) return null; return response; }
formparams.put("query", queryString); formparams.put("queryLn", "SPARQL"); String responseString = HTTPUtil.executeHTTPPostRequest( TripleStoreURL, null, "application/sparql-results+json", formparams);
formparams.put("update", queryString); String responseString = HTTPUtil.executeHTTPPostRequest( tripleStoreURL, null, mime_types.get(RDF_Types.N3.name()), formparams);
public void deleteMappingFromTripleStore(String tripleStoreURL, String context, String mappingURI) throws KarmaException { testTripleStoreConnection(tripleStoreURL); tripleStoreURL = normalizeTripleStoreURL(tripleStoreURL) + "/statements"; try { StringBuilder query = new StringBuilder(); query.append("PREFIX km-dev:<http://isi.edu/integration/karma/dev#>\n"); query.append("PREFIX rr:<http://www.w3.org/ns/r2rml#>\n"); if (null != context && !context.trim().isEmpty()) { query.append("WITH "); formatURI(context, query); query.append("\n"); } query.append("DELETE { ?s ?p ?o } \n"); query.append("WHERE\n"); injectMapping(mappingURI, query); String queryString = query.toString(); logger.debug("query: " + queryString); Map<String, String> formparams = new HashMap<>(); formparams.put("update", queryString); String responseString = HTTPUtil.executeHTTPPostRequest( tripleStoreURL, null, mime_types.get(RDF_Types.N3.name()), formparams); System.out.println(responseString); } catch (Exception e) { logger.error(e.getMessage()); } }
formparams.put("queryLn", "SPARQL"); String responseString = HTTPUtil.executeHTTPPostRequest( tripleStoreURL, null, "application/sparql-results+json", formparams);
formparams.put("queryLn", "SPARQL"); String responseString = HTTPUtil.executeHTTPPostRequest( tripleStoreURL, null, "application/sparql-results+json", formparams);
formparams.put("queryLn", "SPARQL"); String responseString = HTTPUtil.executeHTTPPostRequest( TripleStoreURL, null, "application/sparql-results+json", formparams);
public String getMappingFromTripleStore(String tripleStoreURL, String context, String mappingURI) throws KarmaException { tripleStoreURL = normalizeTripleStoreURL(tripleStoreURL); testTripleStoreConnection(tripleStoreURL); context = normalizeURI(context); mappingURI = normalizeURI(mappingURI); try { StringBuilder query = new StringBuilder(); query.append("PREFIX km-dev:<http://isi.edu/integration/karma/dev#>\n"); query.append("PREFIX rr:<http://www.w3.org/ns/r2rml#>\n"); query.append("CONSTRUCT { ?s ?p ?o }\n"); injectContext(context, query); injectMapping(mappingURI, query); String queryString = query.toString(); logger.debug("query: " + queryString); Map<String, String> formparams = new HashMap<>(); formparams.put("query", queryString); formparams.put("queryLn", "SPARQL"); String responseString = HTTPUtil.executeHTTPPostRequest( tripleStoreURL, null, mime_types.get(RDF_Types.N3.name()), formparams); if (responseString != null) { return responseString; } } catch (Exception e) { logger.error(e.getMessage()); } return ""; }
formparams.put("queryLn", "SPARQL"); String responseString = HTTPUtil.executeHTTPPostRequest( tripleStoreURL, null, "application/sparql-results+json", formparams);
formparams.put("queryLn", "SPARQL"); String responseString = HTTPUtil.executeHTTPPostRequest( tripleStoreURL, null, "application/sparql-results+json", formparams);
formparams.put("queryLn", "SPARQL"); String responseString = HTTPUtil.executeHTTPPostRequest( tripleStoreURL, null, "application/sparql-results+json", formparams);
formparams.put("queryLn", "SPARQL"); String responseString = HTTPUtil.executeHTTPPostRequest( tripleStoreURL, null, "application/sparql-results+json", formparams);
String reqResponse = HTTPUtil.executeHTTPPostRequest(cleaningServiceURL, null, null, formParams);
String reqResponse = HTTPUtil.executeHTTPPostRequest(url, "application/json", null, se);