diff --git a/features/net.bioclipse.core_feature/feature.xml b/features/net.bioclipse.core_feature/feature.xml index f750d8c1f..5bf303003 100644 --- a/features/net.bioclipse.core_feature/feature.xml +++ b/features/net.bioclipse.core_feature/feature.xml @@ -75,6 +75,8 @@ The Eclipse Public License accompanies this distribution, and is available at ht + + formparams = new ArrayList(); + formparams.add(new BasicNameValuePair("query", sparqlQueryString)); + try { + UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8"); + HttpPost httppost = new HttpPost(serviceURL); + httppost.setEntity(entity); + monitor.worked(20); + HttpResponse response = httpclient.execute(httppost); + StatusLine statusLine = response.getStatusLine(); + int statusCode = statusLine.getStatusCode(); + if (statusCode != 200) throw new BioclipseException( + "Expected HTTP 200, but got a " + statusCode + ": " + statusLine.getReasonPhrase() + ); + monitor.worked(60); + + HttpEntity responseEntity = response.getEntity(); + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + responseEntity.writeTo(buffer); + buffer.flush(); + monitor.worked(20); + return buffer.toByteArray(); + } catch (UnsupportedEncodingException exception) { + throw new BioclipseException( + "Error while creating the SPARQL query: " + exception.getMessage(), exception + ); + } catch (IOException exception) { + throw new BioclipseException( + "Error while processing the SPARQL endpoint feedback: " + exception.getMessage(), exception + ); + } + } + public void openURL(URL url) throws BioclipseException { IWorkbenchBrowserSupport browserSupport = diff --git a/plugins/net.bioclipse.business/src/net/bioclipse/business/IBioclipsePlatformManager.java b/plugins/net.bioclipse.business/src/net/bioclipse/business/IBioclipsePlatformManager.java index b589a8490..441144122 100644 --- a/plugins/net.bioclipse.business/src/net/bioclipse/business/IBioclipsePlatformManager.java +++ b/plugins/net.bioclipse.business/src/net/bioclipse/business/IBioclipsePlatformManager.java @@ -1,5 +1,4 @@ -/* ***************************************************************************** - * Copyright (c) 2009 Egon Willighagen +/* Copyright (c) 2009,2018 Egon Willighagen * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contact: http://www.bioclipse.net/ - ******************************************************************************/ + */ package net.bioclipse.business; import org.eclipse.core.resources.IFile; @@ -106,4 +105,11 @@ public void requireVersion( String lowerVersionBound, public String fullPath( String file ); public String fullPath( IFile file ); + + @PublishedMethod( + params = "String url, String SPARQL", + methodSummary = "Queries a remote SPARQL end point without parsing the SPARQL first." + ) + public byte[] sparqlRemote(String url, String SPARQL) + throws BioclipseException; }