X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fjws2%2FJabaWsServerQuery.java;h=f3b8de51371ad1da9629e8cd74c8e50857ac8828;hb=a8f483d04205bb8273ee311c12968b7e86d205fa;hp=5ca506538c3f15723265022b942cc79e6b7ad282;hpb=43e280af80c060ad0bca76e5025ebabc38a52a21;p=jalview.git diff --git a/src/jalview/ws/jws2/JabaWsServerQuery.java b/src/jalview/ws/jws2/JabaWsServerQuery.java index 5ca5065..f3b8de5 100644 --- a/src/jalview/ws/jws2/JabaWsServerQuery.java +++ b/src/jalview/ws/jws2/JabaWsServerQuery.java @@ -1,35 +1,62 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Copyright (C) 2014 The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ /** * */ package jalview.ws.jws2; import jalview.bin.Cache; +import jalview.ws.jws2.jabaws2.Jws2Instance; +import jalview.ws.jws2.jabaws2.Jws2InstanceFactory; + +import java.util.HashSet; +import java.util.Set; -import compbio.data.msa.MsaWS; +import compbio.data.msa.Category; +import compbio.data.msa.JABAService; import compbio.ws.client.Jws2Client; import compbio.ws.client.Services; /** * @author JimP - * + * */ public class JabaWsServerQuery implements Runnable { - Jws2Discoverer jws2Discoverer=null; - String jwsservers=null; - boolean quit=false, - running=false; + Jws2Discoverer jws2Discoverer = null; + + String jwsservers = null; + + boolean quit = false, running = false; + /** * @return the running */ - public boolean isRunning() + public boolean isRunning() { return running; } /** - * @param quit the quit to set + * @param quit + * the quit to set */ public void setQuit(boolean quit) { @@ -39,63 +66,154 @@ public class JabaWsServerQuery implements Runnable public JabaWsServerQuery(Jws2Discoverer jws2Discoverer, String jwsservers) { this.jws2Discoverer = jws2Discoverer; - this.jwsservers=jwsservers; + this.jwsservers = jwsservers; } - /* (non-Javadoc) + Services[] JABAWS1SERVERS = new Services[] + { Services.ClustalWS, Services.MuscleWS, Services.MafftWS, + Services.ProbconsWS, Services.TcoffeeWS }; + + Services[] JABAWS2SERVERS = new Services[] + { Services.ClustalWS, Services.MuscleWS, Services.MafftWS, + Services.ProbconsWS, Services.TcoffeeWS, Services.AAConWS, + Services.DisemblWS, Services.GlobPlotWS, Services.IUPredWS, + Services.JronnWS, Services.RNAalifoldWS }; + + /* + * (non-Javadoc) + * * @see java.lang.Runnable#run() */ @Override public void run() { - running=true; - try + running = true; + try { if (Jws2Client.validURL(jwsservers)) { + compbio.data.msa.RegistryWS registry = null; + Set svccategories = null; + boolean noservices = true; // look for services - for (Services srv : Services.values()) + boolean jabasws2 = false; + // If we are dealing with a JABAWS2 service, then just go and ask the + // JABAWS 2 service registry + Set srv_set = new HashSet(); + + Set categories = Category.getCategories(); + String svc_cat; + + try { - if (quit) + // JBPNote: why is RegistryWS in compbio.data.msa ? + registry = Jws2Client.connectToRegistry(jwsservers); + if (registry != null) { - running=false; - return; + // System.err.println("Test Services Output\n" + // + registry.testAllServices()); + // TODO: enumerate services and test those that haven't been tested + // in the last n-days/hours/etc. + + jabasws2 = true; + srv_set = registry.getSupportedServices(); + + // dan test + System.out.println("registry.getSupportedServices: " + srv_set.toString()); + + svccategories = registry.getServiceCategories(); + + // dan test +// System.out.println("registry.getServiceCategories: " + svccategories.toString()); + } - MsaWS service = null; - try + } catch (Exception ex) + { + System.err.println("Exception whilst trying to get at registry:"); + ex.printStackTrace(); + // if that failed, then we are probably working with a JABAWS1 server. + // in that case, look for each service endpoint + System.err.println("JWS2 Discoverer: " + jwsservers + + " is a JABAWS1 server. Using hardwired list."); + for (Services srv : JABAWS1SERVERS) { - service = Jws2Client.connect(jwsservers, srv); - } catch (Exception e) + srv_set.add(srv); + } + } + for (Category cat : categories) + { + for (Services srv : cat.getServices()) { - System.err.println("Jws2 Discoverer: Problem on " - + jwsservers + " with service " + srv + ":\n" - + e.getMessage()); - if (!(e instanceof javax.xml.ws.WebServiceException)) + if (quit) { - e.printStackTrace(); + running = false; + return; } - } - ; - if (service != null) - { - jws2Discoverer.addService(jwsservers, srv, service); + if (!srv_set.contains(srv)) + { + continue; + } + JABAService service = null; + try + { + service = Jws2Client.connect(jwsservers, srv); + } catch (Exception e) + { + System.err.println("Jws2 Discoverer: Problem on " + + jwsservers + " with service " + srv + ":\n" + + e.getMessage()); + if (!(e instanceof javax.xml.ws.WebServiceException)) + { + e.printStackTrace(); + } + // For moment, report service as a problem. + jws2Discoverer.addInvalidServiceUrl(jwsservers); + } + ; + if (service != null) + { + noservices = false; + Jws2Instance svc = null; + if (registry != null) + { + + String description = registry.getServiceDescription(srv); + + svc = Jws2InstanceFactory.newJws2Instance(jwsservers, srv.toString(), + cat.name, description, service); + } + if (svc == null) + { + svc = Jws2InstanceFactory.newJws2Instance(jwsservers, srv.toString(), + cat.name, "JABAWS 1 Alignment Service", service); + } + jws2Discoverer.addService(jwsservers, svc); + } + } } + if (noservices) + { + jws2Discoverer.addUrlwithnoservices(jwsservers); + } } else { + jws2Discoverer.addInvalidServiceUrl(jwsservers); Cache.log.info("Ignoring invalid Jws2 service url " + jwsservers); } } catch (Exception e) { e.printStackTrace(); Cache.log.warn("Exception when discovering Jws2 services.", e); + jws2Discoverer.addInvalidServiceUrl(jwsservers); } catch (Error e) { Cache.log.error("Exception when discovering Jws2 services.", e); + jws2Discoverer.addInvalidServiceUrl(jwsservers); } - running=false; + running = false; } }