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.gui.Desktop;
28 import jalview.ws.jws2.jabaws2.Jws2Instance;
29 import jalview.ws.jws2.jabaws2.Jws2InstanceFactory;
31 import java.util.HashSet;
34 import javax.swing.JOptionPane;
36 import compbio.data.msa.Category;
37 import compbio.data.msa.JABAService;
38 import compbio.ws.client.Jws2Client;
39 import compbio.ws.client.Services;
45 public class JabaWsServerQuery implements Runnable
48 Jws2Discoverer jws2Discoverer = null;
50 String jwsservers = null;
52 boolean quit = false, running = false;
57 public boolean isRunning()
66 public void setQuit(boolean quit)
71 public JabaWsServerQuery(Jws2Discoverer jws2Discoverer, String jwsservers)
73 this.jws2Discoverer = jws2Discoverer;
74 this.jwsservers = jwsservers;
77 Services[] JABAWS1SERVERS = new Services[]
78 { Services.ClustalWS, Services.MuscleWS, Services.MafftWS,
79 Services.ProbconsWS, Services.TcoffeeWS };
81 Services[] JABAWS2SERVERS = new Services[]
82 { Services.ClustalWS, Services.MuscleWS, Services.MafftWS,
83 Services.ProbconsWS, Services.TcoffeeWS, Services.AAConWS,
84 Services.DisemblWS, Services.GlobPlotWS, Services.IUPredWS,
85 Services.JronnWS, Services.RNAalifoldWS };
90 * @see java.lang.Runnable#run()
98 if (Jws2Client.validURL(jwsservers))
100 compbio.data.msa.RegistryWS registry = null;
101 Set svccategories = null;
102 boolean noservices = true;
104 boolean jabasws2 = false;
105 // If we are dealing with a JABAWS2 service, then just go and ask the
106 // JABAWS 2 service registry
107 Set<Services> srv_set = new HashSet<Services>();
109 Set<Category> categories = Category.getCategories();
114 // JBPNote: why is RegistryWS in compbio.data.msa ?
115 registry = Jws2Client.connectToRegistry(jwsservers);
116 if (registry != null)
118 // System.err.println("Test Services Output\n"
119 // + registry.testAllServices());
120 // TODO: enumerate services and test those that haven't been tested
121 // in the last n-days/hours/etc.
124 srv_set = registry.getSupportedServices();
127 System.out.println("registry.getSupportedServices: "
128 + srv_set.toString());
130 svccategories = registry.getServiceCategories();
133 // System.out.println("registry.getServiceCategories: " +
134 // svccategories.toString());
137 } catch (javax.xml.ws.WebServiceException ex)
140 .showInternalMessageDialog(
142 "Exception whilst trying to access the webservice registry:",
143 "Webservice glitch", JOptionPane.WARNING_MESSAGE);
144 System.err.println("Exception whilst trying to get at registry:");
145 ex.printStackTrace();
146 // if that failed, then we are probably working with a JABAWS1 server.
147 // in that case, look for each service endpoint
148 System.err.println("JWS2 Discoverer: " + jwsservers
149 + " is a JABAWS1 server. Using hardwired list.");
150 for (Services srv : JABAWS1SERVERS)
157 ex.printStackTrace();
159 for (Category cat : categories)
161 for (Services srv : cat.getServices())
168 if (!srv_set.contains(srv))
172 JABAService service = null;
175 service = Jws2Client.connect(jwsservers, srv);
176 } catch (Exception e)
178 System.err.println("Jws2 Discoverer: Problem on "
179 + jwsservers + " with service " + srv + ":\n"
181 if (!(e instanceof javax.xml.ws.WebServiceException))
185 // For moment, report service as a problem.
186 jws2Discoverer.addInvalidServiceUrl(jwsservers);
192 Jws2Instance svc = null;
193 if (registry != null)
196 String description = registry.getServiceDescription(srv);
198 svc = Jws2InstanceFactory.newJws2Instance(jwsservers,
199 srv.toString(), cat.name, description, service);
203 svc = Jws2InstanceFactory.newJws2Instance(jwsservers,
204 srv.toString(), cat.name,
205 "JABAWS 1 Alignment Service", service);
207 jws2Discoverer.addService(jwsservers, svc);
215 jws2Discoverer.addUrlwithnoservices(jwsservers);
220 jws2Discoverer.addInvalidServiceUrl(jwsservers);
221 Cache.log.info("Ignoring invalid Jws2 service url " + jwsservers);
223 } catch (Exception e)
226 Cache.log.warn("Exception when discovering Jws2 services.", e);
227 jws2Discoverer.addInvalidServiceUrl(jwsservers);
230 Cache.log.error("Exception when discovering Jws2 services.", e);
231 jws2Discoverer.addInvalidServiceUrl(jwsservers);