+/* 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
\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
* 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
init();\r
return operating.keySet();\r
}\r
-\r
+/* FOR FUTURE RELEASES!!!\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
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
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
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