/** * Creates a download handler that requests results in specified boolean format. * * @param file Output path. * @param format Format to return the data in. */ public AGDownloadHandler(final File file, final BooleanQueryResultFormat format) { this(file, format.getDefaultMIMEType()); }
private HttpResponse sendBooleanQueryViaHttp(HttpUriRequest method, Set<QueryResultFormat> booleanFormats) throws IOException, RDF4JException { final List<String> acceptValues = new ArrayList<>(booleanFormats.size()); for (QueryResultFormat format : booleanFormats) { // Determine a q-value that reflects the user specified preference int qValue = 10; if (preferredBQRFormat != null && !preferredBQRFormat.equals(format)) { // Prefer specified format over other formats qValue -= 2; } for (String mimeType : format.getMIMETypes()) { String acceptParam = mimeType; if (qValue < 10) { acceptParam += ";q=0." + qValue; } acceptValues.add(acceptParam); } } method.addHeader(ACCEPT_PARAM_NAME, String.join(", ", acceptValues)); return executeOK(method); }
QueryResultFormat format = BooleanQueryResultFormat.matchMIMEType(mimeType, booleanFormats).orElseThrow( () -> new RepositoryException(
private HttpResponse sendBooleanQueryViaHttp(HttpUriRequest method, Set<QueryResultFormat> booleanFormats) throws IOException, RDF4JException { final List<String> acceptValues = new ArrayList<>(booleanFormats.size()); for (QueryResultFormat format : booleanFormats) { // Determine a q-value that reflects the user specified preference int qValue = 10; if (preferredBQRFormat != null && !preferredBQRFormat.equals(format)) { // Prefer specified format over other formats qValue -= 2; } for (String mimeType : format.getMIMETypes()) { String acceptParam = mimeType; if (qValue < 10) { acceptParam += ";q=0." + qValue; } acceptValues.add(acceptParam); } } method.addHeader(ACCEPT_PARAM_NAME, String.join(", ", acceptValues)); return executeOK(method); }
QueryResultFormat format = BooleanQueryResultFormat.matchMIMEType(mimeType, booleanFormats).orElseThrow( () -> new RepositoryException(
/** * Creates a streaming handler that requests results in specified boolean format. * * @param format Format to return the data in. */ public AGRawStreamer(final BooleanQueryResultFormat format) { this(format.getDefaultMIMEType()); }
private HttpResponse sendBooleanQueryViaHttp(HttpUriRequest method, Set<QueryResultFormat> booleanFormats) throws IOException, RDF4JException { final List<String> acceptValues = new ArrayList<>(booleanFormats.size()); for (QueryResultFormat format : booleanFormats) { // Determine a q-value that reflects the user specified preference int qValue = 10; if (preferredBQRFormat != null && !preferredBQRFormat.equals(format)) { // Prefer specified format over other formats qValue -= 2; } for (String mimeType : format.getMIMETypes()) { String acceptParam = mimeType; if (qValue < 10) { acceptParam += ";q=0." + qValue; } acceptValues.add(acceptParam); } } method.addHeader(ACCEPT_PARAM_NAME, String.join(", ", acceptValues)); return executeOK(method); }
QueryResultFormat format = BooleanQueryResultFormat.matchMIMEType(mimeType, booleanFormats).orElseThrow( () -> new RepositoryException(
public AGBQRHandler() { super(BooleanQueryResultFormat.TEXT.getDefaultMIMEType()); }
@Test public void testBooleanQueryStreamMIMEType() throws Exception { final InputStream stream = boolQuery.stream(BooleanQueryResultFormat.TEXT.getDefaultMIMEType()); FileUtils.copyInputStreamToFile(stream, output); checkBoolOutput(); }
@Test public void testBooleanQueryDownloadStrMIMEType() throws Exception { boolQuery.download(output.getAbsolutePath(), BooleanQueryResultFormat.TEXT.getDefaultMIMEType()); checkBoolOutput(); }
@Test public void testBooleanQueryDownloadMIMEType() throws Exception { boolQuery.download(output, BooleanQueryResultFormat.TEXT.getDefaultMIMEType()); checkBoolOutput(); }