2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 package jalview.ws.jws2;
26 import jalview.bin.Cache;
27 import jalview.ws.jws2.jabaws2.Jws2Instance;
28 import jalview.ws.jws2.jabaws2.Jws2InstanceFactory;
30 import java.util.HashSet;
33 import compbio.data.msa.Category;
34 import compbio.data.msa.JABAService;
35 import compbio.ws.client.Jws2Client;
36 import compbio.ws.client.Services;
42 public class JabaWsServerQuery implements Runnable
45 Jws2Discoverer jws2Discoverer = null;
47 String jwsservers = null;
49 boolean quit = false, running = false;
54 public boolean isRunning()
63 public void setQuit(boolean quit)
68 public JabaWsServerQuery(Jws2Discoverer jws2Discoverer, String jwsservers)
70 this.jws2Discoverer = jws2Discoverer;
71 this.jwsservers = jwsservers;
74 Services[] JABAWS1SERVERS = new Services[]
75 { Services.ClustalWS, Services.MuscleWS, Services.MafftWS,
76 Services.ProbconsWS, Services.TcoffeeWS };
78 Services[] JABAWS2SERVERS = new Services[]
79 { Services.ClustalWS, Services.MuscleWS, Services.MafftWS,
80 Services.ProbconsWS, Services.TcoffeeWS, Services.AAConWS,
81 Services.DisemblWS, Services.GlobPlotWS, Services.IUPredWS,
82 Services.JronnWS, Services.RNAalifoldWS };
87 * @see java.lang.Runnable#run()
95 if (Jws2Client.validURL(jwsservers))
97 compbio.data.msa.RegistryWS registry = null;
98 Set svccategories = null;
99 boolean noservices = true;
101 boolean jabasws2 = false;
102 // If we are dealing with a JABAWS2 service, then just go and ask the
103 // JABAWS 2 service registry
104 Set<Services> srv_set = new HashSet<Services>();
106 Set<Category> categories = Category.getCategories();
111 // JBPNote: why is RegistryWS in compbio.data.msa ?
112 registry = Jws2Client.connectToRegistry(jwsservers);
113 if (registry != null)
115 // System.err.println("Test Services Output\n"
116 // + registry.testAllServices());
117 // TODO: enumerate services and test those that haven't been tested
118 // in the last n-days/hours/etc.
121 srv_set = registry.getSupportedServices();
124 System.out.println("registry.getSupportedServices: "
125 + srv_set.toString());
127 svccategories = registry.getServiceCategories();
130 // System.out.println("registry.getServiceCategories: " +
131 // svccategories.toString());
134 } catch (Exception ex)
136 System.err.println("Exception whilst trying to get at registry:");
137 ex.printStackTrace();
138 // if that failed, then we are probably working with a JABAWS1 server.
139 // in that case, look for each service endpoint
140 System.err.println("JWS2 Discoverer: " + jwsservers
141 + " is a JABAWS1 server. Using hardwired list.");
142 for (Services srv : JABAWS1SERVERS)
147 for (Category cat : categories)
149 for (Services srv : cat.getServices())
156 if (!srv_set.contains(srv))
160 JABAService service = null;
163 service = Jws2Client.connect(jwsservers, srv);
164 } catch (Exception e)
166 System.err.println("Jws2 Discoverer: Problem on "
167 + jwsservers + " with service " + srv + ":\n"
169 if (!(e instanceof javax.xml.ws.WebServiceException))
173 // For moment, report service as a problem.
174 jws2Discoverer.addInvalidServiceUrl(jwsservers);
180 Jws2Instance svc = null;
181 if (registry != null)
184 String description = registry.getServiceDescription(srv);
186 svc = Jws2InstanceFactory.newJws2Instance(jwsservers,
187 srv.toString(), cat.name, description, service);
191 svc = Jws2InstanceFactory.newJws2Instance(jwsservers,
192 srv.toString(), cat.name,
193 "JABAWS 1 Alignment Service", service);
195 jws2Discoverer.addService(jwsservers, svc);
203 jws2Discoverer.addUrlwithnoservices(jwsservers);
208 jws2Discoverer.addInvalidServiceUrl(jwsservers);
209 Cache.log.info("Ignoring invalid Jws2 service url " + jwsservers);
211 } catch (Exception e)
214 Cache.log.warn("Exception when discovering Jws2 services.", e);
215 jws2Discoverer.addInvalidServiceUrl(jwsservers);
218 Cache.log.error("Exception when discovering Jws2 services.", e);
219 jws2Discoverer.addInvalidServiceUrl(jwsservers);