Search in sources :

Example 1 with PathwayCommonsResponse

use of org.vcell.sybil.util.http.pathwaycommons.PathwayCommonsResponse in project vcell by virtualcell.

the class PCNeighborsRequest method response.

@Override
public PathwayCommonsResponse response() {
    PathwayCommonsResponse response = null;
    try {
        URL url = url();
        URLConnection connection = url.openConnection();
        String text = StringUtil.textFromInputStream(connection.getInputStream());
        if (PathwayCommonsUtil.isErrorResponse(text)) {
            response = new PCErrorResponse(this, PCErrorResponse.errorElement(text));
        } else {
            try {
                Graph graph = new HashGraph();
                Map<String, String> nsMap = new HashMap<String, String>();
                SesameRioUtil.readRDFFromString(text, graph, nsMap, RDFFormat.RDFXML, uriBase);
                response = new PCTextModelResponse(this, text, graph);
            } catch (Throwable t) {
                response = new PCTextResponse(this, text);
            }
        }
    } catch (MalformedURLException e) {
        response = new PCExceptionResponse(this, e);
    } catch (IOException e) {
        response = new PCExceptionResponse(this, e);
    } catch (SAXException e) {
        response = new PCExceptionResponse(this, e);
    } catch (ParserConfigurationException e) {
        response = new PCExceptionResponse(this, e);
    }
    return response;
}
Also used : MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) PathwayCommonsResponse(org.vcell.sybil.util.http.pathwaycommons.PathwayCommonsResponse) IOException(java.io.IOException) URL(java.net.URL) URLConnection(java.net.URLConnection) SAXException(org.xml.sax.SAXException) HashGraph(org.sbpax.impl.HashGraph) Graph(org.openrdf.model.Graph) HashGraph(org.sbpax.impl.HashGraph) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) PCExceptionResponse(org.vcell.sybil.util.http.pathwaycommons.PCExceptionResponse)

Aggregations

IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 HashMap (java.util.HashMap)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Graph (org.openrdf.model.Graph)1 HashGraph (org.sbpax.impl.HashGraph)1 PCExceptionResponse (org.vcell.sybil.util.http.pathwaycommons.PCExceptionResponse)1 PathwayCommonsResponse (org.vcell.sybil.util.http.pathwaycommons.PathwayCommonsResponse)1 SAXException (org.xml.sax.SAXException)1