<classpathentry kind="lib" path="WEB-INF/lib/compbio-annotations-1.0.jar"/>\r
<classpathentry kind="lib" path="WEB-INF/lib/compbio-util-1.4.jar"/>\r
<classpathentry kind="lib" path="WEB-INF/lib/derby.jar"/>\r
+ <classpathentry kind="lib" path="WEB-INF/lib/compbio-ga-1.0.jar"/>\r
<classpathentry kind="output" path="WEB-INF/classes"/>\r
</classpath>\r
<!-- dependencies on other compbio projects -->\r
<property name="compbio-annotation" value="compbio-annotations-1.0.jar"/>\r
<property name="compbio-util" value="compbio-util-1.4.jar"/>\r
+ <property name="compbio-ga" value="compbio-ga-1.0.jar"/>\r
\r
<!-- products -->\r
<property name="jaba_version" value="2.0"/>\r
-# This file contains settings for Google Analytics Statistics Engine.\r
+# This file contains settings for Google Analytics (GA) Statistics Engine.\r
# Feel free to remove/delete this file if you do not want us to see that you\r
# use JABAWS. However, we would appreciate it greatly if you could leave it on. \r
-# We depend on the JABAWS usage statistics for our future funding. We do not \r
-# collect any personal data. That data that we submit is as follows\r
+# JABAWS usage statistics are collected for funding and reporting purposes, and \r
+# no private information is collected. The data sent by JABAWS is as follows: \r
# 1) The IP address of the JABAWS server machine.\r
# 2) The name of the web service that was called. \r
# 3) A few details of the system such as java version, user language, color depth, screen\r
# resolution and character encoding.\r
\r
-# All calls to statistics are completed asynchronously and create very little\r
+# All calls to GA are completed asynchronously and create very little\r
# overhead. Thus they do not influence the server response time or performance.\r
\r
# Values yes or true = enable GA, any other value will disable it\r
+ "Engine.cluster.properties");\r
File execProp = getResourceFromClasspath(confDir\r
+ "Executable.properties");\r
+ File gaProp = getResourceFromClasspath(confDir\r
+ + "GA.properties");\r
ph = new PropertyHelper(locEngineProp, clustEngineProp,\r
- execProp);\r
+ execProp, gaProp);\r
} catch (IOException e) {\r
log.warn(\r
"Cannot read property files! Reason: "\r
--- /dev/null
+package compbio.ws.server;\r
+\r
+import java.net.InetAddress;\r
+import java.net.UnknownHostException;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import compbio.engine.conf.PropertyHelperManager;\r
+import compbio.stat.ga.AnalyticsConfigData;\r
+import compbio.stat.ga.GoogleAnalyticsTracker;\r
+import compbio.util.PropertyHelper;\r
+import compbio.util.Util;\r
+import compbio.ws.client.Services;\r
+\r
+public class GAUtils {\r
+\r
+ // MODIFY BEFORE RELEASE!\r
+ final static String VERSION_TYPE = "WAR";\r
+\r
+ private static final Logger log = Logger.getLogger(GAUtils.class);\r
+\r
+ static PropertyHelper PROP_HELPER = PropertyHelperManager\r
+ .getPropertyHelper();\r
+\r
+ private static AnalyticsConfigData config = new AnalyticsConfigData(\r
+ "UA-26161150-1");\r
+\r
+ private static GoogleAnalyticsTracker TRACKER = new GoogleAnalyticsTracker(\r
+ config);\r
+\r
+ public static final boolean IS_GA_ENABLED = isGoogleAnalyticsEnabled();\r
+\r
+ private static String SERVER_ADDRESS = getServerIP();\r
+\r
+ private static boolean isGoogleAnalyticsEnabled() {\r
+ String val = PROP_HELPER.getProperty("enable.ga");\r
+ if (Util.isEmpty(val)) {\r
+ return false;\r
+ }\r
+ val = val.trim();\r
+ if ("yes".equalsIgnoreCase(val) || "true".equalsIgnoreCase(val)) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private static String getServerIP() {\r
+ String IP = "127.0.0.1";\r
+ if (!anonymizeIP()) {\r
+ try {\r
+ InetAddress localAddrIP = InetAddress.getLocalHost();\r
+ IP = localAddrIP.getCanonicalHostName();\r
+ } catch (UnknownHostException ignored) {\r
+ }\r
+ }\r
+ return IP;\r
+ }\r
+\r
+ private static boolean anonymizeIP() {\r
+ String val = PROP_HELPER.getProperty("anonymize.ip");\r
+ if (Util.isEmpty(val)) {\r
+ return false;\r
+ }\r
+ if ("yes".equalsIgnoreCase(val) || "true".equalsIgnoreCase(val)) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ static void reportUsage(Services service) {\r
+ String service_name = "UNKNOWN";\r
+ if (service == null) {\r
+ log.warn("GA: Services was NULL!");\r
+ } else {\r
+ service_name = service.toString();\r
+ }\r
+ TRACKER.trackPageViewFromReferrer("JABAWS/2.0/" + service_name,\r
+ service_name, "http://www.compbio.dundee.ac.uk",\r
+ SERVER_ADDRESS, VERSION_TYPE);\r
+ TRACKER.resetSession();\r
+ }\r
+}\r
+++ /dev/null
-http://localhost:7979/Clustal\r
-http://localhost:8080/ws/Clustal\r
-http://localhost:7979/Muscle\r
throws JobSubmissionException {\r
WSUtil.validateFastaInput(sequences);\r
ConfiguredExecutable<Mafft> confMafft = init(sequences);\r
- return WSUtil.align(sequences, confMafft, null, "align", getLimit(""));\r
+ return WSUtil.align(sequences, confMafft, log, "align", getLimit(""));\r
}\r
\r
ConfiguredExecutable<Mafft> init(List<FastaSequence> dataSet)\r
Mafft.KEY_VALUE_SEPARATOR);\r
log.info("Setting parameters: " + params);\r
confMafft.addParameters(params);\r
- return WSUtil.align(sequences, confMafft, null, "customAlign",\r
+ return WSUtil.align(sequences, confMafft, log, "customAlign",\r
getLimit(""));\r
}\r
\r
// particular preset is not found\r
Limit<Mafft> limit = getLimit(preset.getName());\r
\r
- return WSUtil.align(sequences, confMafft, null, "presetAlign", limit);\r
+ return WSUtil.align(sequences, confMafft, log, "presetAlign", limit);\r
}\r
\r
@SuppressWarnings("unchecked")\r
throws JobSubmissionException {\r
WSUtil.validateFastaInput(sequences);\r
ConfiguredExecutable<Muscle> confMuscle = init(sequences);\r
- return WSUtil.align(sequences, confMuscle, null, "align", getLimit(""));\r
+ return WSUtil.align(sequences, confMuscle, log, "align", getLimit(""));\r
}\r
\r
ConfiguredExecutable<Muscle> init(List<FastaSequence> sequences)\r
List<String> params = WSUtil.getCommands(options,\r
Muscle.KEY_VALUE_SEPARATOR);\r
confMuscle.addParameters(params);\r
- return WSUtil.align(sequences, confMuscle, null, "customAlign",\r
+ return WSUtil.align(sequences, confMuscle, log, "customAlign",\r
getLimit(""));\r
}\r
\r
ConfiguredExecutable<Muscle> confMuscle = init(sequences);\r
confMuscle.addParameters(preset.getOptions());\r
Limit<Muscle> limit = getLimit(preset.getName());\r
- return WSUtil.align(sequences, confMuscle, null, "presetAlign", limit);\r
+ return WSUtil.align(sequences, confMuscle, log, "presetAlign", limit);\r
}\r
\r
@SuppressWarnings("unchecked")\r
throws JobSubmissionException {\r
WSUtil.validateFastaInput(sequences);\r
ConfiguredExecutable<Probcons> confProbcons = init(sequences);\r
- return WSUtil.align(sequences, confProbcons, null, "align",\r
- getLimit(""));\r
+ return WSUtil\r
+ .align(sequences, confProbcons, log, "align", getLimit(""));\r
}\r
\r
ConfiguredExecutable<Probcons> init(List<FastaSequence> dataSet)\r
Probcons.KEY_VALUE_SEPARATOR);\r
log.info("Setting parameters:" + params);\r
confProbcons.addParameters(params);\r
- return WSUtil.align(sequences, confProbcons, null, "customAlign",\r
+ return WSUtil.align(sequences, confProbcons, log, "customAlign",\r
getLimit(""));\r
}\r
\r
ConfiguredExecutable<Probcons> confProbcons = init(sequences);\r
confProbcons.addParameters(preset.getOptions());\r
Limit<Probcons> limit = getLimit(preset.getName());\r
- return WSUtil\r
- .align(sequences, confProbcons, null, "presetAlign", limit);\r
+ return WSUtil.align(sequences, confProbcons, log, "presetAlign", limit);\r
}\r
\r
@SuppressWarnings("unchecked")\r
throws JobSubmissionException {\r
WSUtil.validateFastaInput(sequences);\r
ConfiguredExecutable<Tcoffee> confTcoffee = init(sequences);\r
- return WSUtil\r
- .align(sequences, confTcoffee, null, "align", getLimit(""));\r
+ return WSUtil.align(sequences, confTcoffee, log, "align", getLimit(""));\r
}\r
\r
ConfiguredExecutable<Tcoffee> init(List<FastaSequence> sequences)\r
Tcoffee.KEY_VALUE_SEPARATOR);\r
log.info("Setting parameters:" + params);\r
confTcoffee.addParameters(params);\r
- return WSUtil.align(sequences, confTcoffee, null, "customAlign",\r
+ return WSUtil.align(sequences, confTcoffee, log, "customAlign",\r
getLimit(""));\r
}\r
\r
ConfiguredExecutable<Tcoffee> confTcoffee = init(sequences);\r
confTcoffee.addParameters(preset.getOptions());\r
Limit<Tcoffee> limit = getLimit(preset.getName());\r
- return WSUtil.align(sequences, confTcoffee, null, "presetAlign", limit);\r
+ return WSUtil.align(sequences, confTcoffee, log, "presetAlign", limit);\r
}\r
\r
@SuppressWarnings("unchecked")\r
import compbio.metadata.LimitExceededException;\r
import compbio.metadata.Option;\r
import compbio.metadata.ResultNotAvailableException;\r
+import compbio.ws.client.Services;\r
+import compbio.ws.client.ServicesUtil;\r
\r
public final class WSUtil {\r
\r
compbio.runner.Util.writeInput(sequences, confExec);\r
AsyncExecutor engine = Configurator.getAsyncEngine(confExec);\r
String jobId = engine.submitJob(confExec);\r
+ reportUsage(confExec, logger);\r
return jobId;\r
}\r
\r
+ static <T> void reportUsage(ConfiguredExecutable<T> confExec, Logger logger) {\r
+ if (GAUtils.IS_GA_ENABLED) {\r
+ Services service = ServicesUtil.getServiceByRunner(confExec\r
+ .getExecutable().getClass());\r
+ GAUtils.reportUsage(service);\r
+ logger.info("Reporting GA usage for " + service);\r
+ }\r
+ }\r
+\r
public static <T> String analize(List<FastaSequence> sequences,\r
ConfiguredExecutable<T> confExec, Logger log, String method,\r
Limit<T> limit) throws JobSubmissionException {\r
compbio.runner.Util.writeInput(sequences, confExec);\r
AsyncExecutor engine = Configurator.getAsyncEngine(confExec);\r
String jobId = engine.submitJob(confExec);\r
-\r
+ reportUsage(confExec, log);\r
return jobId;\r
}\r
\r