private GoHandler getGoResponse( String goId ) throws IOException, SAXException { String query = SearchReplace.replace( EGO_QUERY, GOID_FLAG, goId ); URL url = new URL( myURL + query ); URLConnection servletConnection = url.openConnection(); // Turn off caching servletConnection.setUseCaches( false ); // Wrting to the server. servletConnection.setDoOutput( true ); // The reader to read response from the server. GoHandler goHandler = null; InputStream inputStream = null; try { inputStream = servletConnection.getInputStream(); goHandler = getGoResponse( inputStream ); } finally { if( inputStream != null ) { try { inputStream.close(); } catch( IOException ioe ) { } } } return goHandler; } // getGoResponse
/** * Queries the ego (http://www.ebi.ac.uk/ego) server with given GO term id. * * @param goId the GO term to query the ego server. * * @return the GO term definition. * * @throws IOException for network errors. * @throws GoIdNotFoundException thrown when the server fails to find a response for GO id. */ public GoResponse query( String goId ) throws IOException, GoIdNotFoundException { GoResponse goRes = null; // Query the ego server. GoHandler goHandler ; // = getGoResponse( goId ); try { goHandler = getGoResponse( goId ); } catch( SAXException e ) { throw new GoIdNotFoundException( goId, e ); } if( goHandler == null ) { throw new GoIdNotFoundException( goId ); } // Values from newt stored in goRes = new GoResponse( goId, goHandler.getName(), goHandler.getCategory() ); return goRes; }
goHandler = getGoResponse( is ); } catch( SAXException e ) { throw new GoIdNotFoundException( goId, e );