From 8880b41555df99543904a0c6c8482bfa4ef8ea7b Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Thu, 5 Sep 2013 10:47:56 +0100 Subject: [PATCH] report both operating and non-operating services --- webservices/compbio/ws/server/RegistryWS.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/webservices/compbio/ws/server/RegistryWS.java b/webservices/compbio/ws/server/RegistryWS.java index c54fc56..1fd7d88 100644 --- a/webservices/compbio/ws/server/RegistryWS.java +++ b/webservices/compbio/ws/server/RegistryWS.java @@ -57,6 +57,7 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService { * Stores tested and passed (the test) services and their testing time */ private final static Map operating = new ConcurrentHashMap(); + private final static Map nonoperating = new ConcurrentHashMap(); /** * Indicate whether the services were tested at all @@ -69,6 +70,12 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService { return operating.keySet(); } + @Override + public Set getNonoperatedServices() { + init(); + return nonoperating.keySet(); + } + private void init() { // Do not allow tests to run concurrently if (timeToTest()) { @@ -137,19 +144,19 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService { Writer testlog = new StringWriter(); PrintWriter writer = new PrintWriter(testlog, true); WSTester tester = new WSTester(getServicePath(), writer); - // This is done deliberately to prevent malicious user from overloading - // the server + // This is done deliberately to prevent malicious user from overloading the server synchronized (operating) { for (Services service : Services.values()) { try { if (tester.checkService(service)) { operating.put(service, new Date()); + } else { + nonoperating.put(service, new Date()); } } catch (Exception e) { log.info(e, e.getCause()); - writer.println("Fails to connect to a web service: " - + service + " With " + e.getLocalizedMessage() - + "\nDetails: "); + String rep = "Fails to connect to a web service: " + service + " with"; + writer.println(rep + e.getLocalizedMessage() + "\nDetails: "); e.printStackTrace(writer); } } @@ -161,8 +168,7 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService { private String getServicePath() { assert wsContext != null : "WS context injection failed!"; MessageContext msContext = wsContext.getMessageContext(); - HttpServletRequest request = (HttpServletRequest) msContext - .get(MessageContext.SERVLET_REQUEST); + HttpServletRequest request = (HttpServletRequest) msContext.get(MessageContext.SERVLET_REQUEST); StringBuffer server = request.getRequestURL(); server = server.delete(server.lastIndexOf("/"), server.length()); -- 1.7.10.2