report both operating and non-operating services
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Thu, 5 Sep 2013 09:47:56 +0000 (10:47 +0100)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Thu, 5 Sep 2013 09:47:56 +0000 (10:47 +0100)
webservices/compbio/ws/server/RegistryWS.java

index c54fc56..1fd7d88 100644 (file)
@@ -57,6 +57,7 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService {
         * Stores tested and passed (the test) services and their testing time\r
         */\r
        private final static Map<Services, Date> operating = new ConcurrentHashMap<Services, Date>();\r
+       private final static Map<Services, Date> nonoperating = new ConcurrentHashMap<Services, Date>();\r
 \r
        /**\r
         * Indicate whether the services were tested at all\r
@@ -69,6 +70,12 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService {
                return operating.keySet();\r
        }\r
 \r
+       @Override\r
+       public Set<Services> getNonoperatedServices() {\r
+               init();\r
+               return nonoperating.keySet();\r
+       }\r
+\r
        private void init() {\r
                // Do not allow tests to run concurrently\r
                if (timeToTest()) {\r
@@ -137,19 +144,19 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService {
                Writer testlog = new StringWriter();\r
                PrintWriter writer = new PrintWriter(testlog, true);\r
                WSTester tester = new WSTester(getServicePath(), writer);\r
-               // This is done deliberately to prevent malicious user from overloading\r
-               // the server\r
+               // This is done deliberately to prevent malicious user from overloading the server\r
                synchronized (operating) {\r
                        for (Services service : Services.values()) {\r
                                try {\r
                                        if (tester.checkService(service)) {\r
                                                operating.put(service, new Date());\r
+                                       } else {\r
+                                               nonoperating.put(service, new Date());\r
                                        }\r
                                } catch (Exception e) {\r
                                        log.info(e, e.getCause());\r
-                                       writer.println("Fails to connect to a web service: "\r
-                                                       + service + " With " + e.getLocalizedMessage()\r
-                                                       + "\nDetails: ");\r
+                                       String rep = "Fails to connect to a web service: " + service + " with";\r
+                                       writer.println(rep + e.getLocalizedMessage() + "\nDetails: ");\r
                                        e.printStackTrace(writer);\r
                                }\r
                        }\r
@@ -161,8 +168,7 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService {
        private String getServicePath() {\r
                assert wsContext != null : "WS context injection failed!";\r
                MessageContext msContext = wsContext.getMessageContext();\r
-               HttpServletRequest request = (HttpServletRequest) msContext\r
-                               .get(MessageContext.SERVLET_REQUEST);\r
+               HttpServletRequest request = (HttpServletRequest) msContext.get(MessageContext.SERVLET_REQUEST);\r
 \r
                StringBuffer server = request.getRequestURL();\r
                server = server.delete(server.lastIndexOf("/"), server.length());\r