Move Category into data.msa package from ws.server to get it into min jabaws package.
[jabaws.git] / webservices / compbio / ws / server / RegistryWS.java
index 0ff4294..c54fc56 100644 (file)
@@ -1,3 +1,20 @@
+/* Copyright (c) 2011 Peter Troshin\r
+ *  \r
+ *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0     \r
+ * \r
+ *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
+ *  Apache License version 2 as published by the Apache Software Foundation\r
+ * \r
+ *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
+ *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
+ *  License for more details.\r
+ * \r
+ *  A copy of the license is in apache_license.txt. It is also available here:\r
+ * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
+ * \r
+ * Any republication or derived work distributed in source code form\r
+ * must include this copyright and license notice.\r
+ */\r
 package compbio.ws.server;\r
 \r
 import java.io.PrintWriter;\r
@@ -16,6 +33,7 @@ import javax.xml.ws.handler.MessageContext;
 \r
 import org.apache.log4j.Logger;\r
 \r
+import compbio.data.msa.Category;\r
 import compbio.data.msa.JABAService;\r
 import compbio.ws.client.Services;\r
 import compbio.ws.client.WSTester;\r
@@ -26,7 +44,7 @@ import compbio.ws.client.WSTester;
  * @author pvtroshin\r
  * \r
  */\r
-@WebService(endpointInterface = "compbio.data.msa.RegistryWS", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "RegistryWS")\r
+@WebService(endpointInterface = "compbio.data.msa.RegistryWS", targetNamespace = JABAService.V2_SERVICE_NAMESPACE, serviceName = "RegistryWS")\r
 public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService {\r
 \r
        // Ask for resource injection\r
@@ -123,8 +141,16 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService {
                // the server\r
                synchronized (operating) {\r
                        for (Services service : Services.values()) {\r
-                               if (tester.checkService(service)) {\r
-                                       operating.put(service, new Date());\r
+                               try {\r
+                                       if (tester.checkService(service)) {\r
+                                               operating.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
+                                       e.printStackTrace(writer);\r
                                }\r
                        }\r
                }\r
@@ -156,16 +182,30 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService {
                                        operating.put(service, new Date());\r
                                }\r
                        }\r
+               } catch (Exception e) {\r
+                       log.info(e, e.getCause());\r
+                       writer.println("Fails to connect to a web service: " + service\r
+                                       + " With " + e.getLocalizedMessage() + "\nDetails: ");\r
+                       e.printStackTrace(writer);\r
                } finally {\r
                        writer.close();\r
                }\r
                return testlog.toString();\r
        }\r
-\r
        @Override\r
        public boolean isOperating(Services service) {\r
                init();\r
                return operating.containsKey(service);\r
        }\r
 \r
+       @Override\r
+       public String getServiceDescription(Services service) {\r
+               return service.getServiceInfo();\r
+       }\r
+\r
+       @Override\r
+       public Set<Category> getServiceCategories() {\r
+               return Category.getCategories();\r
+       }\r
+\r
 }\r