2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
22 package jalview.ws.jws2;
24 import jalview.bin.Cache;
25 import jalview.ws.jws2.jabaws2.Jws2Instance;
26 import jalview.ws.jws2.jabaws2.Jws2InstanceFactory;
28 import java.util.HashSet;
31 import compbio.data.msa.Category;
32 import compbio.data.msa.JABAService;
33 import compbio.ws.client.Jws2Client;
34 import compbio.ws.client.Services;
40 public class JabaWsServerQuery implements Runnable
43 Jws2Discoverer jws2Discoverer = null;
45 String jwsservers = null;
47 boolean quit = false, running = false;
52 public boolean isRunning()
61 public void setQuit(boolean quit)
66 public JabaWsServerQuery(Jws2Discoverer jws2Discoverer, String jwsservers)
68 this.jws2Discoverer = jws2Discoverer;
69 this.jwsservers = jwsservers;
72 Services[] JABAWS1SERVERS = new Services[]
73 { Services.ClustalWS, Services.MuscleWS, Services.MafftWS,
74 Services.ProbconsWS, Services.TcoffeeWS };
76 Services[] JABAWS2SERVERS = new Services[]
77 { Services.ClustalWS, Services.MuscleWS, Services.MafftWS,
78 Services.ProbconsWS, Services.TcoffeeWS, Services.AAConWS,
79 Services.DisemblWS, Services.GlobPlotWS, Services.IUPredWS,
80 Services.JronnWS, Services.RNAalifoldWS };
85 * @see java.lang.Runnable#run()
93 if (Jws2Client.validURL(jwsservers))
95 compbio.data.msa.RegistryWS registry = null;
96 Set svccategories = null;
97 boolean noservices = true;
99 boolean jabasws2 = false;
100 // If we are dealing with a JABAWS2 service, then just go and ask the
101 // JABAWS 2 service registry
102 Set<Services> srv_set = new HashSet<Services>();
104 Set<Category> categories = Category.getCategories();
109 // JBPNote: why is RegistryWS in compbio.data.msa ?
110 registry = Jws2Client.connectToRegistry(jwsservers);
111 if (registry != null)
113 // System.err.println("Test Services Output\n"
114 // + registry.testAllServices());
115 // TODO: enumerate services and test those that haven't been tested
116 // in the last n-days/hours/etc.
119 srv_set = registry.getSupportedServices();
122 System.out.println("registry.getSupportedServices: " + srv_set.toString());
124 svccategories = registry.getServiceCategories();
127 // System.out.println("registry.getServiceCategories: " + svccategories.toString());
130 } catch (Exception ex)
132 System.err.println("Exception whilst trying to get at registry:");
133 ex.printStackTrace();
134 // if that failed, then we are probably working with a JABAWS1 server.
135 // in that case, look for each service endpoint
136 System.err.println("JWS2 Discoverer: " + jwsservers
137 + " is a JABAWS1 server. Using hardwired list.");
138 for (Services srv : JABAWS1SERVERS)
143 for (Category cat : categories)
145 for (Services srv : cat.getServices())
152 if (!srv_set.contains(srv))
156 JABAService service = null;
159 service = Jws2Client.connect(jwsservers, srv);
160 } catch (Exception e)
162 System.err.println("Jws2 Discoverer: Problem on "
163 + jwsservers + " with service " + srv + ":\n"
165 if (!(e instanceof javax.xml.ws.WebServiceException))
169 // For moment, report service as a problem.
170 jws2Discoverer.addInvalidServiceUrl(jwsservers);
176 Jws2Instance svc = null;
177 if (registry != null)
180 String description = registry.getServiceDescription(srv);
182 svc = Jws2InstanceFactory.newJws2Instance(jwsservers, srv.toString(),
183 cat.name, description, service);
187 svc = Jws2InstanceFactory.newJws2Instance(jwsservers, srv.toString(),
188 cat.name, "JABAWS 1 Alignment Service", service);
190 jws2Discoverer.addService(jwsservers, svc);
198 jws2Discoverer.addUrlwithnoservices(jwsservers);
203 jws2Discoverer.addInvalidServiceUrl(jwsservers);
204 Cache.log.info("Ignoring invalid Jws2 service url " + jwsservers);
206 } catch (Exception e)
209 Cache.log.warn("Exception when discovering Jws2 services.", e);
210 jws2Discoverer.addInvalidServiceUrl(jwsservers);
213 Cache.log.error("Exception when discovering Jws2 services.", e);
214 jws2Discoverer.addInvalidServiceUrl(jwsservers);