X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FEBIFetchClient.java;h=eebbfc88cf359bd252b2bcde33197ca697949210;hb=e6d5a919ade2b070a34f40683c8664b684f76cde;hp=3c6e5f9050109f86badd33815603eada6e06b6e4;hpb=99c58ee0ae2a848f982552e53feaf6d5cb9925e5;p=jalview.git diff --git a/src/jalview/io/EBIFetchClient.java b/src/jalview/io/EBIFetchClient.java index 3c6e5f9..eebbfc8 100755 --- a/src/jalview/io/EBIFetchClient.java +++ b/src/jalview/io/EBIFetchClient.java @@ -16,166 +16,238 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.io; +import org.apache.axis.AxisFault; import org.apache.axis.client.*; - -import java.io.*; +import org.apache.axis.encoding.XMLType; +import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory; +import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory; import javax.activation.DataHandler; -import org.apache.axis.AxisFault; -import org.apache.axis.encoding.XMLType; -import javax.xml.rpc.ParameterMode; + import javax.xml.namespace.QName; -import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory; -import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory; +import javax.xml.rpc.ParameterMode; +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class EBIFetchClient { - Call call; - String format = "default"; - String style = "raw"; - - public EBIFetchClient() - { - try{ - call = (Call)new Service().createCall(); - call.setTargetEndpointAddress(new java.net.URL( - "http://www.ebi.ac.uk/ws/services/Dbfetch")); - }catch(Exception ex){} - } - - - public String [] getSupportedDBs() - { - try{ - - call.setOperationName(new QName("urn:Dbfetch", "getSupportedDBs")); - call.setReturnType(XMLType.SOAP_ARRAY); - return (String[]) call.invoke(new Object[]{}); - - }catch(Exception ex){return null;} - } - - public String [] getSupportedFormats() - { - try{ - call.setOperationName(new QName("urn:Dbfetch", "getSupportedFormats")); - call.setReturnType(XMLType.SOAP_ARRAY); - return (String[]) call.invoke(new Object[] {}); - - }catch(Exception ex){ return null; } - } - - public String [] getSupportedStyles() - { - try{ - call.setOperationName(new QName("urn:Dbfetch", "getSupportedStyles")); - call.setReturnType(XMLType.SOAP_ARRAY); - return (String[]) call.invoke(new Object[] {}); - - }catch(Exception ex){return null;} + Call call; + String format = "default"; + String style = "raw"; + + /** + * Creates a new EBIFetchClient object. + */ + public EBIFetchClient() + { + try + { + call = (Call) new Service().createCall(); + call.setTargetEndpointAddress(new java.net.URL( + "http://www.ebi.ac.uk/ws/services/Dbfetch")); + } + catch (Exception ex) + { + } } - public String [] fetchData(String ids, String f, String s) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String[] getSupportedDBs() { - // ids should be of the form uniprot:25KD_SARPE;ADHR_DROPS; - // max 50 ids can be added at one time - try{ - call.setOperationName(new QName("urn:Dbfetch", "fetchData")); - call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN); - call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN); - call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN); - call.setReturnType(XMLType.SOAP_ARRAY); - - if (f != null) - format = f; - - if (s != null) - style = s; - - return (String[]) call.invoke(new Object[] {ids, format, style}); - - }catch(Exception ex){return null;} + try + { + call.setOperationName(new QName("urn:Dbfetch", "getSupportedDBs")); + call.setReturnType(XMLType.SOAP_ARRAY); + return (String[]) call.invoke(new Object[] { }); + } + catch (Exception ex) + { + return null; + } } - public String fetchDataFile(String arg, String f, String s) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String[] getSupportedFormats() { + try + { + call.setOperationName(new QName("urn:Dbfetch", "getSupportedFormats")); + call.setReturnType(XMLType.SOAP_ARRAY); - if (f != null) - format = f; - - if (s != null) - style = s; - - - call.setOperationName(new QName("urn:Dbfetch", "fetchDataFile")); - call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN); - call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN); - call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN); - - QName qnameAttachment = new QName("urn:Dbfetch", "DataHandler"); - call.registerTypeMapping(javax.activation.DataSource.class, - qnameAttachment, - JAFDataHandlerSerializerFactory.class, - JAFDataHandlerDeserializerFactory.class); - - call.setReturnType(qnameAttachment); + return (String[]) call.invoke(new Object[] { }); + } + catch (Exception ex) + { + return null; + } + } - try{ - Object ret = call.invoke(new Object[] - {arg, format, style}); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String[] getSupportedStyles() + { + try + { + call.setOperationName(new QName("urn:Dbfetch", "getSupportedStyles")); + call.setReturnType(XMLType.SOAP_ARRAY); - if (null == ret) + return (String[]) call.invoke(new Object[] { }); + } + catch (Exception ex) { - System.err.println("Received null "); - throw new AxisFault("", "Received null", null, null); + return null; } - if (ret instanceof String) + } + + /** + * DOCUMENT ME! + * + * @param ids DOCUMENT ME! + * @param f DOCUMENT ME! + * @param s DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String[] fetchData(String ids, String f, String s) + { + // ids should be of the form uniprot:25KD_SARPE;ADHR_DROPS; + // max 50 ids can be added at one time + try { - System.err.println("Received problem response from server: " + ret); - throw new AxisFault("", (String) ret, null, null); + call.setOperationName(new QName("urn:Dbfetch", "fetchData")); + call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN); + call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN); + call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN); + call.setReturnType(XMLType.SOAP_ARRAY); + + if (f != null) + { + format = f; + } + + if (s != null) + { + style = s; + } + + return (String[]) call.invoke(new Object[] { ids, format, style }); } - if (! (ret instanceof DataHandler)) + catch (Exception ex) { - //The wrong type of object that what was expected. - System.err.println("Received problem response from server:" + - ret.getClass().getName()); - throw new AxisFault("", "Received problem response from server:" + - ret.getClass().getName(), null, null); - + return null; } - //Still here, so far so good. - DataHandler rdh = (DataHandler) ret; + } - //From here we'll just treat the data resource as file. - String receivedfileName = rdh.getName(); //Get the filename. + /** + * DOCUMENT ME! + * + * @param arg DOCUMENT ME! + * @param f DOCUMENT ME! + * @param s DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String fetchDataFile(String arg, String f, String s) + { + if (f != null) + { + format = f; + } - if (receivedfileName == null) + if (s != null) { - System.err.println("Could not get the file name."); - throw new AxisFault("", "Could not get the file name.", null, null); + style = s; } - if (arg.equalsIgnoreCase("medline")) + + call.setOperationName(new QName("urn:Dbfetch", "fetchDataFile")); + call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN); + call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN); + call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN); + + QName qnameAttachment = new QName("urn:Dbfetch", "DataHandler"); + call.registerTypeMapping(javax.activation.DataSource.class, + qnameAttachment, JAFDataHandlerSerializerFactory.class, + JAFDataHandlerDeserializerFactory.class); + + call.setReturnType(qnameAttachment); + + try { - return receivedfileName; + Object ret = call.invoke(new Object[] { arg, format, style }); + + if (null == ret) + { + System.err.println("Received null "); + throw new AxisFault("", "Received null", null, null); + } + + if (ret instanceof String) + { + System.err.println("Received problem response from server: " + + ret); + throw new AxisFault("", (String) ret, null, null); + } + + if (!(ret instanceof DataHandler)) + { + //The wrong type of object that what was expected. + System.err.println("Received problem response from server:" + + ret.getClass().getName()); + throw new AxisFault("", + "Received problem response from server:" + + ret.getClass().getName(), null, null); + } + + //Still here, so far so good. + DataHandler rdh = (DataHandler) ret; + + //From here we'll just treat the data resource as file. + String receivedfileName = rdh.getName(); //Get the filename. + + if (receivedfileName == null) + { + System.err.println("Could not get the file name."); + throw new AxisFault("", "Could not get the file name.", null, + null); + } + + if (arg.equalsIgnoreCase("medline")) + { + return receivedfileName; + } + else if (arg.equalsIgnoreCase("interpro")) + { + return receivedfileName; + } + else + { + System.err.println(receivedfileName); + } } - else if (arg.equalsIgnoreCase("interpro")) + catch (Exception ex) { - return receivedfileName; + ex.printStackTrace(); } - else - System.err.println(receivedfileName); - }catch(Exception ex) - { - ex.printStackTrace(); - } - - return "ERROR"; - } - + return "ERROR"; + } }