Search in sources :

Example 1 with PCExceptionResponse

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

the class PCIDRequest method response.

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

Example 2 with PCExceptionResponse

use of org.vcell.sybil.util.http.pathwaycommons.PCExceptionResponse 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)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 URLConnection (java.net.URLConnection)2 HashMap (java.util.HashMap)2 Graph (org.openrdf.model.Graph)2 HashGraph (org.sbpax.impl.HashGraph)2 PCExceptionResponse (org.vcell.sybil.util.http.pathwaycommons.PCExceptionResponse)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 RDFHandlerException (org.openrdf.rio.RDFHandlerException)1 RDFParseException (org.openrdf.rio.RDFParseException)1 PathwayCommonsResponse (org.vcell.sybil.util.http.pathwaycommons.PathwayCommonsResponse)1 SAXException (org.xml.sax.SAXException)1