1 /*******************************************************************************
2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
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 *******************************************************************************/
21 package jalview.ws.jws2;
23 import jalview.bin.Cache;
24 import jalview.ws.jws2.jabaws2.Jws2Instance;
26 import java.util.HashSet;
29 import compbio.data.msa.Category;
30 import compbio.data.msa.JABAService;
31 import compbio.ws.client.Jws2Client;
32 import compbio.ws.client.Services;
38 public class JabaWsServerQuery implements Runnable
41 Jws2Discoverer jws2Discoverer = null;
43 String jwsservers = null;
45 boolean quit = false, running = false;
50 public boolean isRunning()
59 public void setQuit(boolean quit)
64 public JabaWsServerQuery(Jws2Discoverer jws2Discoverer, String jwsservers)
66 this.jws2Discoverer = jws2Discoverer;
67 this.jwsservers = jwsservers;
69 Services[] JABAWS1SERVERS=new Services[]
70 { Services.ClustalWS, Services.MuscleWS, Services.MafftWS,
71 Services.ProbconsWS, Services.TcoffeeWS };
72 Services[] JABAWS2SERVERS=new Services[]
73 { Services.ClustalWS, Services.MuscleWS, Services.MafftWS,
74 Services.ProbconsWS, Services.TcoffeeWS, Services.AAConWS, Services.DisemblWS, Services.GlobPlotWS, Services.IUPredWS, Services.JronnWS };
79 * @see java.lang.Runnable#run()
87 if (Jws2Client.validURL(jwsservers))
89 compbio.data.msa.RegistryWS registry = null;
90 Set svccategories = null;
91 boolean noservices = true;
93 boolean jabasws2 = false;
94 // If we are dealing with a JABAWS2 service, then just go and ask the
95 // JABAWS 2 service registry
96 Set<Services> srv_set = new HashSet<Services>();
98 Set<Category> categories = Category.getCategories();
103 // JBPNote: why is RegistryWS in compbio.data.msa ?
104 registry = Jws2Client.connectToRegistry(jwsservers);
105 if (registry != null)
107 // System.err.println("Test Services Output\n"
108 // + registry.testAllServices());
109 // TODO: enumerate services and test those that haven't been tested
110 // in the last n-days/hours/etc.
113 srv_set = registry.getSupportedServices();
114 svccategories = registry.getServiceCategories();
117 } catch (Exception ex)
119 System.err.println("Exception whilst trying to get at registry:");
120 ex.printStackTrace();
121 // if that failed, then we are probably working with a JABAWS1 server.
122 // in that case, look for each service endpoint
123 System.err.println("JWS2 Discoverer: " + jwsservers
124 + " is a JABAWS1 server. Using hardwired list.");
125 for (Services srv : JABAWS1SERVERS)
130 for (Category cat : categories)
132 for (Services srv : cat.getServices())
139 if (!srv_set.contains(srv))
143 JABAService service = null;
146 service = Jws2Client.connect(jwsservers, srv);
147 } catch (Exception e)
149 System.err.println("Jws2 Discoverer: Problem on "
150 + jwsservers + " with service " + srv + ":\n"
152 if (!(e instanceof javax.xml.ws.WebServiceException))
156 // For moment, report service as a problem.
157 jws2Discoverer.addInvalidServiceUrl(jwsservers);
163 Jws2Instance svc = null;
164 if (registry != null)
167 String description = registry.getServiceDescription(srv);
169 svc = new Jws2Instance(jwsservers, srv.toString(),
170 cat.name, description, service);
174 svc = new Jws2Instance(jwsservers, srv.toString(), cat.name,
175 "JABAWS 1 Alignment Service", service);
177 jws2Discoverer.addService(jwsservers, svc);
185 jws2Discoverer.addUrlwithnoservices(jwsservers);
190 jws2Discoverer.addInvalidServiceUrl(jwsservers);
191 Cache.log.info("Ignoring invalid Jws2 service url " + jwsservers);
193 } catch (Exception e)
196 Cache.log.warn("Exception when discovering Jws2 services.", e);
197 jws2Discoverer.addInvalidServiceUrl(jwsservers);
200 Cache.log.error("Exception when discovering Jws2 services.", e);
201 jws2Discoverer.addInvalidServiceUrl(jwsservers);