You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sh...@apache.org on 2015/06/11 23:34:42 UTC
[1/8] airavata git commit: moved commons-utils to commons module
Repository: airavata
Updated Branches:
refs/heads/master a5cb91f0f -> 8d16d0ec5
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/RequestData.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/RequestData.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/RequestData.java
index 0bf56d2..73538b0 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/RequestData.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/RequestData.java
@@ -29,7 +29,6 @@ package org.apache.airavata.gfac.core;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.gfac.core.Constants;
/**
* Encapsulates GFac specific data that are coming in the request.
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/OutputUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/OutputUtils.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/OutputUtils.java
index 81bcf66..904839c 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/OutputUtils.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/OutputUtils.java
@@ -21,7 +21,6 @@
package org.apache.airavata.gfac.impl;
import org.apache.airavata.common.utils.StringUtil;
-import org.apache.airavata.gfac.core.handler.GFacHandlerException;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailMonitorFactory.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailMonitorFactory.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailMonitorFactory.java
index 3a75331..870cfa4 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailMonitorFactory.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailMonitorFactory.java
@@ -25,8 +25,6 @@ import org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerTy
import java.util.Calendar;
import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
public class EmailMonitorFactory {
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
index d00c698..38de3ba 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/ssh/provider/impl/SSHProvider.java
@@ -58,7 +58,6 @@ import org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerTy
import org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission;
import org.apache.airavata.model.workspace.experiment.CorrectiveAction;
import org.apache.airavata.model.workspace.experiment.ErrorCategory;
-import org.apache.airavata.model.workspace.experiment.ExperimentState;
import org.apache.airavata.model.workspace.experiment.JobDetails;
import org.apache.airavata.model.workspace.experiment.JobState;
import org.apache.xmlbeans.XmlException;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/gfac/gfac-service/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-service/pom.xml b/modules/gfac/gfac-service/pom.xml
index f1d4d6c..47595b8 100644
--- a/modules/gfac/gfac-service/pom.xml
+++ b/modules/gfac/gfac-service/pom.xml
@@ -42,7 +42,7 @@
<!--</dependency>-->
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/gfac/gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java b/modules/gfac/gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
index 770eb98..9e89788 100644
--- a/modules/gfac/gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
+++ b/modules/gfac/gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
@@ -102,6 +102,7 @@ public class GfacServerHandler implements GfacService.Iface {
public GfacServerHandler() throws Exception {
try {
+
// start curator client
String zkhostPort = AiravataZKUtils.getZKhostPort();
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 5);
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/messaging/core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/messaging/core/pom.xml b/modules/messaging/core/pom.xml
index 1c42bf7..4e2915a 100644
--- a/modules/messaging/core/pom.xml
+++ b/modules/messaging/core/pom.xml
@@ -30,7 +30,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/messaging/core/src/main/java/org/apache/airavata/messaging/core/Publisher.java
----------------------------------------------------------------------
diff --git a/modules/messaging/core/src/main/java/org/apache/airavata/messaging/core/Publisher.java b/modules/messaging/core/src/main/java/org/apache/airavata/messaging/core/Publisher.java
index 4878254..dea8b00 100644
--- a/modules/messaging/core/src/main/java/org/apache/airavata/messaging/core/Publisher.java
+++ b/modules/messaging/core/src/main/java/org/apache/airavata/messaging/core/Publisher.java
@@ -22,7 +22,6 @@
package org.apache.airavata.messaging.core;
import org.apache.airavata.common.exception.AiravataException;
-import org.apache.airavata.model.messaging.event.*;
/**
* This is the basic publisher interface.
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/messaging/core/src/main/java/org/apache/airavata/messaging/core/impl/RabbitMQTaskLaunchPublisher.java
----------------------------------------------------------------------
diff --git a/modules/messaging/core/src/main/java/org/apache/airavata/messaging/core/impl/RabbitMQTaskLaunchPublisher.java b/modules/messaging/core/src/main/java/org/apache/airavata/messaging/core/impl/RabbitMQTaskLaunchPublisher.java
index 34e2545..53bf373 100644
--- a/modules/messaging/core/src/main/java/org/apache/airavata/messaging/core/impl/RabbitMQTaskLaunchPublisher.java
+++ b/modules/messaging/core/src/main/java/org/apache/airavata/messaging/core/impl/RabbitMQTaskLaunchPublisher.java
@@ -28,7 +28,6 @@ import org.apache.airavata.messaging.core.MessageContext;
import org.apache.airavata.messaging.core.MessagingConstants;
import org.apache.airavata.messaging.core.Publisher;
import org.apache.airavata.model.messaging.event.*;
-import org.apache.catalina.Server;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/orchestrator/orchestrator-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/pom.xml b/modules/orchestrator/orchestrator-core/pom.xml
index f0bbafb..6bf5171 100644
--- a/modules/orchestrator/orchestrator-core/pom.xml
+++ b/modules/orchestrator/orchestrator-core/pom.xml
@@ -41,7 +41,7 @@ the License. -->
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/registry/registry-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/pom.xml b/modules/registry/registry-core/pom.xml
index fb80c1f..25eb17d 100644
--- a/modules/registry/registry-core/pom.xml
+++ b/modules/registry/registry-core/pom.xml
@@ -30,7 +30,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Test -->
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/registry/registry-cpi/pom.xml
----------------------------------------------------------------------
diff --git a/modules/registry/registry-cpi/pom.xml b/modules/registry/registry-cpi/pom.xml
index 8b5f84f..f5a54cc 100644
--- a/modules/registry/registry-cpi/pom.xml
+++ b/modules/registry/registry-cpi/pom.xml
@@ -30,7 +30,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/security/pom.xml
----------------------------------------------------------------------
diff --git a/modules/security/pom.xml b/modules/security/pom.xml
index c968e91..ffba9b8 100644
--- a/modules/security/pom.xml
+++ b/modules/security/pom.xml
@@ -24,7 +24,7 @@
<dependencies>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/security/src/test/java/org/apache/airavata/security/userstore/SessionDBUserStoreTest.java
----------------------------------------------------------------------
diff --git a/modules/security/src/test/java/org/apache/airavata/security/userstore/SessionDBUserStoreTest.java b/modules/security/src/test/java/org/apache/airavata/security/userstore/SessionDBUserStoreTest.java
index 9059c9a..0a8b7ab 100644
--- a/modules/security/src/test/java/org/apache/airavata/security/userstore/SessionDBUserStoreTest.java
+++ b/modules/security/src/test/java/org/apache/airavata/security/userstore/SessionDBUserStoreTest.java
@@ -23,7 +23,6 @@
package org.apache.airavata.security.userstore;
-import junit.framework.TestCase;
import org.apache.airavata.common.utils.DatabaseTestCases;
import org.apache.airavata.common.utils.DerbyUtil;
import org.junit.*;
@@ -32,7 +31,6 @@ import org.w3c.dom.NodeList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.File;
import java.io.InputStream;
/**
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/server/pom.xml
----------------------------------------------------------------------
diff --git a/modules/server/pom.xml b/modules/server/pom.xml
index 37ba141..d8f4419 100644
--- a/modules/server/pom.xml
+++ b/modules/server/pom.xml
@@ -37,7 +37,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/server/src/main/java/org/apache/airavata/server/ServerMain.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/airavata/server/ServerMain.java b/modules/server/src/main/java/org/apache/airavata/server/ServerMain.java
index d90c21b..0117f7a 100644
--- a/modules/server/src/main/java/org/apache/airavata/server/ServerMain.java
+++ b/modules/server/src/main/java/org/apache/airavata/server/ServerMain.java
@@ -24,10 +24,8 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
-import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.*;
@@ -36,8 +34,6 @@ import org.apache.airavata.common.utils.IServer.ServerStatus;
import org.apache.airavata.common.utils.StringUtil.CommandLineParameters;
import org.apache.commons.cli.ParseException;
import org.apache.zookeeper.server.ServerCnxnFactory;
-import org.apache.zookeeper.server.ServerConfig;
-import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/test-suite/multi-tenanted-airavata/pom.xml
----------------------------------------------------------------------
diff --git a/modules/test-suite/multi-tenanted-airavata/pom.xml b/modules/test-suite/multi-tenanted-airavata/pom.xml
index 6c3f41f..58a3b53 100644
--- a/modules/test-suite/multi-tenanted-airavata/pom.xml
+++ b/modules/test-suite/multi-tenanted-airavata/pom.xml
@@ -65,7 +65,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-engine/pom.xml
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-engine/pom.xml b/modules/workflow-model/workflow-engine/pom.xml
index 1361781..6f9bf15 100644
--- a/modules/workflow-model/workflow-engine/pom.xml
+++ b/modules/workflow-model/workflow-engine/pom.xml
@@ -242,7 +242,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<!--<dependency>-->
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/invoker/SimpleInvoker.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/invoker/SimpleInvoker.java b/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/invoker/SimpleInvoker.java
index e205459..eef2f8e 100644
--- a/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/invoker/SimpleInvoker.java
+++ b/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/invoker/SimpleInvoker.java
@@ -21,13 +21,10 @@
package org.apache.airavata.workflow.engine.invoker;
-import java.util.Iterator;
-
import org.apache.airavata.common.utils.XMLUtil;
import org.apache.airavata.workflow.model.exceptions.WorkflowException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.xmlpull.v1.builder.XmlElement;
//import xsul.wsdl.WsdlDefinitions;
//import xsul.wsif.WSIFMessage;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/util/InterpreterUtil.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/util/InterpreterUtil.java b/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/util/InterpreterUtil.java
index c88f6ab..5beda25 100644
--- a/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/util/InterpreterUtil.java
+++ b/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/util/InterpreterUtil.java
@@ -23,7 +23,6 @@ package org.apache.airavata.workflow.engine.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -36,20 +35,11 @@ import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
import org.apache.airavata.workflow.model.graph.DataPort;
import org.apache.airavata.workflow.model.graph.Node;
import org.apache.airavata.workflow.model.graph.Node.NodeExecutionState;
-import org.apache.airavata.workflow.model.graph.amazon.InstanceNode;
import org.apache.airavata.workflow.model.graph.impl.NodeImpl;
-import org.apache.airavata.workflow.model.graph.system.ConstantNode;
-import org.apache.airavata.workflow.model.graph.system.DifferedInputNode;
-import org.apache.airavata.workflow.model.graph.system.DoWhileNode;
-import org.apache.airavata.workflow.model.graph.system.EndDoWhileNode;
import org.apache.airavata.workflow.model.graph.system.EndForEachNode;
-import org.apache.airavata.workflow.model.graph.system.EndifNode;
import org.apache.airavata.workflow.model.graph.system.ForEachNode;
import org.apache.airavata.workflow.model.graph.system.InputNode;
-import org.apache.airavata.workflow.model.graph.system.SystemDataPort;
import org.apache.airavata.workflow.model.graph.ws.WSGraph;
-import org.apache.airavata.workflow.model.graph.ws.WSPort;
-import org.xmlpull.infoset.XmlElement;
//import xsul5.XmlConstants;
//import org.apache.airavata.xbaya.ui.monitor.MonitorEventHandler;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/util/XBayaUtil.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/util/XBayaUtil.java b/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/util/XBayaUtil.java
index 7aaac5d..f56aeca 100644
--- a/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/util/XBayaUtil.java
+++ b/modules/workflow-model/workflow-engine/src/main/java/org/apache/airavata/workflow/engine/util/XBayaUtil.java
@@ -28,15 +28,11 @@ import org.apache.airavata.workflow.model.exceptions.WorkflowException;
import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
import org.apache.airavata.workflow.model.graph.DataPort;
import org.apache.airavata.workflow.model.graph.Node;
-import org.apache.airavata.workflow.model.graph.amazon.InstanceNode;
-import org.apache.airavata.workflow.model.graph.system.ConstantNode;
import org.apache.airavata.workflow.model.graph.system.EndForEachNode;
-import org.apache.airavata.workflow.model.graph.system.EndifNode;
import org.apache.airavata.workflow.model.graph.system.ForEachNode;
import org.apache.airavata.workflow.model.graph.system.InputNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.xmlpull.infoset.XmlElement;
//import xsul5.XmlConstants;
import java.net.HttpURLConnection;
@@ -44,7 +40,6 @@ import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-component/pom.xml
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-component/pom.xml b/modules/workflow-model/workflow-model-component/pom.xml
index c45de00..aa99ab0 100644
--- a/modules/workflow-model/workflow-model-component/pom.xml
+++ b/modules/workflow-model/workflow-model-component/pom.xml
@@ -66,7 +66,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/pom.xml b/modules/workflow-model/workflow-model-core/pom.xml
index 3b31fb7..2e78243 100644
--- a/modules/workflow-model/workflow-model-core/pom.xml
+++ b/modules/workflow-model/workflow-model-core/pom.xml
@@ -67,7 +67,7 @@
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/amazon/InstanceComponentDataPort.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/amazon/InstanceComponentDataPort.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/amazon/InstanceComponentDataPort.java
index 85e7e4a..9702658 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/amazon/InstanceComponentDataPort.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/amazon/InstanceComponentDataPort.java
@@ -21,8 +21,6 @@
package org.apache.airavata.workflow.model.component.amazon;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.workflow.model.component.ComponentDataPort;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/dynamic/DynamicComponentPort.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/dynamic/DynamicComponentPort.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/dynamic/DynamicComponentPort.java
index 0adc686..f5fa500 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/dynamic/DynamicComponentPort.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/dynamic/DynamicComponentPort.java
@@ -21,8 +21,6 @@
package org.apache.airavata.workflow.model.component.dynamic;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.workflow.model.component.ComponentDataPort;
import org.apache.airavata.workflow.model.graph.DataPort;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/url/URLComponentRegistry.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/url/URLComponentRegistry.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/url/URLComponentRegistry.java
index df56cc4..b5bd3b5 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/url/URLComponentRegistry.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/url/URLComponentRegistry.java
@@ -31,7 +31,6 @@ import org.apache.airavata.workflow.model.component.ComponentReference;
import org.apache.airavata.workflow.model.component.ComponentRegistry;
import org.apache.airavata.workflow.model.component.ComponentRegistryException;
import org.apache.airavata.workflow.model.component.ws.WSComponent;
-import org.apache.airavata.workflow.model.component.ws.WSComponentFactory;
//import xsul.wsdl.WsdlDefinitions;
//import xsul.wsdl.WsdlResolver;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/web/WebComponentRegistry.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/web/WebComponentRegistry.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/web/WebComponentRegistry.java
index 3f66877..052868a 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/web/WebComponentRegistry.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/web/WebComponentRegistry.java
@@ -39,7 +39,6 @@ import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.parser.ParserDelegator;
import org.apache.airavata.common.utils.IOUtil;
-import org.apache.airavata.workflow.model.component.ComponentException;
import org.apache.airavata.workflow.model.component.ComponentReference;
import org.apache.airavata.workflow.model.component.ComponentRegistry;
import org.apache.airavata.workflow.model.component.ComponentRegistryException;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentApplication.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentApplication.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentApplication.java
index 1ebc006..c51f39f 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentApplication.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentApplication.java
@@ -34,7 +34,6 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-import javax.xml.namespace.QName;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
@@ -48,7 +47,6 @@ import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
import org.apache.airavata.workflow.model.utils.WorkflowConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.xmlpull.infoset.XmlNamespace;
//import xsul5.XmlConstants;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentPort.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentPort.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentPort.java
index b216b3d..ac4780a 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentPort.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentPort.java
@@ -21,8 +21,6 @@
package org.apache.airavata.workflow.model.component.ws;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.common.utils.XMLUtil;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentRegistry.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentRegistry.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentRegistry.java
index 083aa89..bacb90c 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentRegistry.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/ws/WSComponentRegistry.java
@@ -24,7 +24,6 @@ package org.apache.airavata.workflow.model.component.ws;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -34,7 +33,6 @@ import org.apache.airavata.workflow.model.component.ComponentReference;
import org.apache.airavata.workflow.model.component.ComponentRegistry;
import org.apache.airavata.workflow.model.component.ComponentRegistryException;
import org.apache.airavata.workflow.model.component.system.SubWorkflowComponent;
-import org.apache.airavata.workflow.model.component.url.URLComponentReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/DSCUtil.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/DSCUtil.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/DSCUtil.java
index 7a67672..a7a64e7 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/DSCUtil.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/DSCUtil.java
@@ -23,23 +23,13 @@ package org.apache.airavata.workflow.model.gpel;
import java.io.UnsupportedEncodingException;
import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import javax.xml.namespace.QName;
import org.apache.airavata.common.exception.UtilsException;
import org.apache.airavata.common.utils.WSDLUtil;
import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
-import org.apache.airavata.workflow.model.gpel.script.BPELScript;
-import org.apache.airavata.workflow.model.graph.Graph;
-import org.apache.airavata.workflow.model.graph.util.GraphUtil;
-import org.apache.airavata.workflow.model.graph.ws.WSNode;
-import org.apache.airavata.workflow.model.wf.Workflow;
//import xsul5.wsdl.WsdlDefinitions;
//import xsul5.wsdl.WsdlPortType;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/script/BPELScript.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/script/BPELScript.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/script/BPELScript.java
index 182c0e8..9063207 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/script/BPELScript.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/script/BPELScript.java
@@ -28,40 +28,29 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.common.utils.StringUtil;
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.common.utils.XMLUtil;
import org.apache.airavata.workflow.model.component.ComponentPort;
import org.apache.airavata.workflow.model.component.ws.WSComponent;
import org.apache.airavata.workflow.model.component.ws.WSComponentPort;
-import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
-import org.apache.airavata.workflow.model.graph.DataPort;
import org.apache.airavata.workflow.model.graph.EPRPort;
import org.apache.airavata.workflow.model.graph.Graph;
import org.apache.airavata.workflow.model.graph.GraphException;
import org.apache.airavata.workflow.model.graph.Node;
import org.apache.airavata.workflow.model.graph.Port;
-import org.apache.airavata.workflow.model.graph.amazon.InstanceNode;
-import org.apache.airavata.workflow.model.graph.amazon.ResourceNode;
import org.apache.airavata.workflow.model.graph.system.BlockNode;
import org.apache.airavata.workflow.model.graph.system.ConstantNode;
import org.apache.airavata.workflow.model.graph.system.EndBlockNode;
import org.apache.airavata.workflow.model.graph.system.EndForEachNode;
import org.apache.airavata.workflow.model.graph.system.EndifNode;
-import org.apache.airavata.workflow.model.graph.system.ExitNode;
import org.apache.airavata.workflow.model.graph.system.ForEachNode;
import org.apache.airavata.workflow.model.graph.system.IfNode;
import org.apache.airavata.workflow.model.graph.system.InputNode;
import org.apache.airavata.workflow.model.graph.system.MemoNode;
import org.apache.airavata.workflow.model.graph.system.OutputNode;
-import org.apache.airavata.workflow.model.graph.system.ReceiveNode;
-import org.apache.airavata.workflow.model.graph.system.StreamSourceNode;
import org.apache.airavata.workflow.model.graph.util.GraphUtil;
import org.apache.airavata.workflow.model.graph.ws.WSNode;
-import org.apache.airavata.workflow.model.utils.WorkflowConstants;
-import org.apache.airavata.workflow.model.utils.ApplicationVersion;
import org.apache.airavata.workflow.model.wf.Workflow;
//import org.gpel.GpelConstants;
//import org.gpel.model.GpelAssign;
@@ -82,9 +71,7 @@ import org.apache.airavata.workflow.model.wf.Workflow;
//import org.gpel.model.GpelVariable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.xmlpull.infoset.XmlComment;
import org.xmlpull.infoset.XmlElement;
-import org.xmlpull.infoset.XmlInfosetBuilder;
import org.xmlpull.infoset.XmlNamespace;
//import xsul5.wsdl.WsdlPortType;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/script/WorkflowWSDL.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/script/WorkflowWSDL.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/script/WorkflowWSDL.java
index 5017d24..ee8f40b 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/script/WorkflowWSDL.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/gpel/script/WorkflowWSDL.java
@@ -21,9 +21,7 @@
package org.apache.airavata.workflow.model.gpel.script;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.xml.namespace.QName;
@@ -32,22 +30,16 @@ import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.common.utils.WSDLUtil;
import org.apache.airavata.common.utils.XMLUtil;
import org.apache.airavata.workflow.model.component.ws.WSComponentPort;
-import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
-import org.apache.airavata.workflow.model.graph.DataPort;
import org.apache.airavata.workflow.model.graph.GraphException;
import org.apache.airavata.workflow.model.graph.Node;
import org.apache.airavata.workflow.model.graph.system.InputNode;
import org.apache.airavata.workflow.model.graph.system.ParameterNode;
-import org.apache.airavata.workflow.model.graph.system.ReceiveNode;
import org.apache.airavata.workflow.model.graph.system.SystemDataPort;
-import org.apache.airavata.workflow.model.graph.util.GraphUtil;
import org.apache.airavata.workflow.model.graph.ws.WSGraph;
import org.apache.airavata.workflow.model.utils.WorkflowConstants;
-import org.apache.airavata.workflow.model.utils.ApplicationVersion;
import org.apache.airavata.workflow.model.wf.Workflow;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.xmlpull.infoset.XmlComment;
import org.xmlpull.infoset.XmlElement;
import org.xmlpull.infoset.XmlNamespace;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/impl/EdgeImpl.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/impl/EdgeImpl.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/impl/EdgeImpl.java
index 03b867d..bb2519f 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/impl/EdgeImpl.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/impl/EdgeImpl.java
@@ -21,7 +21,6 @@
package org.apache.airavata.workflow.model.graph.impl;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.apache.airavata.common.utils.XMLUtil;
import org.apache.airavata.workflow.model.graph.Edge;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/impl/PortImpl.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/impl/PortImpl.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/impl/PortImpl.java
index 5231a01..6504d2b 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/impl/PortImpl.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/impl/PortImpl.java
@@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import org.apache.airavata.common.utils.XMLUtil;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ConstantNode.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ConstantNode.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ConstantNode.java
index b69fcae..405dc3b 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ConstantNode.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ConstantNode.java
@@ -23,8 +23,6 @@ package org.apache.airavata.workflow.model.graph.system;
import java.util.List;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.workflow.model.component.Component;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/DifferedInputNode.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/DifferedInputNode.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/DifferedInputNode.java
index 5ef7b1c..2902128 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/DifferedInputNode.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/DifferedInputNode.java
@@ -22,8 +22,6 @@ package org.apache.airavata.workflow.model.graph.system;
import java.util.List;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.workflow.model.component.Component;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndBlockNode.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndBlockNode.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndBlockNode.java
index c515f63..f57294c 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndBlockNode.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndBlockNode.java
@@ -23,8 +23,6 @@ package org.apache.airavata.workflow.model.graph.system;
import java.util.List;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.workflow.model.component.ComponentDataPort;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndDoWhileNode.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndDoWhileNode.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndDoWhileNode.java
index 6c763aa..7b92714 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndDoWhileNode.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndDoWhileNode.java
@@ -23,8 +23,6 @@ package org.apache.airavata.workflow.model.graph.system;
import java.util.List;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.workflow.model.component.ComponentDataPort;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndForEachNode.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndForEachNode.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndForEachNode.java
index feb07c0..c565ed2 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndForEachNode.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndForEachNode.java
@@ -23,8 +23,6 @@ package org.apache.airavata.workflow.model.graph.system;
import java.util.List;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.workflow.model.component.ComponentDataPort;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndifNode.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndifNode.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndifNode.java
index 63c26d6..dbc8382 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndifNode.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/EndifNode.java
@@ -23,8 +23,6 @@ package org.apache.airavata.workflow.model.graph.system;
import java.util.List;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.workflow.model.component.ComponentDataPort;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ForEachNode.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ForEachNode.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ForEachNode.java
index 86dcdef..8962cd8 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ForEachNode.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ForEachNode.java
@@ -23,8 +23,6 @@ package org.apache.airavata.workflow.model.graph.system;
import java.util.List;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.workflow.model.component.ComponentDataPort;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/InputNode.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/InputNode.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/InputNode.java
index ffe017f..5a4c236 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/InputNode.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/InputNode.java
@@ -23,8 +23,6 @@ package org.apache.airavata.workflow.model.graph.system;
import java.util.List;
-import javax.xml.namespace.QName;
-
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.apache.airavata.common.utils.WSConstants;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ParameterNode.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ParameterNode.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ParameterNode.java
index b819e4f..739b231 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ParameterNode.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/ParameterNode.java
@@ -24,8 +24,6 @@ package org.apache.airavata.workflow.model.graph.system;
import java.util.ArrayList;
import java.util.List;
-import javax.xml.namespace.QName;
-
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.apache.airavata.common.exception.UtilsException;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/S3InputNode.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/S3InputNode.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/S3InputNode.java
index a51849c..320135f 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/S3InputNode.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/S3InputNode.java
@@ -23,8 +23,6 @@ package org.apache.airavata.workflow.model.graph.system;
import java.util.List;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.workflow.model.component.Component;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/SystemDataPort.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/SystemDataPort.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/SystemDataPort.java
index 2967f5c..dc821ce 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/SystemDataPort.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/SystemDataPort.java
@@ -21,8 +21,6 @@
package org.apache.airavata.workflow.model.graph.system;
-import javax.xml.namespace.QName;
-
import com.google.gson.JsonObject;
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/SystemNode.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/SystemNode.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/SystemNode.java
index eb83b6b..1962290 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/SystemNode.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/system/SystemNode.java
@@ -23,8 +23,6 @@ package org.apache.airavata.workflow.model.graph.system;
import java.util.List;
-import javax.xml.namespace.QName;
-
import com.google.gson.JsonObject;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/ws/WSGraphFactory.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/ws/WSGraphFactory.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/ws/WSGraphFactory.java
index 9fc9567..cca707d 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/ws/WSGraphFactory.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/ws/WSGraphFactory.java
@@ -24,7 +24,6 @@ package org.apache.airavata.workflow.model.graph.ws;
import java.io.File;
import java.io.IOException;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.apache.airavata.common.utils.IOUtil;
import org.apache.airavata.common.utils.JSONUtil;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/ws/WSPort.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/ws/WSPort.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/ws/WSPort.java
index 0140993..3db6ae6 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/ws/WSPort.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/graph/ws/WSPort.java
@@ -21,8 +21,6 @@
package org.apache.airavata.workflow.model.graph.ws;
-import javax.xml.namespace.QName;
-
import com.google.gson.JsonObject;
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/TridentTransformer.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/TridentTransformer.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/TridentTransformer.java
index 51e1f11..d4fbc38 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/TridentTransformer.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/TridentTransformer.java
@@ -21,13 +21,7 @@
package org.apache.airavata.workflow.model.wf;
-import java.util.LinkedList;
-
import org.apache.airavata.common.utils.XMLUtil;
-import org.apache.airavata.workflow.model.xsd.GFacSimpleTypesXSD;
-import org.apache.airavata.workflow.model.xsd.LeadContextHeaderXSD;
-import org.apache.airavata.workflow.model.xsd.LeadCrosscutXSD;
-import org.xmlpull.infoset.XmlElement;
//import xsul5.wsdl.WsdlDefinitions;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/Workflow.java
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/Workflow.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/Workflow.java
index eb6ebf7..705b4ae 100644
--- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/Workflow.java
+++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/Workflow.java
@@ -28,16 +28,13 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.imageio.ImageIO;
import javax.xml.namespace.QName;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import org.apache.airavata.common.exception.UtilsException;
@@ -52,8 +49,6 @@ import org.apache.airavata.workflow.model.component.ws.WSComponentPort;
import org.apache.airavata.workflow.model.exceptions.WorkflowException;
import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
import org.apache.airavata.workflow.model.gpel.script.BPELScript;
-import org.apache.airavata.workflow.model.gpel.script.BPELScriptType;
-import org.apache.airavata.workflow.model.graph.Graph;
import org.apache.airavata.workflow.model.graph.GraphException;
import org.apache.airavata.workflow.model.graph.GraphSchema;
import org.apache.airavata.workflow.model.graph.Node;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/pom.xml
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/pom.xml b/modules/xbaya-gui/pom.xml
index fa25025..d15c231 100644
--- a/modules/xbaya-gui/pom.xml
+++ b/modules/xbaya-gui/pom.xml
@@ -201,7 +201,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<!--<dependency>-->
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/core/generators/BPELFiler.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/core/generators/BPELFiler.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/core/generators/BPELFiler.java
index cd3954a..eeb6f3c 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/core/generators/BPELFiler.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/core/generators/BPELFiler.java
@@ -22,7 +22,6 @@
package org.apache.airavata.xbaya.core.generators;
import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import javax.swing.JFileChooser;
@@ -30,15 +29,10 @@ import javax.swing.filechooser.FileFilter;
import org.apache.airavata.common.utils.XMLUtil;
import org.apache.airavata.workflow.model.gpel.script.BPELScript;
-import org.apache.airavata.workflow.model.gpel.script.BPELScriptType;
-import org.apache.airavata.workflow.model.gpel.script.WorkflowWSDL;
-import org.apache.airavata.workflow.model.graph.GraphException;
import org.apache.airavata.workflow.model.wf.Workflow;
import org.apache.airavata.xbaya.XBayaConstants;
import org.apache.airavata.xbaya.XBayaEngine;
import org.apache.airavata.xbaya.file.XBayaPathConstants;
-import org.apache.airavata.xbaya.ui.utils.ErrorMessages;
-import org.gpel.model.GpelProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/core/generators/ODEScriptFiler.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/core/generators/ODEScriptFiler.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/core/generators/ODEScriptFiler.java
index 7649754..dbf0044 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/core/generators/ODEScriptFiler.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/core/generators/ODEScriptFiler.java
@@ -22,20 +22,13 @@
package org.apache.airavata.xbaya.core.generators;
import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.Map;
-import java.util.Set;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
-import javax.xml.namespace.QName;
import org.apache.airavata.common.utils.WSDLUtil;
-import org.apache.airavata.workflow.model.component.ComponentException;
-import org.apache.airavata.workflow.model.graph.GraphException;
import org.apache.airavata.workflow.model.wf.Workflow;
import org.apache.airavata.xbaya.XBayaConstants;
import org.apache.airavata.xbaya.XBayaEngine;
@@ -44,10 +37,6 @@ import org.apache.airavata.xbaya.ui.utils.ErrorMessages;
import org.gpel.model.GpelProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.xmlpull.infoset.XmlElement;
-
-import xsul5.XmlConstants;
-import xsul5.wsdl.WsdlDefinitions;
public class ODEScriptFiler {
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/StandaloneNotificationSender.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/StandaloneNotificationSender.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/StandaloneNotificationSender.java
index 432bc56..cd06c60 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/StandaloneNotificationSender.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/StandaloneNotificationSender.java
@@ -31,11 +31,9 @@ import org.apache.airavata.workflow.model.graph.system.OutputNode;
import org.apache.airavata.workflow.model.graph.util.GraphUtil;
import org.apache.airavata.workflow.model.wf.Workflow;
import org.apache.airavata.xbaya.XBayaConstants;
-import org.apache.airavata.xbaya.graph.controller.NodeController;
import org.apache.airavata.xbaya.jython.lib.ServiceNotifiable;
import org.apache.airavata.xbaya.jython.lib.StandaloneServiceNotificationSender;
import org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable;
-import org.apache.airavata.xbaya.ui.monitor.MonitorEventHandler.NodeState;
import org.apache.axis2.addressing.EndpointReference;
import org.python.core.PyObject;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/messaging/EventData.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/messaging/EventData.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/messaging/EventData.java
index ab02662..ba70109 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/messaging/EventData.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/messaging/EventData.java
@@ -27,14 +27,11 @@ import org.apache.airavata.messaging.core.MessageContext;
import org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent;
import org.apache.airavata.model.messaging.event.JobIdentifier;
import org.apache.airavata.model.messaging.event.JobStatusChangeEvent;
-import org.apache.airavata.model.messaging.event.Message;
-import org.apache.airavata.model.messaging.event.MessageLevel;
import org.apache.airavata.model.messaging.event.MessageType;
import org.apache.airavata.model.messaging.event.TaskIdentifier;
import org.apache.airavata.model.messaging.event.TaskStatusChangeEvent;
import org.apache.airavata.model.messaging.event.WorkflowIdentifier;
import org.apache.airavata.model.messaging.event.WorkflowNodeStatusChangeEvent;
-import org.apache.thrift.TException;
import java.util.Date;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/modifier/WorkflowModifier.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/modifier/WorkflowModifier.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/modifier/WorkflowModifier.java
index f8a495a..3b38b1f 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/modifier/WorkflowModifier.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/modifier/WorkflowModifier.java
@@ -51,10 +51,6 @@ import org.apache.airavata.xbaya.messaging.MonitorException;
import org.apache.airavata.xbaya.ui.monitor.MonitorEventHandler.NodeState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.xmlpull.infoset.XmlElement;
-
-import xsul.XmlConstants;
-import xsul5.wsdl.WsdlPortTypeOperation;
public class WorkflowModifier {
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java
index fb1a0b0..3c7a1d4 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java
@@ -52,7 +52,6 @@ import org.apache.airavata.common.utils.SwingUtil;
import org.apache.airavata.workflow.model.component.Component;
import org.apache.airavata.workflow.model.exceptions.WorkflowException;
import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
-import org.apache.airavata.workflow.model.graph.Graph;
import org.apache.airavata.workflow.model.graph.Node;
import org.apache.airavata.workflow.model.graph.Port;
import org.apache.airavata.workflow.model.wf.Workflow;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/ConstantConfigurationDialog.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/ConstantConfigurationDialog.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/ConstantConfigurationDialog.java
index 63b7850..9a99baf 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/ConstantConfigurationDialog.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/ConstantConfigurationDialog.java
@@ -26,7 +26,6 @@ import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JPanel;
-import javax.xml.namespace.QName;
import org.apache.airavata.common.utils.XMLUtil;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/DifferedInputConfigurationDialog.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/DifferedInputConfigurationDialog.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/DifferedInputConfigurationDialog.java
index e81a033..1fc19c7 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/DifferedInputConfigurationDialog.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/DifferedInputConfigurationDialog.java
@@ -26,7 +26,6 @@ import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JPanel;
-import javax.xml.namespace.QName;
import org.apache.airavata.common.utils.WSConstants;
import org.apache.airavata.common.utils.XMLUtil;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/InputConfigurationDialog.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/InputConfigurationDialog.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/InputConfigurationDialog.java
index b0c5f57..fa88ff1 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/InputConfigurationDialog.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/InputConfigurationDialog.java
@@ -26,10 +26,8 @@ import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JPanel;
-import javax.xml.namespace.QName;
import org.apache.airavata.common.utils.XMLUtil;
-import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.workflow.model.graph.system.InputNode;
import org.apache.airavata.xbaya.ui.XBayaGUI;
import org.apache.airavata.xbaya.ui.dialogs.XBayaDialog;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/OutputConfigurationDialog.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/OutputConfigurationDialog.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/OutputConfigurationDialog.java
index 7862959..428b0db 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/OutputConfigurationDialog.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/OutputConfigurationDialog.java
@@ -36,7 +36,6 @@ import org.apache.airavata.xbaya.ui.widgets.GridPanel;
import org.apache.airavata.xbaya.ui.widgets.XBayaLabel;
import org.apache.airavata.xbaya.ui.widgets.XBayaTextArea;
import org.apache.airavata.xbaya.ui.widgets.XBayaTextField;
-import org.xmlpull.infoset.XmlElement;
public class OutputConfigurationDialog {
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/ws/WSNodeWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/ws/WSNodeWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/ws/WSNodeWindow.java
index f5ce749..b23c84b 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/ws/WSNodeWindow.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/ws/WSNodeWindow.java
@@ -37,8 +37,6 @@ import org.apache.airavata.xbaya.ui.widgets.XBayaLabel;
import org.apache.airavata.xbaya.ui.widgets.XBayaTextArea;
import org.apache.airavata.xbaya.ui.widgets.XBayaTextField;
-import xsul5.wsdl.WsdlDefinitions;
-
public class WSNodeWindow {
private XBayaEngine engine;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowImportWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowImportWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowImportWindow.java
index 07d2f46..7feb932 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowImportWindow.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowImportWindow.java
@@ -41,8 +41,6 @@ import org.apache.airavata.common.utils.XMLUtil;
import org.apache.airavata.model.error.AiravataClientException;
import org.apache.airavata.model.error.AiravataSystemException;
import org.apache.airavata.model.error.InvalidRequestException;
-import org.apache.airavata.workflow.model.graph.ws.WSGraph;
-import org.apache.airavata.workflow.model.graph.ws.WSGraphFactory;
import org.apache.airavata.workflow.model.wf.Workflow;
import org.apache.airavata.xbaya.ThriftClientData;
import org.apache.airavata.xbaya.ThriftServiceType;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowPropertyWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowPropertyWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowPropertyWindow.java
index d4bd884..d94054b 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowPropertyWindow.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowPropertyWindow.java
@@ -22,7 +22,6 @@
package org.apache.airavata.xbaya.ui.dialogs.workflow;
import java.awt.event.ActionEvent;
-import java.net.URI;
import java.util.ArrayList;
import java.util.List;
@@ -31,9 +30,6 @@ import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonObject;
import org.apache.airavata.common.utils.JSONUtil;
import org.apache.airavata.common.utils.StringUtil;
import org.apache.airavata.common.utils.WSConstants;
@@ -46,7 +42,6 @@ import org.apache.airavata.xbaya.ui.widgets.GridPanel;
import org.apache.airavata.xbaya.ui.widgets.XBayaLabel;
import org.apache.airavata.xbaya.ui.widgets.XBayaTextArea;
import org.apache.airavata.xbaya.ui.widgets.XBayaTextField;
-import org.xmlpull.infoset.XmlElement;
public class WorkflowPropertyWindow {
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/RegistryWorkflowPublisherWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/RegistryWorkflowPublisherWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/RegistryWorkflowPublisherWindow.java
index 1b4c383..0e9c765 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/RegistryWorkflowPublisherWindow.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/RegistryWorkflowPublisherWindow.java
@@ -21,7 +21,6 @@
package org.apache.airavata.xbaya.ui.experiment;
-import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
@@ -35,11 +34,6 @@ import javax.swing.border.TitledBorder;
import org.apache.airavata.api.Airavata.Client;
import org.apache.airavata.api.client.AiravataClientFactory;
import org.apache.airavata.common.utils.XMLUtil;
-import org.apache.airavata.model.error.AiravataClientConnectException;
-import org.apache.airavata.model.error.AiravataClientException;
-import org.apache.airavata.model.error.AiravataSystemException;
-import org.apache.airavata.model.error.InvalidRequestException;
-import org.apache.airavata.workflow.catalog.WorkflowCatalogFactory;
import org.apache.airavata.workflow.model.wf.Workflow;
import org.apache.airavata.xbaya.ThriftClientData;
import org.apache.airavata.xbaya.ThriftServiceType;
@@ -50,7 +44,6 @@ import org.apache.airavata.xbaya.ui.widgets.GridPanel;
import org.apache.airavata.xbaya.ui.widgets.XBayaLabel;
import org.apache.airavata.xbaya.ui.widgets.XBayaTextArea;
import org.apache.airavata.xbaya.ui.widgets.XBayaTextField;
-import org.apache.thrift.TException;
public class RegistryWorkflowPublisherWindow {
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/WorkflowInterpreterLaunchWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/WorkflowInterpreterLaunchWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/WorkflowInterpreterLaunchWindow.java
index 5ae0c94..ed73d31 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/WorkflowInterpreterLaunchWindow.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/WorkflowInterpreterLaunchWindow.java
@@ -67,7 +67,6 @@ import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;
-import javax.xml.namespace.QName;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Collection;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/GraphCanvas.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/GraphCanvas.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/GraphCanvas.java
index 6e89cbe..24f03ed 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/GraphCanvas.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/GraphCanvas.java
@@ -56,7 +56,6 @@ import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.apache.airavata.common.utils.JSONUtil;
import org.apache.airavata.common.utils.SwingUtil;
@@ -92,7 +91,6 @@ import org.apache.airavata.xbaya.ui.utils.ErrorMessages;
import org.apache.airavata.xbaya.ui.widgets.component.ComponentSourceTransferable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.xmlpull.infoset.XmlElement;
/**
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/widgets/XBayaToolBar.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/widgets/XBayaToolBar.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/widgets/XBayaToolBar.java
index 9f18440..ac7f034 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/widgets/XBayaToolBar.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/widgets/XBayaToolBar.java
@@ -25,11 +25,9 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
@@ -47,8 +45,6 @@ import org.apache.airavata.workflow.model.wf.WorkflowExecutionState;
import org.apache.airavata.xbaya.XBayaEngine;
import org.apache.airavata.xbaya.ui.utils.ErrorMessages;
-import com.amazonaws.transform.MapEntry;
-
public class XBayaToolBar implements XBayaComponent {
private XBayaEngine engine;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/XBayaUtil.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/XBayaUtil.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/XBayaUtil.java
index c67a4c3..d004f18 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/XBayaUtil.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/XBayaUtil.java
@@ -23,41 +23,26 @@ package org.apache.airavata.xbaya.util;
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
-import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import org.apache.airavata.api.Airavata;
import org.apache.airavata.api.Airavata.Client;
import org.apache.airavata.api.client.AiravataClientFactory;
import org.apache.airavata.common.utils.StringUtil;
import org.apache.airavata.model.error.AiravataClientConnectException;
-import org.apache.airavata.workflow.model.exceptions.WorkflowException;
import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
import org.apache.airavata.workflow.model.graph.DataPort;
import org.apache.airavata.workflow.model.graph.Node;
-import org.apache.airavata.workflow.model.graph.amazon.InstanceNode;
-import org.apache.airavata.workflow.model.graph.system.ConstantNode;
import org.apache.airavata.workflow.model.graph.system.EndForEachNode;
-import org.apache.airavata.workflow.model.graph.system.EndifNode;
import org.apache.airavata.workflow.model.graph.system.ForEachNode;
-import org.apache.airavata.workflow.model.graph.system.InputNode;
-import org.apache.airavata.workflow.model.wf.Workflow;
import org.apache.airavata.xbaya.ThriftClientData;
import org.apache.airavata.xbaya.ThriftServiceType;
-import org.apache.airavata.xbaya.XBayaConfiguration;
import org.apache.airavata.xbaya.XBayaEngine;
import org.apache.airavata.xbaya.ui.dialogs.registry.RegistryWindow;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.xmlpull.infoset.XmlElement;
-
-import xsul.lead.LeadContextHeader;
-import xsul.lead.LeadResourceMapping;
-import xsul5.XmlConstants;
public class XBayaUtil {
[4/8] airavata git commit: moved commons-utils to commons module
Posted by sh...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java
deleted file mode 100644
index 9477cc9..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java
+++ /dev/null
@@ -1,677 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.logger;
-
-public interface AiravataLogger{
-
- /**
- * Return the name of this <code>Logger</code> instance.
- *
- * @return name of this logger instance
- */
- String getName();
-
- /**
- * Is the logger instance enabled for the TRACE level?
- *
- * @return True if this Logger is enabled for the TRACE level,
- * false otherwise.
- * @since 1.4
- */
- boolean isTraceEnabled();
-
- /**
- * Log a message at the TRACE level.
- *
- * @param msg the message string to be logged
- * @since 1.4
- */
- void trace(String msg);
-
- /**
- * Log a message at the TRACE level.
- *
- * @param etjId - Experiment , Task or Job Id
- * @param msg the message string to be logged
- * @since 1.4
- */
- void traceId(String etjId, String msg);
-
- /**
- * Log a message at the TRACE level according to the specified format
- * and argument.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the TRACE level. </p>
- *
- * @param format the format string
- * @param arg the argument
- * @since 1.4
- */
- void trace(String format, Object arg);
-
- /**
- * Log a message at the TRACE level according to the specified format
- * and argument.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the TRACE level. </p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arg the argument
- * @since 1.4
- */
- void traceId(String etjId, String format, Object arg);
-
- /**
- * Log a message at the TRACE level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the TRACE level. </p>
- *
- * @param format the format string
- * @param arg1 the first argument
- * @param arg2 the second argument
- * @since 1.4
- */
- void trace(String format, Object arg1, Object arg2);
-
- /**
- * Log a message at the TRACE level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the TRACE level. </p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arg1 the first argument
- * @param arg2 the second argument
- * @since 1.4
- */
- void traceId(String etjId, String format, Object arg1, Object arg2);
-
- /**
- * Log a message at the TRACE level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous string concatenation when the logger
- * is disabled for the TRACE level. However, this variant incurs the hidden
- * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
- * even if this logger is disabled for TRACE. The variants taking {@link #trace(String, Object) one} and
- * {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost.</p>
- *
- * @param format the format string
- * @param arguments a list of 3 or more arguments
- * @since 1.4
- */
- void trace(String format, Object... arguments);
-
- /**
- * Log a message at the TRACE level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous string concatenation when the logger
- * is disabled for the TRACE level. However, this variant incurs the hidden
- * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
- * even if this logger is disabled for TRACE. The variants taking {@link #trace(String, Object) one} and
- * {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost.</p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arguments a list of 3 or more arguments
- * @since 1.4
- */
- void traceId(String etjId, String format, Object... arguments);
-
- /**
- * Log an exception (throwable) at the TRACE level with an
- * accompanying message.
- *
- * @param msg the message accompanying the exception
- * @param t the exception (throwable) to log
- * @since 1.4
- */
- void trace(String msg, Throwable t);
-
- /**
- * Log an exception (throwable) at the TRACE level with an
- * accompanying message.
- *
- * @param etjId - Experiment , Task or Job Id
- * @param msg the message accompanying the exception
- * @param t the exception (throwable) to log
- * @since 1.4
- */
- void traceId(String etjId, String msg, Throwable t);
-
- /**
- * Is the logger instance enabled for the DEBUG level?
- *
- * @return True if this Logger is enabled for the DEBUG level,
- * false otherwise.
- */
- boolean isDebugEnabled();
-
- /**
- * Log a message at the DEBUG level.
- *
- * @param msg the message string to be logged
- */
- void debug(String msg);
-
- /**
- * Log a message at the DEBUG level.
- *
- * @param etjId - Experiment , Task or Job Id
- * @param msg the message string to be logged
- */
- void debugId(String etjId, String msg);
-
- /**
- * Log a message at the DEBUG level according to the specified format
- * and argument.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the DEBUG level. </p>
- *
- * @param format the format string
- * @param arg the argument
- */
- void debug(String format, Object arg);
-
- /**
- * Log a message at the DEBUG level according to the specified format
- * and argument.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the DEBUG level. </p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arg the argument
- */
- void debugId(String etjId, String format, Object arg);
-
- /**
- * Log a message at the DEBUG level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the DEBUG level. </p>
- *
- * @param format the format string
- * @param arg1 the first argument
- * @param arg2 the second argument
- */
- void debug(String format, Object arg1, Object arg2);
-
- /**
- * Log a message at the DEBUG level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the DEBUG level. </p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arg1 the first argument
- * @param arg2 the second argument
- */
- void debugId(String etjId, String format, Object arg1, Object arg2);
-
- /**
- * Log a message at the DEBUG level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous string concatenation when the logger
- * is disabled for the DEBUG level. However, this variant incurs the hidden
- * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
- * even if this logger is disabled for DEBUG. The variants taking
- * {@link #debug(String, Object) one} and {@link #debug(String, Object, Object) two}
- * arguments exist solely in order to avoid this hidden cost.</p>
- *
- * @param format the format string
- * @param arguments a list of 3 or more arguments
- */
- void debug(String format, Object... arguments);
-
- /**
- * Log a message at the DEBUG level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous string concatenation when the logger
- * is disabled for the DEBUG level. However, this variant incurs the hidden
- * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
- * even if this logger is disabled for DEBUG. The variants taking
- * {@link #debug(String, Object) one} and {@link #debug(String, Object, Object) two}
- * arguments exist solely in order to avoid this hidden cost.</p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arguments a list of 3 or more arguments
- */
- void debugId(String etjId, String format, Object... arguments);
-
- /**
- * Log an exception (throwable) at the DEBUG level with an
- * accompanying message.
- *
- * @param msg the message accompanying the exception
- * @param t the exception (throwable) to log
- */
- void debug(String msg, Throwable t);
-
- /**
- * Log an exception (throwable) at the DEBUG level with an
- * accompanying message.
- *
- * @param etjId - Experiment , Task or Job Id
- * @param msg the message accompanying the exception
- * @param t the exception (throwable) to log
- */
- void debugId(String etjId, String msg, Throwable t);
-
- /**
- * Is the logger instance enabled for the INFO level?
- *
- * @return True if this Logger is enabled for the INFO level,
- * false otherwise.
- */
- boolean isInfoEnabled();
-
- /**
- * Log a message at the INFO level.
- *
- * @param msg the message string to be logged
- */
- void info(String msg);
-
- /**
- * Log a message at the INFO level.
- *
- * @param etjId - Experiment , Task or Job Id
- * @param msg the message string to be logged
- */
- void infoId(String etjId, String msg);
-
- /**
- * Log a message at the INFO level according to the specified format
- * and argument.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the INFO level. </p>
- *
- * @param format the format string
- * @param arg the argument
- */
- void info(String format, Object arg);
-
- /**
- * Log a message at the INFO level according to the specified format
- * and argument.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the INFO level. </p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arg the argument
- */
- void infoId(String etjId, String format, Object arg);
-
- /**
- * Log a message at the INFO level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the INFO level. </p>
- *
- * @param format the format string
- * @param arg1 the first argument
- * @param arg2 the second argument
- */
- void info(String format, Object arg1, Object arg2);
-
- /**
- * Log a message at the INFO level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the INFO level. </p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arg1 the first argument
- * @param arg2 the second argument
- */
- void infoId(String etjId, String format, Object arg1, Object arg2);
-
- /**
- * Log a message at the INFO level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous string concatenation when the logger
- * is disabled for the INFO level. However, this variant incurs the hidden
- * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
- * even if this logger is disabled for INFO. The variants taking
- * {@link #info(String, Object) one} and {@link #info(String, Object, Object) two}
- * arguments exist solely in order to avoid this hidden cost.</p>
- *
- * @param format the format string
- * @param arguments a list of 3 or more arguments
- */
- void info(String format, Object... arguments);
-
- /**
- * Log a message at the INFO level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous string concatenation when the logger
- * is disabled for the INFO level. However, this variant incurs the hidden
- * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
- * even if this logger is disabled for INFO. The variants taking
- * {@link #info(String, Object) one} and {@link #info(String, Object, Object) two}
- * arguments exist solely in order to avoid this hidden cost.</p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arguments a list of 3 or more arguments
- */
- void infoId(String etjId, String format, Object... arguments);
-
- /**
- * Log an exception (throwable) at the INFO level with an
- * accompanying message.
- *
- * @param msg the message accompanying the exception
- * @param t the exception (throwable) to log
- */
- void info(String msg, Throwable t);
-
- /**
- * Log an exception (throwable) at the INFO level with an
- * accompanying message.
- *
- * @param etjId - Experiment , Task or Job Id
- * @param msg the message accompanying the exception
- * @param t the exception (throwable) to log
- */
- void infoId(String etjId, String msg, Throwable t);
-
- /**
- * Is the logger instance enabled for the WARN level?
- *
- * @return True if this Logger is enabled for the WARN level,
- * false otherwise.
- */
- boolean isWarnEnabled();
-
- /**
- * Log a message at the WARN level.
- *
- * @param msg the message string to be logged
- */
- void warn(String msg);
-
- /**
- * Log a message at the WARN level.
- *
- * @param etjId - Experiment , Task or Job Id
- * @param msg the message string to be logged
- */
- void warnId(String etjId, String msg);
-
- /**
- * Log a message at the WARN level according to the specified format
- * and argument.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the WARN level. </p>
- *
- * @param format the format string
- * @param arg the argument
- */
- void warn(String format, Object arg);
-
- /**
- * Log a message at the WARN level according to the specified format
- * and argument.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the WARN level. </p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arg the argument
- */
- void warnId(String etjId, String format, Object arg);
-
- /**
- * Log a message at the WARN level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous string concatenation when the logger
- * is disabled for the WARN level. However, this variant incurs the hidden
- * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
- * even if this logger is disabled for WARN. The variants taking
- * {@link #warn(String, Object) one} and {@link #warn(String, Object, Object) two}
- * arguments exist solely in order to avoid this hidden cost.</p>
- *
- * @param format the format string
- * @param arguments a list of 3 or more arguments
- */
- void warn(String format, Object... arguments);
-
- /**
- * Log a message at the WARN level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous string concatenation when the logger
- * is disabled for the WARN level. However, this variant incurs the hidden
- * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
- * even if this logger is disabled for WARN. The variants taking
- * {@link #warn(String, Object) one} and {@link #warn(String, Object, Object) two}
- * arguments exist solely in order to avoid this hidden cost.</p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arguments a list of 3 or more arguments
- */
- void warnId(String etjId, String format, Object... arguments);
-
- /**
- * Log a message at the WARN level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the WARN level. </p>
- *
- * @param format the format string
- * @param arg1 the first argument
- * @param arg2 the second argument
- */
- void warn(String format, Object arg1, Object arg2);
-
- /**
- * Log a message at the WARN level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the WARN level. </p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arg1 the first argument
- * @param arg2 the second argument
- */
- void warnId(String etjId, String format, Object arg1, Object arg2);
-
- /**
- * Log an exception (throwable) at the WARN level with an
- * accompanying message.
- *
- * @param msg the message accompanying the exception
- * @param t the exception (throwable) to log
- */
- void warn(String msg, Throwable t);
-
- /**
- * Log an exception (throwable) at the WARN level with an
- * accompanying message.
- *
- * @param etjId - Experiment , Task or Job Id
- * @param msg the message accompanying the exception
- * @param t the exception (throwable) to log
- */
- void warnId(String etjId, String msg, Throwable t);
-
- /**
- * Is the logger instance enabled for the ERROR level?
- *
- * @return True if this Logger is enabled for the ERROR level,
- * false otherwise.
- */
- boolean isErrorEnabled();
-
- /**
- * Log a message at the ERROR level.
- *
- * @param msg the message string to be logged
- */
- void error(String msg);
-
- /**
- * Log a message at the ERROR level.
- *
- * @param etjId - Experiment , Task or Job Id
- * @param msg the message string to be logged
- */
- void errorId(String etjId, String msg);
-
- /**
- * Log a message at the ERROR level according to the specified format
- * and argument.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the ERROR level. </p>
- *
- * @param format the format string
- * @param arg the argument
- */
- void error(String format, Object arg);
-
- /**
- * Log a message at the ERROR level according to the specified format
- * and argument.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the ERROR level. </p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arg the argument
- */
- void errorId(String etjId, String format, Object arg);
-
- /**
- * Log a message at the ERROR level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the ERROR level. </p>
- *
- * @param format the format string
- * @param arg1 the first argument
- * @param arg2 the second argument
- */
- void error(String format, Object arg1, Object arg2);
-
- /**
- * Log a message at the ERROR level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous object creation when the logger
- * is disabled for the ERROR level. </p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arg1 the first argument
- * @param arg2 the second argument
- */
- void errorId(String etjId, String format, Object arg1, Object arg2);
-
- /**
- * Log a message at the ERROR level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous string concatenation when the logger
- * is disabled for the ERROR level. However, this variant incurs the hidden
- * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
- * even if this logger is disabled for ERROR. The variants taking
- * {@link #error(String, Object) one} and {@link #error(String, Object, Object) two}
- * arguments exist solely in order to avoid this hidden cost.</p>
- *
- * @param format the format string
- * @param arguments a list of 3 or more arguments
- */
- void error(String format, Object... arguments);
-
- /**
- * Log a message at the ERROR level according to the specified format
- * and arguments.
- * <p/>
- * <p>This form avoids superfluous string concatenation when the logger
- * is disabled for the ERROR level. However, this variant incurs the hidden
- * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
- * even if this logger is disabled for ERROR. The variants taking
- * {@link #error(String, Object) one} and {@link #error(String, Object, Object) two}
- * arguments exist solely in order to avoid this hidden cost.</p>
- *
- * @param etjId - Experiment , Task or Job Id
- * @param format the format string
- * @param arguments a list of 3 or more arguments
- */
- void errorId(String etjId, String format, Object... arguments);
-
- /**
- * Log an exception (throwable) at the ERROR level with an
- * accompanying message.
- *
- * @param msg the message accompanying the exception
- * @param t the exception (throwable) to log
- */
- void error(String msg, Throwable t);
-
- /**
- * Log an exception (throwable) at the ERROR level with an
- * accompanying message.
- *
- * @param etjId - Experiment , Task or Job Id
- * @param msg the message accompanying the exception
- * @param t the exception (throwable) to log
- */
- void errorId(String etjId, String msg, Throwable t);
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java
deleted file mode 100644
index a1a9462..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.logger;
-
-public class AiravataLoggerFactory {
-
- public static AiravataLogger getLogger(Class aClass) {
- return new AiravataLoggerImpl(aClass);
- }
-
- public static AiravataLogger getLogger(String className) {
- return new AiravataLoggerImpl(className);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java
deleted file mode 100644
index 74ab401..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.logger;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AiravataLoggerImpl implements AiravataLogger{
-
- private Logger logger;
-
- public AiravataLoggerImpl(Class aClass) {
- logger = LoggerFactory.getLogger(aClass);
- }
-
- public AiravataLoggerImpl(String className) {
- logger = LoggerFactory.getLogger(className);
- }
-
-
- @Override
- public String getName() {
- return logger.getName();
- }
-
- @Override
- public boolean isTraceEnabled() {
- return logger.isTraceEnabled();
- }
-
- @Override
- public void trace(String msg) {
- logger.trace(msg);
- }
-
- @Override
- public void traceId(String etjId, String msg) {
- logger.trace(getAiravataLogMessage(etjId, msg));
- }
-
- @Override
- public void trace(String format, Object arg) {
- logger.trace(format, arg);
- }
-
- @Override
- public void traceId(String etjId, String format, Object arg) {
- logger.trace(getAiravataLogMessage(etjId, format), arg);
- }
-
- @Override
- public void trace(String format, Object arg1, Object arg2) {
- logger.trace(format, arg1, arg2);
- }
-
- @Override
- public void traceId(String etjId, String format, Object arg1, Object arg2) {
- logger.trace(getAiravataLogMessage(etjId,format), arg1, arg2);
- }
-
- @Override
- public void trace(String format, Object... arguments) {
- logger.trace(format, arguments);
- }
-
- @Override
- public void traceId(String etjId, String format, Object... arguments) {
- logger.trace(getAiravataLogMessage(etjId, format), arguments);
- }
-
- @Override
- public void trace(String msg, Throwable t) {
- logger.trace(msg, t);
- }
-
- @Override
- public void traceId(String etjId, String msg, Throwable t) {
- logger.trace(getAiravataLogMessage(etjId, msg), t);
- }
-
- @Override
- public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
- }
-
- @Override
- public void debug(String msg) {
- logger.debug(msg);
- }
-
- @Override
- public void debugId(String etjId, String msg) {
- logger.debug(getAiravataLogMessage(etjId, msg));
- }
-
- @Override
- public void debug(String format, Object arg) {
- logger.debug(format, arg);
- }
-
- @Override
- public void debugId(String etjId, String format, Object arg) {
- logger.debug(getAiravataLogMessage(etjId, format), arg);
- }
-
- @Override
- public void debug(String format, Object arg1, Object arg2) {
- logger.debug(format, arg1, arg2);
- }
-
- @Override
- public void debugId(String etjId, String format, Object arg1, Object arg2) {
- logger.debug(getAiravataLogMessage(etjId, format), arg1, arg2);
- }
-
- @Override
- public void debug(String format, Object... arguments) {
- logger.debug(format, arguments);
- }
-
- @Override
- public void debugId(String etjId, String format, Object... arguments) {
- logger.debug(getAiravataLogMessage(etjId, format), arguments);
- }
-
- @Override
- public void debug(String msg, Throwable t) {
- logger.debug(msg, t);
- }
-
- @Override
- public void debugId(String etjId, String msg, Throwable t) {
- logger.debug(getAiravataLogMessage(etjId, msg), t);
- }
-
- @Override
- public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
- }
-
- @Override
- public void info(String msg) {
- logger.info(msg);
- }
-
- @Override
- public void infoId(String etjId, String msg) {
- logger.info(getAiravataLogMessage(etjId, msg));
- }
-
- @Override
- public void info(String format, Object arg) {
- logger.info(format, arg);
- }
-
- @Override
- public void infoId(String etjId, String format, Object arg) {
- logger.info(getAiravataLogMessage(etjId, format), arg);
- }
-
- @Override
- public void info(String format, Object arg1, Object arg2) {
- logger.info(format, arg1, arg2);
- }
-
- @Override
- public void infoId(String etjId, String format, Object arg1, Object arg2) {
- logger.info(getAiravataLogMessage(etjId, format), arg1, arg2);
- }
-
- @Override
- public void info(String format, Object... arguments) {
- logger.info(format, arguments);
- }
-
- @Override
- public void infoId(String etjId, String format, Object... arguments) {
- logger.info(getAiravataLogMessage(etjId, format), arguments);
- }
-
- @Override
- public void info(String msg, Throwable t) {
- logger.info(msg, t);
- }
-
- @Override
- public void infoId(String etjId, String msg, Throwable t) {
- logger.info(getAiravataLogMessage(etjId, msg), t);
- }
-
- @Override
- public boolean isWarnEnabled() {
- return logger.isWarnEnabled();
- }
-
- @Override
- public void warn(String msg) {
- logger.warn(msg);
- }
-
- @Override
- public void warnId(String etjId, String msg) {
- logger.warn(getAiravataLogMessage(etjId, msg));
- }
-
- @Override
- public void warn(String format, Object arg) {
- logger.warn(format, arg);
- }
-
- @Override
- public void warnId(String etjId, String format, Object arg) {
- logger.warn(getAiravataLogMessage(etjId, format), arg);
- }
-
- @Override
- public void warn(String format, Object... arguments) {
- logger.warn(format, arguments);
- }
-
- @Override
- public void warnId(String etjId, String format, Object... arguments) {
- logger.warn(getAiravataLogMessage(etjId, format), arguments);
- }
-
- @Override
- public void warn(String format, Object arg1, Object arg2) {
- logger.warn(format, arg1, arg2);
- }
-
- @Override
- public void warnId(String etjId, String format, Object arg1, Object arg2) {
- logger.warn(getAiravataLogMessage(etjId, format), arg1, arg2);
- }
-
- @Override
- public void warn(String msg, Throwable t) {
- logger.warn(msg, t);
- }
-
- @Override
- public void warnId(String etjId, String msg, Throwable t) {
- logger.warn(getAiravataLogMessage(etjId, msg), t);
- }
-
- @Override
- public boolean isErrorEnabled() {
- return logger.isErrorEnabled();
- }
-
- @Override
- public void error(String msg) {
- logger.error(msg);
- }
-
- @Override
- public void errorId(String etjId, String msg) {
- logger.error(getAiravataLogMessage(etjId, msg));
- }
-
- @Override
- public void error(String format, Object arg) {
- logger.error(format, arg);
- }
-
- @Override
- public void errorId(String etjId, String format, Object arg) {
- logger.error(getAiravataLogMessage(etjId, format), arg);
- }
-
- @Override
- public void error(String format, Object arg1, Object arg2) {
- logger.error(format, arg1, arg2);
- }
-
- @Override
- public void errorId(String etjId, String format, Object arg1, Object arg2) {
- logger.error(getAiravataLogMessage(etjId, format), arg1, arg2);
- }
-
- @Override
- public void error(String format, Object... arguments) {
- logger.error(format, arguments);
- }
-
- @Override
- public void errorId(String etjId, String format, Object... arguments) {
- logger.error(getAiravataLogMessage(etjId, format), arguments);
- }
-
- @Override
- public void error(String msg, Throwable t) {
- logger.error(msg, t);
- }
-
- @Override
- public void errorId(String etjId, String msg, Throwable t) {
- logger.error(getAiravataLogMessage(etjId, msg), t);
- }
-
- private String getAiravataLogMessage(String etjId, String msg) {
- return new StringBuilder("Id:").append(etjId).append(" : ").append(msg).toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java
deleted file mode 100644
index 83e4218..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.common.utils;
-
-/*
-These are the job statuses shared in database level between orchestrator and
-gfac instances
- */
-public class AiravataJobState {
-
- private State jobState;
-
- public State getJobState() {
- return jobState;
- }
-
- public void setJobState(State jobState) {
- this.jobState = jobState;
- }
-
-
- public enum State {
- CREATED {
- public String toString() {
- return "CREATED";
- }
- },
- ACCEPTED {
- public String toString() {
- return "ACCEPTED";
- }
- },
- FETCHED {
- public String toString() {
- return "FETCHED";
- }
- },
- INHANDLERSDONE {
- public String toString() {
- return "INHANDLERSDONE";
- }
- },
- SUBMITTED {
- public String toString() {
- return "SUBMITTED";
- }
- },
- OUTHANDLERSDONE {
- public String toString() {
- return "OUTHANDLERSDONE";
- }
- },
- RUNNING {
- public String toString() {
- return "RUNNING";
- }
- },
- FAILED {
- public String toString() {
- return "FAILED";
- }
- },
- PAUSED {
- public String toString() {
- return "PAUSED";
- }
- },
- PENDING {
- public String toString() {
- return "PENDING";
- }
- },
- ACTIVE {
- public String toString() {
- return "ACTIVE";
- }
- },
- DONE {
- public String toString() {
- return "DONE";
- }
- },
- CANCELLED {
- public String toString() {
- return "CANCELLED";
- }
- },
- UNKNOWN {
- public String toString() {
- return "UNKNOWN";
- }
- },
- HANGED {
- public String toString() {
- return "HANGED";
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java
deleted file mode 100644
index 52d114f..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.UUID;
-
-public class AiravataUtils {
-
- public static Timestamp getCurrentTimestamp() {
- Calendar calender = Calendar.getInstance();
- java.util.Date d = calender.getTime();
- return new Timestamp(d.getTime());
- }
-
- public static Timestamp getTime(long time) {
- if (time == 0 || time < 0){
- return getCurrentTimestamp();
- }
- return new Timestamp(time);
- }
-
- public static String getId (String name){
- String id = name.replaceAll("\\s", "");
- return id + "_" + UUID.randomUUID();
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java
deleted file mode 100644
index f753bc1..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.common.utils;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.server.ServerCnxnFactory;
-import org.apache.zookeeper.server.ServerConfig;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
-import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.nio.ByteBuffer;
-
-public class AiravataZKUtils implements Watcher {
- private final static Logger logger = LoggerFactory.getLogger(AiravataZKUtils.class);
-
- public static final String ZK_EXPERIMENT_STATE_NODE = "state";
- public static final String DELIVERY_TAG_POSTFIX = "-deliveryTag";
- public static final String CANCEL_DELIVERY_TAG_POSTFIX = "-cancel-deliveryTag";
-
- @Override
- public void process(WatchedEvent event) {
-
- }
-
- public static String getExpZnodePath(String experimentId) throws ApplicationSettingsException {
- return ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE) +
- File.separator +
- ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NAME) + File.separator
- + experimentId;
- }
-
- public static String getExpZnodeHandlerPath(String experimentId, String className) throws ApplicationSettingsException {
- return ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE) +
- File.separator +
- ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NAME) + File.separator
- + experimentId + File.separator + className;
- }
-
- public static String getZKhostPort() throws ApplicationSettingsException {
- return ServerSettings.getSetting(Constants.ZOOKEEPER_SERVER_HOST,"localhost")
- + ":" + ServerSettings.getSetting(Constants.ZOOKEEPER_SERVER_PORT,"2181");
- }
-
- public static int getZKTimeout()throws ApplicationSettingsException {
- return Integer.parseInt(ServerSettings.getSetting(Constants.ZOOKEEPER_TIMEOUT,"30000"));
- }
-
- public static String getExpStatePath(String experimentId) throws ApplicationSettingsException {
- return AiravataZKUtils.getExpZnodePath(experimentId) +
- File.separator +
- "state";
- }
-
- public static String getExpState(CuratorFramework curatorClient, String expId) throws Exception {
- Stat exists = curatorClient.checkExists().forPath(getExpStatePath(expId));
- if (exists != null) {
- return new String(curatorClient.getData().storingStatIn(exists).forPath(getExpStatePath(expId)));
- }
- return null;
- }
-
- public static void runZKFromConfig(ServerConfig config,ServerCnxnFactory cnxnFactory) throws IOException {
- AiravataZKUtils.logger.info("Starting Zookeeper server...");
- FileTxnSnapLog txnLog = null;
- try {
- // Note that this thread isn't going to be doing anything else,
- // so rather than spawning another thread, we will just call
- // run() in this thread.
- // create a file logger url from the command line args
- ZooKeeperServer zkServer = new ZooKeeperServer();
-
- txnLog = new FileTxnSnapLog(new File(config.getDataDir()), new File(
- config.getDataDir()));
- zkServer.setTxnLogFactory(txnLog);
- zkServer.setTickTime(config.getTickTime());
- zkServer.setMinSessionTimeout(config.getMinSessionTimeout());
- zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
- cnxnFactory = ServerCnxnFactory.createFactory();
- cnxnFactory.configure(config.getClientPortAddress(),
- config.getMaxClientCnxns());
- cnxnFactory.startup(zkServer);
- cnxnFactory.join();
- if (zkServer.isRunning()) {
- zkServer.shutdown();
- }
- } catch (InterruptedException e) {
- // warn, but generally this is ok
- AiravataZKUtils.logger.warn("Server interrupted", e);
- System.exit(1);
- } finally {
- if (txnLog != null) {
- txnLog.close();
- }
- }
- }
-
- public static void startEmbeddedZK(ServerCnxnFactory cnxnFactory) {
- if (ServerSettings.isEmbeddedZK()) {
- ServerConfig serverConfig = new ServerConfig();
- URL resource = AiravataZKUtils.class.getClassLoader().getResource("zoo.cfg");
- if (resource == null) {
- logger.error("There is no zoo.cfg file in the classpath... Failed to start Zookeeper Server");
- System.exit(1);
- }
- try {
- serverConfig.parse(resource.getPath());
- } catch (QuorumPeerConfig.ConfigException e) {
- logger.error("Error while starting embedded Zookeeper", e);
- System.exit(2);
- }
-
- final ServerConfig fServerConfig = serverConfig;
- final ServerCnxnFactory fserverCnxnFactory = cnxnFactory;
- (new Thread() {
- public void run() {
- try {
- AiravataZKUtils.runZKFromConfig(fServerConfig,fserverCnxnFactory);
- } catch (IOException e) {
- logger.error("Error while starting embedded Zookeeper", e);
- System.exit(3);
- }
- }
- }).start();
- }else{
- logger.info("Skipping Zookeeper embedded startup ...");
- }
- }
-
- public static byte[] toByteArray(double value) {
- byte[] bytes = new byte[8];
- ByteBuffer.wrap(bytes).putDouble(value);
- return bytes;
- }
-
- public static long getDeliveryTag(String experimentID, CuratorFramework curatorClient, String experimentNode,
- String pickedChild) throws Exception {
- String deliveryTagPath = experimentNode + File.separator + pickedChild + File.separator + experimentID
- + DELIVERY_TAG_POSTFIX;
- Stat exists = curatorClient.checkExists().forPath(deliveryTagPath);
- if(exists==null) {
- logger.error("Cannot find delivery Tag in path:" + deliveryTagPath + " for this experiment");
- return -1;
- }
- return bytesToLong(curatorClient.getData().storingStatIn(exists).forPath(deliveryTagPath));
- }
- public static byte[] longToBytes(long x) {
- ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);
- buffer.putLong(x);
- return buffer.array();
- }
-
- public static long bytesToLong(byte[] bytes) {
- ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);
- buffer.put(bytes);
- buffer.flip();//need flip
- return buffer.getLong();
- }
-
- public static double toDouble(byte[] bytes) {
- return ByteBuffer.wrap(bytes).getDouble();
- }
-
- public static long getCancelDeliveryTagIfExist(String experimentId, CuratorFramework curatorClient,
- String experimentNode, String pickedChild) throws Exception {
-
- String cancelDeliveryTagPath = experimentNode + File.separator + pickedChild + File.separator + experimentId +
- AiravataZKUtils.CANCEL_DELIVERY_TAG_POSTFIX;
- Stat exists = curatorClient.checkExists().forPath(cancelDeliveryTagPath);
- if (exists == null) {
- return -1; // no cancel deliverytag found
- } else {
- return bytesToLong(curatorClient.getData().storingStatIn(exists).forPath(cancelDeliveryTagPath));
- }
-
-
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
deleted file mode 100644
index 9a59573..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.exception.ApplicationSettingsLoadException;
-import org.apache.airavata.common.exception.ApplicationSettingsStoreException;
-import org.apache.airavata.common.exception.UnspecifiedApplicationSettingsException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ApplicationSettings {
- public static final String SERVER_PROPERTIES="airavata-server.properties";
-
- public static String ADDITIONAL_SETTINGS_FILES = "external.settings";
-
- protected Properties properties = new Properties();
- private Exception propertyLoadException;
-
-
- protected static final String TRUST_STORE_PATH="trust.store";
- protected static final String TRUST_STORE_PASSWORD="trust.store.password";
-
- private static final String REGULAR_EXPRESSION = "\\$\\{[a-zA-Z.-]*\\}";
-
- private final static Logger logger = LoggerFactory.getLogger(ApplicationSettings.class);
-
- private static final String SHUTDOWN_STATEGY_STRING="shutdown.strategy";
-
- protected static ApplicationSettings INSTANCE;
- public static enum ShutdownStrategy{
- NONE,
- SELF_TERMINATE
- }
- {
- loadProperties();
- }
-
- private void loadProperties() {
- URL url = getPropertyFileURL();
- try {
-
- properties.load(url.openStream());
- logger.info("Settings loaded from "+url.toString());
- URL[] externalSettingsFileURLs = getExternalSettingsFileURLs();
- for (URL externalSettings : externalSettingsFileURLs) {
- mergeSettingsImpl(externalSettings.openStream());
- logger.info("External settings merged from "+url.toString());
- }
- } catch (Exception e) {
- propertyLoadException=e;
- }
- }
-
- protected URL getPropertyFileURL() {
- return ApplicationSettings.class.getClassLoader().getResource(SERVER_PROPERTIES);
- }
-
- protected URL[] getExternalSettingsFileURLs(){
- try {
- List<URL> externalSettingsFileURLs=new ArrayList<URL>();
- String externalSettingsFileNames = getSettingImpl(ADDITIONAL_SETTINGS_FILES);
- String[] externalSettingFiles = externalSettingsFileNames.split(",");
- for (String externalSettingFile : externalSettingFiles) {
- URL externalSettingFileURL = ApplicationSettings.class.getClassLoader().getResource(externalSettingFile);
- if (externalSettingFileURL==null){
- logger.warn("Could not file external settings file "+externalSettingFile);
- }else{
- externalSettingsFileURLs.add(externalSettingFileURL);
- }
- }
- return externalSettingsFileURLs.toArray(new URL[]{});
- } catch (ApplicationSettingsException e) {
- return new URL[]{};
- }
- }
- protected static ApplicationSettings getInstance(){
- if (INSTANCE==null){
- INSTANCE=new ApplicationSettings();
- }
- return INSTANCE;
- }
-
- protected static void setInstance(ApplicationSettings settingsInstance){
- INSTANCE=settingsInstance;
- }
-
- private void saveProperties() throws ApplicationSettingsStoreException{
- URL url = getPropertyFileURL();
- if (url.getProtocol().equalsIgnoreCase("file")){
- try {
- properties.store(new FileOutputStream(url.getPath()), Calendar.getInstance().toString());
- } catch (Exception e) {
- throw new ApplicationSettingsStoreException(url.getPath(), e);
- }
- }else{
- logger.warn("Properties cannot be updated to location "+url.toString());
- }
- }
-
- private void validateSuccessfulPropertyFileLoad() throws ApplicationSettingsException{
- if (propertyLoadException!=null){
- throw new ApplicationSettingsLoadException(propertyLoadException);
- }
- }
-
- /**
- * Returns the configuration value relevant for the given key.
- * If configuration value contains references to other configuration values they will also
- * be replaced. E.g :- If configuration key reads http://${ip}:${port}/axis2/services/RegistryService?wsdl,
- * the variables ip and port will get replaced by their appropriated values in the configuration.
- * @param key The configuration key to read value of
- * @return The configuration value. For above example caller will get a value like
- * http://192.2.33.12:8080/axis2/services/RegistryService?wsdl
- * @throws ApplicationSettingsException If an error occurred while reading configurations.
- * @deprecated use #getSetting(String) instead
- */
- public String getAbsoluteSetting(String key) throws ApplicationSettingsException {
-
- String configurationValueWithVariables = ApplicationSettings.getSetting(key);
-
- List<String> variableList
- = getAllMatches(configurationValueWithVariables, REGULAR_EXPRESSION);
-
- if (variableList == null || variableList.isEmpty()) {
- return configurationValueWithVariables;
- }
-
- for(String variableIdentifier : variableList) {
- String variableName = getVariableNameOnly(variableIdentifier);
- String value = getAbsoluteSetting(variableName);
-
- configurationValueWithVariables = configurationValueWithVariables.replace(variableIdentifier, value);
- }
-
- return configurationValueWithVariables;
-
- }
-
- private static String getVariableNameOnly(String variableWithIdentifiers) {
- return variableWithIdentifiers.substring(2, (variableWithIdentifiers.length() - 1));
- }
-
- private static List<String> getAllMatches(String text, String regex) {
- List<String> matches = new ArrayList<String>();
- Matcher m = Pattern.compile("(?=(" + regex + "))").matcher(text);
- while(m.find()) {
- matches.add(m.group(1));
- }
- return matches;
- }
-
- public String getSettingImpl(String key) throws ApplicationSettingsException{
- String rawValue=null;
- if (System.getProperties().containsKey(key)){
- rawValue=System.getProperties().getProperty(key);
- }else{
- validateSuccessfulPropertyFileLoad();
- if (properties.containsKey(key)){
- rawValue=properties.getProperty(key);
- }else{
- throw new UnspecifiedApplicationSettingsException(key);
- }
- }
- return deriveAbsoluteValueImpl(rawValue);
- }
-
- public String getSettingImpl(String key, String defaultValue){
- try {
- return getSettingImpl(key);
- } catch (ApplicationSettingsException e) {
- //we'll ignore this error since a default value is provided
- }
- return defaultValue;
- }
-
- private String deriveAbsoluteValueImpl(String property){
- if (property!=null){
- Map<Integer, String> containedParameters = StringUtil.getContainedParameters(property);
- List<String> parametersAlreadyProcessed=new ArrayList<String>();
- for (String parameter : containedParameters.values()) {
- if (!parametersAlreadyProcessed.contains(parameter)) {
- String parameterName = parameter.substring(2,parameter.length() - 1);
- String parameterValue = getSetting(parameterName,parameter);
- property = property.replaceAll(Pattern.quote(parameter), parameterValue);
- parametersAlreadyProcessed.add(parameter);
- }
- }
- }
- return property;
- }
-
- public void setSettingImpl(String key, String value) throws ApplicationSettingsException{
- properties.setProperty(key, value);
- saveProperties();
- }
-
- public boolean isSettingDefinedImpl(String key) throws ApplicationSettingsException{
- validateSuccessfulPropertyFileLoad();
- return properties.containsKey(key);
- }
-
- public String getTrustStorePathImpl() throws ApplicationSettingsException {
- return getSetting(TRUST_STORE_PATH);
- }
-
- public String getTrustStorePasswordImpl() throws ApplicationSettingsException {
- return getSetting(TRUST_STORE_PASSWORD);
- }
-
- public String getCredentialStoreKeyStorePathImpl() throws ApplicationSettingsException {
- return getSetting("credential.store.keystore.url");
- }
-
- public String getCredentialStoreKeyAliasImpl() throws ApplicationSettingsException {
- return getSetting("credential.store.keystore.alias");
- }
-
- public String getCredentialStoreKeyStorePasswordImpl() throws ApplicationSettingsException {
- return getSetting("credential.store.keystore.password");
- }
-
- public String getCredentialStoreNotifierEnabledImpl() throws ApplicationSettingsException {
- return getSetting("notifier.enabled");
- }
-
- public String getCredentialStoreNotifierDurationImpl() throws ApplicationSettingsException {
- return getSetting("notifier.duration");
- }
-
- public String getCredentialStoreEmailServerImpl() throws ApplicationSettingsException {
- return getSetting("email.server");
- }
-
- public String getCredentialStoreEmailServerPortImpl() throws ApplicationSettingsException {
- return getSetting("email.server.port");
- }
-
- public String getCredentialStoreEmailUserImpl() throws ApplicationSettingsException {
- return getSetting("email.user");
- }
-
- public String getCredentialStoreEmailPasswordImpl() throws ApplicationSettingsException {
- return getSetting("email.password");
- }
-
- public String getCredentialStoreEmailSSLConnectImpl() throws ApplicationSettingsException {
- return getSetting("email.ssl");
- }
-
- public String getCredentialStoreEmailFromEmailImpl() throws ApplicationSettingsException {
- return getSetting("email.from");
- }
-
- /**
- * @deprecated use {{@link #getSetting(String)}}
- * @return
- */
- public Properties getPropertiesImpl() {
- return properties;
- }
-
- public void mergeSettingsImpl(Map<String,String> props){
- properties.putAll(props);
- }
-
- public void mergeSettingsImpl(InputStream stream) throws IOException{
- Properties tmpProp = new Properties();
- tmpProp.load(stream);
- properties.putAll(tmpProp);
- }
-
- public void mergeSettingsCommandLineArgsImpl(String[] args){
- properties.putAll(StringUtil.parseCommandLineOptions(args));
- }
-
- public ShutdownStrategy getShutdownStrategyImpl() throws Exception{
- String strategy = null;
- try {
- strategy = getSetting(SHUTDOWN_STATEGY_STRING, ShutdownStrategy.SELF_TERMINATE.toString());
- return ShutdownStrategy.valueOf(strategy);
- } catch (Exception e) {
- //if the string mentioned in config is invalid
- throw new Exception("Invalid shutdown strategy configured : "+strategy);
- }
- }
-
- /*
- * Static methods which will be used by the users
- */
-
- public static String getSetting(String key) throws ApplicationSettingsException{
- return getInstance().getSettingImpl(key);
- }
-
- public static String getSetting(String key, String defaultValue){
- return getInstance().getSettingImpl(key,defaultValue);
-
- }
-
- public static void setSetting(String key, String value) throws ApplicationSettingsException{
- getInstance().properties.setProperty(key, value);
- getInstance().saveProperties();
- }
-
- public static boolean isSettingDefined(String key) throws ApplicationSettingsException{
- return getInstance().properties.containsKey(key);
- }
-
- public static String getTrustStorePath() throws ApplicationSettingsException {
- return getSetting(TRUST_STORE_PATH);
- }
-
- public static String getTrustStorePassword() throws ApplicationSettingsException {
- return getSetting(TRUST_STORE_PASSWORD);
- }
-
- public static void initializeTrustStore() throws ApplicationSettingsException {
- SecurityUtil.setTrustStoreParameters(getTrustStorePath(), getTrustStorePassword());
- }
-
- public static String getCredentialStoreKeyStorePath() throws ApplicationSettingsException {
- return getSetting("credential.store.keystore.url");
- }
-
- public static String getCredentialStoreThriftServerKeyStorePath() throws ApplicationSettingsException {
- return getSetting("credential.store.thrift.server.keystore");
- }
-
- public static boolean isCredentialStoreStartEnabled() throws ApplicationSettingsException {
- String enableCredentialStore = getSetting("start.credential.store");
- if (enableCredentialStore.equals("true")){
- return true;
- }
- return false;
- }
-
- public static String getCredentialStoreKeyAlias() throws ApplicationSettingsException {
- return getSetting("credential.store.keystore.alias");
- }
-
- public static String getCredentialStoreKeyStorePassword() throws ApplicationSettingsException {
- return getSetting("credential.store.keystore.password");
- }
-
- public static String getCredentialStoreThriftServerKeyStorePassword() throws ApplicationSettingsException {
- return getSetting("credential.store.thrift.server.keystore.password");
- }
-
- public static String getCredentialStoreServerHost() throws ApplicationSettingsException {
- return getSetting("credential.store.server.host");
- }
-
- public static String getCredentialStoreServerPort() throws ApplicationSettingsException {
- return getSetting("credential.store.server.port");
- }
- public static String getCredentialStoreNotifierEnabled() throws ApplicationSettingsException {
- return getSetting("notifier.enabled");
- }
-
- public static String getCredentialStoreNotifierDuration() throws ApplicationSettingsException {
- return getSetting("notifier.duration");
- }
-
- public static String getCredentialStoreEmailServer() throws ApplicationSettingsException {
- return getSetting("email.server");
- }
-
- public static String getCredentialStoreEmailServerPort() throws ApplicationSettingsException {
- return getSetting("email.server.port");
- }
-
- public static String getCredentialStoreEmailUser() throws ApplicationSettingsException {
- return getSetting("email.user");
- }
-
- public static String getCredentialStoreEmailPassword() throws ApplicationSettingsException {
- return getSetting("email.password");
- }
-
- public static String getCredentialStoreEmailSSLConnect() throws ApplicationSettingsException {
- return getSetting("email.ssl");
- }
-
- public static String getCredentialStoreEmailFromEmail() throws ApplicationSettingsException {
- return getSetting("email.from");
- }
-
- /**
- * @deprecated use {{@link #getSetting(String)}}
- * @return
- * @throws ApplicationSettingsException
- */
- public static Properties getProperties() throws ApplicationSettingsException {
- return getInstance().properties;
- }
-
- public static void mergeSettings(Map<String,String> props) {
- getInstance().mergeSettingsImpl(props);
- }
-
- public static void mergeSettings(InputStream stream) throws IOException{
- getInstance().mergeSettingsImpl(stream);
- }
-
- public static void mergeSettingsCommandLineArgs(String[] args){
- getInstance().mergeSettingsCommandLineArgsImpl(args);
- }
-
- public static ShutdownStrategy getShutdownStrategy() throws Exception{
- return getInstance().getShutdownStrategyImpl();
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/BrowserLauncher.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/BrowserLauncher.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/BrowserLauncher.java
deleted file mode 100644
index 8946aa3..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/BrowserLauncher.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-
-import org.apache.airavata.common.exception.UtilsException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Opens URLs with the OS-specific browser.
- */
-public class BrowserLauncher {
-
- private static final String ERROR_MESSAGE = "Error while attempting to launch web browser";
-
- private static Logger logger = LoggerFactory.getLogger(BrowserLauncher.class);
-
- /**
- * Opens a specified URL with the browser.
- *
- * @param url
- * The specified URL.
- * @throws UtilsException
- */
- public static void openURL(URL url) throws UtilsException {
- openURL(url.toString());
- }
-
- /**
- * Opens a specified URL with the browser.
- *
- * @param url
- * The specified URL.
- * @throws UtilsException
- */
- public static void openURL(String url) throws UtilsException {
- logger.debug("Enter:" + url);
- String osName = System.getProperty("os.name");
- try {
- if (osName.startsWith("Mac OS")) {
- Class macUtils = Class.forName("com.apple.mrj.MRJFileUtils");
- Method openURL = macUtils.getDeclaredMethod("openURL", new Class[] { String.class });
- openURL.invoke(null, new Object[] { url });
- } else if (osName.startsWith("Windows"))
- Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
- else { // assume Unix or Linux
- String[] browsers = { "firefox", "mozilla", "netscape", "opera", "konqueror" };
- String browser = null;
- for (int count = 0; count < browsers.length && browser == null; count++)
- if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0)
- browser = browsers[count];
- if (browser == null) {
- throw new UtilsException("Could not find web browser.");
- } else {
- Runtime.getRuntime().exec(new String[] { browser, url });
- }
- }
- } catch (ClassNotFoundException e) {
- throw new UtilsException(ERROR_MESSAGE, e);
- } catch (NoSuchMethodException e) {
- throw new UtilsException(ERROR_MESSAGE, e);
- } catch (IllegalAccessException e) {
- throw new UtilsException(ERROR_MESSAGE, e);
- } catch (InvocationTargetException e) {
- throw new UtilsException(ERROR_MESSAGE, e);
- } catch (IOException e) {
- throw new UtilsException(ERROR_MESSAGE, e);
- } catch (InterruptedException e) {
- throw new UtilsException(ERROR_MESSAGE, e);
- } catch (RuntimeException e) {
- throw new UtilsException(ERROR_MESSAGE, e);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ClientSettings.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ClientSettings.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ClientSettings.java
deleted file mode 100644
index 5373772..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ClientSettings.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-
-public class ClientSettings extends ApplicationSettings {
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java
deleted file mode 100644
index 6855a8e..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-/**
- * Constants used in Airavata should go here.
- */
-public final class Constants {
-
- public static final String USER_IN_SESSION = "userName";
-// public static final String GATEWAY_NAME = "gateway_id";
- public static final String GFAC_CONFIG_XML = "gfac-config.xml";
- public static final String PUSH = "push";
- public static final String PULL = "pull";
- public static final String API_SERVER_PORT = "apiserver.server.port";
- public static final String API_SERVER_HOST = "apiserver.server.host";
- public static final String REGISTRY_JDBC_URL = "registry.jdbc.url";
- public static final String APPCATALOG_JDBC_URL = "appcatalog.jdbc.url";
- public static final String RABBITMQ_BROKER_URL = "rabbitmq.broker.url";
- public static final String RABBITMQ_EXCHANGE = "rabbitmq.exchange.name";
- public static final String ORCHESTRATOR_SERVER_HOST = "orchestrator.server.host";
- public static final String ORCHESTRATOR_SERVER_PORT = "orchestrator.server.port";
- public static final String GFAC_SERVER_HOST = "gfac.server.host";
- public static final String GFAC_SERVER_PORT = "gfac.server.port";
- public static final String CREDENTIAL_SERVER_HOST = "credential.store.server.host";
- public static final String CREDENTIAL_SERVER_PORT = "credential.store.server.port";
- public static final String ZOOKEEPER_EXPERIMENT_CATALOG = "experiment-catalog";
- public static final String ZOOKEEPER_APPCATALOG = "app-catalog";
- public static final String ZOOKEEPER_RABBITMQ = "rabbit-mq";
- public static final String ZOOKEEPER_SERVER_HOST = "zookeeper.server.host";
- public static final String ZOOKEEPER_SERVER_PORT = "zookeeper.server.port";
- public static final String ZOOKEEPER_API_SERVER_NODE = "airavata-server";
- public static final String ZOOKEEPER_ORCHESTRATOR_SERVER_NODE = "orchestrator-server";
- public static final String ZOOKEEPER_GFAC_SERVER_NODE = "gfac-server";
- public static final String ZOOKEEPER_GFAC_EXPERIMENT_NODE = "gfac-experiments";
- public static final String ZOOKEEPER_GFAC_SERVER_NAME = "gfac-server-name";
- public static final String ZOOKEEPER_ORCHESTRATOR_SERVER_NAME = "orchestrator-server-name";
- public static final String ZOOKEEPER_API_SERVER_NAME = "api-server-name";
- public static final String STAT = "stat";
- public static final String JOB = "job";
- public static final String ZOOKEEPER_TIMEOUT = "zookeeper.timeout";
- //API security relates property names
- public static final String IS_API_SECURED = "api.secured";
- public static final String REMOTE_OAUTH_SERVER_URL = "remote.oauth.authorization.server";
- public static final String ADMIN_USERNAME = "admin.user.name";
- public static final String ADMIN_PASSWORD = "admin.password";
-}
[2/8] airavata git commit: moved commons-utils to commons module
Posted by sh...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SwingUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SwingUtil.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SwingUtil.java
deleted file mode 100644
index 5b413ae..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SwingUtil.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Image;
-import java.awt.Insets;
-import java.awt.Rectangle;
-import java.awt.Toolkit;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.net.URL;
-import java.util.List;
-
-import javax.swing.ImageIcon;
-import javax.swing.JDialog;
-import javax.swing.JOptionPane;
-import javax.swing.JTextField;
-import javax.swing.Spring;
-import javax.swing.SpringLayout;
-
-public class SwingUtil {
-
- /**
- * Minimum size, zero.
- */
- public static final Dimension MINIMUM_SIZE = new Dimension(0, 0);
-
- /**
- * The default distance between components.
- */
- public static final int PAD = 6;
-
- /**
- * Default cursor.
- */
- public static final Cursor DEFAULT_CURSOR = new Cursor(Cursor.DEFAULT_CURSOR);
-
- /**
- * Hand cursor.
- */
- public static final Cursor HAND_CURSOR = new Cursor(Cursor.HAND_CURSOR);
-
- /**
- * Cross hair cursor.
- */
- public static final Cursor CROSSHAIR_CURSOR = new Cursor(Cursor.CROSSHAIR_CURSOR);
-
- /**
- * Move cursor.
- */
- public static final Cursor MOVE_CURSOR = new Cursor(Cursor.MOVE_CURSOR);
-
- /**
- * Wait cursor.
- */
- public static final Cursor WAIT_CURSOR = new Cursor(Cursor.WAIT_CURSOR);
-
- /**
- * Creates an icon from an image contained in the "images" directory.
- *
- * @param filename
- * @return the ImageIcon created
- */
- public static ImageIcon createImageIcon(String filename) {
- ImageIcon icon = null;
- URL imgURL = getImageURL(filename);
- if (imgURL != null) {
- icon = new ImageIcon(imgURL);
- }
- return icon;
- }
-
- /**
- * Creates an image from an image contained in the "images" directory.
- *
- * @param filename
- * @return the Image created
- */
- public static Image createImage(String filename) {
- Image icon = null;
- URL imgURL = getImageURL(filename);
- if (imgURL != null) {
- icon = Toolkit.getDefaultToolkit().getImage(imgURL);
- }
- return icon;
- }
-
- public static URL getImageURL(String filename) {
- String path = "/images/" + filename;
- URL imgURL = SwingUtil.class.getResource(path);
- return imgURL;
- }
-
- /**
- * Return the Frame of a specified component if any.
- *
- * @param component
- * the specified component
- *
- * @return the Frame of a specified component if any; otherwise null
- */
- public static Frame getFrame(Component component) {
- Frame frame;
- Component parent;
- while ((parent = component.getParent()) != null) {
- component = parent;
- }
- if (component instanceof Frame) {
- frame = (Frame) component;
- } else {
- frame = null;
- }
- return frame;
- }
-
- /**
- * Wight none of rows or eolumns. Used by layoutToGrid().
- */
- public final static int WEIGHT_NONE = -1;
-
- /**
- * Weight all rows or columns equally. Used by layoutToGrid().
- */
- public final static int WEIGHT_EQUALLY = -2;
-
- /**
- * Layouts the child components of a specified parent component using GridBagLayout.
- *
- * @param parent
- * The specified parent component
- * @param numRow
- * The number of rows
- * @param numColumn
- * The number of columns
- * @param weightedRow
- * The row to weight
- * @param weightedColumn
- * The column to weight
- */
- public static void layoutToGrid(Container parent, int numRow, int numColumn, int weightedRow, int weightedColumn) {
- GridBagLayout layout = new GridBagLayout();
- parent.setLayout(layout);
- GridBagConstraints constraints = new GridBagConstraints();
-
- constraints.fill = GridBagConstraints.BOTH;
- constraints.insets = new Insets(SwingUtil.PAD, SwingUtil.PAD, SwingUtil.PAD, SwingUtil.PAD);
-
- for (int row = 0; row < numRow; row++) {
- constraints.gridy = row;
- if (weightedRow == WEIGHT_EQUALLY) {
- constraints.weighty = 1;
- } else if (row == weightedRow) {
- constraints.weighty = 1;
- } else {
- constraints.weighty = 0;
- }
- for (int column = 0; column < numColumn; column++) {
- constraints.gridx = column;
- if (weightedColumn == WEIGHT_EQUALLY) {
- constraints.weightx = 1;
- } else if (column == weightedColumn) {
- constraints.weightx = 1;
- } else {
- constraints.weightx = 0;
- }
- Component component = parent.getComponent(row * numColumn + column);
- layout.setConstraints(component, constraints);
- }
- }
- }
-
- /**
- * @param parent
- * @param rowWeights
- * @param columnWeights
- */
- public static void layoutToGrid(Container parent, double[] rowWeights, double[] columnWeights) {
- GridBagLayout layout = new GridBagLayout();
- parent.setLayout(layout);
- GridBagConstraints constraints = new GridBagConstraints();
-
- constraints.fill = GridBagConstraints.BOTH;
- constraints.insets = new Insets(SwingUtil.PAD, SwingUtil.PAD, SwingUtil.PAD, SwingUtil.PAD);
-
- for (int row = 0; row < rowWeights.length; row++) {
- constraints.gridy = row;
- constraints.weighty = rowWeights[row];
- for (int column = 0; column < columnWeights.length; column++) {
- constraints.gridx = column;
- constraints.weightx = columnWeights[column];
- Component component = parent.getComponent(row * columnWeights.length + column);
- layout.setConstraints(component, constraints);
- }
- }
- }
-
- /**
- * @param parent
- * @param rowWeights
- * @param columnWeights
- */
- @SuppressWarnings("boxing")
- public static void layoutToGrid(Container parent, List<Double> rowWeights, List<Double> columnWeights) {
- GridBagLayout layout = new GridBagLayout();
- parent.setLayout(layout);
- GridBagConstraints constraints = new GridBagConstraints();
-
- constraints.fill = GridBagConstraints.BOTH;
- constraints.insets = new Insets(SwingUtil.PAD, SwingUtil.PAD, SwingUtil.PAD, SwingUtil.PAD);
-
- for (int row = 0; row < rowWeights.size(); row++) {
- constraints.gridy = row;
- constraints.weighty = rowWeights.get(row);
- for (int column = 0; column < columnWeights.size(); column++) {
- constraints.gridx = column;
- constraints.weightx = columnWeights.get(column);
- Component component = parent.getComponent(row * columnWeights.size() + column);
- layout.setConstraints(component, constraints);
- }
- }
- }
-
- /**
- * Aligns the first <code>rows</code> * <code>cols</code> components of <code>parent</code> in a grid. Each
- * component in a column is as wide as the maximum preferred width of the components in that column; height is
- * similarly determined for each row. The parent is made just big enough to fit them all.
- *
- * @param parent
- *
- * @param rows
- * number of rows
- * @param cols
- * number of columns
- */
- public static void makeSpringCompactGrid(Container parent, int rows, int cols) {
- makeSpringCompactGrid(parent, rows, cols, PAD, PAD, PAD, PAD);
- }
-
- /**
- * Aligns the first <code>rows</code> * <code>cols</code> components of <code>parent</code> in a grid. Each
- * component in a column is as wide as the maximum preferred width of the components in that column; height is
- * similarly determined for each row. The parent is made just big enough to fit them all.
- *
- * @param parent
- *
- * @param rows
- * number of rows
- * @param cols
- * number of columns
- * @param initialX
- * x location to start the grid at
- * @param initialY
- * y location to start the grid at
- * @param xPad
- * x padding between cells
- * @param yPad
- * y padding between cells
- */
- private static void makeSpringCompactGrid(Container parent, int rows, int cols, int initialX, int initialY,
- int xPad, int yPad) {
-
- SpringLayout layout = new SpringLayout();
- parent.setLayout(layout);
-
- // Align all cells in each column and make them the same width.
- Spring x = Spring.constant(initialX);
- for (int c = 0; c < cols; c++) {
- Spring width = Spring.constant(0);
- for (int r = 0; r < rows; r++) {
- width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth());
- }
- for (int r = 0; r < rows; r++) {
- SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
- constraints.setX(x);
- constraints.setWidth(width);
- }
- x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
- }
-
- // Align all cells in each row and make them the same height.
- Spring y = Spring.constant(initialY);
- for (int r = 0; r < rows; r++) {
- Spring height = Spring.constant(0);
- for (int c = 0; c < cols; c++) {
- height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight());
- }
- for (int c = 0; c < cols; c++) {
- SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
- constraints.setY(y);
- constraints.setHeight(height);
- }
- y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
- }
-
- // Set the parent's size.
- SpringLayout.Constraints pCons = layout.getConstraints(parent);
- pCons.setConstraint(SpringLayout.SOUTH, y);
- pCons.setConstraint(SpringLayout.EAST, x);
- }
-
- /* Used by makeCompactGrid. */
- private static SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent, int cols) {
- SpringLayout layout = (SpringLayout) parent.getLayout();
- Component c = parent.getComponent(row * cols + col);
- return layout.getConstraints(c);
- }
-
- public static void addPlaceHolder(final JTextField field,final String placeHolderText){
- field.addFocusListener(new FocusListener(){
- private Color fontColor=field.getForeground();
-// private String previousText=field.getText();
-
- public void focusGained(FocusEvent arg0) {
- if (field.getText().equals(placeHolderText)){
- field.setText("");
- }
- field.setForeground(fontColor);
- }
-
- public void focusLost(FocusEvent arg0) {
- if (field.getText().trim().equals("")){
- fontColor=field.getForeground();
- field.setForeground(Color.GRAY);
- field.setText(placeHolderText);
- }
- }
- });
- if (field.getText().trim().equals("")){
- field.setText(placeHolderText);
- field.setForeground(Color.GRAY);
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ThriftUtils.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ThriftUtils.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ThriftUtils.java
deleted file mode 100644
index ee86f74..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ThriftUtils.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import org.apache.thrift.TBase;
-import org.apache.thrift.TDeserializer;
-import org.apache.thrift.TException;
-import org.apache.thrift.TSerializer;
-
-public class ThriftUtils {
- public static byte[] serializeThriftObject(TBase object) throws TException {
- return new TSerializer().serialize(object);
- }
-
- public static void createThriftFromBytes(byte []bytes, TBase object) throws TException {
- new TDeserializer().deserialize(object, bytes);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Version.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Version.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Version.java
deleted file mode 100644
index fe34bb1..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Version.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement
-public class Version {
- public String PROJECT_NAME;
- private Integer majorVersion=0;
- private Integer minorVersion=0;
- private Integer maintenanceVersion;
- private String versionData;
- private BuildType buildType;
-
- public static enum BuildType{
- ALPHA,
- BETA,
- RC
- }
-
- public Version() {
- }
-
- public Version(String PROJECT_NAME,Integer majorVersion,Integer minorVersion,Integer maintenanceVersion,String versionData,BuildType buildType) {
- this.PROJECT_NAME=PROJECT_NAME;
- this.majorVersion=majorVersion;
- this.minorVersion=minorVersion;
- this.maintenanceVersion=maintenanceVersion;
- this.versionData=versionData;
- this.buildType=buildType;
- }
-
- public Integer getMajorVersion() {
- return majorVersion;
- }
-
- public Integer getMinorVersion() {
- return minorVersion;
- }
-
- public Integer getMaintenanceVersion() {
- return maintenanceVersion;
- }
-
- public String getVersionData() {
- return versionData;
- }
-
- public BuildType getBuildType() {
- return buildType;
- }
-
- public String getVersion(){
- String version = getBaseVersion();
- version = attachVersionData(version);
- return version;
- }
-
- private String attachVersionData(String version) {
- if (getVersionData()!=null){
- version+="-"+getVersionData();
- }
- return version;
- }
-
- public String getBaseVersion() {
- String version=getMajorVersion().toString()+"."+getMinorVersion();
- return version;
- }
-
- public String getFullVersion(){
- String version = getBaseVersion();
- version = attachMaintainanceVersion(version);
- version = attachVersionData(version);
- version = attachBuildType(version);
- return version;
- }
-
- private String attachMaintainanceVersion(String version) {
- if (getMaintenanceVersion()!=null){
- version+="."+getMaintenanceVersion();
- }
- return version;
- }
-
- private String attachBuildType(String version) {
- if (getBuildType()!=null){
- version+="-"+getBuildType().name();
- }
- return version;
- }
-
- @Override
- public String toString() {
- return getVersion();
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSConstants.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSConstants.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSConstants.java
deleted file mode 100644
index 9737ac4..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSConstants.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import javax.xml.namespace.QName;
-
-import org.xmlpull.infoset.XmlNamespace;
-
-public interface WSConstants {
-
- /**
- * xmlns
- */
- public final static String XMLNS = "xmlns";
-
- /**
- * XML Schema prefix, xsd
- */
- public static final String XSD_NS_PREFIX = "xsd";
-
- /**
- * XML Schema URI.
- */
- public static final String XSD_NS_URI = "http://www.w3.org/2001/XMLSchema";
-
-// /**
-// * XML Schema Namespace
-// */
-// public static final XmlNamespace XSD_NS = XmlConstants.BUILDER.newNamespace(XSD_NS_PREFIX, XSD_NS_URI);
-
- /**
- * The any type.
- */
- public static final QName XSD_ANY_TYPE = new QName(XSD_NS_URI, "any", XSD_NS_PREFIX);
-
- /**
- * xsd:anyURI
- */
- public static final QName XSD_ANY_URI = new QName(XSD_NS_URI, "anyURI", XSD_NS_PREFIX);
-
- /**
- * tns
- */
- public static final String TARGET_NS_PREFIX = "tns";
-
- /**
- * typens
- */
- public static final String TYPE_NS_PREFIX = "typens";
-
- /**
- * schema
- */
- public static final String SCHEMA_TAG = "schema";
-
- /**
- * Element name for annotation, annotation
- */
- public static final String ANNOTATION_TAG = "annotation";
-
- /**
- * Element name for documentation, documentation
- */
- public static final String DOCUMENTATION_TAG = "documentation";
-
- /**
- * appinfo
- */
- public static final String APPINFO_TAG = "appinfo";
-
- /**
- * element
- */
- public static final String ELEMENT_TAG = "element";
-
- /**
- * sequence
- */
- public static final String SEQUENCE_TAG = "sequence";
-
- /**
- * complexType
- */
- public static final String COMPLEX_TYPE_TAG = "complexType";
-
- /**
- * simpleType
- */
- public static final String SIMPLE_TYPE_TAG = "simpleType";
-
- /**
- * name
- */
- public static final String NAME_ATTRIBUTE = "name";
-
- /**
- * type
- */
- public static final String TYPE_ATTRIBUTE = "type";
-
- /**
- * targetNamespace
- */
- public static final String TARGET_NAMESPACE_ATTRIBUTE = "targetNamespace";
-
- /**
- * elementFormDefault
- */
- public final static String ELEMENT_FORM_DEFAULT_ATTRIBUTE = "elementFormDefault";
-
- /**
- * unqualified
- */
- public final static String UNQUALIFIED_VALUE = "unqualified";
-
- /**
- * default
- */
- public static final String DEFAULT_ATTRIBUTE = "default";
-
- /**
- * UsingAddressing
- */
- public static final String USING_ADDRESSING_TAG = "UsingAddressing";
-
- /**
- * <appinfo xmlns="http://www.w3.org/2001/XMLSchema">
- *
- * </appinfo>
- */
-// public static final String EMPTY_APPINFO = "<appinfo xmlns=\"http://www.w3.org/2001/XMLSchema\">\n\n</appinfo>";
- public static final String EMPTY_APPINFO = "{'appinfo': '' }";
-
- /**
- * minOccurs
- */
- public static final String MIN_OCCURS_ATTRIBUTE = "minOccurs";
-
- /**
- * maxOccurs
- */
- public static final String MAX_OCCURS_ATTRIBUTE = "maxOccurs";
-
- /**
- * unbounded
- */
- public static final String UNBOUNDED_VALUE = "unbounded";
-
- /**
- * import
- */
- public static final String IMPORT_TAG = "import";
-
- /**
- * schemaLocation
- */
- public static final String SCHEMA_LOCATION_ATTRIBUTE = "schemaLocation";
-
- public static final String LEAD_NS_URI = "http://www.extreme.indiana.edu/lead";
-
- /**
- * The any type.
- */
- public static final QName LEAD_ANY_TYPE = new QName(LEAD_NS_URI, "any",
- XSD_NS_PREFIX);
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSDLUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSDLUtil.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSDLUtil.java
deleted file mode 100644
index 522bb73..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSDLUtil.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.airavata.common.exception.UtilsException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.xmlpull.infoset.XmlAttribute;
-import org.xmlpull.infoset.XmlBuilderException;
-import org.xmlpull.infoset.XmlElement;
-import org.xmlpull.infoset.XmlNamespace;
-
-//import xsul.XmlConstants;
-//import xsul5.wsdl.WsdlBinding;
-//import xsul5.wsdl.WsdlDefinitions;
-//import xsul5.wsdl.WsdlPortType;
-//import xsul5.wsdl.WsdlPortTypeOperation;
-//import xsul5.wsdl.WsdlUtil;
-
-public class WSDLUtil {
-
- private static final Logger logger = LoggerFactory.getLogger(WSDLUtil.class);
-
-// /**
-// * @param wsdlString
-// * @return The WSDL
-// * @throws UtilsException
-// */
-// public static WsdlDefinitions stringToWSDL(String wsdlString) throws UtilsException {
-// try {
-// XmlElement wsdlElement = XMLUtil.stringToXmlElement(wsdlString);
-// WsdlDefinitions definitions = new WsdlDefinitions(wsdlElement);
-// return definitions;
-// } catch (RuntimeException e) {
-// throw new UtilsException(e);
-// }
-// }
-//
-// /**
-// * @param definitions3
-// * @return The WsdlDefinitions (XSUL5)
-// */
-// public static xsul5.wsdl.WsdlDefinitions wsdlDefinitions3ToWsdlDefintions5(xsul.wsdl.WsdlDefinitions definitions3) {
-//
-// return new xsul5.wsdl.WsdlDefinitions(XMLUtil.xmlElement3ToXmlElement5(definitions3));
-// }
-//
-// /**
-// * @param definitions5
-// * @return The WsdlDefinitions (XSUL3)
-// */
-// public static xsul.wsdl.WsdlDefinitions wsdlDefinitions5ToWsdlDefintions3(xsul5.wsdl.WsdlDefinitions definitions5) {
-//
-// return new xsul.wsdl.WsdlDefinitions(XMLUtil.xmlElement5ToXmlElement3(definitions5.xml()));
-// }
-//
-// /**
-// * @param definitions
-// * @return The name of the WSDL.
-// */
-// public static String getWSDLName(WsdlDefinitions definitions) {
-// String wsdlName = definitions.xml().attributeValue(WSConstants.NAME_ATTRIBUTE);
-// if (wsdlName == null) {
-// // name is optional.
-// wsdlName = "";
-// }
-// return wsdlName;
-// }
-//
-// /**
-// * @param definitions
-// * @return The QName of the WSDL.
-// */
-// public static QName getWSDLQName(WsdlDefinitions definitions) {
-// String targetNamespace = definitions.getTargetNamespace();
-// String wsdlName = getWSDLName(definitions);
-// return new QName(targetNamespace, wsdlName);
-// }
-//
-// /**
-// * @param definitions
-// * @return The first portType
-// * @throws UtilsException
-// */
-// public static WsdlPortType getFirstPortType(WsdlDefinitions definitions) throws UtilsException {
-// for (WsdlPortType portType : definitions.portTypes()) {
-// return portType;
-// }
-// throw new UtilsException("No portType is defined in WSDL");
-// }
-//
-// public static WsdlPortTypeOperation getFirstOperation(WsdlDefinitions definitions) throws UtilsException {
-// for (WsdlPortTypeOperation operation : getFirstPortType(definitions).operations()) {
-// return operation;
-// }
-// throw new UtilsException("No portType is defined in WSDL");
-// }
-//
-// /**
-// * @param definitions
-// * @return The QName of the first portType.
-// * @throws UtilsException
-// */
-// public static QName getFirstPortTypeQName(WsdlDefinitions definitions) throws UtilsException {
-// String targetNamespace = definitions.getTargetNamespace();
-// for (WsdlPortType portType : definitions.portTypes()) {
-// String portTypeName = portType.getName();
-// QName portTypeQName = new QName(targetNamespace, portTypeName);
-// return portTypeQName;
-// }
-// throw new UtilsException("No portType is defined.");
-// }
-//
-// /**
-// * @param definitions
-// * @param portTypeQName
-// * @return The name of the first operation in a given portType.
-// * @throws UtilsException
-// */
-// public static String getFirstOperationName(WsdlDefinitions definitions, QName portTypeQName) throws UtilsException {
-// WsdlPortType portType = definitions.getPortType(portTypeQName.getLocalPart());
-// for (WsdlPortTypeOperation operation : portType.operations()) {
-// String operationName = operation.getOperationName();
-//
-// // XXX Temporary solution to skip some GFac specific operations.
-// if ("Shutdown".equals(operationName)) {
-// continue;
-// } else if ("Kill".equals(operationName)) {
-// continue;
-// } else if ("Ping".equals(operationName)) {
-// continue;
-// }
-//
-// return operationName;
-// }
-// throw new UtilsException("No operation is defined");
-// }
-//
-// /**
-// * @param definitions
-// * @return The cloned WsdlDefinitions
-// */
-// public static WsdlDefinitions deepClone(WsdlDefinitions definitions) throws UtilsException {
-// return new WsdlDefinitions(XMLUtil.deepClone(definitions.xml()));
-// }
-//
-// /**
-// * @param definitions
-// * @param paramType
-// * @return The schema that includes the type definition
-// */
-// public static XmlElement getSchema(WsdlDefinitions definitions, QName paramType) throws UtilsException {
-// XmlElement types = definitions.getTypes();
-//
-// Iterable<XmlElement> schemas = types.elements(WSConstants.XSD_NS, WSConstants.SCHEMA_TAG);
-// for (XmlElement schema : schemas) {
-// if (isTypeDefinedInSchema(paramType, schema)) {
-// return schema;
-// }
-// }
-//
-// // ok we didnt find the type in the schema in first level
-// // now we try try to see if it exist in schema imports.
-// // we loop in two step because its better to avoid the network
-// // connection if possible
-// for (XmlElement schema : schemas) {
-// Iterable<XmlElement> imports = schema.elements(WSConstants.XSD_NS, WSConstants.IMPORT_TAG);
-// for (XmlElement importEle : imports) {
-// String schemaLocation = importEle.attributeValue(WSConstants.SCHEMA_LOCATION_ATTRIBUTE);
-// if (null != schemaLocation && !"".equals(schemaLocation)) {
-// try {
-// // connect using a url connection
-// URL url = new URL(schemaLocation);
-// URLConnection connection = url.openConnection();
-// connection.connect();
-// XmlElement importedSchema = xsul5.XmlConstants.BUILDER.parseFragmentFromInputStream(connection
-// .getInputStream());
-// if (isTypeDefinedInSchema(paramType, importedSchema)) {
-// // still return the parent schema
-// return schema;
-// }
-// } catch (MalformedURLException e) {
-// throw new UtilsException(e);
-// } catch (XmlBuilderException e) {
-// throw new UtilsException(e);
-// } catch (IOException e) {
-// throw new UtilsException(e);
-// }
-// }
-// }
-// }
-//
-// return null;
-// }
-//
-// private static boolean isTypeDefinedInSchema(QName paramType, XmlElement schema) {
-// String schemaTargetNamespace = schema.attributeValue(WSConstants.TARGET_NAMESPACE_ATTRIBUTE);
-// if (schemaTargetNamespace.equals(paramType.getNamespaceURI())) {
-// for (XmlElement complexType : schema.elements(WSConstants.XSD_NS, WSConstants.COMPLEX_TYPE_TAG)) {
-// String complexTypeName = complexType.attributeValue(WSConstants.NAME_ATTRIBUTE);
-// if (complexTypeName.equals(paramType.getLocalPart())) {
-// return true;
-// }
-// }
-// for (XmlElement simpleType : schema.elements(WSConstants.XSD_NS, WSConstants.SIMPLE_TYPE_TAG)) {
-// String simpleTypeName = simpleType.attributeValue(WSConstants.NAME_ATTRIBUTE);
-// if (simpleTypeName.equals(paramType.getLocalPart())) {
-// return true;
-// }
-// }
-// }
-// return false;
-// }
-//
-// /**
-// * @param definitions
-// * @param paramType
-// * @return The type definition
-// */
-// public static XmlElement getTypeDefinition(WsdlDefinitions definitions, QName paramType) throws UtilsException {
-// XmlElement types = definitions.getTypes();
-// XmlElement returnType = null;
-// types.element(null, WSConstants.SCHEMA_TAG);
-// Iterable<XmlElement> schemas = types.elements(null, WSConstants.SCHEMA_TAG);
-// for (XmlElement schema : schemas) {
-//
-// returnType = findTypeInSchema(paramType, schema);
-// if (returnType != null) {
-// return returnType;
-// }
-// }
-// // ok we didnt find the type in the schemas
-// // try to find it in the schema imports.
-//
-// // if not found it will return null so we would return null
-// return findTypeDefinitionInImports(definitions, paramType);
-//
-// }
-//
-// /**
-// *
-// * @param definitions
-// * @param paramType
-// * @return
-// */
-//
-// public static XmlElement getImportContainingTypeDefinition(WsdlDefinitions definitions, QName paramType)
-// throws UtilsException {
-// XmlElement types = definitions.getTypes();
-// XmlElement returnType = null;
-// Iterable<XmlElement> schemas = types.elements(WSConstants.XSD_NS, WSConstants.SCHEMA_TAG);
-// for (XmlElement schema : schemas) {
-// Iterable<XmlElement> imports = schema.elements(WSConstants.XSD_NS, WSConstants.IMPORT_TAG);
-// for (XmlElement importEle : imports) {
-// String schemaLocation = importEle.attributeValue(WSConstants.SCHEMA_LOCATION_ATTRIBUTE);
-// if (null != schemaLocation && !"".equals(schemaLocation)) {
-// try {
-// // connect using a url connection
-// URL url = new URL(schemaLocation);
-// URLConnection connection = url.openConnection();
-// connection.connect();
-// XmlElement importedSchema = xsul5.XmlConstants.BUILDER.parseFragmentFromInputStream(connection
-// .getInputStream());
-// returnType = findTypeInSchema(paramType, importedSchema);
-// if (returnType != null) {
-// return importEle;
-// }
-//
-// } catch (MalformedURLException e) {
-// throw new UtilsException(e);
-// } catch (XmlBuilderException e) {
-// throw new UtilsException(e);
-// } catch (IOException e) {
-// throw new UtilsException(e);
-// }
-// }
-// }
-// }
-// return null;
-// }
-//
-// /**
-// *
-// * @param definitions
-// * @param paramType
-// * @return
-// */
-//
-// public static XmlElement findTypeDefinitionInImports(WsdlDefinitions definitions, QName paramType)
-// throws UtilsException {
-// XmlElement types = definitions.getTypes();
-// XmlElement returnType = null;
-// Iterable<XmlElement> schemas = types.elements(null, WSConstants.SCHEMA_TAG);
-// for (XmlElement schema : schemas) {
-// Iterable<XmlElement> imports = schema.elements(WSConstants.XSD_NS, WSConstants.IMPORT_TAG);
-// for (XmlElement importEle : imports) {
-// String schemaLocation = importEle.attributeValue(WSConstants.SCHEMA_LOCATION_ATTRIBUTE);
-// if (null != schemaLocation && !"".equals(schemaLocation)) {
-// try {
-// // connect using a url connection
-// URL url = new URL(schemaLocation);
-// URLConnection connection = url.openConnection();
-// connection.connect();
-// XmlElement importedSchema = xsul5.XmlConstants.BUILDER.parseFragmentFromInputStream(connection
-// .getInputStream());
-// returnType = findTypeInSchema(paramType, importedSchema);
-// if (returnType != null) {
-// return returnType;
-// }
-//
-// } catch (MalformedURLException e) {
-// throw new UtilsException(e);
-// } catch (XmlBuilderException e) {
-// throw new UtilsException(e);
-// } catch (IOException e) {
-// throw new UtilsException(e);
-// }
-// }
-// }
-// }
-// return null;
-//
-// }
-//
-// private static XmlElement findTypeInSchema(QName paramType, XmlElement schema) {
-// String schemaTargetNamespace = schema.attributeValue(WSConstants.TARGET_NAMESPACE_ATTRIBUTE);
-// if (null != schemaTargetNamespace && schemaTargetNamespace.equals(paramType.getNamespaceURI())) {
-// for (XmlElement complexType : schema.elements(WSConstants.XSD_NS, WSConstants.COMPLEX_TYPE_TAG)) {
-// String complexTypeName = complexType.attributeValue(WSConstants.NAME_ATTRIBUTE);
-// if (complexTypeName.equals(paramType.getLocalPart())) {
-// return complexType;
-//
-// }
-// }
-// for (XmlElement simpleType : schema.elements(WSConstants.XSD_NS, WSConstants.SIMPLE_TYPE_TAG)) {
-// String simpleTypeName = simpleType.attributeValue(WSConstants.NAME_ATTRIBUTE);
-// if (simpleTypeName.equals(paramType.getLocalPart())) {
-// return simpleType;
-// }
-// }
-// }
-// return null;
-// }
-//
-// /**
-// * @param wsdl
-// * @return true if the WSDL is AWSDL; false otherwise.
-// */
-// public static boolean isAWSDL(WsdlDefinitions wsdl) {
-// if (wsdl.services().iterator().hasNext()) {
-// return false;
-// }
-// return true;
-// }
-//
-// /**
-// * @param definitions
-// * @return true if the service supports asynchronous invocation; false otherwise;
-// */
-// public static boolean isAsynchronousSupported(WsdlDefinitions definitions) {
-// for (WsdlBinding binding : definitions.bindings()) {
-// XmlElement element = binding.xml().element(WSConstants.USING_ADDRESSING_TAG);
-// if (element != null) {
-// return true;
-// }
-// }
-// return false;
-// }
-//
-// /**
-// * Converts a specified AWSDL to CWSDL using DSC URI.
-// *
-// * @param definitions
-// * The specified AWSDL. This will be modified.
-// * @param url
-// * The URL of the service
-// * @return The CWSDL converted.
-// */
-// public static WsdlDefinitions convertToCWSDL(WsdlDefinitions definitions, URI url) {
-// for (WsdlPortType portType : definitions.portTypes()) {
-// WsdlUtil.createCWSDL(definitions, portType, url);
-// }
-// return definitions;
-// }
-
- /**
- * @param uri
- * @return The URI with "?wsdl" at the end.
- */
- public static String appendWSDLQuary(String uri) {
- URI wsdlURI = appendWSDLQuary(URI.create(uri));
- return wsdlURI.toString();
- }
-
- public static List<XmlNamespace> getNamespaces(XmlElement element) {
- LinkedList<XmlNamespace> namespaces = new LinkedList<XmlNamespace>();
- namespaces.add(element.getNamespace());
- Iterable<XmlAttribute> attributes = element.attributes();
- for (XmlAttribute xmlAttribute : attributes) {
- if (xmlAttribute.getNamespace() != null && !namespaces.contains(xmlAttribute.getNamespace())) {
- namespaces.add(xmlAttribute.getNamespace());
- }
- int index = xmlAttribute.getValue().indexOf(':');
- if (-1 != index) {
- String prefix = xmlAttribute.getValue().substring(0, index);
- if (element.lookupNamespaceByPrefix(prefix) != null) {
- namespaces.add(element.lookupNamespaceByPrefix(prefix));
- }
- }
- }
- Iterable children = element.children();
- for (Object object : children) {
- if (object instanceof XmlElement) {
- List<XmlNamespace> newNSs = getNamespaces((XmlElement) object);
- for (XmlNamespace xmlNamespace : newNSs) {
- if (!namespaces.contains(xmlNamespace)) {
- namespaces.add(xmlNamespace);
- }
- }
- }
- }
- return namespaces;
- }
-
- /**
- * @param uri
- * @return The URI with "?wsdl" at the end.
- */
- public static URI appendWSDLQuary(URI uri) {
- if (uri.toString().endsWith("?wsdl")) {
- logger.warn("URL already has ?wsdl at the end: " + uri.toString());
- // Don't throw exception to be more error tolerant.
- return uri;
- }
- String path = uri.getPath();
- if (path == null || path.length() == 0) {
- uri = uri.resolve("/");
- }
- uri = URI.create(uri.toString() + "?wsdl");
- return uri;
- }
-
-// /**
-// * @param valueElement
-// * @return
-// */
-// public static org.xmlpull.v1.builder.XmlElement xmlElement5ToXmlElementv1(XmlElement valueElement) {
-//
-// return XmlConstants.BUILDER.parseFragmentFromReader(new StringReader(xsul5.XmlConstants.BUILDER
-// .serializeToStringPretty(valueElement)));
-// }
-
- /**
- *
- * @param vals
- * @param <T>
- * @return
- */
- public static <T extends Object> T getfirst(Iterable<T> vals) {
- for (T class1 : vals) {
- return class1;
- }
- throw new RuntimeException("Iterator empty");
-
- }
-
-// /**
-// * @param serviceSchema
-// */
-// public static void print(XmlElement serviceSchema) {
-// System.out.println(xsul5.XmlConstants.BUILDER.serializeToStringPretty(serviceSchema));
-// }
-
- /**
- * @param workflowID
- * @return
- */
- public static String findWorkflowName(URI workflowID) {
- String[] splits = workflowID.toString().split("/");
- return splits[splits.length - 1];
-
- }
-
- /**
- *
- * @param element
- * @param name
- * @param oldValue
- * @param newValue
- */
- public static void replaceAttributeValue(XmlElement element, String name, String oldValue, String newValue) {
- XmlAttribute attribute = element.attribute(name);
- if (null != attribute && oldValue.equals(attribute.getValue())) {
- element.removeAttribute(attribute);
- element.setAttributeValue(name, newValue);
- }
- Iterable iterator = element.children();
- for (Object object : iterator) {
- if (object instanceof XmlElement) {
- replaceAttributeValue((XmlElement) object, name, oldValue, newValue);
- }
- }
-
- }
-
- public static boolean attributeExist(XmlElement element, String name, String value) {
- XmlAttribute attribute = element.attribute(name);
- if (null != attribute && value.equals(attribute.getValue())) {
- return true;
- }
- Iterable iterator = element.children();
- boolean ret = false;
- for (Object object : iterator) {
- if (object instanceof XmlElement) {
- ret = ret || attributeExist((XmlElement) object, name, value);
- }
- }
- return ret;
-
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/XMLUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/XMLUtil.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/XMLUtil.java
deleted file mode 100644
index 0ba02f9..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/XMLUtil.java
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.airavata.common.exception.UtilsException;
-import org.apache.xmlbeans.XmlError;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Text;
-import org.xml.sax.SAXException;
-import org.xmlpull.infoset.XmlDocument;
-import org.xmlpull.infoset.XmlElement;
-import org.xmlpull.infoset.XmlNamespace;
-import org.xmlpull.mxp1.MXParserFactory;
-import org.xmlpull.mxp1_serializer.MXSerializer;
-
-public class XMLUtil {
-
- /**
- * The XML builder for XPP5
- */
- public static final org.xmlpull.infoset.XmlInfosetBuilder BUILDER = org.xmlpull.infoset.XmlInfosetBuilder
- .newInstance();
-
- /**
- * The XML builder for XPP3.
- */
- public static final org.xmlpull.v1.builder.XmlInfosetBuilder BUILDER3 = org.xmlpull.v1.builder.XmlInfosetBuilder
- .newInstance(new MXParserFactory());
-
- private static final Logger logger = LoggerFactory.getLogger(XMLUtil.class);
-
- private final static String PROPERTY_SERIALIZER_INDENTATION = "http://xmlpull.org/v1/doc/properties.html#serializer-indentation";
-
- private final static String INDENT = " ";
-
- /**
- * Parses a specified string and returns the XmlElement (XPP3).
- *
- * @param string
- * @return The XmlElement (XPP3) parsed.
- */
- public static org.xmlpull.v1.builder.XmlElement stringToXmlElement3(String string) {
- return BUILDER3.parseFragmentFromReader(new StringReader(string));
- }
-
- /**
- * Parses a specified string and returns the XmlElement (XPP5).
- *
- * @param string
- * @return The XmlElement (XPP5) parsed.
- */
- public static org.xmlpull.infoset.XmlElement stringToXmlElement(String string) {
- XmlDocument document = BUILDER.parseString(string);
- org.xmlpull.infoset.XmlElement element = document.getDocumentElement();
- return element;
- }
-
- /**
- * Converts a specified XmlElement (XPP3) to the XmlElement (XPP5).
- *
- * @param element
- * @return The XmlElement (XPP5) converted.
- */
- public static org.xmlpull.infoset.XmlElement xmlElement3ToXmlElement5(org.xmlpull.v1.builder.XmlElement element) {
- String string = xmlElementToString(element);
- return stringToXmlElement(string);
- }
-
- /**
- * Converts a specified XmlElement (XPP5) to the XmlElement (XPP3).
- *
- * @param element
- * @return The XmlElement (XPP3) converted.
- */
- public static org.xmlpull.v1.builder.XmlElement xmlElement5ToXmlElement3(org.xmlpull.infoset.XmlElement element) {
- String string = xmlElementToString(element);
- return stringToXmlElement3(string);
- }
-
- /**
- * Returns the XML string of a specified XmlElement.
- *
- * @param element
- * The specified XmlElement
- * @return The XML string
- */
- public static String xmlElementToString(org.xmlpull.v1.builder.XmlElement element) {
- MXSerializer serializer = new MXSerializer();
- StringWriter writer = new StringWriter();
- serializer.setOutput(writer);
- serializer.setProperty(PROPERTY_SERIALIZER_INDENTATION, INDENT);
- BUILDER3.serialize(element, serializer);
- String xmlText = writer.toString();
- return xmlText;
- }
-
- /**
- * Returns the XML string as a specified XmlElement (XPP5).
- *
- * @param element
- * The specified XmlElement
- * @return The XML string
- */
- public static String xmlElementToString(org.xmlpull.infoset.XmlElement element) {
- String string;
- if (element == null) {
- string = "";
- } else {
- string = BUILDER.serializeToStringPretty(element);
- }
- return string;
- }
-
- /**
- * Converts a specified XPP5 XML element to a DOM element under a specified document.
- *
- * @param xppElement
- * @param document
- * @return The converted DOM element.
- */
- public static Element xppElementToDomElement(org.xmlpull.infoset.XmlElement xppElement, Document document) {
- Element domElement = document.createElement(xppElement.getName());
-
- for (org.xmlpull.infoset.XmlNamespace namespace : xppElement.namespaces()) {
- logger.debug("namespace: " + namespace);
- }
-
- for (org.xmlpull.infoset.XmlAttribute attribute : xppElement.attributes()) {
- domElement.setAttribute(attribute.getName(), attribute.getValue());
- }
-
- for (Object object : xppElement.children()) {
- if (object instanceof org.xmlpull.infoset.XmlElement) {
- domElement.appendChild(xppElementToDomElement((org.xmlpull.infoset.XmlElement) object, document));
- } else if (object instanceof String) {
- Text text = document.createTextNode((String) object);
- domElement.appendChild(text);
- } else {
- logger.debug("object.getClass(): " + object.getClass());
- }
- }
- return domElement;
- }
-
-// /**
-// * @param definitions3
-// * @return The WsdlDefinitions (XSUL5)
-// */
-// @Deprecated
-// public static xsul5.wsdl.WsdlDefinitions wsdlDefinitions3ToWsdlDefintions5(xsul.wsdl.WsdlDefinitions definitions3) {
-// return WSDLUtil.wsdlDefinitions3ToWsdlDefintions5(definitions3);
-// }
-//
-// /**
-// * @param definitions5
-// * @return The WsdlDefinitions (XSUL3)
-// */
-// @Deprecated
-// public static xsul.wsdl.WsdlDefinitions wsdlDefinitions5ToWsdlDefintions3(xsul5.wsdl.WsdlDefinitions definitions5) {
-// return WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(definitions5);
-// }
-
- /**
- * Converts a specified XPP3 XML element to a DOM element under a specified document.
- *
- * @param xppElement
- * @param document
- * @return The converted DOM element.
- */
- public static Element xppElementToDomElement(org.xmlpull.v1.builder.XmlElement xppElement, Document document) {
- Element domElement = document.createElement(xppElement.getName());
-
- Iterator nsIt = xppElement.namespaces();
- while (nsIt.hasNext()) {
- org.xmlpull.v1.builder.XmlNamespace namespace = (org.xmlpull.v1.builder.XmlNamespace) nsIt.next();
- logger.debug("namespace: " + namespace);
- // TODO
- }
-
- Iterator attrIt = xppElement.attributes();
- while (attrIt.hasNext()) {
- org.xmlpull.v1.builder.XmlAttribute attribute = (org.xmlpull.v1.builder.XmlAttribute) attrIt.next();
- // TODO namespace
- domElement.setAttribute(attribute.getName(), attribute.getValue());
- }
-
- Iterator elementIt = xppElement.children();
- while (elementIt.hasNext()) {
- Object object = elementIt.next();
- if (object instanceof org.xmlpull.v1.builder.XmlElement) {
- domElement.appendChild(xppElementToDomElement((org.xmlpull.v1.builder.XmlElement) object, document));
- } else if (object instanceof String) {
- Text text = document.createTextNode((String) object);
- domElement.appendChild(text);
- } else {
- logger.debug("object.getClass(): " + object.getClass());
- }
- }
- return domElement;
- }
-
- /**
- * @param element
- * @return The cloned XmlElement.
- */
- public static org.xmlpull.infoset.XmlElement deepClone(org.xmlpull.infoset.XmlElement element)
- throws UtilsException {
- try {
- XmlElement clonedElement = element.clone();
- clonedElement.setParent(null);
- return clonedElement;
- } catch (CloneNotSupportedException e) {
- // This should not happen because we don't put any special Objects.
- throw new UtilsException(e);
- }
- }
-
- /**
- * Saves a specified XmlElement to a specified file.
- *
- * @param element
- * @param file
- * @throws IOException
- */
- public static void saveXML(org.xmlpull.infoset.XmlElement element, File file) throws IOException {
- XmlDocument document = BUILDER.newDocument();
- document.setDocumentElement(element);
- String xmlText = BUILDER.serializeToStringPretty(document);
- IOUtil.writeToFile(xmlText, file);
- }
-
- /**
- * Saves a specified XmlElement to a specified file.
- *
- * @param element
- * @param file
- * @throws IOException
- */
- public static void saveXML(org.xmlpull.v1.builder.XmlElement element, File file) throws IOException {
- saveXML(xmlElement3ToXmlElement5(element), file);
- }
-
- /**
- * @param file
- * @return The XmlElement in the document.
- * @throws IOException
- */
- public static org.xmlpull.infoset.XmlElement loadXML(InputStream stream) throws IOException {
- String xmlText = IOUtil.readToString(stream);
- XmlDocument document = BUILDER.parseString(xmlText);
- return document.getDocumentElement();
- }
-
- /**
- * @param file
- * @return The XmlElement in the document.
- * @throws IOException
- */
- public static org.xmlpull.infoset.XmlElement loadXML(File file) throws IOException {
- return loadXML(new FileInputStream(file));
- }
-
- /**
- * @param string
- * @return true if the specified string is XML, false otherwise
- */
- public static boolean isXML(String string) {
- try {
- stringToXmlElement(string);
- return true;
- } catch (RuntimeException e) {
- return false;
- }
- }
-
- /**
- * Validates a specified XmlObject along with logging errors if any.
- *
- * @param xmlObject
- */
- public static void validate(XmlObject xmlObject) throws UtilsException {
- XmlOptions validateOptions = new XmlOptions();
- ArrayList errorList = new ArrayList();
- validateOptions.setErrorListener(errorList);
-
- boolean isValid = xmlObject.validate(validateOptions);
- if (isValid) {
- // Valid
- return;
- }
-
- // Error
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < errorList.size(); i++) {
- XmlError error = (XmlError) errorList.get(i);
- logger.warn("Message: " + error.getMessage());
- logger.warn("Location of invalid XML: " + error.getCursorLocation().xmlText());
- stringBuilder.append("Message:" + error.getMessage());
- stringBuilder.append("Location of invalid XML: " + error.getCursorLocation().xmlText());
- }
- throw new UtilsException(stringBuilder.toString());
- }
-
- /**
- * Returns the local part of a specified QName.
- *
- * @param qname
- * the specified QName in string, e.g. ns:value
- * @return the local part of the QName, e.g. value
- */
- public static String getLocalPartOfQName(String qname) {
- int index = qname.indexOf(':');
- if (index < 0) {
- return qname;
- } else {
- return qname.substring(index + 1);
- }
- }
-
- /**
- * Returns the prefix of a specified QName.
- *
- * @param qname
- * the specified QName in string, e.g. ns:value
- * @return the prefix of the QName, e.g. ns
- */
- public static String getPrefixOfQName(String qname) {
- int index = qname.indexOf(':');
- if (index < 0) {
- return null;
- } else {
- return qname.substring(0, index);
- }
- }
-
- /**
- * @param prefixCandidate
- * @param uri
- * @param alwaysUseSuffix
- * @param element
- * @return The namespace found or declared.
- */
- public static XmlNamespace declareNamespaceIfNecessary(String prefixCandidate, String uri, boolean alwaysUseSuffix,
- XmlElement element) {
- XmlNamespace namespace = element.lookupNamespaceByName(uri);
- if (namespace == null) {
- return declareNamespace(prefixCandidate, uri, alwaysUseSuffix, element);
- } else {
- return namespace;
- }
- }
-
- /**
- * @param prefixCandidate
- * @param uri
- * @param alwaysUseSuffix
- * @param element
- * @return The namespace declared.
- */
- public static XmlNamespace declareNamespace(String prefixCandidate, String uri, boolean alwaysUseSuffix,
- XmlElement element) {
- if (prefixCandidate == null || prefixCandidate.length() == 0) {
- prefixCandidate = "a";
- }
- String prefix = prefixCandidate;
- if (alwaysUseSuffix) {
- prefix += "0";
- }
- if (element.lookupNamespaceByPrefix(prefix) != null) {
- int i = 1;
- prefix = prefixCandidate + i;
- while (element.lookupNamespaceByPrefix(prefix) != null) {
- i++;
- }
- }
- XmlNamespace namespace = element.declareNamespace(prefix, uri);
- return namespace;
- }
-
- /**
- *
- * @param xml
- * @param name
- */
- public static void removeElements(XmlElement xml, String name) {
-
- Iterable<XmlElement> removeElements = xml.elements(null, name);
- LinkedList<XmlElement> removeList = new LinkedList<XmlElement>();
- for (XmlElement xmlElement : removeElements) {
- removeList.add(xmlElement);
- }
- for (XmlElement xmlElement : removeList) {
- xml.removeChild(xmlElement);
- }
- Iterable children = xml.children();
- for (Object object : children) {
- if (object instanceof XmlElement) {
- XmlElement element = (XmlElement) object;
- removeElements(element, name);
- }
- }
- }
-
- /**
- * @param url
- * @return Document
- */
- public static Document retrievalXMLDocFromUrl(String url) {
- try {
- URL xmlUrl = new URL(url);
- InputStream in = xmlUrl.openStream();
- Document ret = null;
- DocumentBuilderFactory domFactory;
- DocumentBuilder builder;
-
- domFactory = DocumentBuilderFactory.newInstance();
- domFactory.setValidating(false);
- domFactory.setNamespaceAware(false);
- builder = domFactory.newDocumentBuilder();
-
- ret = builder.parse(in);
-
- return ret;
- } catch (MalformedURLException e) {
- logger.error(e.getMessage(), e);
- } catch (IOException e) {
- logger.error(e.getMessage(), e);
- } catch (ParserConfigurationException e) {
- logger.error(e.getMessage(), e);
- } catch (SAXException e) {
- logger.error(e.getMessage(), e);
- }
-
- return null;
- }
-
- /**
- * @param url
- * @return Document
- */
- public static Document retrievalXMLDocForParse(String url) {
- try {
- URL xmlUrl = new URL(url);
- InputStream in = xmlUrl.openStream();
- DocumentBuilderFactory xmlFact = DocumentBuilderFactory.newInstance();
- xmlFact.setNamespaceAware(true);
- DocumentBuilder builder = xmlFact.newDocumentBuilder();
- Document doc = builder.parse(in);
-
- return doc;
- } catch (MalformedURLException e) {
- logger.error("Malformed URL", e);
- } catch (IOException e) {
- logger.error(e.getMessage(), e);
- } catch (ParserConfigurationException e) {
- logger.error(e.getMessage(), e);
- } catch (SAXException e) {
- logger.error(e.getMessage(), e);
- }
-
- return null;
- }
-
- public static boolean isEqual(XmlElement elem1, XmlElement elem2) throws Exception {
-
- if (elem1 == null && elem2 == null) {
- return true;
- } else if (elem1 == null) {
- return false;
- } else if (elem2 == null) {
- return false;
- }
-
- if (!elem1.getName().equals(elem2.getName())) {
- return false;
- } else {
- // now check if children are the same
- Iterator children1 = elem1.children().iterator();
- Iterator children2 = elem2.children().iterator();
-
- //check first ones for string
- Object child1 = null;
- Object child2 = null;
- if (children1.hasNext() && children2.hasNext()) {
- child1 = children1.next();
- child2 = children2.next();
-
- if (!children1.hasNext() && !children2.hasNext()) {
- //only one node could be string could be xmlelement
- return compareObjs(child1, child2);
- } else {
- //get new iterators
-
- List<XmlElement> elemSet1 = getXmlElementsOnly(elem1.children().iterator());
- List<XmlElement> elemSet2 = getXmlElementsOnly(elem2.children().iterator());
-
- if(elemSet1.size() != elemSet2.size()){
- return false;
- }
- for(int i =0; i< elemSet1.size(); ++i){
- if(!isEqual(elemSet1.get(i), elemSet2.get(i))){
- return false;
- }
- }
- return true;
- }
-
-
- }else {
- //no internal element
-
- return true;
- }
- }
-
-
- }
-
-
-
- private static List<XmlElement> getXmlElementsOnly(Iterator itr){
- LinkedList<XmlElement> list = new LinkedList<XmlElement>();
- while(itr.hasNext()){
- Object obj = itr.next();
- if(obj instanceof XmlElement){
- list.add((XmlElement) obj);
- }
- }
- return list;
- }
-
-
-
- private static boolean compareObjs(Object child1, Object child2) throws Exception {
- if (child1 instanceof String && child2 instanceof String) {
- return child1.equals(child2);
-
-
- } else if (child1 instanceof XmlElement && child2 instanceof XmlElement) {
- return isEqual((XmlElement) child1, (XmlElement) child2);
- } else {
- return false;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/XmlFormatter.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/XmlFormatter.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/XmlFormatter.java
deleted file mode 100644
index 1440dbf..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/XmlFormatter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.Writer;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * Pretty-prints xml, supplied as a string.
- * <p/>
- * eg. <code>
- * String formattedXml = new XmlFormatter().format("<tag><nested>hello</nested></tag>");
- * </code>
- */
-public class XmlFormatter {
-
- /**
- * @param unformattedXml
- * @return formattedXml
- */
- public static String format(String unformattedXml) {
- try {
- final Document document = parseXmlFile(unformattedXml);
- OutputFormat format = new OutputFormat(document);
- format.setLineWidth(65);
- format.setIndenting(true);
- format.setIndent(2);
- Writer out = new StringWriter();
- XMLSerializer serializer = new XMLSerializer(out, format);
- serializer.serialize(document);
- return out.toString();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- private static Document parseXmlFile(String in) {
- try {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- InputSource is = new InputSource(new StringReader(in));
- return db.parse(is);
- } catch (ParserConfigurationException e) {
- throw new RuntimeException(e);
- } catch (SAXException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/listener/AbstractActivityListener.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/listener/AbstractActivityListener.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/listener/AbstractActivityListener.java
deleted file mode 100644
index e972012..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/listener/AbstractActivityListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils.listener;
-
-
-public interface AbstractActivityListener {
- public void setup(Object... configurations);
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/listener/AbstractStateChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/listener/AbstractStateChangeRequest.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/listener/AbstractStateChangeRequest.java
deleted file mode 100644
index 8529c4b..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/listener/AbstractStateChangeRequest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils.listener;
-
-
-public abstract class AbstractStateChangeRequest implements PublisherMessage {
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/listener/PublisherMessage.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/listener/PublisherMessage.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/listener/PublisherMessage.java
deleted file mode 100644
index 0d5404a..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/listener/PublisherMessage.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils.listener;
-
-public interface PublisherMessage {
-// public String getType();
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/test/java/org/apache/airavata/common/utils/ApplicationSettingsTest.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/test/java/org/apache/airavata/common/utils/ApplicationSettingsTest.java b/modules/commons/utils/src/test/java/org/apache/airavata/common/utils/ApplicationSettingsTest.java
deleted file mode 100644
index ed61793..0000000
--- a/modules/commons/utils/src/test/java/org/apache/airavata/common/utils/ApplicationSettingsTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-/**
- * User: AmilaJ (amilaj@apache.org)
- * Date: 7/5/13
- * Time: 4:39 PM
- */
-
-public class ApplicationSettingsTest extends TestCase {
-
- public void testGetAbsoluteSettingWithSpecialCharacters() throws Exception {
-
- String url = ServerSettings.getSetting("default.registry.user");
- Assert.assertEquals("admin", url);
-
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/test/java/org/apache/airavata/common/utils/SecurityUtilTest.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/test/java/org/apache/airavata/common/utils/SecurityUtilTest.java b/modules/commons/utils/src/test/java/org/apache/airavata/common/utils/SecurityUtilTest.java
deleted file mode 100644
index aa87283..0000000
--- a/modules/commons/utils/src/test/java/org/apache/airavata/common/utils/SecurityUtilTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import junit.framework.Assert;
-import org.junit.Test;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.security.KeyStore;
-
-/**
- * User: AmilaJ (amilaj@apache.org)
- * Date: 10/11/13
- * Time: 10:42 AM
- */
-
-public class SecurityUtilTest {
- @Test
- public void testEncryptString() throws Exception {
-
- URL url = this.getClass().getClassLoader().getResource("mykeystore.jks");
-
- assert url != null;
-
- String stringToEncrypt = "Test string to encrypt";
- byte[] encrypted = SecurityUtil.encryptString(url.getPath(), "mykey", new TestKeyStoreCallback(), stringToEncrypt);
-
- String decrypted = SecurityUtil.decryptString(url.getPath(), "mykey", new TestKeyStoreCallback(), encrypted);
- Assert.assertTrue(stringToEncrypt.equals(decrypted));
-
- }
-
- @Test
- public void testEncryptBytes() throws Exception {
-
- URL url = this.getClass().getClassLoader().getResource("mykeystore.jks");
-
- assert url != null;
-
- String stringToEncrypt = "Test string to encrypt";
- byte[] encrypted = SecurityUtil.encrypt(url.getPath(), "mykey", new TestKeyStoreCallback(),
- stringToEncrypt.getBytes("UTF-8"));
-
- byte[] decrypted = SecurityUtil.decrypt(url.getPath(), "mykey", new TestKeyStoreCallback(), encrypted);
- Assert.assertTrue(stringToEncrypt.equals(new String(decrypted, "UTF-8")));
-
- }
-
- @Test
- public void testLoadKeyStore() throws Exception{
- InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("mykeystore.jks");
-
- KeyStore ks = SecurityUtil.loadKeyStore(inputStream, "jceks", new TestKeyStoreCallback());
- Assert.assertNotNull(ks);
-
- }
-
- @Test
- public void testLoadKeyStoreFromFile() throws Exception{
- URL url = this.getClass().getClassLoader().getResource("mykeystore.jks");
-
- assert url != null;
- KeyStore ks = SecurityUtil.loadKeyStore(url.getPath(), "jceks", new TestKeyStoreCallback());
- Assert.assertNotNull(ks);
-
- }
-
- private class TestKeyStoreCallback implements KeyStorePasswordCallback {
-
- @Override
- public char[] getStorePassword() {
- return "airavata".toCharArray();
- }
-
- @Override
- public char[] getSecretKeyPassPhrase(String keyAlias) {
- if (keyAlias.equals("mykey")) {
- return "airavatasecretkey".toCharArray();
- }
-
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/test/java/org/apache/airavata/common/utils/XMLUtilTest.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/test/java/org/apache/airavata/common/utils/XMLUtilTest.java b/modules/commons/utils/src/test/java/org/apache/airavata/common/utils/XMLUtilTest.java
deleted file mode 100644
index 3c2c189..0000000
--- a/modules/commons/utils/src/test/java/org/apache/airavata/common/utils/XMLUtilTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.common.utils;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class XMLUtilTest {
- private final static Logger logger = LoggerFactory.getLogger(XMLUtilTest.class);
-
- @Test
- public void isXMLTest(){
- String xml = "<test>testing</test>";
- org.junit.Assert.assertTrue(XMLUtil.isXML(xml));
- org.junit.Assert.assertFalse(XMLUtil.isXML("NonXMLString"));
- }
-
- @Test
- public void isEqualTest(){
- String xml1 = "<test><inner>innerValue</inner></test>";
- String xml2 = "<test><inner>innerValue</inner></test>";
- String xml3 = "<test1><inner>innerValue</inner></test1>";
- try {
- org.junit.Assert.assertTrue(XMLUtil.isEqual(XMLUtil.stringToXmlElement(xml1), XMLUtil.stringToXmlElement(xml2)));
- org.junit.Assert.assertFalse(XMLUtil.isEqual(XMLUtil.stringToXmlElement(xml1), XMLUtil.stringToXmlElement(xml3)));
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- }
- }
- @Test
- public void getQNameTest(){
- String qname = "ns1:a";
- org.junit.Assert.assertEquals("a",XMLUtil.getLocalPartOfQName(qname));
- org.junit.Assert.assertEquals("ns1",XMLUtil.getPrefixOfQName(qname));
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/test/resources/mykeystore.jks
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/test/resources/mykeystore.jks b/modules/commons/utils/src/test/resources/mykeystore.jks
deleted file mode 100644
index 335ebf8..0000000
Binary files a/modules/commons/utils/src/test/resources/mykeystore.jks and /dev/null differ
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/credential-store/credential-store-service/pom.xml
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/pom.xml b/modules/credential-store/credential-store-service/pom.xml
index 6a80bba..882e2ec 100644
--- a/modules/credential-store/credential-store-service/pom.xml
+++ b/modules/credential-store/credential-store-service/pom.xml
@@ -114,7 +114,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/notifier/NotifierBootstrap.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/notifier/NotifierBootstrap.java b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/notifier/NotifierBootstrap.java
index de84ae2..979dedc 100644
--- a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/notifier/NotifierBootstrap.java
+++ b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/notifier/NotifierBootstrap.java
@@ -43,7 +43,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.ParseException;
-import java.text.SimpleDateFormat;
import java.util.*;
/**
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java
index ebed9a1..9fa3adb 100644
--- a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java
+++ b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java
@@ -34,7 +34,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.InetAddress;
-import java.net.InetSocketAddress;
public class CredentialStoreServer implements IServer {
private final static Logger logger = LoggerFactory.getLogger(CredentialStoreServer.class);
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/credential-store/credential-store-stubs/pom.xml
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-stubs/pom.xml b/modules/credential-store/credential-store-stubs/pom.xml
index 7af8152..32a4f64 100644
--- a/modules/credential-store/credential-store-stubs/pom.xml
+++ b/modules/credential-store/credential-store-stubs/pom.xml
@@ -37,7 +37,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/credential-store/credential-store-webapp/pom.xml
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-webapp/pom.xml b/modules/credential-store/credential-store-webapp/pom.xml
index 2e66d05..dcac26a 100644
--- a/modules/credential-store/credential-store-webapp/pom.xml
+++ b/modules/credential-store/credential-store-webapp/pom.xml
@@ -100,7 +100,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
[3/8] airavata git commit: moved commons-utils to commons module
Posted by sh...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java
deleted file mode 100644
index bb2ff1d..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DBUtil.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.commons.dbcp.BasicDataSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.sql.DataSource;
-import java.sql.*;
-import java.util.Properties;
-
-/**
- * Database lookup. Abstracts out JDBC operations.
- */
-public class DBUtil {
-
- private String jdbcUrl;
- private String databaseUserName;
- private String databasePassword;
- private String driverName;
-
- protected static Logger log = LoggerFactory.getLogger(DBUtil.class);
-
- private Properties properties;
-
- public DBUtil(String jdbcUrl, String userName, String password, String driver) throws InstantiationException,
- IllegalAccessException, ClassNotFoundException {
-
- this.jdbcUrl = jdbcUrl;
- this.databaseUserName = userName;
- this.databasePassword = password;
- this.driverName = driver;
-
- init();
- }
-
- /**
- * Initializes and load driver. Must be called this before calling anyother method.
- *
- * @throws ClassNotFoundException
- * If DB driver is not found.
- * @throws InstantiationException
- * If unable to create driver class.
- * @throws IllegalAccessException
- * If security does not allow users to instantiate driver object.
- */
- private void init() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
- properties = new Properties();
-
- properties.put("user", databaseUserName);
- properties.put("password", databasePassword);
- properties.put("characterEncoding", "ISO-8859-1");
- properties.put("useUnicode", "true");
-
- loadDriver();
- }
-
- /**
- * Generic method to query values in the database.
- *
- * @param tableName
- * Table name to query
- * @param selectColumn
- * The column selecting
- * @param whereValue
- * The condition query
- * @return The value appropriate to the query.
- * @throws SQLException
- * If an error occurred while querying
- */
- public String getMatchingColumnValue(String tableName, String selectColumn, String whereValue) throws SQLException {
- return getMatchingColumnValue(tableName, selectColumn, selectColumn, whereValue);
- }
-
- /**
- * Generic method to query values in the database.
- *
- * @param tableName
- * Table name to query
- * @param selectColumn
- * The column selecting
- * @param whereColumn
- * The column which condition should apply
- * @param whereValue
- * The condition query
- * @return The value appropriate to the query.
- * @throws SQLException
- * If an error occurred while querying
- */
- public String getMatchingColumnValue(String tableName, String selectColumn, String whereColumn, String whereValue)
- throws SQLException {
-
- StringBuilder stringBuilder = new StringBuilder();
-
- stringBuilder.append("SELECT ").append(selectColumn).append(" FROM ").append(tableName).append(" WHERE ")
- .append(whereColumn).append(" = ?");
-
- String sql = stringBuilder.toString();
-
- Connection connection = getConnection();
-
- PreparedStatement ps = connection.prepareStatement(sql);
- ResultSet rs = null;
-
- try {
- ps.setString(1, whereValue);
- rs = ps.executeQuery();
-
- if (rs.next()) {
- return rs.getString(1);
- }
-
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
-
- ps.close();
- connection.close();
-
- } catch (Exception ignore) {
- log.error("An error occurred while closing database connections ", ignore);
- }
- }
-
- return null;
- }
-
- /**
- * Create table utility method.
- *
- * @param sql
- * SQL to be executed.
- * @throws SQLException
- * If an error occurred while creating the table.
- */
- public void executeSQL(String sql) throws SQLException {
-
- Connection connection = getConnection();
-
- PreparedStatement ps = connection.prepareStatement(sql);
-
- try {
- ps.executeUpdate();
- connection.commit();
- } finally {
- try {
- if (ps != null) {
- ps.close();
- }
-
- connection.close();
-
- } catch (Exception ignore) {
- log.error("An error occurred while closing database connections ", ignore);
- }
- }
-
- }
-
- private void loadDriver() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
- Class.forName(driverName).newInstance();
- }
-
- /**
- * Gets a new DBCP data source.
- *
- * @return A new data source.
- */
- public DataSource getDataSource() {
- BasicDataSource ds = new BasicDataSource();
- ds.setDriverClassName(this.driverName);
- ds.setUsername(this.databaseUserName);
- ds.setPassword(this.databasePassword);
- ds.setUrl(this.jdbcUrl);
-
- return ds;
- }
-
- /**
- * Creates a new JDBC connections based on provided DBCP properties.
- *
- * @return A new DB connection.
- * @throws SQLException
- * If an error occurred while creating the connection.
- */
- public Connection getConnection() throws SQLException {
- Connection connection = DriverManager.getConnection(jdbcUrl, properties);
- connection.setAutoCommit(false);
- return connection;
- }
-
- /**
- * Utility method to close statements and connections.
- *
- * @param preparedStatement
- * The prepared statement to close.
- * @param connection
- * The connection to close.
- */
- public static void cleanup(PreparedStatement preparedStatement, Connection connection) {
- if (preparedStatement != null) {
- try {
- preparedStatement.close();
- } catch (SQLException e) {
- log.error("Error closing prepared statement.", e);
- }
- }
- if (connection != null) {
- try {
- connection.close();
- } catch (SQLException e) {
- log.error("Error closing database connection.", e);
- }
- }
- }
-
- /**
- * Utility method to close statements and connections.
- *
- * @param preparedStatement
- * The prepared statement to close.
- */
- public static void cleanup(PreparedStatement preparedStatement) {
- if (preparedStatement != null) {
- try {
- preparedStatement.close();
- } catch (SQLException e) {
- log.error("Error closing prepared statement.", e);
- }
- }
- }
-
- /**
- * Utility method to close statements and connections.
- *
- * @param preparedStatement
- * The prepared statement to close.
- */
- public static void cleanup(PreparedStatement preparedStatement, ResultSet resultSet) {
- if (resultSet != null) {
- try {
- resultSet.close();
- } catch (SQLException e) {
- log.error("Error closing prepared statement.", e);
- }
- }
-
- cleanup(preparedStatement);
- }
-
- /**
- * Cleanup the connection.
- * @param connection The connection to close.
- */
- public static void cleanup(Connection connection) {
- if (connection != null) {
- try {
- connection.close();
- } catch (SQLException e) {
- log.debug("Error closing connection.", e);
- log.warn("Error closing connection.");
- }
- }
- }
-
- /**
- * Mainly useful for tests.
- *
- * @param tableName
- * The table name.
- * @param connection
- * The connection to be used.
- */
- public static void truncate(String tableName, Connection connection) throws SQLException {
-
- String sql = "delete from " + tableName;
-
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
- preparedStatement.executeUpdate();
-
- connection.commit();
-
- }
-
- /**
- * Creates a DBUtil object based on servlet context configurations.
- *
- * @return DBUtil object.
- * @throws Exception
- * If an error occurred while reading configurations or while creating database object.
- */
- public static DBUtil getCredentialStoreDBUtil() throws ApplicationSettingsException, IllegalAccessException,
- ClassNotFoundException, InstantiationException {
- String jdbcUrl = ServerSettings.getCredentialStoreDBURL();
- String userName = ServerSettings.getCredentialStoreDBUser();
- String password = ServerSettings.getCredentialStoreDBPassword();
- String driverName = ServerSettings.getCredentialStoreDBDriver();
-
- StringBuilder stringBuilder = new StringBuilder("Starting credential store, connecting to database - ");
- stringBuilder.append(jdbcUrl).append(" DB user - ").append(userName).append(" driver name - ")
- .append(driverName);
-
- log.debug(stringBuilder.toString());
-
- DBUtil dbUtil = new DBUtil(jdbcUrl, userName, password, driverName);
- dbUtil.init();
-
- return dbUtil;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DatabaseTestCases.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DatabaseTestCases.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DatabaseTestCases.java
deleted file mode 100644
index 6ff528d..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DatabaseTestCases.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * An abstraction for database specific test classes. This will create a database and provides methods to execute SQLs.
- */
-public class DatabaseTestCases {
-
- private static final Logger logger = LoggerFactory.getLogger(DatabaseTestCases.class);
-
- protected static String hostAddress = "localhost";
- protected static int port = 20000;
- protected static String userName = "admin";
- protected static String password = "admin";
- protected static String driver = "org.apache.derby.jdbc.ClientDriver";
-
- public static String getHostAddress() {
- return hostAddress;
- }
-
- public static int getPort() {
- return port;
- }
-
- public static String getUserName() {
- return userName;
- }
-
- public static String getPassword() {
- return password;
- }
-
- public static String getDriver() {
- return driver;
- }
-
- public static String getJDBCUrl() {
- return new StringBuilder().append("jdbc:derby://").append(getHostAddress()).append(":").append(getPort())
- .append("/experiment_catalog;create=true;user=").append(getUserName()).append(";password=")
- .append(getPassword()).toString();
- }
-
- public static void waitTillServerStarts() {
- DBUtil dbUtil = null;
-
- try {
- dbUtil = new DBUtil(getJDBCUrl(), getUserName(), getPassword(), getDriver());
- } catch (Exception e) {
- // ignore
- }
-
- Connection connection = null;
- try {
- if (dbUtil != null) {
- connection = dbUtil.getConnection();
- }
- } catch (Throwable e) {
- // ignore
- }
-
- while (connection == null) {
- try {
- Thread.sleep(1000);
- try {
- if (dbUtil != null) {
- connection = dbUtil.getConnection();
- }
- } catch (SQLException e) {
- // ignore
- }
- } catch (InterruptedException e) {
- // ignore
- }
- }
-
- }
-
- public static void executeSQL(String sql) throws Exception {
- DBUtil dbUtil = new DBUtil(getJDBCUrl(), getUserName(), getPassword(), getDriver());
- dbUtil.executeSQL(sql);
- }
-
- public DBUtil getDbUtil () throws Exception {
- return new DBUtil(getJDBCUrl(), getUserName(), getPassword(), getDriver());
-
- }
-
- public Connection getConnection() throws Exception {
-
- DBUtil dbUtil = getDbUtil ();
- Connection connection = dbUtil.getConnection();
- connection.setAutoCommit(true);
- return connection;
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java
deleted file mode 100644
index fc7792b..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-
-/**
- * User: AmilaJ (amilaj@apache.org)
- * Date: 12/29/13
- * Time: 12:10 PM
- */
-
-public class DefaultKeyStorePasswordCallback implements KeyStorePasswordCallback {
-
- public DefaultKeyStorePasswordCallback(){
-
- }
-
- @Override
- public char[] getStorePassword() {
- try {
- return ApplicationSettings.getCredentialStoreKeyStorePassword().toCharArray();
- } catch (ApplicationSettingsException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public char[] getSecretKeyPassPhrase(String keyAlias) {
- try {
- return ApplicationSettings.getCredentialStoreKeyStorePassword().toCharArray();
- } catch (ApplicationSettingsException e) {
- throw new RuntimeException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DerbyUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DerbyUtil.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DerbyUtil.java
deleted file mode 100644
index 4fb35b9..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/DerbyUtil.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.InetAddress;
-import java.sql.DriverManager;
-import org.apache.derby.drda.NetworkServerControl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.SQLException;
-
-/**
- * This class includes methods to start stop Derby database. Mainly user for tests.
- */
-public class DerbyUtil {
-
- private static NetworkServerControl server;
-
- private static final Logger logger = LoggerFactory.getLogger(DerbyUtil.class);
-
- public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
-
- /**
- * Starts new derby server instance with given configurations.
- *
- * @param hostAddress
- * The host address start the server.
- * @param port
- * The port number which server is starting.
- * @param user
- * JDBC user name.
- * @param password
- * JDBC password.
- * @throws Exception
- * If an error occurred while starting the server.
- */
- public static void startDerbyInServerMode(String hostAddress, int port, String user, String password)
- throws Exception {
- PrintWriter consoleWriter = null;
-
- try {
- System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
- server = new NetworkServerControl(InetAddress.getByName(hostAddress), port, user, password);
- consoleWriter = new PrintWriter(System.out, true);
- server.start(consoleWriter);
-
- } catch (IOException e) {
- logger.error("Unable to start Apache derby in the server mode! Check whether "
- + "specified port is available", e);
- throw e;
- } catch (Exception e) {
- logger.error("Unable to start Apache derby in the server mode! Check whether "
- + "specified port is available", e);
- throw e;
- } finally {
-
- if (consoleWriter != null) {
- consoleWriter.close();
- }
-
- }
-
- }
-
- /**
- * Starts derby server in embedded mode.
- *
- * @throws ClassNotFoundException
- * If specified driver not found in the class path.
- * @throws SQLException
- * If an error occurred while creat
- */
- public static void startDerbyInEmbeddedMode() throws ClassNotFoundException, SQLException {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
- DriverManager.getConnection("jdbc:derby:memory:unit-testing-jpa;create=true").close();
- }
-
- /**
- * Shuts down the server.
- *
- * @throws Exception
- * If an error occurred while shutting down.
- */
- public static void stopDerbyServer() throws Exception {
- try {
- server.shutdown();
- } catch (Exception e) {
- logger.error("Error shutting down derby server.", e);
- throw e;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ExecutionMode.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ExecutionMode.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ExecutionMode.java
deleted file mode 100644
index cf17ef0..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ExecutionMode.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-public enum ExecutionMode {
- CLIENT,
- SERVER,
- UNKNOWN
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/IOUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/IOUtil.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/IOUtil.java
deleted file mode 100644
index 9d1d7dd..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/IOUtil.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.Writer;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class IOUtil {
-
- private static final Logger logger = LoggerFactory.getLogger(IOUtil.class);
-
- /**
- * @param path
- * @param content
- * @throws IOException
- */
- public static void writeToFile(String content, String path) throws IOException {
- logger.debug("Path:" + path + " Content:" + content);
-
- FileWriter fw = new FileWriter(path);
- writeToWriter(content, fw);
- }
-
- /**
- * @param content
- * @param file
- * @throws IOException
- */
- public static void writeToFile(String content, File file) throws IOException {
- FileWriter fw = new FileWriter(file);
- writeToWriter(content, fw);
- }
-
- /**
- * @param inputStream
- * @param file
- * @throws IOException
- */
- public static void writeToFile(InputStream inputStream, File file) throws IOException {
- FileOutputStream outputStream = new FileOutputStream(file);
- byte[] bytes = new byte[1024];
- int len;
- while ((len = inputStream.read(bytes)) != -1) {
- outputStream.write(bytes, 0, len);
- }
- outputStream.close();
- }
-
- /**
- * Writes a specified String to a specified Writer.
- *
- * @param content
- * The content to write
- * @param writer
- * The specified Writer
- *
- * @throws IOException
- */
- public static void writeToWriter(String content, Writer writer) throws IOException {
- writer.write(content);
- writer.close();
- }
-
- /**
- * Returns the content of a specified file as a String.
- *
- * @param path
- * @return the content of a specified file as a String
- * @throws IOException
- */
- public static String readFileToString(String path) throws IOException {
- FileReader read = new FileReader(path);
- return readToString(read);
- }
-
- /**
- * Returns the content of a specified file as a String.
- *
- * @param file
- * @return the content of a specified file as a String
- * @throws IOException
- */
- public static String readFileToString(File file) throws IOException {
- FileReader reader = new FileReader(file);
- return readToString(reader);
- }
-
- /**
- * Returns a String read from a specified InputStream.
- *
- * @param stream
- * The specified InputStream
- * @return The String read from the specified InputStream
- * @throws IOException
- */
- public static String readToString(InputStream stream) throws IOException {
- return readToString(new InputStreamReader(stream));
- }
-
- /**
- * Returns a String read from a specified Reader.
- *
- * @param reader
- * The specified Reader
- * @return The String read from the specified Reader
- * @throws IOException
- */
- public static String readToString(Reader reader) throws IOException {
- char[] cbuf = new char[1024];
- StringBuilder sbuf = new StringBuilder();
- int len;
- while ((len = reader.read(cbuf)) != -1) {
- sbuf.append(cbuf, 0, len);
- }
- return sbuf.toString();
- }
-
- /**
- * @param file
- * @return The byte array
- * @throws IOException
- */
- public static byte[] readToByteArray(File file) throws IOException {
- return readToByteArray(new FileInputStream(file));
- }
-
- /**
- * @param inputStream
- * @return The byte array.
- * @throws IOException
- */
- public static byte[] readToByteArray(InputStream inputStream) throws IOException {
- byte[] buf = new byte[1024];
- ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
- int len;
- while ((len = inputStream.read(buf)) != -1) {
- byteArrayStream.write(buf, 0, len);
- }
- return byteArrayStream.toByteArray();
- }
-
- /**
- * @param path
- * @return <code>true</code> if and only if the file or directory is successfully deleted; <code>false</code>
- * otherwise
- */
- public static boolean deleteDirectory(File path) {
- if (path.exists()) {
- File[] files = path.listFiles();
- for (File file : files) {
- if (file.isDirectory()) {
- deleteDirectory(file);
- } else {
- file.delete();
- }
- }
- }
- return path.delete();
- }
-
- /**
- * Gets the extension of a specified file.
- *
- * @param file
- * the specified file.
- * @return the extension of the file in lower case if there is an extension; null otherwise
- */
- public static String getExtension(File file) {
- String ext = null;
- String name = file.getName();
-
- int index = name.lastIndexOf('.');
- if (index > 0 && index < name.length() - 1) {
- ext = name.substring(index + 1).toLowerCase();
- }
- return ext;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/IServer.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/IServer.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/IServer.java
deleted file mode 100644
index 867eb45..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/IServer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.util.Calendar;
-import java.util.Date;
-
-public interface IServer {
- public enum ServerStatus{
- STOPING,
- STOPPED,
- STARTING,
- STARTED,
- FAILED;
- public void updateTime(){
- now=Calendar.getInstance().getTime();
- }
- private Date now;
- public Date getTime(){
- return now;
- }
- }
- public String getName();
- public String getVersion();
- public void start() throws Exception;
- public void stop() throws Exception;
- public void restart() throws Exception;
- public void configure() throws Exception;
- public ServerStatus getStatus() throws Exception;
-// public void waitForServerToStart() throws Exception;
-// public void waitForServerToStop() throws Exception;
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/JSONUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/JSONUtil.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/JSONUtil.java
deleted file mode 100644
index 7946acc..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/JSONUtil.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.stream.JsonReader;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.Map;
-import java.util.Set;
-
-public class JSONUtil {
-
-
- public static void saveJSON(JsonElement jsonElement, File file) throws IOException {
- IOUtil.writeToFile(jsonElementToString(jsonElement), file);
- }
-
- public static JsonObject stringToJSONObject(String workflowString) {
- JsonParser parser = new JsonParser();
- return (JsonObject) parser.parse(workflowString);
- }
-
- public static JsonObject loadJSON(File file) throws IOException {
- return loadJSON(new FileReader(file));
- }
-
- public static JsonObject loadJSON(Reader reader) throws IOException {
- JsonParser parser = new JsonParser();
- JsonElement jsonElement = parser.parse(reader);
- if (jsonElement instanceof JsonObject) {
- return (JsonObject) jsonElement;
- } else {
- throw new RuntimeException("Error while loading Json from file");
- }
-
- }
-
- public static String jsonElementToString(JsonElement jsonElement) {
- Gson gson = new GsonBuilder().setPrettyPrinting().create();
- return gson.toJson(jsonElement);
- }
-
- public static boolean isEqual(JsonObject originalJsonObject, JsonObject newJsonObject) {
- // TODO - Implement this method
- if (originalJsonObject == null && newJsonObject == null) {
- return true;
- }else if (originalJsonObject == null || newJsonObject == null) {
- return false;
- } else {
- // check the number of childs
- Set<Map.Entry<String , JsonElement>> entrySetOfOriginalJson = originalJsonObject.entrySet();
- Set<Map.Entry<String , JsonElement>> entrySetOfNewJson = newJsonObject.entrySet();
- if (entrySetOfOriginalJson.size() != entrySetOfNewJson.size()) {
- return false;
- }
-
- for (Map.Entry<String, JsonElement> keyString : entrySetOfOriginalJson) {
- JsonElement valueOrig = keyString.getValue();
- JsonElement valueNew = newJsonObject.get(keyString.getKey());
- if (valueOrig instanceof JsonObject && valueNew instanceof JsonObject &&
- !isEqual((JsonObject) valueOrig, (JsonObject) valueNew)) {
- return false;
- }else if (valueOrig instanceof JsonArray && valueNew instanceof JsonArray &&
- !isEqual((JsonArray) valueOrig, (JsonArray) valueNew)) {
- return false;
- }else if (valueOrig instanceof JsonPrimitive && valueNew instanceof JsonPrimitive &&
- !isEqual((JsonPrimitive) valueOrig, (JsonPrimitive) valueNew)) {
- return false;
- }
- }
- }
- return true;
- }
-
- private static boolean isEqual(JsonArray arrayOriginal, JsonArray arrayNew) {
- if (arrayOriginal == null && arrayNew == null) {
- return true;
- }else if (arrayOriginal == null || arrayNew == null) {
- return false;
- }else {
- // check the number of element
- if (arrayOriginal.size() != arrayNew.size()) {
- return false;
- }else if (arrayOriginal.size() == 0) {
- return true;
- } else {
- for (int i = 0; i < arrayOriginal.size(); i++) {
- JsonElement valueOrig = arrayOriginal.get(i);
- JsonElement valueNew = arrayNew.get(i);
- if (valueOrig instanceof JsonObject && valueNew instanceof JsonObject) {
- if (!isEqual((JsonObject) valueOrig, (JsonObject) valueNew)) {
- return false;
- }
- }else if (valueOrig instanceof JsonPrimitive && valueNew instanceof JsonPrimitive) {
- if (!isEqual((JsonPrimitive) valueOrig, (JsonPrimitive) valueNew)) {
- return false;
- }
- }
- }
- }
- }
- return true;
- }
-
- private static boolean isEqual(JsonPrimitive primitiveOrig, JsonPrimitive primitiveNew) {
- if (primitiveOrig == null && primitiveNew == null) {
- return true;
- }else if (primitiveOrig == null || primitiveNew == null) {
- return false;
- } else {
- if (primitiveOrig.isString() && primitiveNew.isString()){
- if(!primitiveOrig.getAsString().equals(primitiveNew.getAsString())) {
- return false;
- }
- }else if (primitiveOrig.isBoolean() && primitiveNew.isBoolean()) {
- if ((Boolean.valueOf(primitiveOrig.getAsBoolean()).compareTo(primitiveNew.getAsBoolean()) != 0)) {
- return false;
- }
- }else if (primitiveOrig.isNumber() && primitiveNew.isNumber() ) {
- if (new Double(primitiveOrig.getAsDouble()).compareTo(primitiveNew.getAsDouble()) != 0) {
- return false;
- }
- }else {
- return primitiveOrig.isJsonNull() && primitiveNew.isJsonNull();
- }
- }
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java
deleted file mode 100644
index bafaff3..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.apache.airavata.common.utils;/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * User: AmilaJ (amilaj@apache.org)
- * Date: 10/11/13
- * Time: 11:30 AM
- */
-
-/**
- * An interface to get keystore password in a form of a callback.
- */
-public interface KeyStorePasswordCallback {
-
- /**
- * Caller should implement the interface. Should return the password for
- * the keystore. This should return the keystore password. i.e. password used to open the keystore.
- * Instead of the actual file.
- * @return The password to open the keystore.
- */
- char[] getStorePassword() throws RuntimeException;
-
- /**
- * Caller should implement the interface. Should return the pass phrase for
- * the secret key.
- * Instead of the actual file.
- * @param keyAlias The alias of the key
- * @return The pass phrase for the secret key.
- */
- char[] getSecretKeyPassPhrase(String keyAlias);
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/MonitorPublisher.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/MonitorPublisher.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/MonitorPublisher.java
deleted file mode 100644
index 7f64e86..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/MonitorPublisher.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.common.utils;
-
-import com.google.common.eventbus.EventBus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MonitorPublisher{
- private final static Logger logger = LoggerFactory.getLogger(MonitorPublisher.class);
- private EventBus eventBus;
-
- public MonitorPublisher(EventBus eventBus) {
- this.eventBus = eventBus;
- }
-
- public void registerListener(Object listener) {
- eventBus.register(listener);
- }
-
- public void unregisterListener(Object listener) {
- eventBus.unregister(listener);
- }
-
- public void publish(Object o) {
- eventBus.post(o);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/NameValidator.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/NameValidator.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/NameValidator.java
deleted file mode 100644
index 98530cf..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/NameValidator.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class NameValidator {
-
- /**
- * @param name
- * @return Is it valid name?
- */
- public static boolean validate(String name) {
- // Set the name pattern string
- Pattern p = Pattern.compile("([a-zA-Z]){1,}([0-9]|_|\\.|[a-zA-Z]){0,}$");
-
- // Match the given string with the pattern
- Matcher m = p.matcher(name);
-
- // Check whether match is found
- boolean matchFound = m.matches();
-
- return matchFound;
- }
-
- /**
- * @param args
- * @Description some quick tests
- */
- public static void main(String[] args) {
- System.out.println(validate("abc90_90abc")); // true
-
- System.out.println(validate("abc_abc_123")); // true
-
- System.out.println(validate("abc_abc_")); // true
-
- System.out.println(validate("abc_abc")); // true
-
- System.out.println(validate("abc.abc")); // true
-
- System.out.println(validate("9abc_abc")); // false, name cannot start with number
-
- System.out.println(validate("_abc_abc")); // false, name cannot start with "_"
-
- System.out.println(validate("\\abc_abc")); // false, name cannot start with "\"
-
- System.out.println(validate("abc\\_abc")); // false, name cannot contain "\"
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Pair.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Pair.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Pair.java
deleted file mode 100644
index ee24360..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Pair.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-public class Pair<L, R> {
-
- private L left;
-
- private R right;
-
- /**
- * Constructs a Pair.
- *
- * @param left
- * @param right
- */
- public Pair(L left, R right) {
- this.left = left;
- this.right = right;
- }
-
- /**
- * Returns the left.
- *
- * @return The left
- */
- public L getLeft() {
- return this.left;
- }
-
- /**
- * Sets left.
- *
- * @param left
- * The left to set.
- */
- public void setLeft(L left) {
- this.left = left;
- }
-
- /**
- * Returns the right.
- *
- * @return The right
- */
- public R getRight() {
- return this.right;
- }
-
- /**
- * Sets right.
- *
- * @param right
- * The right to set.
- */
- public void setRight(R right) {
- this.right = right;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java
deleted file mode 100644
index aeec807..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.crypto.Cipher;
-import javax.crypto.spec.IvParameterSpec;
-import javax.crypto.spec.SecretKeySpec;
-import java.io.*;
-import java.security.*;
-import java.security.cert.CertificateException;
-
-/**
- * Class which includes security utilities.
- */
-public class SecurityUtil {
-
- public static final String PASSWORD_HASH_METHOD_PLAINTEXT = "PLAINTEXT";
-
- public static final String CHARSET_ENCODING = "UTF-8";
- public static final String ENCRYPTION_ALGORITHM = "AES";
- public static final String PADDING_MECHANISM = "AES/CBC/PKCS5Padding";
-
- private static final Logger logger = LoggerFactory.getLogger(SecurityUtil.class);
-
- /**
- * Creates a hash of given string with the given hash algorithm.
- *
- * @param stringToDigest
- * The string to digest.
- * @param digestingAlgorithm
- * Hash algorithm.
- * @return The digested string.
- * @throws NoSuchAlgorithmException
- * If given hash algorithm doesnt exists.
- */
- public static String digestString(String stringToDigest, String digestingAlgorithm) throws NoSuchAlgorithmException {
-
- if (digestingAlgorithm == null || digestingAlgorithm.equals(PASSWORD_HASH_METHOD_PLAINTEXT)) {
- return stringToDigest;
- }
-
- MessageDigest messageDigest = MessageDigest.getInstance(digestingAlgorithm);
- try {
- return new String(messageDigest.digest(stringToDigest.getBytes("UTF-8")));
- } catch (UnsupportedEncodingException e) {
- logger.error("Error encoding password string when creating digest", e);
- throw new RuntimeException("Error encoding password string when creating digest", e);
- }
- }
-
- /**
- * Sets the truststore for application. Useful when communicating over HTTPS.
- *
- * @param trustStoreFilePath
- * Where trust store is located.
- * @param trustStorePassword
- * The trust store password.
- */
- public static void setTrustStoreParameters(String trustStoreFilePath, String trustStorePassword) {
-
- if (System.getProperty("javax.net.ssl.trustStrore") == null) {
- logger.info("Setting Java trust store to " + trustStoreFilePath);
- System.setProperty("javax.net.ssl.trustStrore", trustStoreFilePath);
- }
-
- if (System.getProperty("javax.net.ssl.trustStorePassword") == null) {
- System.setProperty("javax.net.ssl.trustStorePassword", trustStoreFilePath);
- }
-
- }
-
- public static byte[] encryptString(String keyStorePath, String keyAlias,
- KeyStorePasswordCallback passwordCallback, String value)
- throws GeneralSecurityException, IOException {
- return encrypt(keyStorePath, keyAlias, passwordCallback, value.getBytes(CHARSET_ENCODING));
- }
-
- public static byte[] encrypt(String keyStorePath, String keyAlias,
- KeyStorePasswordCallback passwordCallback, byte[] value)
- throws GeneralSecurityException, IOException {
-
- Key secretKey = getSymmetricKey(keyStorePath, keyAlias, passwordCallback);
-
- Cipher cipher = Cipher.getInstance(PADDING_MECHANISM);
- cipher.init(Cipher.ENCRYPT_MODE, secretKey,
- new IvParameterSpec(new byte[16]));
- return cipher.doFinal(value);
- }
-
- private static Key getSymmetricKey(String keyStorePath, String keyAlias,
- KeyStorePasswordCallback passwordCallback)
- throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException,
- UnrecoverableKeyException {
-
- KeyStore ks = SecurityUtil.loadKeyStore(keyStorePath, "jceks", passwordCallback);
-
- if (ks == null) {
- throw new IOException("Unable to load Java keystore " + keyStorePath);
- }
-
- return ks.getKey(keyAlias, passwordCallback.getSecretKeyPassPhrase(keyAlias));
-
- }
-
- public static byte[] decrypt(String keyStorePath, String keyAlias,
- KeyStorePasswordCallback passwordCallback, byte[] encrypted)
- throws GeneralSecurityException, IOException {
-
- Key secretKey = getSymmetricKey(keyStorePath, keyAlias, passwordCallback);
-
- Cipher cipher = Cipher.getInstance(PADDING_MECHANISM);
- cipher.init(Cipher.DECRYPT_MODE, secretKey,
- new IvParameterSpec(new byte[16]));
-
- return cipher.doFinal(encrypted);
- }
-
- public static String decryptString(String keyStorePath, String keyAlias,
- KeyStorePasswordCallback passwordCallback, byte[] encrypted)
- throws GeneralSecurityException, IOException {
-
- byte[] decrypted = decrypt(keyStorePath, keyAlias, passwordCallback, encrypted);
- return new String(decrypted, CHARSET_ENCODING);
- }
-
- public static KeyStore loadKeyStore(String keyStoreFilePath, String keyStoreType,
- KeyStorePasswordCallback passwordCallback)
- throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
-
- java.io.FileInputStream fis = null;
- try {
- fis = new java.io.FileInputStream(keyStoreFilePath);
- return loadKeyStore(fis, keyStoreType, passwordCallback);
- } finally {
- if (fis != null) {
- fis.close();
- }
- }
- }
-
- public static KeyStore loadKeyStore(InputStream inputStream, String keyStoreType,
- KeyStorePasswordCallback passwordCallback)
- throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
-
- if (keyStoreType == null) {
- keyStoreType = KeyStore.getDefaultType();
- }
-
- KeyStore ks = KeyStore.getInstance(keyStoreType);
- ks.load(inputStream, passwordCallback.getStorePassword());
-
- return ks;
- }
-
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
deleted file mode 100644
index 8370e40..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-
-public class ServerSettings extends ApplicationSettings {
-
- private static final String DEFAULT_USER = "default.registry.user";
- private static final String DEFAULT_USER_PASSWORD = "default.registry.password";
- private static final String DEFAULT_USER_GATEWAY = "default.registry.gateway";
-
- private static final String SERVER_CONTEXT_ROOT = "server.context-root";
- public static final String EMBEDDED_ZK = "embedded.zk";
- public static final String IP = "ip";
-
- private static final String CREDENTIAL_STORE_DB_URL = "credential.store.jdbc.url";
- private static final String CREDENTIAL_STORE_DB_USER = "credential.store.jdbc.user";
- private static final String CREDENTIAL_STORE_DB_PASSWORD = "credential.store.jdbc.password";
- private static final String CREDENTIAL_STORE_DB_DRIVER = "credential.store.jdbc.driver";
-
- private static final String REGISTRY_DB_URL = "registry.jdbc.url";
- private static final String REGISTRY_DB_USER = "registry.jdbc.user";
- private static final String REGISTRY_DB_PASSWORD = "registry.jdbc.password";
- private static final String REGISTRY_DB_DRIVER = "registry.jdbc.driver";
- private static final String ENABLE_HTTPS = "enable.https";
- private static final String HOST_SCHEDULER = "host.scheduler";
- private static final String MY_PROXY_SERVER = "myproxy.server";
- private static final String MY_PROXY_USER = "myproxy.user";
- private static final String MY_PROXY_PASSWORD = "myproxy.password";
- private static final String MY_PROXY_LIFETIME = "myproxy.life";
- private static final String STATUS_PUBLISHER = "status.publisher";
- private static final String TASK_LAUNCH_PUBLISHER = "task.launch.publisher";
- private static final String ACTIVITY_LISTENERS = "activity.listeners";
- public static final String JOB_NOTIFICATION_ENABLE = "job.notification.enable";
- public static final String JOB_NOTIFICATION_EMAILIDS = "job.notification.emailids";
- public static final String JOB_NOTIFICATION_FLAGS = "job.notification.flags";
- public static final String GFAC_PASSIVE = "gfac.passive"; // by default this is desabled
- public static final String LAUNCH_QUEUE_NAME = "launch.queue.name";
- public static final String CANCEL_QUEUE_NAME = "cancel.queue.name";
-
-
- // Workflow Enactment Service component configuration.
- private static final String ENACTMENT_THREAD_POOL_SIZE = "enactment.thread.pool.size";
- private static final int DEFAULT_ENACTMENT_THREAD_POOL_SIZE = 10;
- private static final String WORKFLOW_PARSER = "workflow.parser";
-
- // email based monitoring configurations
- private static final String EMAIL_BASED_MONITORING_PERIOD = "email.based.monitoring.period";
- private static final String EMAIL_BASED_MONITOR_HOST = "email.based.monitor.host";
- private static final String EMAIL_BASED_MONITOR_ADDRESS = "email.based.monitor.address";
- private static final String EMAIL_BASED_MONITOR_PASSWORD = "email.based.monitor.password";
- private static final String EMAIL_BASED_MONITOR_FOLDER_NAME = "email.based.monitor.folder.name";
- private static final String EMAIL_BASED_MONITOR_STORE_PROTOCOL = "email.based.monitor.store.protocol";
- private static final String ENABLE_EMAIL_BASED_MONITORING = "enable.email.based.monitoring";
-
- private static boolean stopAllThreads = false;
- private static boolean emailBaseNotificationEnable;
-
- public static String getDefaultUser() throws ApplicationSettingsException {
- return getSetting(DEFAULT_USER);
- }
-
- public static String getLaunchQueueName() {
- return getSetting(LAUNCH_QUEUE_NAME, "launch.queue");
- }
-
-
- public static String getCancelQueueName() {
- return getSetting(CANCEL_QUEUE_NAME, "cancel.queue");
- }
-
- public static String getDefaultUserPassword() throws ApplicationSettingsException {
- return getSetting(DEFAULT_USER_PASSWORD);
- }
-
- public static String getDefaultUserGateway() throws ApplicationSettingsException {
- return getSetting(DEFAULT_USER_GATEWAY);
- }
-
- public static String getServerContextRoot() {
- return getSetting(SERVER_CONTEXT_ROOT, "axis2");
- }
-
- public static String getCredentialStoreDBUser() throws ApplicationSettingsException {
- try {
- return getSetting(CREDENTIAL_STORE_DB_USER);
- } catch (ApplicationSettingsException e) {
- return getSetting(REGISTRY_DB_USER);
- }
- }
-
- public static String getCredentialStoreDBPassword() throws ApplicationSettingsException {
- try {
- return getSetting(CREDENTIAL_STORE_DB_PASSWORD);
- } catch (ApplicationSettingsException e) {
- return getSetting(REGISTRY_DB_PASSWORD);
- }
- }
-
- public static String getCredentialStoreDBDriver() throws ApplicationSettingsException {
- try {
- return getSetting(CREDENTIAL_STORE_DB_DRIVER);
- } catch (ApplicationSettingsException e) {
- return getSetting(REGISTRY_DB_DRIVER);
- }
- }
-
- public static String getCredentialStoreDBURL() throws ApplicationSettingsException {
- try {
- return getSetting(CREDENTIAL_STORE_DB_URL);
- } catch (ApplicationSettingsException e) {
- return getSetting(REGISTRY_DB_URL);
- }
-
- }
-
- public static boolean isEnableHttps() {
- try {
- return Boolean.parseBoolean(getSetting(ENABLE_HTTPS));
- } catch (ApplicationSettingsException e) {
- return false;
- }
- }
-
-
- public static String getHostScheduler() throws ApplicationSettingsException {
- return getSetting(HOST_SCHEDULER);
- }
-
- public static boolean isStopAllThreads() {
- return stopAllThreads;
- }
-
- public static void setStopAllThreads(boolean stopAllThreads) {
- ServerSettings.stopAllThreads = stopAllThreads;
- }
-
- public static String getMyProxyServer() throws ApplicationSettingsException {
- return getSetting(MY_PROXY_SERVER);
- }
-
- public static String getMyProxyUser() throws ApplicationSettingsException {
- return getSetting(MY_PROXY_USER);
- }
-
- public static String getMyProxyPassword() throws ApplicationSettingsException {
- return getSetting(MY_PROXY_PASSWORD);
- }
-
- public static int getMyProxyLifetime() throws ApplicationSettingsException {
- return Integer.parseInt(getSetting(MY_PROXY_LIFETIME));
- }
-
- public static String[] getActivityListeners() throws ApplicationSettingsException {
- return getSetting(ACTIVITY_LISTENERS).split(",");
- }
-
- public static String getStatusPublisher() throws ApplicationSettingsException {
- return getSetting(STATUS_PUBLISHER);
- }
-
- public static String getTaskLaunchPublisher() throws ApplicationSettingsException {
- return getSetting(TASK_LAUNCH_PUBLISHER);
- }
-
- public static boolean isGFacPassiveMode()throws ApplicationSettingsException {
- String setting = getSetting(GFAC_PASSIVE);
- return Boolean.parseBoolean(setting);
- }
-
- public static boolean isEmbeddedZK() {
- return Boolean.parseBoolean(getSetting(EMBEDDED_ZK, "true"));
- }
-
- public static String getIp() {
- try {
- return getSetting(IP);
- } catch (ApplicationSettingsException e) {
- try {
- return InetAddress.getLocalHost().getHostAddress();
- } catch (UnknownHostException e1) {
- e1.printStackTrace();
- }
- }
- return null;
- }
-
- public static int getEnactmentThreadPoolSize() {
- String threadPoolSize = null;
- try {
- threadPoolSize = getSetting(ENACTMENT_THREAD_POOL_SIZE);
- } catch (ApplicationSettingsException e) {
- return DEFAULT_ENACTMENT_THREAD_POOL_SIZE;
- }
- return Integer.valueOf(threadPoolSize);
- }
-
- public static String getWorkflowParser() throws ApplicationSettingsException {
- return getSetting(WORKFLOW_PARSER);
- }
-
-
- public static int getEmailMonitorPeriod() throws ApplicationSettingsException {
- return Integer.valueOf(getSetting(EMAIL_BASED_MONITORING_PERIOD, "100000"));
-
- }
-
- public static String getEmailBasedMonitorHost() throws ApplicationSettingsException {
- return getSetting(EMAIL_BASED_MONITOR_HOST);
- }
-
- public static String getEmailBasedMonitorAddress() throws ApplicationSettingsException {
- return getSetting(EMAIL_BASED_MONITOR_ADDRESS);
- }
-
- public static String getEmailBasedMonitorPassword() throws ApplicationSettingsException {
- return getSetting(EMAIL_BASED_MONITOR_PASSWORD);
- }
-
- public static String getEmailBasedMonitorFolderName() throws ApplicationSettingsException {
- return getSetting(EMAIL_BASED_MONITOR_FOLDER_NAME);
- }
-
- public static String getEmailBasedMonitorStoreProtocol() throws ApplicationSettingsException {
- return getSetting(EMAIL_BASED_MONITOR_STORE_PROTOCOL);
- }
-
- public static boolean isEmailBasedNotificationEnable() {
- return Boolean.valueOf(getSetting(ENABLE_EMAIL_BASED_MONITORING, "false"));
- }
-
- public static boolean isAPISecured() throws ApplicationSettingsException {
- return Boolean.valueOf(getSetting(Constants.IS_API_SECURED));
- }
-
- public static String getRemoteOauthServerUrl() throws ApplicationSettingsException {
- return getSetting(Constants.REMOTE_OAUTH_SERVER_URL);
- }
-
- public static String getAdminUsername() throws ApplicationSettingsException {
- return getSetting(Constants.ADMIN_USERNAME);
- }
-
- public static String getAdminPassword() throws ApplicationSettingsException {
- return getSetting(Constants.ADMIN_PASSWORD);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java
deleted file mode 100644
index 0c54053..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java
+++ /dev/null
@@ -1,93 +0,0 @@
-///*
-// *
-// * Licensed to the Apache Software Foundation (ASF) under one
-// * or more contributor license agreements. See the NOTICE file
-// * distributed with this work for additional information
-// * regarding copyright ownership. The ASF licenses this file
-// * to you under the Apache License, Version 2.0 (the
-// * "License"); you may not use this file except in compliance
-// * with the License. You may obtain a copy of the License at
-// *
-// * http://www.apache.org/licenses/LICENSE-2.0
-// *
-// * Unless required by applicable law or agreed to in writing,
-// * software distributed under the License is distributed on an
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// * KIND, either express or implied. See the License for the
-// * specific language governing permissions and limitations
-// * under the License.
-// *
-// */
-//
-//package org.apache.airavata.common.utils;
-//
-//import java.io.IOException;
-//import java.net.SocketException;
-//
-//import org.apache.airavata.common.exception.ApplicationSettingsException;
-//import org.apache.axis2.context.ConfigurationContext;
-//import org.apache.axis2.description.TransportInDescription;
-//import org.apache.axis2.util.Utils;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
-//
-//public class ServiceUtils {
-// private static final Logger log = LoggerFactory.getLogger(ServiceUtils.class);
-//// private static final String REPOSITORY_PROPERTIES = "airavata-server.properties";
-// public static final String IP = "ip";
-// public static final String PORT = "port";
-//
-// public static String generateServiceURLFromConfigurationContext(
-// ConfigurationContext context, String serviceName) throws IOException, ApplicationSettingsException {
-//// URL url = ServiceUtils.class.getClassLoader()
-//// .getResource(REPOSITORY_PROPERTIES);
-// String localAddress = null;
-// String port = null;
-//// Properties properties = new Properties();
-// try {
-// localAddress = ServerSettings.getSetting(IP);
-// } catch (ApplicationSettingsException e) {
-// //we will ignore this exception since the properties file will not contain the values
-// //when it is ok to retrieve them from the axis2 context
-// }
-// if(localAddress == null){
-// try {
-// localAddress = Utils.getIpAddress(context
-// .getAxisConfiguration());
-// } catch (SocketException e) {
-// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
-// }
-// }
-// String protocol="http";
-// if(ServerSettings.isEnableHttps()){
-// protocol="https";
-// }
-//
-// try {
-// port = ServerSettings.getTomcatPort(protocol);
-// } catch (ApplicationSettingsException e) {
-// //we will ignore this exception since the properties file will not contain the values
-// //when it is ok to retrieve them from the axis2 context
-// }
-// if (port == null) {
-// TransportInDescription transportInDescription = context
-// .getAxisConfiguration().getTransportsIn()
-// .get(protocol);
-// if (transportInDescription != null
-// && transportInDescription.getParameter(PORT) != null) {
-// port = (String) transportInDescription
-// .getParameter(PORT).getValue();
-// }
-// }
-// localAddress = protocol+"://" + localAddress + ":" + port;
-// localAddress = localAddress + "/"
-// //We are not using axis2 config context to get the context root because it is invalid
-// //+ context.getContextRoot() + "/"
-// //FIXME: the context root will be correct after updating the web.xml
-// + ServerSettings.getServerContextRoot() + "/"
-// + context.getServicePath() + "/"
-// + serviceName;
-// log.debug("Service Address Configured:" + localAddress);
-// return localAddress;
-// }
-//}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/StringUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/StringUtil.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/StringUtil.java
deleted file mode 100644
index 3ce5cda..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/StringUtil.java
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.utils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
-
-public class StringUtil {
- public static final String DELIMETER=",";
- public static final String QUOTE="\"";
-
- public static Map<Integer, String> getContainedParameters(String s) {
- Map<Integer,String> parameterMap=new HashMap<Integer,String>();
- int i=0;
- for(i=0;i<s.length();i++){
- if (s.charAt(i)=='$' && (i+1)<s.length() && s.charAt(i+1)=='{'){
- int i2=s.indexOf('{', i+2);
- int e=s.indexOf('}', i+2);
- if (e!=-1){
- if (i2==-1 || e<i2){
- parameterMap.put(i, s.substring(i,e+1));
- i=e;
- }
- }
- }
- }
- return parameterMap;
- }
-
- // Merits for the following function should go to
- // http://blog.houen.net/java-get-url-from-string/
- public static List<String> getURLS(String text) {
- List<String> links = new ArrayList<String>();
- String regex = "\\(?\\b((http|https|ftp)://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]";
- Pattern p = Pattern.compile(regex);
- Matcher m = p.matcher(text);
- while (m.find()) {
- String urlStr = m.group();
- if (urlStr.startsWith("(") && urlStr.endsWith(")")) {
- urlStr = urlStr.substring(1, urlStr.length() - 1);
- }
- if (!links.contains(urlStr)) {
- links.add(urlStr);
- }
- }
- return links;
- }
-
- public static String createHTMLUrlTaggedString2(String value, List<String> pullLinks) {
- for (String url : pullLinks) {
- String hyperlinkString="<a href='"+url+"'>"+url+"</a>";
- value=value.replaceAll(Pattern.quote(url), hyperlinkString);
- }
- return value;
- }
- public static String createHTMLUrlTaggedString(String value) {
- String urledString = "";
- int lastIndex=0,index=0;
- while(index!=-1){
- index=value.toLowerCase().indexOf("://",lastIndex);
- if (index!=-1){
- int beginIndex=value.lastIndexOf(" ",index);
- urledString+=value.substring(lastIndex,beginIndex+1);
- int endIndex=value.indexOf(" ",index);
- if (beginIndex==-1){
- beginIndex=0;
- }else{
- beginIndex++;
- }
- if (endIndex==-1){
- endIndex=value.length();
- }
- String url=value.substring(beginIndex, endIndex);
- urledString+="<a href='"+url+"'>"+url+"</a>";
- lastIndex=endIndex;
- }
- }
- urledString+=value.substring(lastIndex, value.length());
- return urledString;
- }
-
- private static boolean isQuoted(String s, String delimiter){
- //Check if we need quotes
- if (s.contains(delimiter)){
- //Check if its already quoted
- s=s.replaceAll("\"\"", "");
- return (s.substring(0,1).equals(QUOTE) && s.subSequence(s.length()-1, s.length()).equals(QUOTE));
- }
- //no delimiters present, so already in proper form
- return true;
- }
-
- private static boolean isQuoted(String s){
- return isQuoted(s, DELIMETER);
- }
-
- /**
- * Create a delimiter separated string out of a list
- * @param list
- * @return
- */
- public static String createDelimiteredString(String[] list) {
- return createDelimiteredString(list, DELIMETER);
- }
-
-
- /**
- * Create a delimiter separated string out of a list
- * @param list
- * @return
- */
- public static String createDelimiteredString(String[] list,String delimiter){
- String s=null;
- for (String ss : list) {
- ss=quoteString(ss, delimiter);
- if (s==null){
- s=ss;
- }else{
- s+=delimiter +ss;
- }
- }
- return s;
- }
-
- /**
- * Return a proper quoted string if the string contains the delimiter character
- * @param s
- * @return
- */
- public static String quoteString(String s) {
- return quoteString(s, DELIMETER);
- }
-
-
- /**
- * Return a proper quoted string if the string contains the delimiter character
- * @param s
- * @return
- */
- public static String quoteString(String s,String delimiter){
- if (isQuoted(s,delimiter)){
- return s;
- }else{
- return QUOTE+s.replaceAll(QUOTE, QUOTE+QUOTE)+QUOTE;
- }
- }
-
- /**
- * Parse the delimitered string and return elements as a string array
- * @param s
- * @return
- */
- public static String[] getElementsFromString(String s, String delimeter, String quote) {
- List<String> list=new ArrayList<String>();
- String currentItem="";
- String previousChar=null;
- boolean insideQuote=false;
- for(int i=0;i<s.length();i++){
- String c=s.substring(i,i+1);
- if (c.equals(delimeter)){
- //if not inside a quoted string ignore the delimiter character
- if (insideQuote) {
- currentItem+=c;
- }else{
- list.add(currentItem);
- currentItem = "";
- }
- }else if (c.equals(quote)){
- if (quote.equals(previousChar)){
- //which means previousChar was an escape character, not a quote for the string
- currentItem+=quote;
- if (insideQuote){
- //mistakenly thought previous char was opening quote char, thus need to make this false
- insideQuote=false;
- }else{
- //mistakenly thought previous char was closing quote char, thus need to make this true
- insideQuote=true;
- }
- } else{
- if (insideQuote){
- //quote ended
- insideQuote=false;
- }else{
- //quote beginning
- insideQuote=true;
- }
- }
- }else{
- currentItem+=c;
- }
- previousChar=c;
- }
- list.add(currentItem);
- return list.toArray(new String[]{});
- }
-
- /**
- * Parse the delimitered string and return elements as a string array
- * @param s
- * @return
- */
- public static String[] getElementsFromString(String s) {
- return getElementsFromString(s, DELIMETER, QUOTE);
- }
-
- /**
- * Converts object to String without worrying about null check.
- *
- * @param object
- * @return The object.toString if object is not null; "" otherwise.
- */
- public static String toString(Object object) {
- if (object == null) {
- return "";
- } else {
- return object.toString();
- }
- }
-
- /**
- * Trims a specified string, and makes it null if the result is empty string.
- *
- * @param string
- * @return the string processed
- */
- public static String trimAndNullify(String string) {
- if (string != null) {
- string = string.trim();
- if (string.equals("")) {
- string = null;
- }
- }
- return string;
- }
-
- /**
- * @param oldName
- * @return Trimmed String
- */
- public static String trimSpaceInString(String oldName) {
- if (oldName == null) {
- return "";
- }
- return oldName.replace(" ", "");
- }
-
- /**
- * Converts a specified string to a Java identifier.
- *
- * @param name
- * @return the Java identifier
- */
- public static String convertToJavaIdentifier(String name) {
-
- final char REPLACE_CHAR = '_';
-
- if (name == null || name.length() == 0) {
- return "" + REPLACE_CHAR;
- }
-
- StringBuilder buf = new StringBuilder();
-
- char c = name.charAt(0);
- if (!Character.isJavaIdentifierStart(c)) {
- // Add _ at the beggining instead of replacing it to _. This is
- // more readable if the name is like 3D_Model.
- buf.append(REPLACE_CHAR);
- }
-
- for (int i = 0; i < name.length(); i++) {
- c = name.charAt(i);
- if (Character.isJavaIdentifierPart(c)) {
- buf.append(c);
- } else {
- buf.append(REPLACE_CHAR);
- }
- }
-
- return buf.toString();
- }
-
- /**
- * Creates a new name by incrementing the number after the underscore at the end of the old name. If there is no
- * underscore and number at the end, put "_2" at the end.
- *
- * @param oldName
- * @return the new name
- */
- public static String incrementName(String oldName) {
-
- final char PREFIX = '_';
-
- String newName;
- if (oldName == null || oldName.length() == 0) {
- newName = "noName";
- } else {
- int lastDashIndex = oldName.lastIndexOf(PREFIX);
- if (lastDashIndex < 0) {
- newName = oldName + PREFIX + 2;
- } else {
- String suffix = oldName.substring(lastDashIndex + 1);
- try {
- int number = Integer.parseInt(suffix);
- int newNumber = number + 1;
- newName = oldName.substring(0, lastDashIndex + 1) + newNumber;
- } catch (RuntimeException e) {
- // It was not a number
- newName = oldName + PREFIX + 2;
- }
- }
- }
- return newName;
- }
-
- /**
- * Returns the local class name of a specified class.
- *
- * @param klass
- * The specified class
- * @return The local class name
- */
- public static String getClassName(Class klass) {
- String fullName = klass.getName();
- int index = fullName.lastIndexOf(".");
- if (index < 0) {
- return fullName;
- } else {
- return fullName.substring(index + 1);
- }
- }
-
- /**
- * @param throwable
- * @return The stackTrace in String
- */
- public static String getStackTraceInString(Throwable throwable) {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- PrintStream printStream = new PrintStream(byteArrayOutputStream);
- throwable.printStackTrace(printStream);
- printStream.flush();
- return byteArrayOutputStream.toString();
- }
-
- private static Options deriveCommandLineOptions(String[] args){
- Options options = new Options();
- String[] argCopy = getChangedList(args);
- int i=0;
- for (String arg : argCopy) {
- if (arg.startsWith("--")){
- arg=arg.substring(2);
- int pos = arg.indexOf('=');
- String opt;
- boolean hasArgs=true;
- if (pos==-1){ //if not of the form --arg=value
- if (i==argCopy.length-1 || argCopy[i+1].startsWith("-")){ // no value specified
- hasArgs=false;
- }
- opt=arg;
- }else{
- opt=arg.substring(0, pos);
- }
- options.addOption(opt, hasArgs, "");
- }
- i++;
- }
- return options;
- }
-
- public static Map<String, String> parseCommandLineOptions(String[] args) {
- Map<String,String> commandLineOptions=new HashMap<String,String>();
- try {
- CommandLineParameters cmdParameters = getCommandLineParser(args);
- Map<String, String> parameters = cmdParameters.getParameters();
- for (String s : parameters.keySet()) {
- commandLineOptions.put(s, parameters.get(s)==null? "":parameters.get(s));
- }
- } catch (ParseException e1) {
- e1.printStackTrace();
- }
- return commandLineOptions;
- }
-
- public static CommandLineParameters getCommandLineParser(String[] args)
- throws ParseException {
- String[] argCopy = getChangedList(args);
- CommandLineParser parser = new DynamicOptionPosixParser();
- CommandLine cmdLine = parser.parse(deriveCommandLineOptions(argCopy), argCopy);
- return new CommandLineParameters(cmdLine);
- }
-
-
- //commons-cli does not support arg names having the period (".")
- private static final String ARG_DOT_REPLACE="dot_replacement_value";
-
- private static String[] getChangedList(String[] args) {
- String[] argCopy = Arrays.asList(args).toArray(new String []{});
- for (int i=0;i<argCopy.length; i++) {
- argCopy[i]=changeOption(argCopy[i]);
- }
- return argCopy;
- }
-
- private static String revertOption(String option){
- return option==null? option : option.replaceAll(Pattern.quote(ARG_DOT_REPLACE), ".");
- }
-
- private static String changeOption(String option){
- return option==null? option : option.replaceAll(Pattern.quote("."), ARG_DOT_REPLACE);
- }
-
- private static class DynamicOptionPosixParser extends PosixParser{
- @Override
- protected void processOption(String arg0, @SuppressWarnings("rawtypes") ListIterator arg1)
- throws ParseException {
- if (getOptions().hasOption(arg0)){
- super.processOption(arg0, arg1);
- }
- }
- }
-
- public static class CommandLineParameters{
- private Map<String,String> parameters=new HashMap<String, String>();
- private List<String> arguments=new ArrayList<String>();
- protected CommandLineParameters(CommandLine cmd){
- for(Option opt:cmd.getOptions()){
- parameters.put(revertOption(opt.getOpt()), revertOption(opt.getValue()));
- }
- for(String arg:cmd.getArgs()){
- arguments.add(revertOption(arg));
- }
- }
- public List<String> getArguments() {
- return arguments;
- }
- public void setArguments(List<String> arguments) {
- this.arguments = arguments;
- }
- public Map<String,String> getParameters() {
- return parameters;
- }
- public void setParameters(Map<String,String> parameters) {
- this.parameters = parameters;
- }
- }
-
-}
\ No newline at end of file
[7/8] airavata git commit: moved commons-utils to commons module
Posted by sh...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java
new file mode 100644
index 0000000..f753bc1
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java
@@ -0,0 +1,205 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.common.utils;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.ServerCnxnFactory;
+import org.apache.zookeeper.server.ServerConfig;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
+import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.ByteBuffer;
+
+public class AiravataZKUtils implements Watcher {
+ private final static Logger logger = LoggerFactory.getLogger(AiravataZKUtils.class);
+
+ public static final String ZK_EXPERIMENT_STATE_NODE = "state";
+ public static final String DELIVERY_TAG_POSTFIX = "-deliveryTag";
+ public static final String CANCEL_DELIVERY_TAG_POSTFIX = "-cancel-deliveryTag";
+
+ @Override
+ public void process(WatchedEvent event) {
+
+ }
+
+ public static String getExpZnodePath(String experimentId) throws ApplicationSettingsException {
+ return ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE) +
+ File.separator +
+ ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NAME) + File.separator
+ + experimentId;
+ }
+
+ public static String getExpZnodeHandlerPath(String experimentId, String className) throws ApplicationSettingsException {
+ return ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE) +
+ File.separator +
+ ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NAME) + File.separator
+ + experimentId + File.separator + className;
+ }
+
+ public static String getZKhostPort() throws ApplicationSettingsException {
+ return ServerSettings.getSetting(Constants.ZOOKEEPER_SERVER_HOST,"localhost")
+ + ":" + ServerSettings.getSetting(Constants.ZOOKEEPER_SERVER_PORT,"2181");
+ }
+
+ public static int getZKTimeout()throws ApplicationSettingsException {
+ return Integer.parseInt(ServerSettings.getSetting(Constants.ZOOKEEPER_TIMEOUT,"30000"));
+ }
+
+ public static String getExpStatePath(String experimentId) throws ApplicationSettingsException {
+ return AiravataZKUtils.getExpZnodePath(experimentId) +
+ File.separator +
+ "state";
+ }
+
+ public static String getExpState(CuratorFramework curatorClient, String expId) throws Exception {
+ Stat exists = curatorClient.checkExists().forPath(getExpStatePath(expId));
+ if (exists != null) {
+ return new String(curatorClient.getData().storingStatIn(exists).forPath(getExpStatePath(expId)));
+ }
+ return null;
+ }
+
+ public static void runZKFromConfig(ServerConfig config,ServerCnxnFactory cnxnFactory) throws IOException {
+ AiravataZKUtils.logger.info("Starting Zookeeper server...");
+ FileTxnSnapLog txnLog = null;
+ try {
+ // Note that this thread isn't going to be doing anything else,
+ // so rather than spawning another thread, we will just call
+ // run() in this thread.
+ // create a file logger url from the command line args
+ ZooKeeperServer zkServer = new ZooKeeperServer();
+
+ txnLog = new FileTxnSnapLog(new File(config.getDataDir()), new File(
+ config.getDataDir()));
+ zkServer.setTxnLogFactory(txnLog);
+ zkServer.setTickTime(config.getTickTime());
+ zkServer.setMinSessionTimeout(config.getMinSessionTimeout());
+ zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
+ cnxnFactory = ServerCnxnFactory.createFactory();
+ cnxnFactory.configure(config.getClientPortAddress(),
+ config.getMaxClientCnxns());
+ cnxnFactory.startup(zkServer);
+ cnxnFactory.join();
+ if (zkServer.isRunning()) {
+ zkServer.shutdown();
+ }
+ } catch (InterruptedException e) {
+ // warn, but generally this is ok
+ AiravataZKUtils.logger.warn("Server interrupted", e);
+ System.exit(1);
+ } finally {
+ if (txnLog != null) {
+ txnLog.close();
+ }
+ }
+ }
+
+ public static void startEmbeddedZK(ServerCnxnFactory cnxnFactory) {
+ if (ServerSettings.isEmbeddedZK()) {
+ ServerConfig serverConfig = new ServerConfig();
+ URL resource = AiravataZKUtils.class.getClassLoader().getResource("zoo.cfg");
+ if (resource == null) {
+ logger.error("There is no zoo.cfg file in the classpath... Failed to start Zookeeper Server");
+ System.exit(1);
+ }
+ try {
+ serverConfig.parse(resource.getPath());
+ } catch (QuorumPeerConfig.ConfigException e) {
+ logger.error("Error while starting embedded Zookeeper", e);
+ System.exit(2);
+ }
+
+ final ServerConfig fServerConfig = serverConfig;
+ final ServerCnxnFactory fserverCnxnFactory = cnxnFactory;
+ (new Thread() {
+ public void run() {
+ try {
+ AiravataZKUtils.runZKFromConfig(fServerConfig,fserverCnxnFactory);
+ } catch (IOException e) {
+ logger.error("Error while starting embedded Zookeeper", e);
+ System.exit(3);
+ }
+ }
+ }).start();
+ }else{
+ logger.info("Skipping Zookeeper embedded startup ...");
+ }
+ }
+
+ public static byte[] toByteArray(double value) {
+ byte[] bytes = new byte[8];
+ ByteBuffer.wrap(bytes).putDouble(value);
+ return bytes;
+ }
+
+ public static long getDeliveryTag(String experimentID, CuratorFramework curatorClient, String experimentNode,
+ String pickedChild) throws Exception {
+ String deliveryTagPath = experimentNode + File.separator + pickedChild + File.separator + experimentID
+ + DELIVERY_TAG_POSTFIX;
+ Stat exists = curatorClient.checkExists().forPath(deliveryTagPath);
+ if(exists==null) {
+ logger.error("Cannot find delivery Tag in path:" + deliveryTagPath + " for this experiment");
+ return -1;
+ }
+ return bytesToLong(curatorClient.getData().storingStatIn(exists).forPath(deliveryTagPath));
+ }
+ public static byte[] longToBytes(long x) {
+ ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);
+ buffer.putLong(x);
+ return buffer.array();
+ }
+
+ public static long bytesToLong(byte[] bytes) {
+ ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);
+ buffer.put(bytes);
+ buffer.flip();//need flip
+ return buffer.getLong();
+ }
+
+ public static double toDouble(byte[] bytes) {
+ return ByteBuffer.wrap(bytes).getDouble();
+ }
+
+ public static long getCancelDeliveryTagIfExist(String experimentId, CuratorFramework curatorClient,
+ String experimentNode, String pickedChild) throws Exception {
+
+ String cancelDeliveryTagPath = experimentNode + File.separator + pickedChild + File.separator + experimentId +
+ AiravataZKUtils.CANCEL_DELIVERY_TAG_POSTFIX;
+ Stat exists = curatorClient.checkExists().forPath(cancelDeliveryTagPath);
+ if (exists == null) {
+ return -1; // no cancel deliverytag found
+ } else {
+ return bytesToLong(curatorClient.getData().storingStatIn(exists).forPath(cancelDeliveryTagPath));
+ }
+
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
new file mode 100644
index 0000000..9a59573
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
@@ -0,0 +1,444 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.exception.ApplicationSettingsLoadException;
+import org.apache.airavata.common.exception.ApplicationSettingsStoreException;
+import org.apache.airavata.common.exception.UnspecifiedApplicationSettingsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ApplicationSettings {
+ public static final String SERVER_PROPERTIES="airavata-server.properties";
+
+ public static String ADDITIONAL_SETTINGS_FILES = "external.settings";
+
+ protected Properties properties = new Properties();
+ private Exception propertyLoadException;
+
+
+ protected static final String TRUST_STORE_PATH="trust.store";
+ protected static final String TRUST_STORE_PASSWORD="trust.store.password";
+
+ private static final String REGULAR_EXPRESSION = "\\$\\{[a-zA-Z.-]*\\}";
+
+ private final static Logger logger = LoggerFactory.getLogger(ApplicationSettings.class);
+
+ private static final String SHUTDOWN_STATEGY_STRING="shutdown.strategy";
+
+ protected static ApplicationSettings INSTANCE;
+ public static enum ShutdownStrategy{
+ NONE,
+ SELF_TERMINATE
+ }
+ {
+ loadProperties();
+ }
+
+ private void loadProperties() {
+ URL url = getPropertyFileURL();
+ try {
+
+ properties.load(url.openStream());
+ logger.info("Settings loaded from "+url.toString());
+ URL[] externalSettingsFileURLs = getExternalSettingsFileURLs();
+ for (URL externalSettings : externalSettingsFileURLs) {
+ mergeSettingsImpl(externalSettings.openStream());
+ logger.info("External settings merged from "+url.toString());
+ }
+ } catch (Exception e) {
+ propertyLoadException=e;
+ }
+ }
+
+ protected URL getPropertyFileURL() {
+ return ApplicationSettings.class.getClassLoader().getResource(SERVER_PROPERTIES);
+ }
+
+ protected URL[] getExternalSettingsFileURLs(){
+ try {
+ List<URL> externalSettingsFileURLs=new ArrayList<URL>();
+ String externalSettingsFileNames = getSettingImpl(ADDITIONAL_SETTINGS_FILES);
+ String[] externalSettingFiles = externalSettingsFileNames.split(",");
+ for (String externalSettingFile : externalSettingFiles) {
+ URL externalSettingFileURL = ApplicationSettings.class.getClassLoader().getResource(externalSettingFile);
+ if (externalSettingFileURL==null){
+ logger.warn("Could not file external settings file "+externalSettingFile);
+ }else{
+ externalSettingsFileURLs.add(externalSettingFileURL);
+ }
+ }
+ return externalSettingsFileURLs.toArray(new URL[]{});
+ } catch (ApplicationSettingsException e) {
+ return new URL[]{};
+ }
+ }
+ protected static ApplicationSettings getInstance(){
+ if (INSTANCE==null){
+ INSTANCE=new ApplicationSettings();
+ }
+ return INSTANCE;
+ }
+
+ protected static void setInstance(ApplicationSettings settingsInstance){
+ INSTANCE=settingsInstance;
+ }
+
+ private void saveProperties() throws ApplicationSettingsStoreException{
+ URL url = getPropertyFileURL();
+ if (url.getProtocol().equalsIgnoreCase("file")){
+ try {
+ properties.store(new FileOutputStream(url.getPath()), Calendar.getInstance().toString());
+ } catch (Exception e) {
+ throw new ApplicationSettingsStoreException(url.getPath(), e);
+ }
+ }else{
+ logger.warn("Properties cannot be updated to location "+url.toString());
+ }
+ }
+
+ private void validateSuccessfulPropertyFileLoad() throws ApplicationSettingsException{
+ if (propertyLoadException!=null){
+ throw new ApplicationSettingsLoadException(propertyLoadException);
+ }
+ }
+
+ /**
+ * Returns the configuration value relevant for the given key.
+ * If configuration value contains references to other configuration values they will also
+ * be replaced. E.g :- If configuration key reads http://${ip}:${port}/axis2/services/RegistryService?wsdl,
+ * the variables ip and port will get replaced by their appropriated values in the configuration.
+ * @param key The configuration key to read value of
+ * @return The configuration value. For above example caller will get a value like
+ * http://192.2.33.12:8080/axis2/services/RegistryService?wsdl
+ * @throws ApplicationSettingsException If an error occurred while reading configurations.
+ * @deprecated use #getSetting(String) instead
+ */
+ public String getAbsoluteSetting(String key) throws ApplicationSettingsException {
+
+ String configurationValueWithVariables = ApplicationSettings.getSetting(key);
+
+ List<String> variableList
+ = getAllMatches(configurationValueWithVariables, REGULAR_EXPRESSION);
+
+ if (variableList == null || variableList.isEmpty()) {
+ return configurationValueWithVariables;
+ }
+
+ for(String variableIdentifier : variableList) {
+ String variableName = getVariableNameOnly(variableIdentifier);
+ String value = getAbsoluteSetting(variableName);
+
+ configurationValueWithVariables = configurationValueWithVariables.replace(variableIdentifier, value);
+ }
+
+ return configurationValueWithVariables;
+
+ }
+
+ private static String getVariableNameOnly(String variableWithIdentifiers) {
+ return variableWithIdentifiers.substring(2, (variableWithIdentifiers.length() - 1));
+ }
+
+ private static List<String> getAllMatches(String text, String regex) {
+ List<String> matches = new ArrayList<String>();
+ Matcher m = Pattern.compile("(?=(" + regex + "))").matcher(text);
+ while(m.find()) {
+ matches.add(m.group(1));
+ }
+ return matches;
+ }
+
+ public String getSettingImpl(String key) throws ApplicationSettingsException{
+ String rawValue=null;
+ if (System.getProperties().containsKey(key)){
+ rawValue=System.getProperties().getProperty(key);
+ }else{
+ validateSuccessfulPropertyFileLoad();
+ if (properties.containsKey(key)){
+ rawValue=properties.getProperty(key);
+ }else{
+ throw new UnspecifiedApplicationSettingsException(key);
+ }
+ }
+ return deriveAbsoluteValueImpl(rawValue);
+ }
+
+ public String getSettingImpl(String key, String defaultValue){
+ try {
+ return getSettingImpl(key);
+ } catch (ApplicationSettingsException e) {
+ //we'll ignore this error since a default value is provided
+ }
+ return defaultValue;
+ }
+
+ private String deriveAbsoluteValueImpl(String property){
+ if (property!=null){
+ Map<Integer, String> containedParameters = StringUtil.getContainedParameters(property);
+ List<String> parametersAlreadyProcessed=new ArrayList<String>();
+ for (String parameter : containedParameters.values()) {
+ if (!parametersAlreadyProcessed.contains(parameter)) {
+ String parameterName = parameter.substring(2,parameter.length() - 1);
+ String parameterValue = getSetting(parameterName,parameter);
+ property = property.replaceAll(Pattern.quote(parameter), parameterValue);
+ parametersAlreadyProcessed.add(parameter);
+ }
+ }
+ }
+ return property;
+ }
+
+ public void setSettingImpl(String key, String value) throws ApplicationSettingsException{
+ properties.setProperty(key, value);
+ saveProperties();
+ }
+
+ public boolean isSettingDefinedImpl(String key) throws ApplicationSettingsException{
+ validateSuccessfulPropertyFileLoad();
+ return properties.containsKey(key);
+ }
+
+ public String getTrustStorePathImpl() throws ApplicationSettingsException {
+ return getSetting(TRUST_STORE_PATH);
+ }
+
+ public String getTrustStorePasswordImpl() throws ApplicationSettingsException {
+ return getSetting(TRUST_STORE_PASSWORD);
+ }
+
+ public String getCredentialStoreKeyStorePathImpl() throws ApplicationSettingsException {
+ return getSetting("credential.store.keystore.url");
+ }
+
+ public String getCredentialStoreKeyAliasImpl() throws ApplicationSettingsException {
+ return getSetting("credential.store.keystore.alias");
+ }
+
+ public String getCredentialStoreKeyStorePasswordImpl() throws ApplicationSettingsException {
+ return getSetting("credential.store.keystore.password");
+ }
+
+ public String getCredentialStoreNotifierEnabledImpl() throws ApplicationSettingsException {
+ return getSetting("notifier.enabled");
+ }
+
+ public String getCredentialStoreNotifierDurationImpl() throws ApplicationSettingsException {
+ return getSetting("notifier.duration");
+ }
+
+ public String getCredentialStoreEmailServerImpl() throws ApplicationSettingsException {
+ return getSetting("email.server");
+ }
+
+ public String getCredentialStoreEmailServerPortImpl() throws ApplicationSettingsException {
+ return getSetting("email.server.port");
+ }
+
+ public String getCredentialStoreEmailUserImpl() throws ApplicationSettingsException {
+ return getSetting("email.user");
+ }
+
+ public String getCredentialStoreEmailPasswordImpl() throws ApplicationSettingsException {
+ return getSetting("email.password");
+ }
+
+ public String getCredentialStoreEmailSSLConnectImpl() throws ApplicationSettingsException {
+ return getSetting("email.ssl");
+ }
+
+ public String getCredentialStoreEmailFromEmailImpl() throws ApplicationSettingsException {
+ return getSetting("email.from");
+ }
+
+ /**
+ * @deprecated use {{@link #getSetting(String)}}
+ * @return
+ */
+ public Properties getPropertiesImpl() {
+ return properties;
+ }
+
+ public void mergeSettingsImpl(Map<String,String> props){
+ properties.putAll(props);
+ }
+
+ public void mergeSettingsImpl(InputStream stream) throws IOException{
+ Properties tmpProp = new Properties();
+ tmpProp.load(stream);
+ properties.putAll(tmpProp);
+ }
+
+ public void mergeSettingsCommandLineArgsImpl(String[] args){
+ properties.putAll(StringUtil.parseCommandLineOptions(args));
+ }
+
+ public ShutdownStrategy getShutdownStrategyImpl() throws Exception{
+ String strategy = null;
+ try {
+ strategy = getSetting(SHUTDOWN_STATEGY_STRING, ShutdownStrategy.SELF_TERMINATE.toString());
+ return ShutdownStrategy.valueOf(strategy);
+ } catch (Exception e) {
+ //if the string mentioned in config is invalid
+ throw new Exception("Invalid shutdown strategy configured : "+strategy);
+ }
+ }
+
+ /*
+ * Static methods which will be used by the users
+ */
+
+ public static String getSetting(String key) throws ApplicationSettingsException{
+ return getInstance().getSettingImpl(key);
+ }
+
+ public static String getSetting(String key, String defaultValue){
+ return getInstance().getSettingImpl(key,defaultValue);
+
+ }
+
+ public static void setSetting(String key, String value) throws ApplicationSettingsException{
+ getInstance().properties.setProperty(key, value);
+ getInstance().saveProperties();
+ }
+
+ public static boolean isSettingDefined(String key) throws ApplicationSettingsException{
+ return getInstance().properties.containsKey(key);
+ }
+
+ public static String getTrustStorePath() throws ApplicationSettingsException {
+ return getSetting(TRUST_STORE_PATH);
+ }
+
+ public static String getTrustStorePassword() throws ApplicationSettingsException {
+ return getSetting(TRUST_STORE_PASSWORD);
+ }
+
+ public static void initializeTrustStore() throws ApplicationSettingsException {
+ SecurityUtil.setTrustStoreParameters(getTrustStorePath(), getTrustStorePassword());
+ }
+
+ public static String getCredentialStoreKeyStorePath() throws ApplicationSettingsException {
+ return getSetting("credential.store.keystore.url");
+ }
+
+ public static String getCredentialStoreThriftServerKeyStorePath() throws ApplicationSettingsException {
+ return getSetting("credential.store.thrift.server.keystore");
+ }
+
+ public static boolean isCredentialStoreStartEnabled() throws ApplicationSettingsException {
+ String enableCredentialStore = getSetting("start.credential.store");
+ if (enableCredentialStore.equals("true")){
+ return true;
+ }
+ return false;
+ }
+
+ public static String getCredentialStoreKeyAlias() throws ApplicationSettingsException {
+ return getSetting("credential.store.keystore.alias");
+ }
+
+ public static String getCredentialStoreKeyStorePassword() throws ApplicationSettingsException {
+ return getSetting("credential.store.keystore.password");
+ }
+
+ public static String getCredentialStoreThriftServerKeyStorePassword() throws ApplicationSettingsException {
+ return getSetting("credential.store.thrift.server.keystore.password");
+ }
+
+ public static String getCredentialStoreServerHost() throws ApplicationSettingsException {
+ return getSetting("credential.store.server.host");
+ }
+
+ public static String getCredentialStoreServerPort() throws ApplicationSettingsException {
+ return getSetting("credential.store.server.port");
+ }
+ public static String getCredentialStoreNotifierEnabled() throws ApplicationSettingsException {
+ return getSetting("notifier.enabled");
+ }
+
+ public static String getCredentialStoreNotifierDuration() throws ApplicationSettingsException {
+ return getSetting("notifier.duration");
+ }
+
+ public static String getCredentialStoreEmailServer() throws ApplicationSettingsException {
+ return getSetting("email.server");
+ }
+
+ public static String getCredentialStoreEmailServerPort() throws ApplicationSettingsException {
+ return getSetting("email.server.port");
+ }
+
+ public static String getCredentialStoreEmailUser() throws ApplicationSettingsException {
+ return getSetting("email.user");
+ }
+
+ public static String getCredentialStoreEmailPassword() throws ApplicationSettingsException {
+ return getSetting("email.password");
+ }
+
+ public static String getCredentialStoreEmailSSLConnect() throws ApplicationSettingsException {
+ return getSetting("email.ssl");
+ }
+
+ public static String getCredentialStoreEmailFromEmail() throws ApplicationSettingsException {
+ return getSetting("email.from");
+ }
+
+ /**
+ * @deprecated use {{@link #getSetting(String)}}
+ * @return
+ * @throws ApplicationSettingsException
+ */
+ public static Properties getProperties() throws ApplicationSettingsException {
+ return getInstance().properties;
+ }
+
+ public static void mergeSettings(Map<String,String> props) {
+ getInstance().mergeSettingsImpl(props);
+ }
+
+ public static void mergeSettings(InputStream stream) throws IOException{
+ getInstance().mergeSettingsImpl(stream);
+ }
+
+ public static void mergeSettingsCommandLineArgs(String[] args){
+ getInstance().mergeSettingsCommandLineArgsImpl(args);
+ }
+
+ public static ShutdownStrategy getShutdownStrategy() throws Exception{
+ return getInstance().getShutdownStrategyImpl();
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/BrowserLauncher.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/BrowserLauncher.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/BrowserLauncher.java
new file mode 100644
index 0000000..8946aa3
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/BrowserLauncher.java
@@ -0,0 +1,98 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+
+import org.apache.airavata.common.exception.UtilsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Opens URLs with the OS-specific browser.
+ */
+public class BrowserLauncher {
+
+ private static final String ERROR_MESSAGE = "Error while attempting to launch web browser";
+
+ private static Logger logger = LoggerFactory.getLogger(BrowserLauncher.class);
+
+ /**
+ * Opens a specified URL with the browser.
+ *
+ * @param url
+ * The specified URL.
+ * @throws UtilsException
+ */
+ public static void openURL(URL url) throws UtilsException {
+ openURL(url.toString());
+ }
+
+ /**
+ * Opens a specified URL with the browser.
+ *
+ * @param url
+ * The specified URL.
+ * @throws UtilsException
+ */
+ public static void openURL(String url) throws UtilsException {
+ logger.debug("Enter:" + url);
+ String osName = System.getProperty("os.name");
+ try {
+ if (osName.startsWith("Mac OS")) {
+ Class macUtils = Class.forName("com.apple.mrj.MRJFileUtils");
+ Method openURL = macUtils.getDeclaredMethod("openURL", new Class[] { String.class });
+ openURL.invoke(null, new Object[] { url });
+ } else if (osName.startsWith("Windows"))
+ Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
+ else { // assume Unix or Linux
+ String[] browsers = { "firefox", "mozilla", "netscape", "opera", "konqueror" };
+ String browser = null;
+ for (int count = 0; count < browsers.length && browser == null; count++)
+ if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0)
+ browser = browsers[count];
+ if (browser == null) {
+ throw new UtilsException("Could not find web browser.");
+ } else {
+ Runtime.getRuntime().exec(new String[] { browser, url });
+ }
+ }
+ } catch (ClassNotFoundException e) {
+ throw new UtilsException(ERROR_MESSAGE, e);
+ } catch (NoSuchMethodException e) {
+ throw new UtilsException(ERROR_MESSAGE, e);
+ } catch (IllegalAccessException e) {
+ throw new UtilsException(ERROR_MESSAGE, e);
+ } catch (InvocationTargetException e) {
+ throw new UtilsException(ERROR_MESSAGE, e);
+ } catch (IOException e) {
+ throw new UtilsException(ERROR_MESSAGE, e);
+ } catch (InterruptedException e) {
+ throw new UtilsException(ERROR_MESSAGE, e);
+ } catch (RuntimeException e) {
+ throw new UtilsException(ERROR_MESSAGE, e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/ClientSettings.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/ClientSettings.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/ClientSettings.java
new file mode 100644
index 0000000..5373772
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/ClientSettings.java
@@ -0,0 +1,27 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+
+public class ClientSettings extends ApplicationSettings {
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/Constants.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/Constants.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/Constants.java
new file mode 100644
index 0000000..6855a8e
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/Constants.java
@@ -0,0 +1,66 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+/**
+ * Constants used in Airavata should go here.
+ */
+public final class Constants {
+
+ public static final String USER_IN_SESSION = "userName";
+// public static final String GATEWAY_NAME = "gateway_id";
+ public static final String GFAC_CONFIG_XML = "gfac-config.xml";
+ public static final String PUSH = "push";
+ public static final String PULL = "pull";
+ public static final String API_SERVER_PORT = "apiserver.server.port";
+ public static final String API_SERVER_HOST = "apiserver.server.host";
+ public static final String REGISTRY_JDBC_URL = "registry.jdbc.url";
+ public static final String APPCATALOG_JDBC_URL = "appcatalog.jdbc.url";
+ public static final String RABBITMQ_BROKER_URL = "rabbitmq.broker.url";
+ public static final String RABBITMQ_EXCHANGE = "rabbitmq.exchange.name";
+ public static final String ORCHESTRATOR_SERVER_HOST = "orchestrator.server.host";
+ public static final String ORCHESTRATOR_SERVER_PORT = "orchestrator.server.port";
+ public static final String GFAC_SERVER_HOST = "gfac.server.host";
+ public static final String GFAC_SERVER_PORT = "gfac.server.port";
+ public static final String CREDENTIAL_SERVER_HOST = "credential.store.server.host";
+ public static final String CREDENTIAL_SERVER_PORT = "credential.store.server.port";
+ public static final String ZOOKEEPER_EXPERIMENT_CATALOG = "experiment-catalog";
+ public static final String ZOOKEEPER_APPCATALOG = "app-catalog";
+ public static final String ZOOKEEPER_RABBITMQ = "rabbit-mq";
+ public static final String ZOOKEEPER_SERVER_HOST = "zookeeper.server.host";
+ public static final String ZOOKEEPER_SERVER_PORT = "zookeeper.server.port";
+ public static final String ZOOKEEPER_API_SERVER_NODE = "airavata-server";
+ public static final String ZOOKEEPER_ORCHESTRATOR_SERVER_NODE = "orchestrator-server";
+ public static final String ZOOKEEPER_GFAC_SERVER_NODE = "gfac-server";
+ public static final String ZOOKEEPER_GFAC_EXPERIMENT_NODE = "gfac-experiments";
+ public static final String ZOOKEEPER_GFAC_SERVER_NAME = "gfac-server-name";
+ public static final String ZOOKEEPER_ORCHESTRATOR_SERVER_NAME = "orchestrator-server-name";
+ public static final String ZOOKEEPER_API_SERVER_NAME = "api-server-name";
+ public static final String STAT = "stat";
+ public static final String JOB = "job";
+ public static final String ZOOKEEPER_TIMEOUT = "zookeeper.timeout";
+ //API security relates property names
+ public static final String IS_API_SECURED = "api.secured";
+ public static final String REMOTE_OAUTH_SERVER_URL = "remote.oauth.authorization.server";
+ public static final String ADMIN_USERNAME = "admin.user.name";
+ public static final String ADMIN_PASSWORD = "admin.password";
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/DBUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/DBUtil.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/DBUtil.java
new file mode 100644
index 0000000..bb2ff1d
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/DBUtil.java
@@ -0,0 +1,334 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.commons.dbcp.BasicDataSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.sql.DataSource;
+import java.sql.*;
+import java.util.Properties;
+
+/**
+ * Database lookup. Abstracts out JDBC operations.
+ */
+public class DBUtil {
+
+ private String jdbcUrl;
+ private String databaseUserName;
+ private String databasePassword;
+ private String driverName;
+
+ protected static Logger log = LoggerFactory.getLogger(DBUtil.class);
+
+ private Properties properties;
+
+ public DBUtil(String jdbcUrl, String userName, String password, String driver) throws InstantiationException,
+ IllegalAccessException, ClassNotFoundException {
+
+ this.jdbcUrl = jdbcUrl;
+ this.databaseUserName = userName;
+ this.databasePassword = password;
+ this.driverName = driver;
+
+ init();
+ }
+
+ /**
+ * Initializes and load driver. Must be called this before calling anyother method.
+ *
+ * @throws ClassNotFoundException
+ * If DB driver is not found.
+ * @throws InstantiationException
+ * If unable to create driver class.
+ * @throws IllegalAccessException
+ * If security does not allow users to instantiate driver object.
+ */
+ private void init() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+ properties = new Properties();
+
+ properties.put("user", databaseUserName);
+ properties.put("password", databasePassword);
+ properties.put("characterEncoding", "ISO-8859-1");
+ properties.put("useUnicode", "true");
+
+ loadDriver();
+ }
+
+ /**
+ * Generic method to query values in the database.
+ *
+ * @param tableName
+ * Table name to query
+ * @param selectColumn
+ * The column selecting
+ * @param whereValue
+ * The condition query
+ * @return The value appropriate to the query.
+ * @throws SQLException
+ * If an error occurred while querying
+ */
+ public String getMatchingColumnValue(String tableName, String selectColumn, String whereValue) throws SQLException {
+ return getMatchingColumnValue(tableName, selectColumn, selectColumn, whereValue);
+ }
+
+ /**
+ * Generic method to query values in the database.
+ *
+ * @param tableName
+ * Table name to query
+ * @param selectColumn
+ * The column selecting
+ * @param whereColumn
+ * The column which condition should apply
+ * @param whereValue
+ * The condition query
+ * @return The value appropriate to the query.
+ * @throws SQLException
+ * If an error occurred while querying
+ */
+ public String getMatchingColumnValue(String tableName, String selectColumn, String whereColumn, String whereValue)
+ throws SQLException {
+
+ StringBuilder stringBuilder = new StringBuilder();
+
+ stringBuilder.append("SELECT ").append(selectColumn).append(" FROM ").append(tableName).append(" WHERE ")
+ .append(whereColumn).append(" = ?");
+
+ String sql = stringBuilder.toString();
+
+ Connection connection = getConnection();
+
+ PreparedStatement ps = connection.prepareStatement(sql);
+ ResultSet rs = null;
+
+ try {
+ ps.setString(1, whereValue);
+ rs = ps.executeQuery();
+
+ if (rs.next()) {
+ return rs.getString(1);
+ }
+
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+
+ ps.close();
+ connection.close();
+
+ } catch (Exception ignore) {
+ log.error("An error occurred while closing database connections ", ignore);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Create table utility method.
+ *
+ * @param sql
+ * SQL to be executed.
+ * @throws SQLException
+ * If an error occurred while creating the table.
+ */
+ public void executeSQL(String sql) throws SQLException {
+
+ Connection connection = getConnection();
+
+ PreparedStatement ps = connection.prepareStatement(sql);
+
+ try {
+ ps.executeUpdate();
+ connection.commit();
+ } finally {
+ try {
+ if (ps != null) {
+ ps.close();
+ }
+
+ connection.close();
+
+ } catch (Exception ignore) {
+ log.error("An error occurred while closing database connections ", ignore);
+ }
+ }
+
+ }
+
+ private void loadDriver() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+ Class.forName(driverName).newInstance();
+ }
+
+ /**
+ * Gets a new DBCP data source.
+ *
+ * @return A new data source.
+ */
+ public DataSource getDataSource() {
+ BasicDataSource ds = new BasicDataSource();
+ ds.setDriverClassName(this.driverName);
+ ds.setUsername(this.databaseUserName);
+ ds.setPassword(this.databasePassword);
+ ds.setUrl(this.jdbcUrl);
+
+ return ds;
+ }
+
+ /**
+ * Creates a new JDBC connections based on provided DBCP properties.
+ *
+ * @return A new DB connection.
+ * @throws SQLException
+ * If an error occurred while creating the connection.
+ */
+ public Connection getConnection() throws SQLException {
+ Connection connection = DriverManager.getConnection(jdbcUrl, properties);
+ connection.setAutoCommit(false);
+ return connection;
+ }
+
+ /**
+ * Utility method to close statements and connections.
+ *
+ * @param preparedStatement
+ * The prepared statement to close.
+ * @param connection
+ * The connection to close.
+ */
+ public static void cleanup(PreparedStatement preparedStatement, Connection connection) {
+ if (preparedStatement != null) {
+ try {
+ preparedStatement.close();
+ } catch (SQLException e) {
+ log.error("Error closing prepared statement.", e);
+ }
+ }
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (SQLException e) {
+ log.error("Error closing database connection.", e);
+ }
+ }
+ }
+
+ /**
+ * Utility method to close statements and connections.
+ *
+ * @param preparedStatement
+ * The prepared statement to close.
+ */
+ public static void cleanup(PreparedStatement preparedStatement) {
+ if (preparedStatement != null) {
+ try {
+ preparedStatement.close();
+ } catch (SQLException e) {
+ log.error("Error closing prepared statement.", e);
+ }
+ }
+ }
+
+ /**
+ * Utility method to close statements and connections.
+ *
+ * @param preparedStatement
+ * The prepared statement to close.
+ */
+ public static void cleanup(PreparedStatement preparedStatement, ResultSet resultSet) {
+ if (resultSet != null) {
+ try {
+ resultSet.close();
+ } catch (SQLException e) {
+ log.error("Error closing prepared statement.", e);
+ }
+ }
+
+ cleanup(preparedStatement);
+ }
+
+ /**
+ * Cleanup the connection.
+ * @param connection The connection to close.
+ */
+ public static void cleanup(Connection connection) {
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (SQLException e) {
+ log.debug("Error closing connection.", e);
+ log.warn("Error closing connection.");
+ }
+ }
+ }
+
+ /**
+ * Mainly useful for tests.
+ *
+ * @param tableName
+ * The table name.
+ * @param connection
+ * The connection to be used.
+ */
+ public static void truncate(String tableName, Connection connection) throws SQLException {
+
+ String sql = "delete from " + tableName;
+
+ PreparedStatement preparedStatement = connection.prepareStatement(sql);
+ preparedStatement.executeUpdate();
+
+ connection.commit();
+
+ }
+
+ /**
+ * Creates a DBUtil object based on servlet context configurations.
+ *
+ * @return DBUtil object.
+ * @throws Exception
+ * If an error occurred while reading configurations or while creating database object.
+ */
+ public static DBUtil getCredentialStoreDBUtil() throws ApplicationSettingsException, IllegalAccessException,
+ ClassNotFoundException, InstantiationException {
+ String jdbcUrl = ServerSettings.getCredentialStoreDBURL();
+ String userName = ServerSettings.getCredentialStoreDBUser();
+ String password = ServerSettings.getCredentialStoreDBPassword();
+ String driverName = ServerSettings.getCredentialStoreDBDriver();
+
+ StringBuilder stringBuilder = new StringBuilder("Starting credential store, connecting to database - ");
+ stringBuilder.append(jdbcUrl).append(" DB user - ").append(userName).append(" driver name - ")
+ .append(driverName);
+
+ log.debug(stringBuilder.toString());
+
+ DBUtil dbUtil = new DBUtil(jdbcUrl, userName, password, driverName);
+ dbUtil.init();
+
+ return dbUtil;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/DatabaseTestCases.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/DatabaseTestCases.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/DatabaseTestCases.java
new file mode 100644
index 0000000..6ff528d
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/DatabaseTestCases.java
@@ -0,0 +1,123 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * An abstraction for database specific test classes. This will create a database and provides methods to execute SQLs.
+ */
+public class DatabaseTestCases {
+
+ private static final Logger logger = LoggerFactory.getLogger(DatabaseTestCases.class);
+
+ protected static String hostAddress = "localhost";
+ protected static int port = 20000;
+ protected static String userName = "admin";
+ protected static String password = "admin";
+ protected static String driver = "org.apache.derby.jdbc.ClientDriver";
+
+ public static String getHostAddress() {
+ return hostAddress;
+ }
+
+ public static int getPort() {
+ return port;
+ }
+
+ public static String getUserName() {
+ return userName;
+ }
+
+ public static String getPassword() {
+ return password;
+ }
+
+ public static String getDriver() {
+ return driver;
+ }
+
+ public static String getJDBCUrl() {
+ return new StringBuilder().append("jdbc:derby://").append(getHostAddress()).append(":").append(getPort())
+ .append("/experiment_catalog;create=true;user=").append(getUserName()).append(";password=")
+ .append(getPassword()).toString();
+ }
+
+ public static void waitTillServerStarts() {
+ DBUtil dbUtil = null;
+
+ try {
+ dbUtil = new DBUtil(getJDBCUrl(), getUserName(), getPassword(), getDriver());
+ } catch (Exception e) {
+ // ignore
+ }
+
+ Connection connection = null;
+ try {
+ if (dbUtil != null) {
+ connection = dbUtil.getConnection();
+ }
+ } catch (Throwable e) {
+ // ignore
+ }
+
+ while (connection == null) {
+ try {
+ Thread.sleep(1000);
+ try {
+ if (dbUtil != null) {
+ connection = dbUtil.getConnection();
+ }
+ } catch (SQLException e) {
+ // ignore
+ }
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+
+ }
+
+ public static void executeSQL(String sql) throws Exception {
+ DBUtil dbUtil = new DBUtil(getJDBCUrl(), getUserName(), getPassword(), getDriver());
+ dbUtil.executeSQL(sql);
+ }
+
+ public DBUtil getDbUtil () throws Exception {
+ return new DBUtil(getJDBCUrl(), getUserName(), getPassword(), getDriver());
+
+ }
+
+ public Connection getConnection() throws Exception {
+
+ DBUtil dbUtil = getDbUtil ();
+ Connection connection = dbUtil.getConnection();
+ connection.setAutoCommit(true);
+ return connection;
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java
new file mode 100644
index 0000000..fc7792b
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/DefaultKeyStorePasswordCallback.java
@@ -0,0 +1,55 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 12/29/13
+ * Time: 12:10 PM
+ */
+
+public class DefaultKeyStorePasswordCallback implements KeyStorePasswordCallback {
+
+ public DefaultKeyStorePasswordCallback(){
+
+ }
+
+ @Override
+ public char[] getStorePassword() {
+ try {
+ return ApplicationSettings.getCredentialStoreKeyStorePassword().toCharArray();
+ } catch (ApplicationSettingsException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public char[] getSecretKeyPassPhrase(String keyAlias) {
+ try {
+ return ApplicationSettings.getCredentialStoreKeyStorePassword().toCharArray();
+ } catch (ApplicationSettingsException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/DerbyUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/DerbyUtil.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/DerbyUtil.java
new file mode 100644
index 0000000..4fb35b9
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/DerbyUtil.java
@@ -0,0 +1,114 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.InetAddress;
+import java.sql.DriverManager;
+import org.apache.derby.drda.NetworkServerControl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.SQLException;
+
+/**
+ * This class includes methods to start stop Derby database. Mainly user for tests.
+ */
+public class DerbyUtil {
+
+ private static NetworkServerControl server;
+
+ private static final Logger logger = LoggerFactory.getLogger(DerbyUtil.class);
+
+ public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
+
+ /**
+ * Starts new derby server instance with given configurations.
+ *
+ * @param hostAddress
+ * The host address start the server.
+ * @param port
+ * The port number which server is starting.
+ * @param user
+ * JDBC user name.
+ * @param password
+ * JDBC password.
+ * @throws Exception
+ * If an error occurred while starting the server.
+ */
+ public static void startDerbyInServerMode(String hostAddress, int port, String user, String password)
+ throws Exception {
+ PrintWriter consoleWriter = null;
+
+ try {
+ System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
+ server = new NetworkServerControl(InetAddress.getByName(hostAddress), port, user, password);
+ consoleWriter = new PrintWriter(System.out, true);
+ server.start(consoleWriter);
+
+ } catch (IOException e) {
+ logger.error("Unable to start Apache derby in the server mode! Check whether "
+ + "specified port is available", e);
+ throw e;
+ } catch (Exception e) {
+ logger.error("Unable to start Apache derby in the server mode! Check whether "
+ + "specified port is available", e);
+ throw e;
+ } finally {
+
+ if (consoleWriter != null) {
+ consoleWriter.close();
+ }
+
+ }
+
+ }
+
+ /**
+ * Starts derby server in embedded mode.
+ *
+ * @throws ClassNotFoundException
+ * If specified driver not found in the class path.
+ * @throws SQLException
+ * If an error occurred while creat
+ */
+ public static void startDerbyInEmbeddedMode() throws ClassNotFoundException, SQLException {
+ Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+ DriverManager.getConnection("jdbc:derby:memory:unit-testing-jpa;create=true").close();
+ }
+
+ /**
+ * Shuts down the server.
+ *
+ * @throws Exception
+ * If an error occurred while shutting down.
+ */
+ public static void stopDerbyServer() throws Exception {
+ try {
+ server.shutdown();
+ } catch (Exception e) {
+ logger.error("Error shutting down derby server.", e);
+ throw e;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/ExecutionMode.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/ExecutionMode.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/ExecutionMode.java
new file mode 100644
index 0000000..cf17ef0
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/ExecutionMode.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+public enum ExecutionMode {
+ CLIENT,
+ SERVER,
+ UNKNOWN
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/IOUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/IOUtil.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/IOUtil.java
new file mode 100644
index 0000000..9d1d7dd
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/IOUtil.java
@@ -0,0 +1,209 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.Writer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IOUtil {
+
+ private static final Logger logger = LoggerFactory.getLogger(IOUtil.class);
+
+ /**
+ * @param path
+ * @param content
+ * @throws IOException
+ */
+ public static void writeToFile(String content, String path) throws IOException {
+ logger.debug("Path:" + path + " Content:" + content);
+
+ FileWriter fw = new FileWriter(path);
+ writeToWriter(content, fw);
+ }
+
+ /**
+ * @param content
+ * @param file
+ * @throws IOException
+ */
+ public static void writeToFile(String content, File file) throws IOException {
+ FileWriter fw = new FileWriter(file);
+ writeToWriter(content, fw);
+ }
+
+ /**
+ * @param inputStream
+ * @param file
+ * @throws IOException
+ */
+ public static void writeToFile(InputStream inputStream, File file) throws IOException {
+ FileOutputStream outputStream = new FileOutputStream(file);
+ byte[] bytes = new byte[1024];
+ int len;
+ while ((len = inputStream.read(bytes)) != -1) {
+ outputStream.write(bytes, 0, len);
+ }
+ outputStream.close();
+ }
+
+ /**
+ * Writes a specified String to a specified Writer.
+ *
+ * @param content
+ * The content to write
+ * @param writer
+ * The specified Writer
+ *
+ * @throws IOException
+ */
+ public static void writeToWriter(String content, Writer writer) throws IOException {
+ writer.write(content);
+ writer.close();
+ }
+
+ /**
+ * Returns the content of a specified file as a String.
+ *
+ * @param path
+ * @return the content of a specified file as a String
+ * @throws IOException
+ */
+ public static String readFileToString(String path) throws IOException {
+ FileReader read = new FileReader(path);
+ return readToString(read);
+ }
+
+ /**
+ * Returns the content of a specified file as a String.
+ *
+ * @param file
+ * @return the content of a specified file as a String
+ * @throws IOException
+ */
+ public static String readFileToString(File file) throws IOException {
+ FileReader reader = new FileReader(file);
+ return readToString(reader);
+ }
+
+ /**
+ * Returns a String read from a specified InputStream.
+ *
+ * @param stream
+ * The specified InputStream
+ * @return The String read from the specified InputStream
+ * @throws IOException
+ */
+ public static String readToString(InputStream stream) throws IOException {
+ return readToString(new InputStreamReader(stream));
+ }
+
+ /**
+ * Returns a String read from a specified Reader.
+ *
+ * @param reader
+ * The specified Reader
+ * @return The String read from the specified Reader
+ * @throws IOException
+ */
+ public static String readToString(Reader reader) throws IOException {
+ char[] cbuf = new char[1024];
+ StringBuilder sbuf = new StringBuilder();
+ int len;
+ while ((len = reader.read(cbuf)) != -1) {
+ sbuf.append(cbuf, 0, len);
+ }
+ return sbuf.toString();
+ }
+
+ /**
+ * @param file
+ * @return The byte array
+ * @throws IOException
+ */
+ public static byte[] readToByteArray(File file) throws IOException {
+ return readToByteArray(new FileInputStream(file));
+ }
+
+ /**
+ * @param inputStream
+ * @return The byte array.
+ * @throws IOException
+ */
+ public static byte[] readToByteArray(InputStream inputStream) throws IOException {
+ byte[] buf = new byte[1024];
+ ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
+ int len;
+ while ((len = inputStream.read(buf)) != -1) {
+ byteArrayStream.write(buf, 0, len);
+ }
+ return byteArrayStream.toByteArray();
+ }
+
+ /**
+ * @param path
+ * @return <code>true</code> if and only if the file or directory is successfully deleted; <code>false</code>
+ * otherwise
+ */
+ public static boolean deleteDirectory(File path) {
+ if (path.exists()) {
+ File[] files = path.listFiles();
+ for (File file : files) {
+ if (file.isDirectory()) {
+ deleteDirectory(file);
+ } else {
+ file.delete();
+ }
+ }
+ }
+ return path.delete();
+ }
+
+ /**
+ * Gets the extension of a specified file.
+ *
+ * @param file
+ * the specified file.
+ * @return the extension of the file in lower case if there is an extension; null otherwise
+ */
+ public static String getExtension(File file) {
+ String ext = null;
+ String name = file.getName();
+
+ int index = name.lastIndexOf('.');
+ if (index > 0 && index < name.length() - 1) {
+ ext = name.substring(index + 1).toLowerCase();
+ }
+ return ext;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/IServer.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/IServer.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/IServer.java
new file mode 100644
index 0000000..867eb45
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/IServer.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.util.Calendar;
+import java.util.Date;
+
+public interface IServer {
+ public enum ServerStatus{
+ STOPING,
+ STOPPED,
+ STARTING,
+ STARTED,
+ FAILED;
+ public void updateTime(){
+ now=Calendar.getInstance().getTime();
+ }
+ private Date now;
+ public Date getTime(){
+ return now;
+ }
+ }
+ public String getName();
+ public String getVersion();
+ public void start() throws Exception;
+ public void stop() throws Exception;
+ public void restart() throws Exception;
+ public void configure() throws Exception;
+ public ServerStatus getStatus() throws Exception;
+// public void waitForServerToStart() throws Exception;
+// public void waitForServerToStop() throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/JSONUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/JSONUtil.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/JSONUtil.java
new file mode 100644
index 0000000..222e5a2
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/JSONUtil.java
@@ -0,0 +1,158 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.stream.JsonReader;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Map;
+import java.util.Set;
+
+public class JSONUtil {
+
+
+ public static void saveJSON(JsonElement jsonElement, File file) throws IOException {
+ IOUtil.writeToFile(jsonElementToString(jsonElement), file);
+ }
+
+ public static JsonObject stringToJSONObject(String workflowString) {
+ JsonParser parser = new JsonParser();
+ return (JsonObject) parser.parse(workflowString);
+ }
+
+ public static JsonObject loadJSON(File file) throws IOException {
+ return loadJSON(new FileReader(file));
+ }
+
+ public static JsonObject loadJSON(Reader reader) throws IOException {
+ JsonParser parser = new JsonParser();
+ JsonElement jsonElement = parser.parse(reader);
+ if (jsonElement instanceof JsonObject) {
+ return (JsonObject) jsonElement;
+ } else {
+ throw new RuntimeException("Error while loading Json from file");
+ }
+
+ }
+
+ public static String jsonElementToString(JsonElement jsonElement) {
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ return gson.toJson(jsonElement);
+ }
+
+ public static boolean isEqual(JsonObject originalJsonObject, JsonObject newJsonObject) {
+ // TODO - Implement this method
+ if (originalJsonObject == null && newJsonObject == null) {
+ return true;
+ }else if (originalJsonObject == null || newJsonObject == null) {
+ return false;
+ } else {
+ // check the number of childs
+ Set<Map.Entry<String , JsonElement>> entrySetOfOriginalJson = originalJsonObject.entrySet();
+ Set<Map.Entry<String , JsonElement>> entrySetOfNewJson = newJsonObject.entrySet();
+ if (entrySetOfOriginalJson.size() != entrySetOfNewJson.size()) {
+ return false;
+ }
+
+ for (Map.Entry<String, JsonElement> keyString : entrySetOfOriginalJson) {
+ JsonElement valueOrig = keyString.getValue();
+ JsonElement valueNew = newJsonObject.get(keyString.getKey());
+ if (valueOrig instanceof JsonObject && valueNew instanceof JsonObject &&
+ !isEqual((JsonObject) valueOrig, (JsonObject) valueNew)) {
+ return false;
+ }else if (valueOrig instanceof JsonArray && valueNew instanceof JsonArray &&
+ !isEqual((JsonArray) valueOrig, (JsonArray) valueNew)) {
+ return false;
+ }else if (valueOrig instanceof JsonPrimitive && valueNew instanceof JsonPrimitive &&
+ !isEqual((JsonPrimitive) valueOrig, (JsonPrimitive) valueNew)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private static boolean isEqual(JsonArray arrayOriginal, JsonArray arrayNew) {
+ if (arrayOriginal == null && arrayNew == null) {
+ return true;
+ }else if (arrayOriginal == null || arrayNew == null) {
+ return false;
+ }else {
+ // check the number of element
+ if (arrayOriginal.size() != arrayNew.size()) {
+ return false;
+ }else if (arrayOriginal.size() == 0) {
+ return true;
+ } else {
+ for (int i = 0; i < arrayOriginal.size(); i++) {
+ JsonElement valueOrig = arrayOriginal.get(i);
+ JsonElement valueNew = arrayNew.get(i);
+ if (valueOrig instanceof JsonObject && valueNew instanceof JsonObject) {
+ if (!isEqual((JsonObject) valueOrig, (JsonObject) valueNew)) {
+ return false;
+ }
+ }else if (valueOrig instanceof JsonPrimitive && valueNew instanceof JsonPrimitive) {
+ if (!isEqual((JsonPrimitive) valueOrig, (JsonPrimitive) valueNew)) {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ private static boolean isEqual(JsonPrimitive primitiveOrig, JsonPrimitive primitiveNew) {
+ if (primitiveOrig == null && primitiveNew == null) {
+ return true;
+ }else if (primitiveOrig == null || primitiveNew == null) {
+ return false;
+ } else {
+ if (primitiveOrig.isString() && primitiveNew.isString()){
+ if(!primitiveOrig.getAsString().equals(primitiveNew.getAsString())) {
+ return false;
+ }
+ }else if (primitiveOrig.isBoolean() && primitiveNew.isBoolean()) {
+ if ((Boolean.valueOf(primitiveOrig.getAsBoolean()).compareTo(primitiveNew.getAsBoolean()) != 0)) {
+ return false;
+ }
+ }else if (primitiveOrig.isNumber() && primitiveNew.isNumber() ) {
+ if (new Double(primitiveOrig.getAsDouble()).compareTo(primitiveNew.getAsDouble()) != 0) {
+ return false;
+ }
+ }else {
+ return primitiveOrig.isJsonNull() && primitiveNew.isJsonNull();
+ }
+ }
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java
new file mode 100644
index 0000000..bafaff3
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/KeyStorePasswordCallback.java
@@ -0,0 +1,50 @@
+package org.apache.airavata.common.utils;/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/11/13
+ * Time: 11:30 AM
+ */
+
+/**
+ * An interface to get keystore password in a form of a callback.
+ */
+public interface KeyStorePasswordCallback {
+
+ /**
+ * Caller should implement the interface. Should return the password for
+ * the keystore. This should return the keystore password. i.e. password used to open the keystore.
+ * Instead of the actual file.
+ * @return The password to open the keystore.
+ */
+ char[] getStorePassword() throws RuntimeException;
+
+ /**
+ * Caller should implement the interface. Should return the pass phrase for
+ * the secret key.
+ * Instead of the actual file.
+ * @param keyAlias The alias of the key
+ * @return The pass phrase for the secret key.
+ */
+ char[] getSecretKeyPassPhrase(String keyAlias);
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/MonitorPublisher.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/MonitorPublisher.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/MonitorPublisher.java
new file mode 100644
index 0000000..7f64e86
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/MonitorPublisher.java
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.common.utils;
+
+import com.google.common.eventbus.EventBus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MonitorPublisher{
+ private final static Logger logger = LoggerFactory.getLogger(MonitorPublisher.class);
+ private EventBus eventBus;
+
+ public MonitorPublisher(EventBus eventBus) {
+ this.eventBus = eventBus;
+ }
+
+ public void registerListener(Object listener) {
+ eventBus.register(listener);
+ }
+
+ public void unregisterListener(Object listener) {
+ eventBus.unregister(listener);
+ }
+
+ public void publish(Object o) {
+ eventBus.post(o);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/NameValidator.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/NameValidator.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/NameValidator.java
new file mode 100644
index 0000000..98530cf
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/NameValidator.java
@@ -0,0 +1,70 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class NameValidator {
+
+ /**
+ * @param name
+ * @return Is it valid name?
+ */
+ public static boolean validate(String name) {
+ // Set the name pattern string
+ Pattern p = Pattern.compile("([a-zA-Z]){1,}([0-9]|_|\\.|[a-zA-Z]){0,}$");
+
+ // Match the given string with the pattern
+ Matcher m = p.matcher(name);
+
+ // Check whether match is found
+ boolean matchFound = m.matches();
+
+ return matchFound;
+ }
+
+ /**
+ * @param args
+ * @Description some quick tests
+ */
+ public static void main(String[] args) {
+ System.out.println(validate("abc90_90abc")); // true
+
+ System.out.println(validate("abc_abc_123")); // true
+
+ System.out.println(validate("abc_abc_")); // true
+
+ System.out.println(validate("abc_abc")); // true
+
+ System.out.println(validate("abc.abc")); // true
+
+ System.out.println(validate("9abc_abc")); // false, name cannot start with number
+
+ System.out.println(validate("_abc_abc")); // false, name cannot start with "_"
+
+ System.out.println(validate("\\abc_abc")); // false, name cannot start with "\"
+
+ System.out.println(validate("abc\\_abc")); // false, name cannot contain "\"
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/Pair.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/Pair.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/Pair.java
new file mode 100644
index 0000000..ee24360
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/Pair.java
@@ -0,0 +1,79 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+public class Pair<L, R> {
+
+ private L left;
+
+ private R right;
+
+ /**
+ * Constructs a Pair.
+ *
+ * @param left
+ * @param right
+ */
+ public Pair(L left, R right) {
+ this.left = left;
+ this.right = right;
+ }
+
+ /**
+ * Returns the left.
+ *
+ * @return The left
+ */
+ public L getLeft() {
+ return this.left;
+ }
+
+ /**
+ * Sets left.
+ *
+ * @param left
+ * The left to set.
+ */
+ public void setLeft(L left) {
+ this.left = left;
+ }
+
+ /**
+ * Returns the right.
+ *
+ * @return The right
+ */
+ public R getRight() {
+ return this.right;
+ }
+
+ /**
+ * Sets right.
+ *
+ * @param right
+ * The right to set.
+ */
+ public void setRight(R right) {
+ this.right = right;
+ }
+
+}
\ No newline at end of file
[6/8] airavata git commit: moved commons-utils to commons module
Posted by sh...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java
new file mode 100644
index 0000000..845a040
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/SecurityUtil.java
@@ -0,0 +1,180 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import java.io.*;
+import java.security.*;
+import java.security.cert.CertificateException;
+
+/**
+ * Class which includes security utilities.
+ */
+public class SecurityUtil {
+
+ public static final String PASSWORD_HASH_METHOD_PLAINTEXT = "PLAINTEXT";
+
+ public static final String CHARSET_ENCODING = "UTF-8";
+ public static final String ENCRYPTION_ALGORITHM = "AES";
+ public static final String PADDING_MECHANISM = "AES/CBC/PKCS5Padding";
+
+ private static final Logger logger = LoggerFactory.getLogger(SecurityUtil.class);
+
+ /**
+ * Creates a hash of given string with the given hash algorithm.
+ *
+ * @param stringToDigest
+ * The string to digest.
+ * @param digestingAlgorithm
+ * Hash algorithm.
+ * @return The digested string.
+ * @throws NoSuchAlgorithmException
+ * If given hash algorithm doesnt exists.
+ */
+ public static String digestString(String stringToDigest, String digestingAlgorithm) throws NoSuchAlgorithmException {
+
+ if (digestingAlgorithm == null || digestingAlgorithm.equals(PASSWORD_HASH_METHOD_PLAINTEXT)) {
+ return stringToDigest;
+ }
+
+ MessageDigest messageDigest = MessageDigest.getInstance(digestingAlgorithm);
+ try {
+ return new String(messageDigest.digest(stringToDigest.getBytes("UTF-8")));
+ } catch (UnsupportedEncodingException e) {
+ logger.error("Error encoding password string when creating digest", e);
+ throw new RuntimeException("Error encoding password string when creating digest", e);
+ }
+ }
+
+ /**
+ * Sets the truststore for application. Useful when communicating over HTTPS.
+ *
+ * @param trustStoreFilePath
+ * Where trust store is located.
+ * @param trustStorePassword
+ * The trust store password.
+ */
+ public static void setTrustStoreParameters(String trustStoreFilePath, String trustStorePassword) {
+
+ if (System.getProperty("javax.net.ssl.trustStrore") == null) {
+ logger.info("Setting Java trust store to " + trustStoreFilePath);
+ System.setProperty("javax.net.ssl.trustStrore", trustStoreFilePath);
+ }
+
+ if (System.getProperty("javax.net.ssl.trustStorePassword") == null) {
+ System.setProperty("javax.net.ssl.trustStorePassword", trustStoreFilePath);
+ }
+
+ }
+
+ public static byte[] encryptString(String keyStorePath, String keyAlias,
+ KeyStorePasswordCallback passwordCallback, String value)
+ throws GeneralSecurityException, IOException {
+ return encrypt(keyStorePath, keyAlias, passwordCallback, value.getBytes(CHARSET_ENCODING));
+ }
+
+ public static byte[] encrypt(String keyStorePath, String keyAlias,
+ KeyStorePasswordCallback passwordCallback, byte[] value)
+ throws GeneralSecurityException, IOException {
+
+ Key secretKey = getSymmetricKey(keyStorePath, keyAlias, passwordCallback);
+
+ Cipher cipher = Cipher.getInstance(PADDING_MECHANISM);
+ cipher.init(Cipher.ENCRYPT_MODE, secretKey,
+ new IvParameterSpec(new byte[16]));
+ return cipher.doFinal(value);
+ }
+
+ private static Key getSymmetricKey(String keyStorePath, String keyAlias,
+ KeyStorePasswordCallback passwordCallback)
+ throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException,
+ UnrecoverableKeyException {
+
+ KeyStore ks = SecurityUtil.loadKeyStore(keyStorePath, "jceks", passwordCallback);
+
+ if (ks == null) {
+ throw new IOException("Unable to load Java keystore " + keyStorePath);
+ }
+
+ return ks.getKey(keyAlias, passwordCallback.getSecretKeyPassPhrase(keyAlias));
+
+ }
+
+ public static byte[] decrypt(String keyStorePath, String keyAlias,
+ KeyStorePasswordCallback passwordCallback, byte[] encrypted)
+ throws GeneralSecurityException, IOException {
+
+ Key secretKey = getSymmetricKey(keyStorePath, keyAlias, passwordCallback);
+
+ Cipher cipher = Cipher.getInstance(PADDING_MECHANISM);
+ cipher.init(Cipher.DECRYPT_MODE, secretKey,
+ new IvParameterSpec(new byte[16]));
+
+ return cipher.doFinal(encrypted);
+ }
+
+ public static String decryptString(String keyStorePath, String keyAlias,
+ KeyStorePasswordCallback passwordCallback, byte[] encrypted)
+ throws GeneralSecurityException, IOException {
+
+ byte[] decrypted = decrypt(keyStorePath, keyAlias, passwordCallback, encrypted);
+ return new String(decrypted, CHARSET_ENCODING);
+ }
+
+ public static KeyStore loadKeyStore(String keyStoreFilePath, String keyStoreType,
+ KeyStorePasswordCallback passwordCallback)
+ throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
+
+ java.io.FileInputStream fis = null;
+ try {
+ fis = new java.io.FileInputStream(keyStoreFilePath);
+ return loadKeyStore(fis, keyStoreType, passwordCallback);
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+ }
+ }
+
+ public static KeyStore loadKeyStore(InputStream inputStream, String keyStoreType,
+ KeyStorePasswordCallback passwordCallback)
+ throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
+
+ if (keyStoreType == null) {
+ keyStoreType = KeyStore.getDefaultType();
+ }
+
+ KeyStore ks = KeyStore.getInstance(keyStoreType);
+ ks.load(inputStream, passwordCallback.getStorePassword());
+
+ return ks;
+ }
+
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/ServerSettings.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
new file mode 100644
index 0000000..8370e40
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
@@ -0,0 +1,270 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+
+public class ServerSettings extends ApplicationSettings {
+
+ private static final String DEFAULT_USER = "default.registry.user";
+ private static final String DEFAULT_USER_PASSWORD = "default.registry.password";
+ private static final String DEFAULT_USER_GATEWAY = "default.registry.gateway";
+
+ private static final String SERVER_CONTEXT_ROOT = "server.context-root";
+ public static final String EMBEDDED_ZK = "embedded.zk";
+ public static final String IP = "ip";
+
+ private static final String CREDENTIAL_STORE_DB_URL = "credential.store.jdbc.url";
+ private static final String CREDENTIAL_STORE_DB_USER = "credential.store.jdbc.user";
+ private static final String CREDENTIAL_STORE_DB_PASSWORD = "credential.store.jdbc.password";
+ private static final String CREDENTIAL_STORE_DB_DRIVER = "credential.store.jdbc.driver";
+
+ private static final String REGISTRY_DB_URL = "registry.jdbc.url";
+ private static final String REGISTRY_DB_USER = "registry.jdbc.user";
+ private static final String REGISTRY_DB_PASSWORD = "registry.jdbc.password";
+ private static final String REGISTRY_DB_DRIVER = "registry.jdbc.driver";
+ private static final String ENABLE_HTTPS = "enable.https";
+ private static final String HOST_SCHEDULER = "host.scheduler";
+ private static final String MY_PROXY_SERVER = "myproxy.server";
+ private static final String MY_PROXY_USER = "myproxy.user";
+ private static final String MY_PROXY_PASSWORD = "myproxy.password";
+ private static final String MY_PROXY_LIFETIME = "myproxy.life";
+ private static final String STATUS_PUBLISHER = "status.publisher";
+ private static final String TASK_LAUNCH_PUBLISHER = "task.launch.publisher";
+ private static final String ACTIVITY_LISTENERS = "activity.listeners";
+ public static final String JOB_NOTIFICATION_ENABLE = "job.notification.enable";
+ public static final String JOB_NOTIFICATION_EMAILIDS = "job.notification.emailids";
+ public static final String JOB_NOTIFICATION_FLAGS = "job.notification.flags";
+ public static final String GFAC_PASSIVE = "gfac.passive"; // by default this is desabled
+ public static final String LAUNCH_QUEUE_NAME = "launch.queue.name";
+ public static final String CANCEL_QUEUE_NAME = "cancel.queue.name";
+
+
+ // Workflow Enactment Service component configuration.
+ private static final String ENACTMENT_THREAD_POOL_SIZE = "enactment.thread.pool.size";
+ private static final int DEFAULT_ENACTMENT_THREAD_POOL_SIZE = 10;
+ private static final String WORKFLOW_PARSER = "workflow.parser";
+
+ // email based monitoring configurations
+ private static final String EMAIL_BASED_MONITORING_PERIOD = "email.based.monitoring.period";
+ private static final String EMAIL_BASED_MONITOR_HOST = "email.based.monitor.host";
+ private static final String EMAIL_BASED_MONITOR_ADDRESS = "email.based.monitor.address";
+ private static final String EMAIL_BASED_MONITOR_PASSWORD = "email.based.monitor.password";
+ private static final String EMAIL_BASED_MONITOR_FOLDER_NAME = "email.based.monitor.folder.name";
+ private static final String EMAIL_BASED_MONITOR_STORE_PROTOCOL = "email.based.monitor.store.protocol";
+ private static final String ENABLE_EMAIL_BASED_MONITORING = "enable.email.based.monitoring";
+
+ private static boolean stopAllThreads = false;
+ private static boolean emailBaseNotificationEnable;
+
+ public static String getDefaultUser() throws ApplicationSettingsException {
+ return getSetting(DEFAULT_USER);
+ }
+
+ public static String getLaunchQueueName() {
+ return getSetting(LAUNCH_QUEUE_NAME, "launch.queue");
+ }
+
+
+ public static String getCancelQueueName() {
+ return getSetting(CANCEL_QUEUE_NAME, "cancel.queue");
+ }
+
+ public static String getDefaultUserPassword() throws ApplicationSettingsException {
+ return getSetting(DEFAULT_USER_PASSWORD);
+ }
+
+ public static String getDefaultUserGateway() throws ApplicationSettingsException {
+ return getSetting(DEFAULT_USER_GATEWAY);
+ }
+
+ public static String getServerContextRoot() {
+ return getSetting(SERVER_CONTEXT_ROOT, "axis2");
+ }
+
+ public static String getCredentialStoreDBUser() throws ApplicationSettingsException {
+ try {
+ return getSetting(CREDENTIAL_STORE_DB_USER);
+ } catch (ApplicationSettingsException e) {
+ return getSetting(REGISTRY_DB_USER);
+ }
+ }
+
+ public static String getCredentialStoreDBPassword() throws ApplicationSettingsException {
+ try {
+ return getSetting(CREDENTIAL_STORE_DB_PASSWORD);
+ } catch (ApplicationSettingsException e) {
+ return getSetting(REGISTRY_DB_PASSWORD);
+ }
+ }
+
+ public static String getCredentialStoreDBDriver() throws ApplicationSettingsException {
+ try {
+ return getSetting(CREDENTIAL_STORE_DB_DRIVER);
+ } catch (ApplicationSettingsException e) {
+ return getSetting(REGISTRY_DB_DRIVER);
+ }
+ }
+
+ public static String getCredentialStoreDBURL() throws ApplicationSettingsException {
+ try {
+ return getSetting(CREDENTIAL_STORE_DB_URL);
+ } catch (ApplicationSettingsException e) {
+ return getSetting(REGISTRY_DB_URL);
+ }
+
+ }
+
+ public static boolean isEnableHttps() {
+ try {
+ return Boolean.parseBoolean(getSetting(ENABLE_HTTPS));
+ } catch (ApplicationSettingsException e) {
+ return false;
+ }
+ }
+
+
+ public static String getHostScheduler() throws ApplicationSettingsException {
+ return getSetting(HOST_SCHEDULER);
+ }
+
+ public static boolean isStopAllThreads() {
+ return stopAllThreads;
+ }
+
+ public static void setStopAllThreads(boolean stopAllThreads) {
+ ServerSettings.stopAllThreads = stopAllThreads;
+ }
+
+ public static String getMyProxyServer() throws ApplicationSettingsException {
+ return getSetting(MY_PROXY_SERVER);
+ }
+
+ public static String getMyProxyUser() throws ApplicationSettingsException {
+ return getSetting(MY_PROXY_USER);
+ }
+
+ public static String getMyProxyPassword() throws ApplicationSettingsException {
+ return getSetting(MY_PROXY_PASSWORD);
+ }
+
+ public static int getMyProxyLifetime() throws ApplicationSettingsException {
+ return Integer.parseInt(getSetting(MY_PROXY_LIFETIME));
+ }
+
+ public static String[] getActivityListeners() throws ApplicationSettingsException {
+ return getSetting(ACTIVITY_LISTENERS).split(",");
+ }
+
+ public static String getStatusPublisher() throws ApplicationSettingsException {
+ return getSetting(STATUS_PUBLISHER);
+ }
+
+ public static String getTaskLaunchPublisher() throws ApplicationSettingsException {
+ return getSetting(TASK_LAUNCH_PUBLISHER);
+ }
+
+ public static boolean isGFacPassiveMode()throws ApplicationSettingsException {
+ String setting = getSetting(GFAC_PASSIVE);
+ return Boolean.parseBoolean(setting);
+ }
+
+ public static boolean isEmbeddedZK() {
+ return Boolean.parseBoolean(getSetting(EMBEDDED_ZK, "true"));
+ }
+
+ public static String getIp() {
+ try {
+ return getSetting(IP);
+ } catch (ApplicationSettingsException e) {
+ try {
+ return InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e1) {
+ e1.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ public static int getEnactmentThreadPoolSize() {
+ String threadPoolSize = null;
+ try {
+ threadPoolSize = getSetting(ENACTMENT_THREAD_POOL_SIZE);
+ } catch (ApplicationSettingsException e) {
+ return DEFAULT_ENACTMENT_THREAD_POOL_SIZE;
+ }
+ return Integer.valueOf(threadPoolSize);
+ }
+
+ public static String getWorkflowParser() throws ApplicationSettingsException {
+ return getSetting(WORKFLOW_PARSER);
+ }
+
+
+ public static int getEmailMonitorPeriod() throws ApplicationSettingsException {
+ return Integer.valueOf(getSetting(EMAIL_BASED_MONITORING_PERIOD, "100000"));
+
+ }
+
+ public static String getEmailBasedMonitorHost() throws ApplicationSettingsException {
+ return getSetting(EMAIL_BASED_MONITOR_HOST);
+ }
+
+ public static String getEmailBasedMonitorAddress() throws ApplicationSettingsException {
+ return getSetting(EMAIL_BASED_MONITOR_ADDRESS);
+ }
+
+ public static String getEmailBasedMonitorPassword() throws ApplicationSettingsException {
+ return getSetting(EMAIL_BASED_MONITOR_PASSWORD);
+ }
+
+ public static String getEmailBasedMonitorFolderName() throws ApplicationSettingsException {
+ return getSetting(EMAIL_BASED_MONITOR_FOLDER_NAME);
+ }
+
+ public static String getEmailBasedMonitorStoreProtocol() throws ApplicationSettingsException {
+ return getSetting(EMAIL_BASED_MONITOR_STORE_PROTOCOL);
+ }
+
+ public static boolean isEmailBasedNotificationEnable() {
+ return Boolean.valueOf(getSetting(ENABLE_EMAIL_BASED_MONITORING, "false"));
+ }
+
+ public static boolean isAPISecured() throws ApplicationSettingsException {
+ return Boolean.valueOf(getSetting(Constants.IS_API_SECURED));
+ }
+
+ public static String getRemoteOauthServerUrl() throws ApplicationSettingsException {
+ return getSetting(Constants.REMOTE_OAUTH_SERVER_URL);
+ }
+
+ public static String getAdminUsername() throws ApplicationSettingsException {
+ return getSetting(Constants.ADMIN_USERNAME);
+ }
+
+ public static String getAdminPassword() throws ApplicationSettingsException {
+ return getSetting(Constants.ADMIN_PASSWORD);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java
new file mode 100644
index 0000000..0c54053
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java
@@ -0,0 +1,93 @@
+///*
+// *
+// * Licensed to the Apache Software Foundation (ASF) under one
+// * or more contributor license agreements. See the NOTICE file
+// * distributed with this work for additional information
+// * regarding copyright ownership. The ASF licenses this file
+// * to you under the Apache License, Version 2.0 (the
+// * "License"); you may not use this file except in compliance
+// * with the License. You may obtain a copy of the License at
+// *
+// * http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing,
+// * software distributed under the License is distributed on an
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// * KIND, either express or implied. See the License for the
+// * specific language governing permissions and limitations
+// * under the License.
+// *
+// */
+//
+//package org.apache.airavata.common.utils;
+//
+//import java.io.IOException;
+//import java.net.SocketException;
+//
+//import org.apache.airavata.common.exception.ApplicationSettingsException;
+//import org.apache.axis2.context.ConfigurationContext;
+//import org.apache.axis2.description.TransportInDescription;
+//import org.apache.axis2.util.Utils;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//
+//public class ServiceUtils {
+// private static final Logger log = LoggerFactory.getLogger(ServiceUtils.class);
+//// private static final String REPOSITORY_PROPERTIES = "airavata-server.properties";
+// public static final String IP = "ip";
+// public static final String PORT = "port";
+//
+// public static String generateServiceURLFromConfigurationContext(
+// ConfigurationContext context, String serviceName) throws IOException, ApplicationSettingsException {
+//// URL url = ServiceUtils.class.getClassLoader()
+//// .getResource(REPOSITORY_PROPERTIES);
+// String localAddress = null;
+// String port = null;
+//// Properties properties = new Properties();
+// try {
+// localAddress = ServerSettings.getSetting(IP);
+// } catch (ApplicationSettingsException e) {
+// //we will ignore this exception since the properties file will not contain the values
+// //when it is ok to retrieve them from the axis2 context
+// }
+// if(localAddress == null){
+// try {
+// localAddress = Utils.getIpAddress(context
+// .getAxisConfiguration());
+// } catch (SocketException e) {
+// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+// }
+// }
+// String protocol="http";
+// if(ServerSettings.isEnableHttps()){
+// protocol="https";
+// }
+//
+// try {
+// port = ServerSettings.getTomcatPort(protocol);
+// } catch (ApplicationSettingsException e) {
+// //we will ignore this exception since the properties file will not contain the values
+// //when it is ok to retrieve them from the axis2 context
+// }
+// if (port == null) {
+// TransportInDescription transportInDescription = context
+// .getAxisConfiguration().getTransportsIn()
+// .get(protocol);
+// if (transportInDescription != null
+// && transportInDescription.getParameter(PORT) != null) {
+// port = (String) transportInDescription
+// .getParameter(PORT).getValue();
+// }
+// }
+// localAddress = protocol+"://" + localAddress + ":" + port;
+// localAddress = localAddress + "/"
+// //We are not using axis2 config context to get the context root because it is invalid
+// //+ context.getContextRoot() + "/"
+// //FIXME: the context root will be correct after updating the web.xml
+// + ServerSettings.getServerContextRoot() + "/"
+// + context.getServicePath() + "/"
+// + serviceName;
+// log.debug("Service Address Configured:" + localAddress);
+// return localAddress;
+// }
+//}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/StringUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/StringUtil.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/StringUtil.java
new file mode 100644
index 0000000..3ce5cda
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/StringUtil.java
@@ -0,0 +1,480 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
+
+public class StringUtil {
+ public static final String DELIMETER=",";
+ public static final String QUOTE="\"";
+
+ public static Map<Integer, String> getContainedParameters(String s) {
+ Map<Integer,String> parameterMap=new HashMap<Integer,String>();
+ int i=0;
+ for(i=0;i<s.length();i++){
+ if (s.charAt(i)=='$' && (i+1)<s.length() && s.charAt(i+1)=='{'){
+ int i2=s.indexOf('{', i+2);
+ int e=s.indexOf('}', i+2);
+ if (e!=-1){
+ if (i2==-1 || e<i2){
+ parameterMap.put(i, s.substring(i,e+1));
+ i=e;
+ }
+ }
+ }
+ }
+ return parameterMap;
+ }
+
+ // Merits for the following function should go to
+ // http://blog.houen.net/java-get-url-from-string/
+ public static List<String> getURLS(String text) {
+ List<String> links = new ArrayList<String>();
+ String regex = "\\(?\\b((http|https|ftp)://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]";
+ Pattern p = Pattern.compile(regex);
+ Matcher m = p.matcher(text);
+ while (m.find()) {
+ String urlStr = m.group();
+ if (urlStr.startsWith("(") && urlStr.endsWith(")")) {
+ urlStr = urlStr.substring(1, urlStr.length() - 1);
+ }
+ if (!links.contains(urlStr)) {
+ links.add(urlStr);
+ }
+ }
+ return links;
+ }
+
+ public static String createHTMLUrlTaggedString2(String value, List<String> pullLinks) {
+ for (String url : pullLinks) {
+ String hyperlinkString="<a href='"+url+"'>"+url+"</a>";
+ value=value.replaceAll(Pattern.quote(url), hyperlinkString);
+ }
+ return value;
+ }
+ public static String createHTMLUrlTaggedString(String value) {
+ String urledString = "";
+ int lastIndex=0,index=0;
+ while(index!=-1){
+ index=value.toLowerCase().indexOf("://",lastIndex);
+ if (index!=-1){
+ int beginIndex=value.lastIndexOf(" ",index);
+ urledString+=value.substring(lastIndex,beginIndex+1);
+ int endIndex=value.indexOf(" ",index);
+ if (beginIndex==-1){
+ beginIndex=0;
+ }else{
+ beginIndex++;
+ }
+ if (endIndex==-1){
+ endIndex=value.length();
+ }
+ String url=value.substring(beginIndex, endIndex);
+ urledString+="<a href='"+url+"'>"+url+"</a>";
+ lastIndex=endIndex;
+ }
+ }
+ urledString+=value.substring(lastIndex, value.length());
+ return urledString;
+ }
+
+ private static boolean isQuoted(String s, String delimiter){
+ //Check if we need quotes
+ if (s.contains(delimiter)){
+ //Check if its already quoted
+ s=s.replaceAll("\"\"", "");
+ return (s.substring(0,1).equals(QUOTE) && s.subSequence(s.length()-1, s.length()).equals(QUOTE));
+ }
+ //no delimiters present, so already in proper form
+ return true;
+ }
+
+ private static boolean isQuoted(String s){
+ return isQuoted(s, DELIMETER);
+ }
+
+ /**
+ * Create a delimiter separated string out of a list
+ * @param list
+ * @return
+ */
+ public static String createDelimiteredString(String[] list) {
+ return createDelimiteredString(list, DELIMETER);
+ }
+
+
+ /**
+ * Create a delimiter separated string out of a list
+ * @param list
+ * @return
+ */
+ public static String createDelimiteredString(String[] list,String delimiter){
+ String s=null;
+ for (String ss : list) {
+ ss=quoteString(ss, delimiter);
+ if (s==null){
+ s=ss;
+ }else{
+ s+=delimiter +ss;
+ }
+ }
+ return s;
+ }
+
+ /**
+ * Return a proper quoted string if the string contains the delimiter character
+ * @param s
+ * @return
+ */
+ public static String quoteString(String s) {
+ return quoteString(s, DELIMETER);
+ }
+
+
+ /**
+ * Return a proper quoted string if the string contains the delimiter character
+ * @param s
+ * @return
+ */
+ public static String quoteString(String s,String delimiter){
+ if (isQuoted(s,delimiter)){
+ return s;
+ }else{
+ return QUOTE+s.replaceAll(QUOTE, QUOTE+QUOTE)+QUOTE;
+ }
+ }
+
+ /**
+ * Parse the delimitered string and return elements as a string array
+ * @param s
+ * @return
+ */
+ public static String[] getElementsFromString(String s, String delimeter, String quote) {
+ List<String> list=new ArrayList<String>();
+ String currentItem="";
+ String previousChar=null;
+ boolean insideQuote=false;
+ for(int i=0;i<s.length();i++){
+ String c=s.substring(i,i+1);
+ if (c.equals(delimeter)){
+ //if not inside a quoted string ignore the delimiter character
+ if (insideQuote) {
+ currentItem+=c;
+ }else{
+ list.add(currentItem);
+ currentItem = "";
+ }
+ }else if (c.equals(quote)){
+ if (quote.equals(previousChar)){
+ //which means previousChar was an escape character, not a quote for the string
+ currentItem+=quote;
+ if (insideQuote){
+ //mistakenly thought previous char was opening quote char, thus need to make this false
+ insideQuote=false;
+ }else{
+ //mistakenly thought previous char was closing quote char, thus need to make this true
+ insideQuote=true;
+ }
+ } else{
+ if (insideQuote){
+ //quote ended
+ insideQuote=false;
+ }else{
+ //quote beginning
+ insideQuote=true;
+ }
+ }
+ }else{
+ currentItem+=c;
+ }
+ previousChar=c;
+ }
+ list.add(currentItem);
+ return list.toArray(new String[]{});
+ }
+
+ /**
+ * Parse the delimitered string and return elements as a string array
+ * @param s
+ * @return
+ */
+ public static String[] getElementsFromString(String s) {
+ return getElementsFromString(s, DELIMETER, QUOTE);
+ }
+
+ /**
+ * Converts object to String without worrying about null check.
+ *
+ * @param object
+ * @return The object.toString if object is not null; "" otherwise.
+ */
+ public static String toString(Object object) {
+ if (object == null) {
+ return "";
+ } else {
+ return object.toString();
+ }
+ }
+
+ /**
+ * Trims a specified string, and makes it null if the result is empty string.
+ *
+ * @param string
+ * @return the string processed
+ */
+ public static String trimAndNullify(String string) {
+ if (string != null) {
+ string = string.trim();
+ if (string.equals("")) {
+ string = null;
+ }
+ }
+ return string;
+ }
+
+ /**
+ * @param oldName
+ * @return Trimmed String
+ */
+ public static String trimSpaceInString(String oldName) {
+ if (oldName == null) {
+ return "";
+ }
+ return oldName.replace(" ", "");
+ }
+
+ /**
+ * Converts a specified string to a Java identifier.
+ *
+ * @param name
+ * @return the Java identifier
+ */
+ public static String convertToJavaIdentifier(String name) {
+
+ final char REPLACE_CHAR = '_';
+
+ if (name == null || name.length() == 0) {
+ return "" + REPLACE_CHAR;
+ }
+
+ StringBuilder buf = new StringBuilder();
+
+ char c = name.charAt(0);
+ if (!Character.isJavaIdentifierStart(c)) {
+ // Add _ at the beggining instead of replacing it to _. This is
+ // more readable if the name is like 3D_Model.
+ buf.append(REPLACE_CHAR);
+ }
+
+ for (int i = 0; i < name.length(); i++) {
+ c = name.charAt(i);
+ if (Character.isJavaIdentifierPart(c)) {
+ buf.append(c);
+ } else {
+ buf.append(REPLACE_CHAR);
+ }
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * Creates a new name by incrementing the number after the underscore at the end of the old name. If there is no
+ * underscore and number at the end, put "_2" at the end.
+ *
+ * @param oldName
+ * @return the new name
+ */
+ public static String incrementName(String oldName) {
+
+ final char PREFIX = '_';
+
+ String newName;
+ if (oldName == null || oldName.length() == 0) {
+ newName = "noName";
+ } else {
+ int lastDashIndex = oldName.lastIndexOf(PREFIX);
+ if (lastDashIndex < 0) {
+ newName = oldName + PREFIX + 2;
+ } else {
+ String suffix = oldName.substring(lastDashIndex + 1);
+ try {
+ int number = Integer.parseInt(suffix);
+ int newNumber = number + 1;
+ newName = oldName.substring(0, lastDashIndex + 1) + newNumber;
+ } catch (RuntimeException e) {
+ // It was not a number
+ newName = oldName + PREFIX + 2;
+ }
+ }
+ }
+ return newName;
+ }
+
+ /**
+ * Returns the local class name of a specified class.
+ *
+ * @param klass
+ * The specified class
+ * @return The local class name
+ */
+ public static String getClassName(Class klass) {
+ String fullName = klass.getName();
+ int index = fullName.lastIndexOf(".");
+ if (index < 0) {
+ return fullName;
+ } else {
+ return fullName.substring(index + 1);
+ }
+ }
+
+ /**
+ * @param throwable
+ * @return The stackTrace in String
+ */
+ public static String getStackTraceInString(Throwable throwable) {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ PrintStream printStream = new PrintStream(byteArrayOutputStream);
+ throwable.printStackTrace(printStream);
+ printStream.flush();
+ return byteArrayOutputStream.toString();
+ }
+
+ private static Options deriveCommandLineOptions(String[] args){
+ Options options = new Options();
+ String[] argCopy = getChangedList(args);
+ int i=0;
+ for (String arg : argCopy) {
+ if (arg.startsWith("--")){
+ arg=arg.substring(2);
+ int pos = arg.indexOf('=');
+ String opt;
+ boolean hasArgs=true;
+ if (pos==-1){ //if not of the form --arg=value
+ if (i==argCopy.length-1 || argCopy[i+1].startsWith("-")){ // no value specified
+ hasArgs=false;
+ }
+ opt=arg;
+ }else{
+ opt=arg.substring(0, pos);
+ }
+ options.addOption(opt, hasArgs, "");
+ }
+ i++;
+ }
+ return options;
+ }
+
+ public static Map<String, String> parseCommandLineOptions(String[] args) {
+ Map<String,String> commandLineOptions=new HashMap<String,String>();
+ try {
+ CommandLineParameters cmdParameters = getCommandLineParser(args);
+ Map<String, String> parameters = cmdParameters.getParameters();
+ for (String s : parameters.keySet()) {
+ commandLineOptions.put(s, parameters.get(s)==null? "":parameters.get(s));
+ }
+ } catch (ParseException e1) {
+ e1.printStackTrace();
+ }
+ return commandLineOptions;
+ }
+
+ public static CommandLineParameters getCommandLineParser(String[] args)
+ throws ParseException {
+ String[] argCopy = getChangedList(args);
+ CommandLineParser parser = new DynamicOptionPosixParser();
+ CommandLine cmdLine = parser.parse(deriveCommandLineOptions(argCopy), argCopy);
+ return new CommandLineParameters(cmdLine);
+ }
+
+
+ //commons-cli does not support arg names having the period (".")
+ private static final String ARG_DOT_REPLACE="dot_replacement_value";
+
+ private static String[] getChangedList(String[] args) {
+ String[] argCopy = Arrays.asList(args).toArray(new String []{});
+ for (int i=0;i<argCopy.length; i++) {
+ argCopy[i]=changeOption(argCopy[i]);
+ }
+ return argCopy;
+ }
+
+ private static String revertOption(String option){
+ return option==null? option : option.replaceAll(Pattern.quote(ARG_DOT_REPLACE), ".");
+ }
+
+ private static String changeOption(String option){
+ return option==null? option : option.replaceAll(Pattern.quote("."), ARG_DOT_REPLACE);
+ }
+
+ private static class DynamicOptionPosixParser extends PosixParser{
+ @Override
+ protected void processOption(String arg0, @SuppressWarnings("rawtypes") ListIterator arg1)
+ throws ParseException {
+ if (getOptions().hasOption(arg0)){
+ super.processOption(arg0, arg1);
+ }
+ }
+ }
+
+ public static class CommandLineParameters{
+ private Map<String,String> parameters=new HashMap<String, String>();
+ private List<String> arguments=new ArrayList<String>();
+ protected CommandLineParameters(CommandLine cmd){
+ for(Option opt:cmd.getOptions()){
+ parameters.put(revertOption(opt.getOpt()), revertOption(opt.getValue()));
+ }
+ for(String arg:cmd.getArgs()){
+ arguments.add(revertOption(arg));
+ }
+ }
+ public List<String> getArguments() {
+ return arguments;
+ }
+ public void setArguments(List<String> arguments) {
+ this.arguments = arguments;
+ }
+ public Map<String,String> getParameters() {
+ return parameters;
+ }
+ public void setParameters(Map<String,String> parameters) {
+ this.parameters = parameters;
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/SwingUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/SwingUtil.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/SwingUtil.java
new file mode 100644
index 0000000..dc9a7e2
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/SwingUtil.java
@@ -0,0 +1,358 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Toolkit;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.net.URL;
+import java.util.List;
+
+import javax.swing.ImageIcon;
+import javax.swing.JTextField;
+import javax.swing.Spring;
+import javax.swing.SpringLayout;
+
+public class SwingUtil {
+
+ /**
+ * Minimum size, zero.
+ */
+ public static final Dimension MINIMUM_SIZE = new Dimension(0, 0);
+
+ /**
+ * The default distance between components.
+ */
+ public static final int PAD = 6;
+
+ /**
+ * Default cursor.
+ */
+ public static final Cursor DEFAULT_CURSOR = new Cursor(Cursor.DEFAULT_CURSOR);
+
+ /**
+ * Hand cursor.
+ */
+ public static final Cursor HAND_CURSOR = new Cursor(Cursor.HAND_CURSOR);
+
+ /**
+ * Cross hair cursor.
+ */
+ public static final Cursor CROSSHAIR_CURSOR = new Cursor(Cursor.CROSSHAIR_CURSOR);
+
+ /**
+ * Move cursor.
+ */
+ public static final Cursor MOVE_CURSOR = new Cursor(Cursor.MOVE_CURSOR);
+
+ /**
+ * Wait cursor.
+ */
+ public static final Cursor WAIT_CURSOR = new Cursor(Cursor.WAIT_CURSOR);
+
+ /**
+ * Creates an icon from an image contained in the "images" directory.
+ *
+ * @param filename
+ * @return the ImageIcon created
+ */
+ public static ImageIcon createImageIcon(String filename) {
+ ImageIcon icon = null;
+ URL imgURL = getImageURL(filename);
+ if (imgURL != null) {
+ icon = new ImageIcon(imgURL);
+ }
+ return icon;
+ }
+
+ /**
+ * Creates an image from an image contained in the "images" directory.
+ *
+ * @param filename
+ * @return the Image created
+ */
+ public static Image createImage(String filename) {
+ Image icon = null;
+ URL imgURL = getImageURL(filename);
+ if (imgURL != null) {
+ icon = Toolkit.getDefaultToolkit().getImage(imgURL);
+ }
+ return icon;
+ }
+
+ public static URL getImageURL(String filename) {
+ String path = "/images/" + filename;
+ URL imgURL = SwingUtil.class.getResource(path);
+ return imgURL;
+ }
+
+ /**
+ * Return the Frame of a specified component if any.
+ *
+ * @param component
+ * the specified component
+ *
+ * @return the Frame of a specified component if any; otherwise null
+ */
+ public static Frame getFrame(Component component) {
+ Frame frame;
+ Component parent;
+ while ((parent = component.getParent()) != null) {
+ component = parent;
+ }
+ if (component instanceof Frame) {
+ frame = (Frame) component;
+ } else {
+ frame = null;
+ }
+ return frame;
+ }
+
+ /**
+ * Wight none of rows or eolumns. Used by layoutToGrid().
+ */
+ public final static int WEIGHT_NONE = -1;
+
+ /**
+ * Weight all rows or columns equally. Used by layoutToGrid().
+ */
+ public final static int WEIGHT_EQUALLY = -2;
+
+ /**
+ * Layouts the child components of a specified parent component using GridBagLayout.
+ *
+ * @param parent
+ * The specified parent component
+ * @param numRow
+ * The number of rows
+ * @param numColumn
+ * The number of columns
+ * @param weightedRow
+ * The row to weight
+ * @param weightedColumn
+ * The column to weight
+ */
+ public static void layoutToGrid(Container parent, int numRow, int numColumn, int weightedRow, int weightedColumn) {
+ GridBagLayout layout = new GridBagLayout();
+ parent.setLayout(layout);
+ GridBagConstraints constraints = new GridBagConstraints();
+
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.insets = new Insets(SwingUtil.PAD, SwingUtil.PAD, SwingUtil.PAD, SwingUtil.PAD);
+
+ for (int row = 0; row < numRow; row++) {
+ constraints.gridy = row;
+ if (weightedRow == WEIGHT_EQUALLY) {
+ constraints.weighty = 1;
+ } else if (row == weightedRow) {
+ constraints.weighty = 1;
+ } else {
+ constraints.weighty = 0;
+ }
+ for (int column = 0; column < numColumn; column++) {
+ constraints.gridx = column;
+ if (weightedColumn == WEIGHT_EQUALLY) {
+ constraints.weightx = 1;
+ } else if (column == weightedColumn) {
+ constraints.weightx = 1;
+ } else {
+ constraints.weightx = 0;
+ }
+ Component component = parent.getComponent(row * numColumn + column);
+ layout.setConstraints(component, constraints);
+ }
+ }
+ }
+
+ /**
+ * @param parent
+ * @param rowWeights
+ * @param columnWeights
+ */
+ public static void layoutToGrid(Container parent, double[] rowWeights, double[] columnWeights) {
+ GridBagLayout layout = new GridBagLayout();
+ parent.setLayout(layout);
+ GridBagConstraints constraints = new GridBagConstraints();
+
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.insets = new Insets(SwingUtil.PAD, SwingUtil.PAD, SwingUtil.PAD, SwingUtil.PAD);
+
+ for (int row = 0; row < rowWeights.length; row++) {
+ constraints.gridy = row;
+ constraints.weighty = rowWeights[row];
+ for (int column = 0; column < columnWeights.length; column++) {
+ constraints.gridx = column;
+ constraints.weightx = columnWeights[column];
+ Component component = parent.getComponent(row * columnWeights.length + column);
+ layout.setConstraints(component, constraints);
+ }
+ }
+ }
+
+ /**
+ * @param parent
+ * @param rowWeights
+ * @param columnWeights
+ */
+ @SuppressWarnings("boxing")
+ public static void layoutToGrid(Container parent, List<Double> rowWeights, List<Double> columnWeights) {
+ GridBagLayout layout = new GridBagLayout();
+ parent.setLayout(layout);
+ GridBagConstraints constraints = new GridBagConstraints();
+
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.insets = new Insets(SwingUtil.PAD, SwingUtil.PAD, SwingUtil.PAD, SwingUtil.PAD);
+
+ for (int row = 0; row < rowWeights.size(); row++) {
+ constraints.gridy = row;
+ constraints.weighty = rowWeights.get(row);
+ for (int column = 0; column < columnWeights.size(); column++) {
+ constraints.gridx = column;
+ constraints.weightx = columnWeights.get(column);
+ Component component = parent.getComponent(row * columnWeights.size() + column);
+ layout.setConstraints(component, constraints);
+ }
+ }
+ }
+
+ /**
+ * Aligns the first <code>rows</code> * <code>cols</code> components of <code>parent</code> in a grid. Each
+ * component in a column is as wide as the maximum preferred width of the components in that column; height is
+ * similarly determined for each row. The parent is made just big enough to fit them all.
+ *
+ * @param parent
+ *
+ * @param rows
+ * number of rows
+ * @param cols
+ * number of columns
+ */
+ public static void makeSpringCompactGrid(Container parent, int rows, int cols) {
+ makeSpringCompactGrid(parent, rows, cols, PAD, PAD, PAD, PAD);
+ }
+
+ /**
+ * Aligns the first <code>rows</code> * <code>cols</code> components of <code>parent</code> in a grid. Each
+ * component in a column is as wide as the maximum preferred width of the components in that column; height is
+ * similarly determined for each row. The parent is made just big enough to fit them all.
+ *
+ * @param parent
+ *
+ * @param rows
+ * number of rows
+ * @param cols
+ * number of columns
+ * @param initialX
+ * x location to start the grid at
+ * @param initialY
+ * y location to start the grid at
+ * @param xPad
+ * x padding between cells
+ * @param yPad
+ * y padding between cells
+ */
+ private static void makeSpringCompactGrid(Container parent, int rows, int cols, int initialX, int initialY,
+ int xPad, int yPad) {
+
+ SpringLayout layout = new SpringLayout();
+ parent.setLayout(layout);
+
+ // Align all cells in each column and make them the same width.
+ Spring x = Spring.constant(initialX);
+ for (int c = 0; c < cols; c++) {
+ Spring width = Spring.constant(0);
+ for (int r = 0; r < rows; r++) {
+ width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth());
+ }
+ for (int r = 0; r < rows; r++) {
+ SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
+ constraints.setX(x);
+ constraints.setWidth(width);
+ }
+ x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
+ }
+
+ // Align all cells in each row and make them the same height.
+ Spring y = Spring.constant(initialY);
+ for (int r = 0; r < rows; r++) {
+ Spring height = Spring.constant(0);
+ for (int c = 0; c < cols; c++) {
+ height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight());
+ }
+ for (int c = 0; c < cols; c++) {
+ SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
+ constraints.setY(y);
+ constraints.setHeight(height);
+ }
+ y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
+ }
+
+ // Set the parent's size.
+ SpringLayout.Constraints pCons = layout.getConstraints(parent);
+ pCons.setConstraint(SpringLayout.SOUTH, y);
+ pCons.setConstraint(SpringLayout.EAST, x);
+ }
+
+ /* Used by makeCompactGrid. */
+ private static SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent, int cols) {
+ SpringLayout layout = (SpringLayout) parent.getLayout();
+ Component c = parent.getComponent(row * cols + col);
+ return layout.getConstraints(c);
+ }
+
+ public static void addPlaceHolder(final JTextField field,final String placeHolderText){
+ field.addFocusListener(new FocusListener(){
+ private Color fontColor=field.getForeground();
+// private String previousText=field.getText();
+
+ public void focusGained(FocusEvent arg0) {
+ if (field.getText().equals(placeHolderText)){
+ field.setText("");
+ }
+ field.setForeground(fontColor);
+ }
+
+ public void focusLost(FocusEvent arg0) {
+ if (field.getText().trim().equals("")){
+ fontColor=field.getForeground();
+ field.setForeground(Color.GRAY);
+ field.setText(placeHolderText);
+ }
+ }
+ });
+ if (field.getText().trim().equals("")){
+ field.setText(placeHolderText);
+ field.setForeground(Color.GRAY);
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/ThriftUtils.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/ThriftUtils.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/ThriftUtils.java
new file mode 100644
index 0000000..ee86f74
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/ThriftUtils.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import org.apache.thrift.TBase;
+import org.apache.thrift.TDeserializer;
+import org.apache.thrift.TException;
+import org.apache.thrift.TSerializer;
+
+public class ThriftUtils {
+ public static byte[] serializeThriftObject(TBase object) throws TException {
+ return new TSerializer().serialize(object);
+ }
+
+ public static void createThriftFromBytes(byte []bytes, TBase object) throws TException {
+ new TDeserializer().deserialize(object, bytes);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/Version.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/Version.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/Version.java
new file mode 100644
index 0000000..fe34bb1
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/Version.java
@@ -0,0 +1,120 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlRootElement
+public class Version {
+ public String PROJECT_NAME;
+ private Integer majorVersion=0;
+ private Integer minorVersion=0;
+ private Integer maintenanceVersion;
+ private String versionData;
+ private BuildType buildType;
+
+ public static enum BuildType{
+ ALPHA,
+ BETA,
+ RC
+ }
+
+ public Version() {
+ }
+
+ public Version(String PROJECT_NAME,Integer majorVersion,Integer minorVersion,Integer maintenanceVersion,String versionData,BuildType buildType) {
+ this.PROJECT_NAME=PROJECT_NAME;
+ this.majorVersion=majorVersion;
+ this.minorVersion=minorVersion;
+ this.maintenanceVersion=maintenanceVersion;
+ this.versionData=versionData;
+ this.buildType=buildType;
+ }
+
+ public Integer getMajorVersion() {
+ return majorVersion;
+ }
+
+ public Integer getMinorVersion() {
+ return minorVersion;
+ }
+
+ public Integer getMaintenanceVersion() {
+ return maintenanceVersion;
+ }
+
+ public String getVersionData() {
+ return versionData;
+ }
+
+ public BuildType getBuildType() {
+ return buildType;
+ }
+
+ public String getVersion(){
+ String version = getBaseVersion();
+ version = attachVersionData(version);
+ return version;
+ }
+
+ private String attachVersionData(String version) {
+ if (getVersionData()!=null){
+ version+="-"+getVersionData();
+ }
+ return version;
+ }
+
+ public String getBaseVersion() {
+ String version=getMajorVersion().toString()+"."+getMinorVersion();
+ return version;
+ }
+
+ public String getFullVersion(){
+ String version = getBaseVersion();
+ version = attachMaintainanceVersion(version);
+ version = attachVersionData(version);
+ version = attachBuildType(version);
+ return version;
+ }
+
+ private String attachMaintainanceVersion(String version) {
+ if (getMaintenanceVersion()!=null){
+ version+="."+getMaintenanceVersion();
+ }
+ return version;
+ }
+
+ private String attachBuildType(String version) {
+ if (getBuildType()!=null){
+ version+="-"+getBuildType().name();
+ }
+ return version;
+ }
+
+ @Override
+ public String toString() {
+ return getVersion();
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/WSConstants.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/WSConstants.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/WSConstants.java
new file mode 100644
index 0000000..9737ac4
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/WSConstants.java
@@ -0,0 +1,187 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import javax.xml.namespace.QName;
+
+import org.xmlpull.infoset.XmlNamespace;
+
+public interface WSConstants {
+
+ /**
+ * xmlns
+ */
+ public final static String XMLNS = "xmlns";
+
+ /**
+ * XML Schema prefix, xsd
+ */
+ public static final String XSD_NS_PREFIX = "xsd";
+
+ /**
+ * XML Schema URI.
+ */
+ public static final String XSD_NS_URI = "http://www.w3.org/2001/XMLSchema";
+
+// /**
+// * XML Schema Namespace
+// */
+// public static final XmlNamespace XSD_NS = XmlConstants.BUILDER.newNamespace(XSD_NS_PREFIX, XSD_NS_URI);
+
+ /**
+ * The any type.
+ */
+ public static final QName XSD_ANY_TYPE = new QName(XSD_NS_URI, "any", XSD_NS_PREFIX);
+
+ /**
+ * xsd:anyURI
+ */
+ public static final QName XSD_ANY_URI = new QName(XSD_NS_URI, "anyURI", XSD_NS_PREFIX);
+
+ /**
+ * tns
+ */
+ public static final String TARGET_NS_PREFIX = "tns";
+
+ /**
+ * typens
+ */
+ public static final String TYPE_NS_PREFIX = "typens";
+
+ /**
+ * schema
+ */
+ public static final String SCHEMA_TAG = "schema";
+
+ /**
+ * Element name for annotation, annotation
+ */
+ public static final String ANNOTATION_TAG = "annotation";
+
+ /**
+ * Element name for documentation, documentation
+ */
+ public static final String DOCUMENTATION_TAG = "documentation";
+
+ /**
+ * appinfo
+ */
+ public static final String APPINFO_TAG = "appinfo";
+
+ /**
+ * element
+ */
+ public static final String ELEMENT_TAG = "element";
+
+ /**
+ * sequence
+ */
+ public static final String SEQUENCE_TAG = "sequence";
+
+ /**
+ * complexType
+ */
+ public static final String COMPLEX_TYPE_TAG = "complexType";
+
+ /**
+ * simpleType
+ */
+ public static final String SIMPLE_TYPE_TAG = "simpleType";
+
+ /**
+ * name
+ */
+ public static final String NAME_ATTRIBUTE = "name";
+
+ /**
+ * type
+ */
+ public static final String TYPE_ATTRIBUTE = "type";
+
+ /**
+ * targetNamespace
+ */
+ public static final String TARGET_NAMESPACE_ATTRIBUTE = "targetNamespace";
+
+ /**
+ * elementFormDefault
+ */
+ public final static String ELEMENT_FORM_DEFAULT_ATTRIBUTE = "elementFormDefault";
+
+ /**
+ * unqualified
+ */
+ public final static String UNQUALIFIED_VALUE = "unqualified";
+
+ /**
+ * default
+ */
+ public static final String DEFAULT_ATTRIBUTE = "default";
+
+ /**
+ * UsingAddressing
+ */
+ public static final String USING_ADDRESSING_TAG = "UsingAddressing";
+
+ /**
+ * <appinfo xmlns="http://www.w3.org/2001/XMLSchema">
+ *
+ * </appinfo>
+ */
+// public static final String EMPTY_APPINFO = "<appinfo xmlns=\"http://www.w3.org/2001/XMLSchema\">\n\n</appinfo>";
+ public static final String EMPTY_APPINFO = "{'appinfo': '' }";
+
+ /**
+ * minOccurs
+ */
+ public static final String MIN_OCCURS_ATTRIBUTE = "minOccurs";
+
+ /**
+ * maxOccurs
+ */
+ public static final String MAX_OCCURS_ATTRIBUTE = "maxOccurs";
+
+ /**
+ * unbounded
+ */
+ public static final String UNBOUNDED_VALUE = "unbounded";
+
+ /**
+ * import
+ */
+ public static final String IMPORT_TAG = "import";
+
+ /**
+ * schemaLocation
+ */
+ public static final String SCHEMA_LOCATION_ATTRIBUTE = "schemaLocation";
+
+ public static final String LEAD_NS_URI = "http://www.extreme.indiana.edu/lead";
+
+ /**
+ * The any type.
+ */
+ public static final QName LEAD_ANY_TYPE = new QName(LEAD_NS_URI, "any",
+ XSD_NS_PREFIX);
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/WSDLUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/WSDLUtil.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/WSDLUtil.java
new file mode 100644
index 0000000..81c8d93
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/WSDLUtil.java
@@ -0,0 +1,546 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.net.URI;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.airavata.common.exception.UtilsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xmlpull.infoset.XmlAttribute;
+import org.xmlpull.infoset.XmlBuilderException;
+import org.xmlpull.infoset.XmlElement;
+import org.xmlpull.infoset.XmlNamespace;
+
+//import xsul.XmlConstants;
+//import xsul5.wsdl.WsdlBinding;
+//import xsul5.wsdl.WsdlDefinitions;
+//import xsul5.wsdl.WsdlPortType;
+//import xsul5.wsdl.WsdlPortTypeOperation;
+//import xsul5.wsdl.WsdlUtil;
+
+public class WSDLUtil {
+
+ private static final Logger logger = LoggerFactory.getLogger(WSDLUtil.class);
+
+// /**
+// * @param wsdlString
+// * @return The WSDL
+// * @throws UtilsException
+// */
+// public static WsdlDefinitions stringToWSDL(String wsdlString) throws UtilsException {
+// try {
+// XmlElement wsdlElement = XMLUtil.stringToXmlElement(wsdlString);
+// WsdlDefinitions definitions = new WsdlDefinitions(wsdlElement);
+// return definitions;
+// } catch (RuntimeException e) {
+// throw new UtilsException(e);
+// }
+// }
+//
+// /**
+// * @param definitions3
+// * @return The WsdlDefinitions (XSUL5)
+// */
+// public static xsul5.wsdl.WsdlDefinitions wsdlDefinitions3ToWsdlDefintions5(xsul.wsdl.WsdlDefinitions definitions3) {
+//
+// return new xsul5.wsdl.WsdlDefinitions(XMLUtil.xmlElement3ToXmlElement5(definitions3));
+// }
+//
+// /**
+// * @param definitions5
+// * @return The WsdlDefinitions (XSUL3)
+// */
+// public static xsul.wsdl.WsdlDefinitions wsdlDefinitions5ToWsdlDefintions3(xsul5.wsdl.WsdlDefinitions definitions5) {
+//
+// return new xsul.wsdl.WsdlDefinitions(XMLUtil.xmlElement5ToXmlElement3(definitions5.xml()));
+// }
+//
+// /**
+// * @param definitions
+// * @return The name of the WSDL.
+// */
+// public static String getWSDLName(WsdlDefinitions definitions) {
+// String wsdlName = definitions.xml().attributeValue(WSConstants.NAME_ATTRIBUTE);
+// if (wsdlName == null) {
+// // name is optional.
+// wsdlName = "";
+// }
+// return wsdlName;
+// }
+//
+// /**
+// * @param definitions
+// * @return The QName of the WSDL.
+// */
+// public static QName getWSDLQName(WsdlDefinitions definitions) {
+// String targetNamespace = definitions.getTargetNamespace();
+// String wsdlName = getWSDLName(definitions);
+// return new QName(targetNamespace, wsdlName);
+// }
+//
+// /**
+// * @param definitions
+// * @return The first portType
+// * @throws UtilsException
+// */
+// public static WsdlPortType getFirstPortType(WsdlDefinitions definitions) throws UtilsException {
+// for (WsdlPortType portType : definitions.portTypes()) {
+// return portType;
+// }
+// throw new UtilsException("No portType is defined in WSDL");
+// }
+//
+// public static WsdlPortTypeOperation getFirstOperation(WsdlDefinitions definitions) throws UtilsException {
+// for (WsdlPortTypeOperation operation : getFirstPortType(definitions).operations()) {
+// return operation;
+// }
+// throw new UtilsException("No portType is defined in WSDL");
+// }
+//
+// /**
+// * @param definitions
+// * @return The QName of the first portType.
+// * @throws UtilsException
+// */
+// public static QName getFirstPortTypeQName(WsdlDefinitions definitions) throws UtilsException {
+// String targetNamespace = definitions.getTargetNamespace();
+// for (WsdlPortType portType : definitions.portTypes()) {
+// String portTypeName = portType.getName();
+// QName portTypeQName = new QName(targetNamespace, portTypeName);
+// return portTypeQName;
+// }
+// throw new UtilsException("No portType is defined.");
+// }
+//
+// /**
+// * @param definitions
+// * @param portTypeQName
+// * @return The name of the first operation in a given portType.
+// * @throws UtilsException
+// */
+// public static String getFirstOperationName(WsdlDefinitions definitions, QName portTypeQName) throws UtilsException {
+// WsdlPortType portType = definitions.getPortType(portTypeQName.getLocalPart());
+// for (WsdlPortTypeOperation operation : portType.operations()) {
+// String operationName = operation.getOperationName();
+//
+// // XXX Temporary solution to skip some GFac specific operations.
+// if ("Shutdown".equals(operationName)) {
+// continue;
+// } else if ("Kill".equals(operationName)) {
+// continue;
+// } else if ("Ping".equals(operationName)) {
+// continue;
+// }
+//
+// return operationName;
+// }
+// throw new UtilsException("No operation is defined");
+// }
+//
+// /**
+// * @param definitions
+// * @return The cloned WsdlDefinitions
+// */
+// public static WsdlDefinitions deepClone(WsdlDefinitions definitions) throws UtilsException {
+// return new WsdlDefinitions(XMLUtil.deepClone(definitions.xml()));
+// }
+//
+// /**
+// * @param definitions
+// * @param paramType
+// * @return The schema that includes the type definition
+// */
+// public static XmlElement getSchema(WsdlDefinitions definitions, QName paramType) throws UtilsException {
+// XmlElement types = definitions.getTypes();
+//
+// Iterable<XmlElement> schemas = types.elements(WSConstants.XSD_NS, WSConstants.SCHEMA_TAG);
+// for (XmlElement schema : schemas) {
+// if (isTypeDefinedInSchema(paramType, schema)) {
+// return schema;
+// }
+// }
+//
+// // ok we didnt find the type in the schema in first level
+// // now we try try to see if it exist in schema imports.
+// // we loop in two step because its better to avoid the network
+// // connection if possible
+// for (XmlElement schema : schemas) {
+// Iterable<XmlElement> imports = schema.elements(WSConstants.XSD_NS, WSConstants.IMPORT_TAG);
+// for (XmlElement importEle : imports) {
+// String schemaLocation = importEle.attributeValue(WSConstants.SCHEMA_LOCATION_ATTRIBUTE);
+// if (null != schemaLocation && !"".equals(schemaLocation)) {
+// try {
+// // connect using a url connection
+// URL url = new URL(schemaLocation);
+// URLConnection connection = url.openConnection();
+// connection.connect();
+// XmlElement importedSchema = xsul5.XmlConstants.BUILDER.parseFragmentFromInputStream(connection
+// .getInputStream());
+// if (isTypeDefinedInSchema(paramType, importedSchema)) {
+// // still return the parent schema
+// return schema;
+// }
+// } catch (MalformedURLException e) {
+// throw new UtilsException(e);
+// } catch (XmlBuilderException e) {
+// throw new UtilsException(e);
+// } catch (IOException e) {
+// throw new UtilsException(e);
+// }
+// }
+// }
+// }
+//
+// return null;
+// }
+//
+// private static boolean isTypeDefinedInSchema(QName paramType, XmlElement schema) {
+// String schemaTargetNamespace = schema.attributeValue(WSConstants.TARGET_NAMESPACE_ATTRIBUTE);
+// if (schemaTargetNamespace.equals(paramType.getNamespaceURI())) {
+// for (XmlElement complexType : schema.elements(WSConstants.XSD_NS, WSConstants.COMPLEX_TYPE_TAG)) {
+// String complexTypeName = complexType.attributeValue(WSConstants.NAME_ATTRIBUTE);
+// if (complexTypeName.equals(paramType.getLocalPart())) {
+// return true;
+// }
+// }
+// for (XmlElement simpleType : schema.elements(WSConstants.XSD_NS, WSConstants.SIMPLE_TYPE_TAG)) {
+// String simpleTypeName = simpleType.attributeValue(WSConstants.NAME_ATTRIBUTE);
+// if (simpleTypeName.equals(paramType.getLocalPart())) {
+// return true;
+// }
+// }
+// }
+// return false;
+// }
+//
+// /**
+// * @param definitions
+// * @param paramType
+// * @return The type definition
+// */
+// public static XmlElement getTypeDefinition(WsdlDefinitions definitions, QName paramType) throws UtilsException {
+// XmlElement types = definitions.getTypes();
+// XmlElement returnType = null;
+// types.element(null, WSConstants.SCHEMA_TAG);
+// Iterable<XmlElement> schemas = types.elements(null, WSConstants.SCHEMA_TAG);
+// for (XmlElement schema : schemas) {
+//
+// returnType = findTypeInSchema(paramType, schema);
+// if (returnType != null) {
+// return returnType;
+// }
+// }
+// // ok we didnt find the type in the schemas
+// // try to find it in the schema imports.
+//
+// // if not found it will return null so we would return null
+// return findTypeDefinitionInImports(definitions, paramType);
+//
+// }
+//
+// /**
+// *
+// * @param definitions
+// * @param paramType
+// * @return
+// */
+//
+// public static XmlElement getImportContainingTypeDefinition(WsdlDefinitions definitions, QName paramType)
+// throws UtilsException {
+// XmlElement types = definitions.getTypes();
+// XmlElement returnType = null;
+// Iterable<XmlElement> schemas = types.elements(WSConstants.XSD_NS, WSConstants.SCHEMA_TAG);
+// for (XmlElement schema : schemas) {
+// Iterable<XmlElement> imports = schema.elements(WSConstants.XSD_NS, WSConstants.IMPORT_TAG);
+// for (XmlElement importEle : imports) {
+// String schemaLocation = importEle.attributeValue(WSConstants.SCHEMA_LOCATION_ATTRIBUTE);
+// if (null != schemaLocation && !"".equals(schemaLocation)) {
+// try {
+// // connect using a url connection
+// URL url = new URL(schemaLocation);
+// URLConnection connection = url.openConnection();
+// connection.connect();
+// XmlElement importedSchema = xsul5.XmlConstants.BUILDER.parseFragmentFromInputStream(connection
+// .getInputStream());
+// returnType = findTypeInSchema(paramType, importedSchema);
+// if (returnType != null) {
+// return importEle;
+// }
+//
+// } catch (MalformedURLException e) {
+// throw new UtilsException(e);
+// } catch (XmlBuilderException e) {
+// throw new UtilsException(e);
+// } catch (IOException e) {
+// throw new UtilsException(e);
+// }
+// }
+// }
+// }
+// return null;
+// }
+//
+// /**
+// *
+// * @param definitions
+// * @param paramType
+// * @return
+// */
+//
+// public static XmlElement findTypeDefinitionInImports(WsdlDefinitions definitions, QName paramType)
+// throws UtilsException {
+// XmlElement types = definitions.getTypes();
+// XmlElement returnType = null;
+// Iterable<XmlElement> schemas = types.elements(null, WSConstants.SCHEMA_TAG);
+// for (XmlElement schema : schemas) {
+// Iterable<XmlElement> imports = schema.elements(WSConstants.XSD_NS, WSConstants.IMPORT_TAG);
+// for (XmlElement importEle : imports) {
+// String schemaLocation = importEle.attributeValue(WSConstants.SCHEMA_LOCATION_ATTRIBUTE);
+// if (null != schemaLocation && !"".equals(schemaLocation)) {
+// try {
+// // connect using a url connection
+// URL url = new URL(schemaLocation);
+// URLConnection connection = url.openConnection();
+// connection.connect();
+// XmlElement importedSchema = xsul5.XmlConstants.BUILDER.parseFragmentFromInputStream(connection
+// .getInputStream());
+// returnType = findTypeInSchema(paramType, importedSchema);
+// if (returnType != null) {
+// return returnType;
+// }
+//
+// } catch (MalformedURLException e) {
+// throw new UtilsException(e);
+// } catch (XmlBuilderException e) {
+// throw new UtilsException(e);
+// } catch (IOException e) {
+// throw new UtilsException(e);
+// }
+// }
+// }
+// }
+// return null;
+//
+// }
+//
+// private static XmlElement findTypeInSchema(QName paramType, XmlElement schema) {
+// String schemaTargetNamespace = schema.attributeValue(WSConstants.TARGET_NAMESPACE_ATTRIBUTE);
+// if (null != schemaTargetNamespace && schemaTargetNamespace.equals(paramType.getNamespaceURI())) {
+// for (XmlElement complexType : schema.elements(WSConstants.XSD_NS, WSConstants.COMPLEX_TYPE_TAG)) {
+// String complexTypeName = complexType.attributeValue(WSConstants.NAME_ATTRIBUTE);
+// if (complexTypeName.equals(paramType.getLocalPart())) {
+// return complexType;
+//
+// }
+// }
+// for (XmlElement simpleType : schema.elements(WSConstants.XSD_NS, WSConstants.SIMPLE_TYPE_TAG)) {
+// String simpleTypeName = simpleType.attributeValue(WSConstants.NAME_ATTRIBUTE);
+// if (simpleTypeName.equals(paramType.getLocalPart())) {
+// return simpleType;
+// }
+// }
+// }
+// return null;
+// }
+//
+// /**
+// * @param wsdl
+// * @return true if the WSDL is AWSDL; false otherwise.
+// */
+// public static boolean isAWSDL(WsdlDefinitions wsdl) {
+// if (wsdl.services().iterator().hasNext()) {
+// return false;
+// }
+// return true;
+// }
+//
+// /**
+// * @param definitions
+// * @return true if the service supports asynchronous invocation; false otherwise;
+// */
+// public static boolean isAsynchronousSupported(WsdlDefinitions definitions) {
+// for (WsdlBinding binding : definitions.bindings()) {
+// XmlElement element = binding.xml().element(WSConstants.USING_ADDRESSING_TAG);
+// if (element != null) {
+// return true;
+// }
+// }
+// return false;
+// }
+//
+// /**
+// * Converts a specified AWSDL to CWSDL using DSC URI.
+// *
+// * @param definitions
+// * The specified AWSDL. This will be modified.
+// * @param url
+// * The URL of the service
+// * @return The CWSDL converted.
+// */
+// public static WsdlDefinitions convertToCWSDL(WsdlDefinitions definitions, URI url) {
+// for (WsdlPortType portType : definitions.portTypes()) {
+// WsdlUtil.createCWSDL(definitions, portType, url);
+// }
+// return definitions;
+// }
+
+ /**
+ * @param uri
+ * @return The URI with "?wsdl" at the end.
+ */
+ public static String appendWSDLQuary(String uri) {
+ URI wsdlURI = appendWSDLQuary(URI.create(uri));
+ return wsdlURI.toString();
+ }
+
+ public static List<XmlNamespace> getNamespaces(XmlElement element) {
+ LinkedList<XmlNamespace> namespaces = new LinkedList<XmlNamespace>();
+ namespaces.add(element.getNamespace());
+ Iterable<XmlAttribute> attributes = element.attributes();
+ for (XmlAttribute xmlAttribute : attributes) {
+ if (xmlAttribute.getNamespace() != null && !namespaces.contains(xmlAttribute.getNamespace())) {
+ namespaces.add(xmlAttribute.getNamespace());
+ }
+ int index = xmlAttribute.getValue().indexOf(':');
+ if (-1 != index) {
+ String prefix = xmlAttribute.getValue().substring(0, index);
+ if (element.lookupNamespaceByPrefix(prefix) != null) {
+ namespaces.add(element.lookupNamespaceByPrefix(prefix));
+ }
+ }
+ }
+ Iterable children = element.children();
+ for (Object object : children) {
+ if (object instanceof XmlElement) {
+ List<XmlNamespace> newNSs = getNamespaces((XmlElement) object);
+ for (XmlNamespace xmlNamespace : newNSs) {
+ if (!namespaces.contains(xmlNamespace)) {
+ namespaces.add(xmlNamespace);
+ }
+ }
+ }
+ }
+ return namespaces;
+ }
+
+ /**
+ * @param uri
+ * @return The URI with "?wsdl" at the end.
+ */
+ public static URI appendWSDLQuary(URI uri) {
+ if (uri.toString().endsWith("?wsdl")) {
+ logger.warn("URL already has ?wsdl at the end: " + uri.toString());
+ // Don't throw exception to be more error tolerant.
+ return uri;
+ }
+ String path = uri.getPath();
+ if (path == null || path.length() == 0) {
+ uri = uri.resolve("/");
+ }
+ uri = URI.create(uri.toString() + "?wsdl");
+ return uri;
+ }
+
+// /**
+// * @param valueElement
+// * @return
+// */
+// public static org.xmlpull.v1.builder.XmlElement xmlElement5ToXmlElementv1(XmlElement valueElement) {
+//
+// return XmlConstants.BUILDER.parseFragmentFromReader(new StringReader(xsul5.XmlConstants.BUILDER
+// .serializeToStringPretty(valueElement)));
+// }
+
+ /**
+ *
+ * @param vals
+ * @param <T>
+ * @return
+ */
+ public static <T extends Object> T getfirst(Iterable<T> vals) {
+ for (T class1 : vals) {
+ return class1;
+ }
+ throw new RuntimeException("Iterator empty");
+
+ }
+
+// /**
+// * @param serviceSchema
+// */
+// public static void print(XmlElement serviceSchema) {
+// System.out.println(xsul5.XmlConstants.BUILDER.serializeToStringPretty(serviceSchema));
+// }
+
+ /**
+ * @param workflowID
+ * @return
+ */
+ public static String findWorkflowName(URI workflowID) {
+ String[] splits = workflowID.toString().split("/");
+ return splits[splits.length - 1];
+
+ }
+
+ /**
+ *
+ * @param element
+ * @param name
+ * @param oldValue
+ * @param newValue
+ */
+ public static void replaceAttributeValue(XmlElement element, String name, String oldValue, String newValue) {
+ XmlAttribute attribute = element.attribute(name);
+ if (null != attribute && oldValue.equals(attribute.getValue())) {
+ element.removeAttribute(attribute);
+ element.setAttributeValue(name, newValue);
+ }
+ Iterable iterator = element.children();
+ for (Object object : iterator) {
+ if (object instanceof XmlElement) {
+ replaceAttributeValue((XmlElement) object, name, oldValue, newValue);
+ }
+ }
+
+ }
+
+ public static boolean attributeExist(XmlElement element, String name, String value) {
+ XmlAttribute attribute = element.attribute(name);
+ if (null != attribute && value.equals(attribute.getValue())) {
+ return true;
+ }
+ Iterable iterator = element.children();
+ boolean ret = false;
+ for (Object object : iterator) {
+ if (object instanceof XmlElement) {
+ ret = ret || attributeExist((XmlElement) object, name, value);
+ }
+ }
+ return ret;
+
+ }
+
+
+}
\ No newline at end of file
[5/8] airavata git commit: moved commons-utils to commons module
Posted by sh...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/XMLUtil.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/XMLUtil.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/XMLUtil.java
new file mode 100644
index 0000000..0ba02f9
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/XMLUtil.java
@@ -0,0 +1,586 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.airavata.common.exception.UtilsException;
+import org.apache.xmlbeans.XmlError;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+import org.xml.sax.SAXException;
+import org.xmlpull.infoset.XmlDocument;
+import org.xmlpull.infoset.XmlElement;
+import org.xmlpull.infoset.XmlNamespace;
+import org.xmlpull.mxp1.MXParserFactory;
+import org.xmlpull.mxp1_serializer.MXSerializer;
+
+public class XMLUtil {
+
+ /**
+ * The XML builder for XPP5
+ */
+ public static final org.xmlpull.infoset.XmlInfosetBuilder BUILDER = org.xmlpull.infoset.XmlInfosetBuilder
+ .newInstance();
+
+ /**
+ * The XML builder for XPP3.
+ */
+ public static final org.xmlpull.v1.builder.XmlInfosetBuilder BUILDER3 = org.xmlpull.v1.builder.XmlInfosetBuilder
+ .newInstance(new MXParserFactory());
+
+ private static final Logger logger = LoggerFactory.getLogger(XMLUtil.class);
+
+ private final static String PROPERTY_SERIALIZER_INDENTATION = "http://xmlpull.org/v1/doc/properties.html#serializer-indentation";
+
+ private final static String INDENT = " ";
+
+ /**
+ * Parses a specified string and returns the XmlElement (XPP3).
+ *
+ * @param string
+ * @return The XmlElement (XPP3) parsed.
+ */
+ public static org.xmlpull.v1.builder.XmlElement stringToXmlElement3(String string) {
+ return BUILDER3.parseFragmentFromReader(new StringReader(string));
+ }
+
+ /**
+ * Parses a specified string and returns the XmlElement (XPP5).
+ *
+ * @param string
+ * @return The XmlElement (XPP5) parsed.
+ */
+ public static org.xmlpull.infoset.XmlElement stringToXmlElement(String string) {
+ XmlDocument document = BUILDER.parseString(string);
+ org.xmlpull.infoset.XmlElement element = document.getDocumentElement();
+ return element;
+ }
+
+ /**
+ * Converts a specified XmlElement (XPP3) to the XmlElement (XPP5).
+ *
+ * @param element
+ * @return The XmlElement (XPP5) converted.
+ */
+ public static org.xmlpull.infoset.XmlElement xmlElement3ToXmlElement5(org.xmlpull.v1.builder.XmlElement element) {
+ String string = xmlElementToString(element);
+ return stringToXmlElement(string);
+ }
+
+ /**
+ * Converts a specified XmlElement (XPP5) to the XmlElement (XPP3).
+ *
+ * @param element
+ * @return The XmlElement (XPP3) converted.
+ */
+ public static org.xmlpull.v1.builder.XmlElement xmlElement5ToXmlElement3(org.xmlpull.infoset.XmlElement element) {
+ String string = xmlElementToString(element);
+ return stringToXmlElement3(string);
+ }
+
+ /**
+ * Returns the XML string of a specified XmlElement.
+ *
+ * @param element
+ * The specified XmlElement
+ * @return The XML string
+ */
+ public static String xmlElementToString(org.xmlpull.v1.builder.XmlElement element) {
+ MXSerializer serializer = new MXSerializer();
+ StringWriter writer = new StringWriter();
+ serializer.setOutput(writer);
+ serializer.setProperty(PROPERTY_SERIALIZER_INDENTATION, INDENT);
+ BUILDER3.serialize(element, serializer);
+ String xmlText = writer.toString();
+ return xmlText;
+ }
+
+ /**
+ * Returns the XML string as a specified XmlElement (XPP5).
+ *
+ * @param element
+ * The specified XmlElement
+ * @return The XML string
+ */
+ public static String xmlElementToString(org.xmlpull.infoset.XmlElement element) {
+ String string;
+ if (element == null) {
+ string = "";
+ } else {
+ string = BUILDER.serializeToStringPretty(element);
+ }
+ return string;
+ }
+
+ /**
+ * Converts a specified XPP5 XML element to a DOM element under a specified document.
+ *
+ * @param xppElement
+ * @param document
+ * @return The converted DOM element.
+ */
+ public static Element xppElementToDomElement(org.xmlpull.infoset.XmlElement xppElement, Document document) {
+ Element domElement = document.createElement(xppElement.getName());
+
+ for (org.xmlpull.infoset.XmlNamespace namespace : xppElement.namespaces()) {
+ logger.debug("namespace: " + namespace);
+ }
+
+ for (org.xmlpull.infoset.XmlAttribute attribute : xppElement.attributes()) {
+ domElement.setAttribute(attribute.getName(), attribute.getValue());
+ }
+
+ for (Object object : xppElement.children()) {
+ if (object instanceof org.xmlpull.infoset.XmlElement) {
+ domElement.appendChild(xppElementToDomElement((org.xmlpull.infoset.XmlElement) object, document));
+ } else if (object instanceof String) {
+ Text text = document.createTextNode((String) object);
+ domElement.appendChild(text);
+ } else {
+ logger.debug("object.getClass(): " + object.getClass());
+ }
+ }
+ return domElement;
+ }
+
+// /**
+// * @param definitions3
+// * @return The WsdlDefinitions (XSUL5)
+// */
+// @Deprecated
+// public static xsul5.wsdl.WsdlDefinitions wsdlDefinitions3ToWsdlDefintions5(xsul.wsdl.WsdlDefinitions definitions3) {
+// return WSDLUtil.wsdlDefinitions3ToWsdlDefintions5(definitions3);
+// }
+//
+// /**
+// * @param definitions5
+// * @return The WsdlDefinitions (XSUL3)
+// */
+// @Deprecated
+// public static xsul.wsdl.WsdlDefinitions wsdlDefinitions5ToWsdlDefintions3(xsul5.wsdl.WsdlDefinitions definitions5) {
+// return WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(definitions5);
+// }
+
+ /**
+ * Converts a specified XPP3 XML element to a DOM element under a specified document.
+ *
+ * @param xppElement
+ * @param document
+ * @return The converted DOM element.
+ */
+ public static Element xppElementToDomElement(org.xmlpull.v1.builder.XmlElement xppElement, Document document) {
+ Element domElement = document.createElement(xppElement.getName());
+
+ Iterator nsIt = xppElement.namespaces();
+ while (nsIt.hasNext()) {
+ org.xmlpull.v1.builder.XmlNamespace namespace = (org.xmlpull.v1.builder.XmlNamespace) nsIt.next();
+ logger.debug("namespace: " + namespace);
+ // TODO
+ }
+
+ Iterator attrIt = xppElement.attributes();
+ while (attrIt.hasNext()) {
+ org.xmlpull.v1.builder.XmlAttribute attribute = (org.xmlpull.v1.builder.XmlAttribute) attrIt.next();
+ // TODO namespace
+ domElement.setAttribute(attribute.getName(), attribute.getValue());
+ }
+
+ Iterator elementIt = xppElement.children();
+ while (elementIt.hasNext()) {
+ Object object = elementIt.next();
+ if (object instanceof org.xmlpull.v1.builder.XmlElement) {
+ domElement.appendChild(xppElementToDomElement((org.xmlpull.v1.builder.XmlElement) object, document));
+ } else if (object instanceof String) {
+ Text text = document.createTextNode((String) object);
+ domElement.appendChild(text);
+ } else {
+ logger.debug("object.getClass(): " + object.getClass());
+ }
+ }
+ return domElement;
+ }
+
+ /**
+ * @param element
+ * @return The cloned XmlElement.
+ */
+ public static org.xmlpull.infoset.XmlElement deepClone(org.xmlpull.infoset.XmlElement element)
+ throws UtilsException {
+ try {
+ XmlElement clonedElement = element.clone();
+ clonedElement.setParent(null);
+ return clonedElement;
+ } catch (CloneNotSupportedException e) {
+ // This should not happen because we don't put any special Objects.
+ throw new UtilsException(e);
+ }
+ }
+
+ /**
+ * Saves a specified XmlElement to a specified file.
+ *
+ * @param element
+ * @param file
+ * @throws IOException
+ */
+ public static void saveXML(org.xmlpull.infoset.XmlElement element, File file) throws IOException {
+ XmlDocument document = BUILDER.newDocument();
+ document.setDocumentElement(element);
+ String xmlText = BUILDER.serializeToStringPretty(document);
+ IOUtil.writeToFile(xmlText, file);
+ }
+
+ /**
+ * Saves a specified XmlElement to a specified file.
+ *
+ * @param element
+ * @param file
+ * @throws IOException
+ */
+ public static void saveXML(org.xmlpull.v1.builder.XmlElement element, File file) throws IOException {
+ saveXML(xmlElement3ToXmlElement5(element), file);
+ }
+
+ /**
+ * @param file
+ * @return The XmlElement in the document.
+ * @throws IOException
+ */
+ public static org.xmlpull.infoset.XmlElement loadXML(InputStream stream) throws IOException {
+ String xmlText = IOUtil.readToString(stream);
+ XmlDocument document = BUILDER.parseString(xmlText);
+ return document.getDocumentElement();
+ }
+
+ /**
+ * @param file
+ * @return The XmlElement in the document.
+ * @throws IOException
+ */
+ public static org.xmlpull.infoset.XmlElement loadXML(File file) throws IOException {
+ return loadXML(new FileInputStream(file));
+ }
+
+ /**
+ * @param string
+ * @return true if the specified string is XML, false otherwise
+ */
+ public static boolean isXML(String string) {
+ try {
+ stringToXmlElement(string);
+ return true;
+ } catch (RuntimeException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Validates a specified XmlObject along with logging errors if any.
+ *
+ * @param xmlObject
+ */
+ public static void validate(XmlObject xmlObject) throws UtilsException {
+ XmlOptions validateOptions = new XmlOptions();
+ ArrayList errorList = new ArrayList();
+ validateOptions.setErrorListener(errorList);
+
+ boolean isValid = xmlObject.validate(validateOptions);
+ if (isValid) {
+ // Valid
+ return;
+ }
+
+ // Error
+ StringBuilder stringBuilder = new StringBuilder();
+ for (int i = 0; i < errorList.size(); i++) {
+ XmlError error = (XmlError) errorList.get(i);
+ logger.warn("Message: " + error.getMessage());
+ logger.warn("Location of invalid XML: " + error.getCursorLocation().xmlText());
+ stringBuilder.append("Message:" + error.getMessage());
+ stringBuilder.append("Location of invalid XML: " + error.getCursorLocation().xmlText());
+ }
+ throw new UtilsException(stringBuilder.toString());
+ }
+
+ /**
+ * Returns the local part of a specified QName.
+ *
+ * @param qname
+ * the specified QName in string, e.g. ns:value
+ * @return the local part of the QName, e.g. value
+ */
+ public static String getLocalPartOfQName(String qname) {
+ int index = qname.indexOf(':');
+ if (index < 0) {
+ return qname;
+ } else {
+ return qname.substring(index + 1);
+ }
+ }
+
+ /**
+ * Returns the prefix of a specified QName.
+ *
+ * @param qname
+ * the specified QName in string, e.g. ns:value
+ * @return the prefix of the QName, e.g. ns
+ */
+ public static String getPrefixOfQName(String qname) {
+ int index = qname.indexOf(':');
+ if (index < 0) {
+ return null;
+ } else {
+ return qname.substring(0, index);
+ }
+ }
+
+ /**
+ * @param prefixCandidate
+ * @param uri
+ * @param alwaysUseSuffix
+ * @param element
+ * @return The namespace found or declared.
+ */
+ public static XmlNamespace declareNamespaceIfNecessary(String prefixCandidate, String uri, boolean alwaysUseSuffix,
+ XmlElement element) {
+ XmlNamespace namespace = element.lookupNamespaceByName(uri);
+ if (namespace == null) {
+ return declareNamespace(prefixCandidate, uri, alwaysUseSuffix, element);
+ } else {
+ return namespace;
+ }
+ }
+
+ /**
+ * @param prefixCandidate
+ * @param uri
+ * @param alwaysUseSuffix
+ * @param element
+ * @return The namespace declared.
+ */
+ public static XmlNamespace declareNamespace(String prefixCandidate, String uri, boolean alwaysUseSuffix,
+ XmlElement element) {
+ if (prefixCandidate == null || prefixCandidate.length() == 0) {
+ prefixCandidate = "a";
+ }
+ String prefix = prefixCandidate;
+ if (alwaysUseSuffix) {
+ prefix += "0";
+ }
+ if (element.lookupNamespaceByPrefix(prefix) != null) {
+ int i = 1;
+ prefix = prefixCandidate + i;
+ while (element.lookupNamespaceByPrefix(prefix) != null) {
+ i++;
+ }
+ }
+ XmlNamespace namespace = element.declareNamespace(prefix, uri);
+ return namespace;
+ }
+
+ /**
+ *
+ * @param xml
+ * @param name
+ */
+ public static void removeElements(XmlElement xml, String name) {
+
+ Iterable<XmlElement> removeElements = xml.elements(null, name);
+ LinkedList<XmlElement> removeList = new LinkedList<XmlElement>();
+ for (XmlElement xmlElement : removeElements) {
+ removeList.add(xmlElement);
+ }
+ for (XmlElement xmlElement : removeList) {
+ xml.removeChild(xmlElement);
+ }
+ Iterable children = xml.children();
+ for (Object object : children) {
+ if (object instanceof XmlElement) {
+ XmlElement element = (XmlElement) object;
+ removeElements(element, name);
+ }
+ }
+ }
+
+ /**
+ * @param url
+ * @return Document
+ */
+ public static Document retrievalXMLDocFromUrl(String url) {
+ try {
+ URL xmlUrl = new URL(url);
+ InputStream in = xmlUrl.openStream();
+ Document ret = null;
+ DocumentBuilderFactory domFactory;
+ DocumentBuilder builder;
+
+ domFactory = DocumentBuilderFactory.newInstance();
+ domFactory.setValidating(false);
+ domFactory.setNamespaceAware(false);
+ builder = domFactory.newDocumentBuilder();
+
+ ret = builder.parse(in);
+
+ return ret;
+ } catch (MalformedURLException e) {
+ logger.error(e.getMessage(), e);
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ } catch (ParserConfigurationException e) {
+ logger.error(e.getMessage(), e);
+ } catch (SAXException e) {
+ logger.error(e.getMessage(), e);
+ }
+
+ return null;
+ }
+
+ /**
+ * @param url
+ * @return Document
+ */
+ public static Document retrievalXMLDocForParse(String url) {
+ try {
+ URL xmlUrl = new URL(url);
+ InputStream in = xmlUrl.openStream();
+ DocumentBuilderFactory xmlFact = DocumentBuilderFactory.newInstance();
+ xmlFact.setNamespaceAware(true);
+ DocumentBuilder builder = xmlFact.newDocumentBuilder();
+ Document doc = builder.parse(in);
+
+ return doc;
+ } catch (MalformedURLException e) {
+ logger.error("Malformed URL", e);
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ } catch (ParserConfigurationException e) {
+ logger.error(e.getMessage(), e);
+ } catch (SAXException e) {
+ logger.error(e.getMessage(), e);
+ }
+
+ return null;
+ }
+
+ public static boolean isEqual(XmlElement elem1, XmlElement elem2) throws Exception {
+
+ if (elem1 == null && elem2 == null) {
+ return true;
+ } else if (elem1 == null) {
+ return false;
+ } else if (elem2 == null) {
+ return false;
+ }
+
+ if (!elem1.getName().equals(elem2.getName())) {
+ return false;
+ } else {
+ // now check if children are the same
+ Iterator children1 = elem1.children().iterator();
+ Iterator children2 = elem2.children().iterator();
+
+ //check first ones for string
+ Object child1 = null;
+ Object child2 = null;
+ if (children1.hasNext() && children2.hasNext()) {
+ child1 = children1.next();
+ child2 = children2.next();
+
+ if (!children1.hasNext() && !children2.hasNext()) {
+ //only one node could be string could be xmlelement
+ return compareObjs(child1, child2);
+ } else {
+ //get new iterators
+
+ List<XmlElement> elemSet1 = getXmlElementsOnly(elem1.children().iterator());
+ List<XmlElement> elemSet2 = getXmlElementsOnly(elem2.children().iterator());
+
+ if(elemSet1.size() != elemSet2.size()){
+ return false;
+ }
+ for(int i =0; i< elemSet1.size(); ++i){
+ if(!isEqual(elemSet1.get(i), elemSet2.get(i))){
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ }else {
+ //no internal element
+
+ return true;
+ }
+ }
+
+
+ }
+
+
+
+ private static List<XmlElement> getXmlElementsOnly(Iterator itr){
+ LinkedList<XmlElement> list = new LinkedList<XmlElement>();
+ while(itr.hasNext()){
+ Object obj = itr.next();
+ if(obj instanceof XmlElement){
+ list.add((XmlElement) obj);
+ }
+ }
+ return list;
+ }
+
+
+
+ private static boolean compareObjs(Object child1, Object child2) throws Exception {
+ if (child1 instanceof String && child2 instanceof String) {
+ return child1.equals(child2);
+
+
+ } else if (child1 instanceof XmlElement && child2 instanceof XmlElement) {
+ return isEqual((XmlElement) child1, (XmlElement) child2);
+ } else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/XmlFormatter.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/XmlFormatter.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/XmlFormatter.java
new file mode 100644
index 0000000..1440dbf
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/XmlFormatter.java
@@ -0,0 +1,82 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Pretty-prints xml, supplied as a string.
+ * <p/>
+ * eg. <code>
+ * String formattedXml = new XmlFormatter().format("<tag><nested>hello</nested></tag>");
+ * </code>
+ */
+public class XmlFormatter {
+
+ /**
+ * @param unformattedXml
+ * @return formattedXml
+ */
+ public static String format(String unformattedXml) {
+ try {
+ final Document document = parseXmlFile(unformattedXml);
+ OutputFormat format = new OutputFormat(document);
+ format.setLineWidth(65);
+ format.setIndenting(true);
+ format.setIndent(2);
+ Writer out = new StringWriter();
+ XMLSerializer serializer = new XMLSerializer(out, format);
+ serializer.serialize(document);
+ return out.toString();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static Document parseXmlFile(String in) {
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ InputSource is = new InputSource(new StringReader(in));
+ return db.parse(is);
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ } catch (SAXException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/listener/AbstractActivityListener.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/listener/AbstractActivityListener.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/listener/AbstractActivityListener.java
new file mode 100644
index 0000000..e972012
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/listener/AbstractActivityListener.java
@@ -0,0 +1,27 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils.listener;
+
+
+public interface AbstractActivityListener {
+ public void setup(Object... configurations);
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/listener/AbstractStateChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/listener/AbstractStateChangeRequest.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/listener/AbstractStateChangeRequest.java
new file mode 100644
index 0000000..8529c4b
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/listener/AbstractStateChangeRequest.java
@@ -0,0 +1,27 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils.listener;
+
+
+public abstract class AbstractStateChangeRequest implements PublisherMessage {
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/listener/PublisherMessage.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/listener/PublisherMessage.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/listener/PublisherMessage.java
new file mode 100644
index 0000000..0d5404a
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/listener/PublisherMessage.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils.listener;
+
+public interface PublisherMessage {
+// public String getType();
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/test/java/org/apache/airavata/common/utils/ApplicationSettingsTest.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/test/java/org/apache/airavata/common/utils/ApplicationSettingsTest.java b/modules/commons/src/test/java/org/apache/airavata/common/utils/ApplicationSettingsTest.java
new file mode 100644
index 0000000..ed61793
--- /dev/null
+++ b/modules/commons/src/test/java/org/apache/airavata/common/utils/ApplicationSettingsTest.java
@@ -0,0 +1,43 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 7/5/13
+ * Time: 4:39 PM
+ */
+
+public class ApplicationSettingsTest extends TestCase {
+
+ public void testGetAbsoluteSettingWithSpecialCharacters() throws Exception {
+
+ String url = ServerSettings.getSetting("default.registry.user");
+ Assert.assertEquals("admin", url);
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/test/java/org/apache/airavata/common/utils/SecurityUtilTest.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/test/java/org/apache/airavata/common/utils/SecurityUtilTest.java b/modules/commons/src/test/java/org/apache/airavata/common/utils/SecurityUtilTest.java
new file mode 100644
index 0000000..aa87283
--- /dev/null
+++ b/modules/commons/src/test/java/org/apache/airavata/common/utils/SecurityUtilTest.java
@@ -0,0 +1,104 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import junit.framework.Assert;
+import org.junit.Test;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.security.KeyStore;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/11/13
+ * Time: 10:42 AM
+ */
+
+public class SecurityUtilTest {
+ @Test
+ public void testEncryptString() throws Exception {
+
+ URL url = this.getClass().getClassLoader().getResource("mykeystore.jks");
+
+ assert url != null;
+
+ String stringToEncrypt = "Test string to encrypt";
+ byte[] encrypted = SecurityUtil.encryptString(url.getPath(), "mykey", new TestKeyStoreCallback(), stringToEncrypt);
+
+ String decrypted = SecurityUtil.decryptString(url.getPath(), "mykey", new TestKeyStoreCallback(), encrypted);
+ Assert.assertTrue(stringToEncrypt.equals(decrypted));
+
+ }
+
+ @Test
+ public void testEncryptBytes() throws Exception {
+
+ URL url = this.getClass().getClassLoader().getResource("mykeystore.jks");
+
+ assert url != null;
+
+ String stringToEncrypt = "Test string to encrypt";
+ byte[] encrypted = SecurityUtil.encrypt(url.getPath(), "mykey", new TestKeyStoreCallback(),
+ stringToEncrypt.getBytes("UTF-8"));
+
+ byte[] decrypted = SecurityUtil.decrypt(url.getPath(), "mykey", new TestKeyStoreCallback(), encrypted);
+ Assert.assertTrue(stringToEncrypt.equals(new String(decrypted, "UTF-8")));
+
+ }
+
+ @Test
+ public void testLoadKeyStore() throws Exception{
+ InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("mykeystore.jks");
+
+ KeyStore ks = SecurityUtil.loadKeyStore(inputStream, "jceks", new TestKeyStoreCallback());
+ Assert.assertNotNull(ks);
+
+ }
+
+ @Test
+ public void testLoadKeyStoreFromFile() throws Exception{
+ URL url = this.getClass().getClassLoader().getResource("mykeystore.jks");
+
+ assert url != null;
+ KeyStore ks = SecurityUtil.loadKeyStore(url.getPath(), "jceks", new TestKeyStoreCallback());
+ Assert.assertNotNull(ks);
+
+ }
+
+ private class TestKeyStoreCallback implements KeyStorePasswordCallback {
+
+ @Override
+ public char[] getStorePassword() {
+ return "airavata".toCharArray();
+ }
+
+ @Override
+ public char[] getSecretKeyPassPhrase(String keyAlias) {
+ if (keyAlias.equals("mykey")) {
+ return "airavatasecretkey".toCharArray();
+ }
+
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/test/java/org/apache/airavata/common/utils/XMLUtilTest.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/test/java/org/apache/airavata/common/utils/XMLUtilTest.java b/modules/commons/src/test/java/org/apache/airavata/common/utils/XMLUtilTest.java
new file mode 100644
index 0000000..3c2c189
--- /dev/null
+++ b/modules/commons/src/test/java/org/apache/airavata/common/utils/XMLUtilTest.java
@@ -0,0 +1,56 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.common.utils;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class XMLUtilTest {
+ private final static Logger logger = LoggerFactory.getLogger(XMLUtilTest.class);
+
+ @Test
+ public void isXMLTest(){
+ String xml = "<test>testing</test>";
+ org.junit.Assert.assertTrue(XMLUtil.isXML(xml));
+ org.junit.Assert.assertFalse(XMLUtil.isXML("NonXMLString"));
+ }
+
+ @Test
+ public void isEqualTest(){
+ String xml1 = "<test><inner>innerValue</inner></test>";
+ String xml2 = "<test><inner>innerValue</inner></test>";
+ String xml3 = "<test1><inner>innerValue</inner></test1>";
+ try {
+ org.junit.Assert.assertTrue(XMLUtil.isEqual(XMLUtil.stringToXmlElement(xml1), XMLUtil.stringToXmlElement(xml2)));
+ org.junit.Assert.assertFalse(XMLUtil.isEqual(XMLUtil.stringToXmlElement(xml1), XMLUtil.stringToXmlElement(xml3)));
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ @Test
+ public void getQNameTest(){
+ String qname = "ns1:a";
+ org.junit.Assert.assertEquals("a",XMLUtil.getLocalPartOfQName(qname));
+ org.junit.Assert.assertEquals("ns1",XMLUtil.getPrefixOfQName(qname));
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/test/resources/mykeystore.jks
----------------------------------------------------------------------
diff --git a/modules/commons/src/test/resources/mykeystore.jks b/modules/commons/src/test/resources/mykeystore.jks
new file mode 100644
index 0000000..335ebf8
Binary files /dev/null and b/modules/commons/src/test/resources/mykeystore.jks differ
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/pom.xml
----------------------------------------------------------------------
diff --git a/modules/commons/utils/pom.xml b/modules/commons/utils/pom.xml
deleted file mode 100644
index b3dd589..0000000
--- a/modules/commons/utils/pom.xml
+++ /dev/null
@@ -1,150 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under
- the Apache License, Version 2.0 (theÏ "License"); you may not use this file except in compliance with the License. You may
- obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to
- in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
- ANY ~ KIND, either express or implied. See the License for the specific language governing permissions and limitations under
- the License. -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.apache.airavata</groupId>
- <artifactId>commons</artifactId>
- <version>0.16-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>airavata-common-utils</artifactId>
- <packaging>jar</packaging>
- <name>Airavata Common Utilities</name>
- <url>http://airavata.apache.org/</url>
-
- <dependencies>
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- <version>2.9.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.xmlbeans</groupId>
- <artifactId>xmlbeans</artifactId>
- <version>${xmlbeans.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ogce</groupId>
- <artifactId>xpp3</artifactId>
- <version>${xpp3.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ogce</groupId>
- <artifactId>xpp5</artifactId>
- <version>${xpp5.version}</version>
- </dependency>
- <!--dependency>
- <groupId>org.ogce</groupId>
- <artifactId>xsul</artifactId>
- <version>${xsul.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcprov-jdk16</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.ogce</groupId>
- <artifactId>xsul5</artifactId>
- <version>${xsul5.version}</version>
- </dependency>
- -->
- <dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>12.0</version>
- </dependency>
-
- <!-- Logging -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${derby.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbyclient</artifactId>
- <version>${derby.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbynet</artifactId>
- <version>${derby.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
- <version>${derby.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-core</artifactId>
- <version>7.0.22</version>
- </dependency>
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- <version>1.2</version>
- </dependency>
- <!-- Testing -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.airavata</groupId>
- <artifactId>airavata-server-configuration</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <version>${curator.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.thrift</groupId>
- <artifactId>libthrift</artifactId>
- <version>${thrift.version}</version>
- </dependency>
-
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>${google.gson.version}</version>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/context/RequestContext.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/context/RequestContext.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/context/RequestContext.java
deleted file mode 100644
index 724d3a3..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/context/RequestContext.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.context;
-
-/**
- * The request context class. This will be local to a thread. User data that needs to propagate relevant to a request
- * will be stored here. We use thread local globals to store request data. Currently we only store user identity.
- */
-public class RequestContext {
-
- public String getUserIdentity() {
- return userIdentity;
- }
-
- public void setUserIdentity(String userIdentity) {
- this.userIdentity = userIdentity;
- }
-
- /**
- * User associated with current request.
- */
- private String userIdentity;
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- /**
- * The gateway id.
- */
- private String gatewayId;
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/context/WorkflowContext.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/context/WorkflowContext.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/context/WorkflowContext.java
deleted file mode 100644
index 59142e4..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/context/WorkflowContext.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.context;
-
-/**
- * The workflow context class. This will be local to a thread. Workflow data that needs to propagate relevant to a
- * request will be stored here. We use thread local globals to store request data. Currently we only store user
- * identity.
- */
-public class WorkflowContext {
-
- private static final ThreadLocal userThreadLocal = new InheritableThreadLocal();
-
- /**
- * Sets the context.
- *
- * @param context
- * The context to be set. - Careful when calling this. Make sure other data relevant to context is
- * preserved.
- */
- public static void set(RequestContext context) {
- userThreadLocal.set(context);
- }
-
- /**
- * Clears the context
- */
- public static void unset() {
- userThreadLocal.remove();
- }
-
- /**
- * Gets the context associated with current context.
- *
- * @return The context associated with current thread.
- */
- public static RequestContext get() {
- return (RequestContext) userThreadLocal.get();
- }
-
- /**
- * Gets the user associated with current user.
- *
- * @return User id associated with current request.
- */
- public static synchronized String getRequestUser() {
-
- RequestContext requestContext = (RequestContext) userThreadLocal.get();
-
- if (requestContext != null) {
- return requestContext.getUserIdentity();
- }
-
- return null;
- }
-
- public static synchronized String getGatewayId() {
-
- RequestContext requestContext = (RequestContext) userThreadLocal.get();
-
- if (requestContext != null) {
- return requestContext.getGatewayId();
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java
deleted file mode 100644
index 874e029..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.exception;
-
-public class AiravataConfigurationException extends AiravataException {
- private static final long serialVersionUID = -9124231436834631249L;
-
- public AiravataConfigurationException() {
- }
-
- public AiravataConfigurationException(String message){
- this(message, null);
- }
-
- public AiravataConfigurationException(String message, Throwable e){
- super(message,e);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataException.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataException.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataException.java
deleted file mode 100644
index a41b77d..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.exception;
-
-public class AiravataException extends Exception {
-
- private static final long serialVersionUID = -5665822765183116821L;
- public AiravataException() {
- }
-
- public AiravataException(String message, Throwable e) {
- super(message,e);
- }
-
- public AiravataException(String message) {
- super(message);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java
deleted file mode 100644
index b669fe0..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.exception;
-
-public class ApplicationSettingsException extends AiravataException {
-
- private static final long serialVersionUID = -4901850535475160411L;
-
- public ApplicationSettingsException(String message) {
- super(message);
- }
-
- public ApplicationSettingsException(String message, Throwable e) {
- super(message, e);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsLoadException.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsLoadException.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsLoadException.java
deleted file mode 100644
index 2735cf3..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsLoadException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.exception;
-
-public class ApplicationSettingsLoadException extends ApplicationSettingsException {
-
- private static final long serialVersionUID = -5102090895499711299L;
- public ApplicationSettingsLoadException(String message) {
- super(message);
- }
-
- public ApplicationSettingsLoadException(Throwable e) {
- this(e.getMessage(),e);
- }
-
- public ApplicationSettingsLoadException(String message, Throwable e) {
- super(message,e);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsStoreException.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsStoreException.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsStoreException.java
deleted file mode 100644
index 5f258bf..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsStoreException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.exception;
-
-public class ApplicationSettingsStoreException extends ApplicationSettingsException {
-
- private static final long serialVersionUID = -5102090895499711299L;
- public ApplicationSettingsStoreException(String filePath) {
- super("Error while attempting to store settings in "+filePath);
- }
-
- public ApplicationSettingsStoreException(String filePath, Throwable e) {
- super(filePath,e);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/LazyLoadedDataException.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/LazyLoadedDataException.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/LazyLoadedDataException.java
deleted file mode 100644
index 4ba58d7..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/LazyLoadedDataException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.exception;
-
-public class LazyLoadedDataException extends AiravataException {
- private static final long serialVersionUID = -3164776318582067936L;
- public LazyLoadedDataException(String message) {
- super(message);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UnspecifiedApplicationSettingsException.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UnspecifiedApplicationSettingsException.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UnspecifiedApplicationSettingsException.java
deleted file mode 100644
index c29ff24..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UnspecifiedApplicationSettingsException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.exception;
-
-public class UnspecifiedApplicationSettingsException extends ApplicationSettingsException {
-
- private static final long serialVersionUID = -1159027432434546003L;
- public UnspecifiedApplicationSettingsException(String key) {
- super("The '"+key+"' is not configured in settings!!!");
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UtilsException.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UtilsException.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UtilsException.java
deleted file mode 100644
index a412fe1..0000000
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UtilsException.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.common.exception;
-
-public class UtilsException extends Exception {
-
- /**
- * Constructs a UtilsException.
- *
- */
- public UtilsException() {
- super();
- }
-
- /**
- * Constructs a UtilsException.
- *
- * @param message
- */
- public UtilsException(String message) {
- super(message);
- }
-
- /**
- * Constructs a UtilsException.
- *
- * @param cause
- */
- public UtilsException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Constructs a UtilsException.
- *
- * @param message
- * @param cause
- */
- public UtilsException(String message, Throwable cause) {
- super(message, cause);
- }
-}
[8/8] airavata git commit: moved commons-utils to commons module
Posted by sh...@apache.org.
moved commons-utils to commons module
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/8d16d0ec
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/8d16d0ec
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/8d16d0ec
Branch: refs/heads/master
Commit: 8d16d0ec5da700f1b576fbcc582e584978d43e60
Parents: a5cb91f
Author: Shameera Rathanyaka <sh...@gmail.com>
Authored: Thu Jun 11 17:34:31 2015 -0400
Committer: Shameera Rathanyaka <sh...@gmail.com>
Committed: Thu Jun 11 17:34:31 2015 -0400
----------------------------------------------------------------------
airavata-api/airavata-api-server/pom.xml | 2 +-
.../airavata/api/server/AiravataAPIServer.java | 5 -
.../api/server/handler/utils/ExpCatInit.java | 4 -
distribution/pom.xml | 2 +-
modules/commons/pom.xml | 122 +++-
.../airavata/common/context/RequestContext.java | 56 ++
.../common/context/WorkflowContext.java | 86 +++
.../AiravataConfigurationException.java | 37 +
.../common/exception/AiravataException.java | 37 +
.../exception/ApplicationSettingsException.java | 35 +
.../ApplicationSettingsLoadException.java | 38 ++
.../ApplicationSettingsStoreException.java | 34 +
.../exception/LazyLoadedDataException.java | 30 +
...UnspecifiedApplicationSettingsException.java | 30 +
.../common/exception/UtilsException.java | 61 ++
.../airavata/common/logger/AiravataLogger.java | 677 +++++++++++++++++++
.../common/logger/AiravataLoggerFactory.java | 34 +
.../common/logger/AiravataLoggerImpl.java | 323 +++++++++
.../airavata/common/utils/AiravataJobState.java | 117 ++++
.../airavata/common/utils/AiravataUtils.java | 47 ++
.../airavata/common/utils/AiravataZKUtils.java | 205 ++++++
.../common/utils/ApplicationSettings.java | 444 ++++++++++++
.../airavata/common/utils/BrowserLauncher.java | 98 +++
.../airavata/common/utils/ClientSettings.java | 27 +
.../apache/airavata/common/utils/Constants.java | 66 ++
.../apache/airavata/common/utils/DBUtil.java | 334 +++++++++
.../common/utils/DatabaseTestCases.java | 123 ++++
.../utils/DefaultKeyStorePasswordCallback.java | 55 ++
.../apache/airavata/common/utils/DerbyUtil.java | 114 ++++
.../airavata/common/utils/ExecutionMode.java | 28 +
.../apache/airavata/common/utils/IOUtil.java | 209 ++++++
.../apache/airavata/common/utils/IServer.java | 51 ++
.../apache/airavata/common/utils/JSONUtil.java | 158 +++++
.../common/utils/KeyStorePasswordCallback.java | 50 ++
.../airavata/common/utils/MonitorPublisher.java | 47 ++
.../airavata/common/utils/NameValidator.java | 70 ++
.../org/apache/airavata/common/utils/Pair.java | 79 +++
.../airavata/common/utils/SecurityUtil.java | 180 +++++
.../airavata/common/utils/ServerSettings.java | 270 ++++++++
.../airavata/common/utils/ServiceUtils.java | 93 +++
.../airavata/common/utils/StringUtil.java | 480 +++++++++++++
.../apache/airavata/common/utils/SwingUtil.java | 358 ++++++++++
.../airavata/common/utils/ThriftUtils.java | 37 +
.../apache/airavata/common/utils/Version.java | 120 ++++
.../airavata/common/utils/WSConstants.java | 187 +++++
.../apache/airavata/common/utils/WSDLUtil.java | 546 +++++++++++++++
.../apache/airavata/common/utils/XMLUtil.java | 586 ++++++++++++++++
.../airavata/common/utils/XmlFormatter.java | 82 +++
.../listener/AbstractActivityListener.java | 27 +
.../listener/AbstractStateChangeRequest.java | 27 +
.../common/utils/listener/PublisherMessage.java | 26 +
.../common/utils/ApplicationSettingsTest.java | 43 ++
.../airavata/common/utils/SecurityUtilTest.java | 104 +++
.../airavata/common/utils/XMLUtilTest.java | 56 ++
.../commons/src/test/resources/mykeystore.jks | Bin 0 -> 498 bytes
modules/commons/utils/pom.xml | 150 ----
.../airavata/common/context/RequestContext.java | 56 --
.../common/context/WorkflowContext.java | 86 ---
.../AiravataConfigurationException.java | 37 -
.../common/exception/AiravataException.java | 37 -
.../exception/ApplicationSettingsException.java | 35 -
.../ApplicationSettingsLoadException.java | 38 --
.../ApplicationSettingsStoreException.java | 34 -
.../exception/LazyLoadedDataException.java | 30 -
...UnspecifiedApplicationSettingsException.java | 30 -
.../common/exception/UtilsException.java | 61 --
.../airavata/common/logger/AiravataLogger.java | 677 -------------------
.../common/logger/AiravataLoggerFactory.java | 34 -
.../common/logger/AiravataLoggerImpl.java | 323 ---------
.../airavata/common/utils/AiravataJobState.java | 117 ----
.../airavata/common/utils/AiravataUtils.java | 47 --
.../airavata/common/utils/AiravataZKUtils.java | 205 ------
.../common/utils/ApplicationSettings.java | 444 ------------
.../airavata/common/utils/BrowserLauncher.java | 98 ---
.../airavata/common/utils/ClientSettings.java | 27 -
.../apache/airavata/common/utils/Constants.java | 66 --
.../apache/airavata/common/utils/DBUtil.java | 334 ---------
.../common/utils/DatabaseTestCases.java | 123 ----
.../utils/DefaultKeyStorePasswordCallback.java | 55 --
.../apache/airavata/common/utils/DerbyUtil.java | 114 ----
.../airavata/common/utils/ExecutionMode.java | 28 -
.../apache/airavata/common/utils/IOUtil.java | 209 ------
.../apache/airavata/common/utils/IServer.java | 51 --
.../apache/airavata/common/utils/JSONUtil.java | 160 -----
.../common/utils/KeyStorePasswordCallback.java | 50 --
.../airavata/common/utils/MonitorPublisher.java | 47 --
.../airavata/common/utils/NameValidator.java | 70 --
.../org/apache/airavata/common/utils/Pair.java | 79 ---
.../airavata/common/utils/SecurityUtil.java | 181 -----
.../airavata/common/utils/ServerSettings.java | 270 --------
.../airavata/common/utils/ServiceUtils.java | 93 ---
.../airavata/common/utils/StringUtil.java | 480 -------------
.../apache/airavata/common/utils/SwingUtil.java | 361 ----------
.../airavata/common/utils/ThriftUtils.java | 37 -
.../apache/airavata/common/utils/Version.java | 120 ----
.../airavata/common/utils/WSConstants.java | 187 -----
.../apache/airavata/common/utils/WSDLUtil.java | 553 ---------------
.../apache/airavata/common/utils/XMLUtil.java | 586 ----------------
.../airavata/common/utils/XmlFormatter.java | 82 ---
.../listener/AbstractActivityListener.java | 27 -
.../listener/AbstractStateChangeRequest.java | 27 -
.../common/utils/listener/PublisherMessage.java | 26 -
.../common/utils/ApplicationSettingsTest.java | 43 --
.../airavata/common/utils/SecurityUtilTest.java | 104 ---
.../airavata/common/utils/XMLUtilTest.java | 56 --
.../utils/src/test/resources/mykeystore.jks | Bin 498 -> 0 bytes
.../credential-store-service/pom.xml | 2 +-
.../store/notifier/NotifierBootstrap.java | 1 -
.../store/server/CredentialStoreServer.java | 1 -
.../credential-store-stubs/pom.xml | 2 +-
.../credential-store-webapp/pom.xml | 2 +-
.../apache/airavata/gfac/core/RequestData.java | 1 -
.../apache/airavata/gfac/impl/OutputUtils.java | 1 -
.../gfac/monitor/email/EmailMonitorFactory.java | 2 -
.../gfac/ssh/provider/impl/SSHProvider.java | 1 -
modules/gfac/gfac-service/pom.xml | 2 +-
.../airavata/gfac/server/GfacServerHandler.java | 1 +
modules/messaging/core/pom.xml | 2 +-
.../airavata/messaging/core/Publisher.java | 1 -
.../core/impl/RabbitMQTaskLaunchPublisher.java | 1 -
modules/orchestrator/orchestrator-core/pom.xml | 2 +-
modules/registry/registry-core/pom.xml | 2 +-
modules/registry/registry-cpi/pom.xml | 2 +-
modules/security/pom.xml | 2 +-
.../userstore/SessionDBUserStoreTest.java | 2 -
modules/server/pom.xml | 2 +-
.../org/apache/airavata/server/ServerMain.java | 4 -
.../test-suite/multi-tenanted-airavata/pom.xml | 2 +-
modules/workflow-model/workflow-engine/pom.xml | 2 +-
.../workflow/engine/invoker/SimpleInvoker.java | 3 -
.../workflow/engine/util/InterpreterUtil.java | 10 -
.../workflow/engine/util/XBayaUtil.java | 5 -
.../workflow-model-component/pom.xml | 2 +-
.../workflow-model/workflow-model-core/pom.xml | 2 +-
.../amazon/InstanceComponentDataPort.java | 2 -
.../component/dynamic/DynamicComponentPort.java | 2 -
.../component/url/URLComponentRegistry.java | 1 -
.../component/web/WebComponentRegistry.java | 1 -
.../component/ws/WSComponentApplication.java | 2 -
.../model/component/ws/WSComponentPort.java | 2 -
.../model/component/ws/WSComponentRegistry.java | 2 -
.../airavata/workflow/model/gpel/DSCUtil.java | 10 -
.../workflow/model/gpel/script/BPELScript.java | 13 -
.../model/gpel/script/WorkflowWSDL.java | 8 -
.../workflow/model/graph/impl/EdgeImpl.java | 1 -
.../workflow/model/graph/impl/PortImpl.java | 1 -
.../model/graph/system/ConstantNode.java | 2 -
.../model/graph/system/DifferedInputNode.java | 2 -
.../model/graph/system/EndBlockNode.java | 2 -
.../model/graph/system/EndDoWhileNode.java | 2 -
.../model/graph/system/EndForEachNode.java | 2 -
.../workflow/model/graph/system/EndifNode.java | 2 -
.../model/graph/system/ForEachNode.java | 2 -
.../workflow/model/graph/system/InputNode.java | 2 -
.../model/graph/system/ParameterNode.java | 2 -
.../model/graph/system/S3InputNode.java | 2 -
.../model/graph/system/SystemDataPort.java | 2 -
.../workflow/model/graph/system/SystemNode.java | 2 -
.../workflow/model/graph/ws/WSGraphFactory.java | 1 -
.../workflow/model/graph/ws/WSPort.java | 2 -
.../workflow/model/wf/TridentTransformer.java | 6 -
.../airavata/workflow/model/wf/Workflow.java | 5 -
modules/xbaya-gui/pom.xml | 2 +-
.../xbaya/core/generators/BPELFiler.java | 6 -
.../xbaya/core/generators/ODEScriptFiler.java | 11 -
.../StandaloneNotificationSender.java | 2 -
.../airavata/xbaya/messaging/EventData.java | 3 -
.../xbaya/modifier/WorkflowModifier.java | 4 -
.../org/apache/airavata/xbaya/ui/XBayaGUI.java | 1 -
.../system/ConstantConfigurationDialog.java | 1 -
.../DifferedInputConfigurationDialog.java | 1 -
.../graph/system/InputConfigurationDialog.java | 2 -
.../graph/system/OutputConfigurationDialog.java | 1 -
.../xbaya/ui/dialogs/graph/ws/WSNodeWindow.java | 2 -
.../dialogs/workflow/WorkflowImportWindow.java | 2 -
.../workflow/WorkflowPropertyWindow.java | 5 -
.../RegistryWorkflowPublisherWindow.java | 7 -
.../WorkflowInterpreterLaunchWindow.java | 1 -
.../airavata/xbaya/ui/graph/GraphCanvas.java | 2 -
.../airavata/xbaya/ui/widgets/XBayaToolBar.java | 4 -
.../apache/airavata/xbaya/util/XBayaUtil.java | 15 -
181 files changed, 7149 insertions(+), 7410 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/airavata-api/airavata-api-server/pom.xml
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/pom.xml b/airavata-api/airavata-api-server/pom.xml
index e0af0f8..d3d1fc5 100644
--- a/airavata-api/airavata-api-server/pom.xml
+++ b/airavata-api/airavata-api-server/pom.xml
@@ -43,7 +43,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
index 8402a6f..42f8c1a 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
@@ -21,10 +21,7 @@
package org.apache.airavata.api.server;
-import java.io.File;
-import java.io.IOException;
import java.net.InetSocketAddress;
-import java.util.Random;
import org.apache.airavata.api.Airavata;
import org.apache.airavata.api.server.handler.AiravataServerHandler;
@@ -43,8 +40,6 @@ import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransportException;
-import org.apache.zookeeper.*;
-import org.apache.zookeeper.data.Stat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java b/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java
index 20643b5..7eabc62 100644
--- a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java
+++ b/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java
@@ -23,17 +23,13 @@ package org.apache.airavata.api.server.handler.utils;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
import org.apache.airavata.registry.core.experiment.catalog.resources.*;
import org.apache.airavata.registry.cpi.*;
import org.apache.derby.drda.NetworkServerControl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.persistence.EntityManager;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/distribution/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 8c94c71..9f0eb5d 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -228,7 +228,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
+ <artifactId>airavata-commons</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/pom.xml
----------------------------------------------------------------------
diff --git a/modules/commons/pom.xml b/modules/commons/pom.xml
index c21d9a0..f6c34d4 100644
--- a/modules/commons/pom.xml
+++ b/modules/commons/pom.xml
@@ -18,22 +18,118 @@
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>commons</artifactId>
- <packaging>pom</packaging>
+ <artifactId>airavata-commons</artifactId>
+ <packaging>jar</packaging>
<name>Airavata Commons</name>
<url>http://airavata.apache.org/</url>
- <profiles>
- <profile>
- <id>default</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <modules>
- <module>utils</module>
- </modules>
- </profile>
- </profiles>
+ <dependencies>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xmlbeans</groupId>
+ <artifactId>xmlbeans</artifactId>
+ <version>${xmlbeans.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ogce</groupId>
+ <artifactId>xpp3</artifactId>
+ <version>${xpp3.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ogce</groupId>
+ <artifactId>xpp5</artifactId>
+ <version>${xpp5.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>12.0</version>
+ </dependency>
+
+ <!-- Logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>${derby.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derbyclient</artifactId>
+ <version>${derby.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derbynet</artifactId>
+ <version>${derby.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derbytools</artifactId>
+ <version>${derby.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-core</artifactId>
+ <version>7.0.22</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <!-- Testing -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-server-configuration</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-framework</artifactId>
+ <version>${curator.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.thrift</groupId>
+ <artifactId>libthrift</artifactId>
+ <version>${thrift.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${google.gson.version}</version>
+ </dependency>
+ </dependencies>
+
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/context/RequestContext.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/context/RequestContext.java b/modules/commons/src/main/java/org/apache/airavata/common/context/RequestContext.java
new file mode 100644
index 0000000..724d3a3
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/context/RequestContext.java
@@ -0,0 +1,56 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.context;
+
+/**
+ * The request context class. This will be local to a thread. User data that needs to propagate relevant to a request
+ * will be stored here. We use thread local globals to store request data. Currently we only store user identity.
+ */
+public class RequestContext {
+
+ public String getUserIdentity() {
+ return userIdentity;
+ }
+
+ public void setUserIdentity(String userIdentity) {
+ this.userIdentity = userIdentity;
+ }
+
+ /**
+ * User associated with current request.
+ */
+ private String userIdentity;
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ /**
+ * The gateway id.
+ */
+ private String gatewayId;
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/context/WorkflowContext.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/context/WorkflowContext.java b/modules/commons/src/main/java/org/apache/airavata/common/context/WorkflowContext.java
new file mode 100644
index 0000000..59142e4
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/context/WorkflowContext.java
@@ -0,0 +1,86 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.context;
+
+/**
+ * The workflow context class. This will be local to a thread. Workflow data that needs to propagate relevant to a
+ * request will be stored here. We use thread local globals to store request data. Currently we only store user
+ * identity.
+ */
+public class WorkflowContext {
+
+ private static final ThreadLocal userThreadLocal = new InheritableThreadLocal();
+
+ /**
+ * Sets the context.
+ *
+ * @param context
+ * The context to be set. - Careful when calling this. Make sure other data relevant to context is
+ * preserved.
+ */
+ public static void set(RequestContext context) {
+ userThreadLocal.set(context);
+ }
+
+ /**
+ * Clears the context
+ */
+ public static void unset() {
+ userThreadLocal.remove();
+ }
+
+ /**
+ * Gets the context associated with current context.
+ *
+ * @return The context associated with current thread.
+ */
+ public static RequestContext get() {
+ return (RequestContext) userThreadLocal.get();
+ }
+
+ /**
+ * Gets the user associated with current user.
+ *
+ * @return User id associated with current request.
+ */
+ public static synchronized String getRequestUser() {
+
+ RequestContext requestContext = (RequestContext) userThreadLocal.get();
+
+ if (requestContext != null) {
+ return requestContext.getUserIdentity();
+ }
+
+ return null;
+ }
+
+ public static synchronized String getGatewayId() {
+
+ RequestContext requestContext = (RequestContext) userThreadLocal.get();
+
+ if (requestContext != null) {
+ return requestContext.getGatewayId();
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java
new file mode 100644
index 0000000..874e029
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.exception;
+
+public class AiravataConfigurationException extends AiravataException {
+ private static final long serialVersionUID = -9124231436834631249L;
+
+ public AiravataConfigurationException() {
+ }
+
+ public AiravataConfigurationException(String message){
+ this(message, null);
+ }
+
+ public AiravataConfigurationException(String message, Throwable e){
+ super(message,e);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataException.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataException.java
new file mode 100644
index 0000000..a41b77d
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataException.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.exception;
+
+public class AiravataException extends Exception {
+
+ private static final long serialVersionUID = -5665822765183116821L;
+ public AiravataException() {
+ }
+
+ public AiravataException(String message, Throwable e) {
+ super(message,e);
+ }
+
+ public AiravataException(String message) {
+ super(message);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java
new file mode 100644
index 0000000..b669fe0
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java
@@ -0,0 +1,35 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.exception;
+
+public class ApplicationSettingsException extends AiravataException {
+
+ private static final long serialVersionUID = -4901850535475160411L;
+
+ public ApplicationSettingsException(String message) {
+ super(message);
+ }
+
+ public ApplicationSettingsException(String message, Throwable e) {
+ super(message, e);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsLoadException.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsLoadException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsLoadException.java
new file mode 100644
index 0000000..2735cf3
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsLoadException.java
@@ -0,0 +1,38 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.exception;
+
+public class ApplicationSettingsLoadException extends ApplicationSettingsException {
+
+ private static final long serialVersionUID = -5102090895499711299L;
+ public ApplicationSettingsLoadException(String message) {
+ super(message);
+ }
+
+ public ApplicationSettingsLoadException(Throwable e) {
+ this(e.getMessage(),e);
+ }
+
+ public ApplicationSettingsLoadException(String message, Throwable e) {
+ super(message,e);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsStoreException.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsStoreException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsStoreException.java
new file mode 100644
index 0000000..5f258bf
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsStoreException.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.exception;
+
+public class ApplicationSettingsStoreException extends ApplicationSettingsException {
+
+ private static final long serialVersionUID = -5102090895499711299L;
+ public ApplicationSettingsStoreException(String filePath) {
+ super("Error while attempting to store settings in "+filePath);
+ }
+
+ public ApplicationSettingsStoreException(String filePath, Throwable e) {
+ super(filePath,e);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/LazyLoadedDataException.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/LazyLoadedDataException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/LazyLoadedDataException.java
new file mode 100644
index 0000000..4ba58d7
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/LazyLoadedDataException.java
@@ -0,0 +1,30 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.exception;
+
+public class LazyLoadedDataException extends AiravataException {
+ private static final long serialVersionUID = -3164776318582067936L;
+ public LazyLoadedDataException(String message) {
+ super(message);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/UnspecifiedApplicationSettingsException.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/UnspecifiedApplicationSettingsException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/UnspecifiedApplicationSettingsException.java
new file mode 100644
index 0000000..c29ff24
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/UnspecifiedApplicationSettingsException.java
@@ -0,0 +1,30 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.exception;
+
+public class UnspecifiedApplicationSettingsException extends ApplicationSettingsException {
+
+ private static final long serialVersionUID = -1159027432434546003L;
+ public UnspecifiedApplicationSettingsException(String key) {
+ super("The '"+key+"' is not configured in settings!!!");
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/UtilsException.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/UtilsException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/UtilsException.java
new file mode 100644
index 0000000..a412fe1
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/UtilsException.java
@@ -0,0 +1,61 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.exception;
+
+public class UtilsException extends Exception {
+
+ /**
+ * Constructs a UtilsException.
+ *
+ */
+ public UtilsException() {
+ super();
+ }
+
+ /**
+ * Constructs a UtilsException.
+ *
+ * @param message
+ */
+ public UtilsException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a UtilsException.
+ *
+ * @param cause
+ */
+ public UtilsException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Constructs a UtilsException.
+ *
+ * @param message
+ * @param cause
+ */
+ public UtilsException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java b/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java
new file mode 100644
index 0000000..9477cc9
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java
@@ -0,0 +1,677 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.logger;
+
+public interface AiravataLogger{
+
+ /**
+ * Return the name of this <code>Logger</code> instance.
+ *
+ * @return name of this logger instance
+ */
+ String getName();
+
+ /**
+ * Is the logger instance enabled for the TRACE level?
+ *
+ * @return True if this Logger is enabled for the TRACE level,
+ * false otherwise.
+ * @since 1.4
+ */
+ boolean isTraceEnabled();
+
+ /**
+ * Log a message at the TRACE level.
+ *
+ * @param msg the message string to be logged
+ * @since 1.4
+ */
+ void trace(String msg);
+
+ /**
+ * Log a message at the TRACE level.
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param msg the message string to be logged
+ * @since 1.4
+ */
+ void traceId(String etjId, String msg);
+
+ /**
+ * Log a message at the TRACE level according to the specified format
+ * and argument.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the TRACE level. </p>
+ *
+ * @param format the format string
+ * @param arg the argument
+ * @since 1.4
+ */
+ void trace(String format, Object arg);
+
+ /**
+ * Log a message at the TRACE level according to the specified format
+ * and argument.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the TRACE level. </p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arg the argument
+ * @since 1.4
+ */
+ void traceId(String etjId, String format, Object arg);
+
+ /**
+ * Log a message at the TRACE level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the TRACE level. </p>
+ *
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ * @since 1.4
+ */
+ void trace(String format, Object arg1, Object arg2);
+
+ /**
+ * Log a message at the TRACE level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the TRACE level. </p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ * @since 1.4
+ */
+ void traceId(String etjId, String format, Object arg1, Object arg2);
+
+ /**
+ * Log a message at the TRACE level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous string concatenation when the logger
+ * is disabled for the TRACE level. However, this variant incurs the hidden
+ * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
+ * even if this logger is disabled for TRACE. The variants taking {@link #trace(String, Object) one} and
+ * {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost.</p>
+ *
+ * @param format the format string
+ * @param arguments a list of 3 or more arguments
+ * @since 1.4
+ */
+ void trace(String format, Object... arguments);
+
+ /**
+ * Log a message at the TRACE level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous string concatenation when the logger
+ * is disabled for the TRACE level. However, this variant incurs the hidden
+ * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
+ * even if this logger is disabled for TRACE. The variants taking {@link #trace(String, Object) one} and
+ * {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost.</p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arguments a list of 3 or more arguments
+ * @since 1.4
+ */
+ void traceId(String etjId, String format, Object... arguments);
+
+ /**
+ * Log an exception (throwable) at the TRACE level with an
+ * accompanying message.
+ *
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ * @since 1.4
+ */
+ void trace(String msg, Throwable t);
+
+ /**
+ * Log an exception (throwable) at the TRACE level with an
+ * accompanying message.
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ * @since 1.4
+ */
+ void traceId(String etjId, String msg, Throwable t);
+
+ /**
+ * Is the logger instance enabled for the DEBUG level?
+ *
+ * @return True if this Logger is enabled for the DEBUG level,
+ * false otherwise.
+ */
+ boolean isDebugEnabled();
+
+ /**
+ * Log a message at the DEBUG level.
+ *
+ * @param msg the message string to be logged
+ */
+ void debug(String msg);
+
+ /**
+ * Log a message at the DEBUG level.
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param msg the message string to be logged
+ */
+ void debugId(String etjId, String msg);
+
+ /**
+ * Log a message at the DEBUG level according to the specified format
+ * and argument.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the DEBUG level. </p>
+ *
+ * @param format the format string
+ * @param arg the argument
+ */
+ void debug(String format, Object arg);
+
+ /**
+ * Log a message at the DEBUG level according to the specified format
+ * and argument.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the DEBUG level. </p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arg the argument
+ */
+ void debugId(String etjId, String format, Object arg);
+
+ /**
+ * Log a message at the DEBUG level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the DEBUG level. </p>
+ *
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ */
+ void debug(String format, Object arg1, Object arg2);
+
+ /**
+ * Log a message at the DEBUG level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the DEBUG level. </p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ */
+ void debugId(String etjId, String format, Object arg1, Object arg2);
+
+ /**
+ * Log a message at the DEBUG level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous string concatenation when the logger
+ * is disabled for the DEBUG level. However, this variant incurs the hidden
+ * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
+ * even if this logger is disabled for DEBUG. The variants taking
+ * {@link #debug(String, Object) one} and {@link #debug(String, Object, Object) two}
+ * arguments exist solely in order to avoid this hidden cost.</p>
+ *
+ * @param format the format string
+ * @param arguments a list of 3 or more arguments
+ */
+ void debug(String format, Object... arguments);
+
+ /**
+ * Log a message at the DEBUG level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous string concatenation when the logger
+ * is disabled for the DEBUG level. However, this variant incurs the hidden
+ * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
+ * even if this logger is disabled for DEBUG. The variants taking
+ * {@link #debug(String, Object) one} and {@link #debug(String, Object, Object) two}
+ * arguments exist solely in order to avoid this hidden cost.</p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arguments a list of 3 or more arguments
+ */
+ void debugId(String etjId, String format, Object... arguments);
+
+ /**
+ * Log an exception (throwable) at the DEBUG level with an
+ * accompanying message.
+ *
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void debug(String msg, Throwable t);
+
+ /**
+ * Log an exception (throwable) at the DEBUG level with an
+ * accompanying message.
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void debugId(String etjId, String msg, Throwable t);
+
+ /**
+ * Is the logger instance enabled for the INFO level?
+ *
+ * @return True if this Logger is enabled for the INFO level,
+ * false otherwise.
+ */
+ boolean isInfoEnabled();
+
+ /**
+ * Log a message at the INFO level.
+ *
+ * @param msg the message string to be logged
+ */
+ void info(String msg);
+
+ /**
+ * Log a message at the INFO level.
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param msg the message string to be logged
+ */
+ void infoId(String etjId, String msg);
+
+ /**
+ * Log a message at the INFO level according to the specified format
+ * and argument.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the INFO level. </p>
+ *
+ * @param format the format string
+ * @param arg the argument
+ */
+ void info(String format, Object arg);
+
+ /**
+ * Log a message at the INFO level according to the specified format
+ * and argument.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the INFO level. </p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arg the argument
+ */
+ void infoId(String etjId, String format, Object arg);
+
+ /**
+ * Log a message at the INFO level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the INFO level. </p>
+ *
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ */
+ void info(String format, Object arg1, Object arg2);
+
+ /**
+ * Log a message at the INFO level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the INFO level. </p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ */
+ void infoId(String etjId, String format, Object arg1, Object arg2);
+
+ /**
+ * Log a message at the INFO level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous string concatenation when the logger
+ * is disabled for the INFO level. However, this variant incurs the hidden
+ * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
+ * even if this logger is disabled for INFO. The variants taking
+ * {@link #info(String, Object) one} and {@link #info(String, Object, Object) two}
+ * arguments exist solely in order to avoid this hidden cost.</p>
+ *
+ * @param format the format string
+ * @param arguments a list of 3 or more arguments
+ */
+ void info(String format, Object... arguments);
+
+ /**
+ * Log a message at the INFO level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous string concatenation when the logger
+ * is disabled for the INFO level. However, this variant incurs the hidden
+ * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
+ * even if this logger is disabled for INFO. The variants taking
+ * {@link #info(String, Object) one} and {@link #info(String, Object, Object) two}
+ * arguments exist solely in order to avoid this hidden cost.</p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arguments a list of 3 or more arguments
+ */
+ void infoId(String etjId, String format, Object... arguments);
+
+ /**
+ * Log an exception (throwable) at the INFO level with an
+ * accompanying message.
+ *
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void info(String msg, Throwable t);
+
+ /**
+ * Log an exception (throwable) at the INFO level with an
+ * accompanying message.
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void infoId(String etjId, String msg, Throwable t);
+
+ /**
+ * Is the logger instance enabled for the WARN level?
+ *
+ * @return True if this Logger is enabled for the WARN level,
+ * false otherwise.
+ */
+ boolean isWarnEnabled();
+
+ /**
+ * Log a message at the WARN level.
+ *
+ * @param msg the message string to be logged
+ */
+ void warn(String msg);
+
+ /**
+ * Log a message at the WARN level.
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param msg the message string to be logged
+ */
+ void warnId(String etjId, String msg);
+
+ /**
+ * Log a message at the WARN level according to the specified format
+ * and argument.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the WARN level. </p>
+ *
+ * @param format the format string
+ * @param arg the argument
+ */
+ void warn(String format, Object arg);
+
+ /**
+ * Log a message at the WARN level according to the specified format
+ * and argument.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the WARN level. </p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arg the argument
+ */
+ void warnId(String etjId, String format, Object arg);
+
+ /**
+ * Log a message at the WARN level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous string concatenation when the logger
+ * is disabled for the WARN level. However, this variant incurs the hidden
+ * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
+ * even if this logger is disabled for WARN. The variants taking
+ * {@link #warn(String, Object) one} and {@link #warn(String, Object, Object) two}
+ * arguments exist solely in order to avoid this hidden cost.</p>
+ *
+ * @param format the format string
+ * @param arguments a list of 3 or more arguments
+ */
+ void warn(String format, Object... arguments);
+
+ /**
+ * Log a message at the WARN level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous string concatenation when the logger
+ * is disabled for the WARN level. However, this variant incurs the hidden
+ * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
+ * even if this logger is disabled for WARN. The variants taking
+ * {@link #warn(String, Object) one} and {@link #warn(String, Object, Object) two}
+ * arguments exist solely in order to avoid this hidden cost.</p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arguments a list of 3 or more arguments
+ */
+ void warnId(String etjId, String format, Object... arguments);
+
+ /**
+ * Log a message at the WARN level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the WARN level. </p>
+ *
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ */
+ void warn(String format, Object arg1, Object arg2);
+
+ /**
+ * Log a message at the WARN level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the WARN level. </p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ */
+ void warnId(String etjId, String format, Object arg1, Object arg2);
+
+ /**
+ * Log an exception (throwable) at the WARN level with an
+ * accompanying message.
+ *
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void warn(String msg, Throwable t);
+
+ /**
+ * Log an exception (throwable) at the WARN level with an
+ * accompanying message.
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void warnId(String etjId, String msg, Throwable t);
+
+ /**
+ * Is the logger instance enabled for the ERROR level?
+ *
+ * @return True if this Logger is enabled for the ERROR level,
+ * false otherwise.
+ */
+ boolean isErrorEnabled();
+
+ /**
+ * Log a message at the ERROR level.
+ *
+ * @param msg the message string to be logged
+ */
+ void error(String msg);
+
+ /**
+ * Log a message at the ERROR level.
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param msg the message string to be logged
+ */
+ void errorId(String etjId, String msg);
+
+ /**
+ * Log a message at the ERROR level according to the specified format
+ * and argument.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the ERROR level. </p>
+ *
+ * @param format the format string
+ * @param arg the argument
+ */
+ void error(String format, Object arg);
+
+ /**
+ * Log a message at the ERROR level according to the specified format
+ * and argument.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the ERROR level. </p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arg the argument
+ */
+ void errorId(String etjId, String format, Object arg);
+
+ /**
+ * Log a message at the ERROR level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the ERROR level. </p>
+ *
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ */
+ void error(String format, Object arg1, Object arg2);
+
+ /**
+ * Log a message at the ERROR level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the ERROR level. </p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ */
+ void errorId(String etjId, String format, Object arg1, Object arg2);
+
+ /**
+ * Log a message at the ERROR level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous string concatenation when the logger
+ * is disabled for the ERROR level. However, this variant incurs the hidden
+ * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
+ * even if this logger is disabled for ERROR. The variants taking
+ * {@link #error(String, Object) one} and {@link #error(String, Object, Object) two}
+ * arguments exist solely in order to avoid this hidden cost.</p>
+ *
+ * @param format the format string
+ * @param arguments a list of 3 or more arguments
+ */
+ void error(String format, Object... arguments);
+
+ /**
+ * Log a message at the ERROR level according to the specified format
+ * and arguments.
+ * <p/>
+ * <p>This form avoids superfluous string concatenation when the logger
+ * is disabled for the ERROR level. However, this variant incurs the hidden
+ * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
+ * even if this logger is disabled for ERROR. The variants taking
+ * {@link #error(String, Object) one} and {@link #error(String, Object, Object) two}
+ * arguments exist solely in order to avoid this hidden cost.</p>
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param format the format string
+ * @param arguments a list of 3 or more arguments
+ */
+ void errorId(String etjId, String format, Object... arguments);
+
+ /**
+ * Log an exception (throwable) at the ERROR level with an
+ * accompanying message.
+ *
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void error(String msg, Throwable t);
+
+ /**
+ * Log an exception (throwable) at the ERROR level with an
+ * accompanying message.
+ *
+ * @param etjId - Experiment , Task or Job Id
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void errorId(String etjId, String msg, Throwable t);
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java b/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java
new file mode 100644
index 0000000..a1a9462
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.logger;
+
+public class AiravataLoggerFactory {
+
+ public static AiravataLogger getLogger(Class aClass) {
+ return new AiravataLoggerImpl(aClass);
+ }
+
+ public static AiravataLogger getLogger(String className) {
+ return new AiravataLoggerImpl(className);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java b/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java
new file mode 100644
index 0000000..74ab401
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java
@@ -0,0 +1,323 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.logger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AiravataLoggerImpl implements AiravataLogger{
+
+ private Logger logger;
+
+ public AiravataLoggerImpl(Class aClass) {
+ logger = LoggerFactory.getLogger(aClass);
+ }
+
+ public AiravataLoggerImpl(String className) {
+ logger = LoggerFactory.getLogger(className);
+ }
+
+
+ @Override
+ public String getName() {
+ return logger.getName();
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return logger.isTraceEnabled();
+ }
+
+ @Override
+ public void trace(String msg) {
+ logger.trace(msg);
+ }
+
+ @Override
+ public void traceId(String etjId, String msg) {
+ logger.trace(getAiravataLogMessage(etjId, msg));
+ }
+
+ @Override
+ public void trace(String format, Object arg) {
+ logger.trace(format, arg);
+ }
+
+ @Override
+ public void traceId(String etjId, String format, Object arg) {
+ logger.trace(getAiravataLogMessage(etjId, format), arg);
+ }
+
+ @Override
+ public void trace(String format, Object arg1, Object arg2) {
+ logger.trace(format, arg1, arg2);
+ }
+
+ @Override
+ public void traceId(String etjId, String format, Object arg1, Object arg2) {
+ logger.trace(getAiravataLogMessage(etjId,format), arg1, arg2);
+ }
+
+ @Override
+ public void trace(String format, Object... arguments) {
+ logger.trace(format, arguments);
+ }
+
+ @Override
+ public void traceId(String etjId, String format, Object... arguments) {
+ logger.trace(getAiravataLogMessage(etjId, format), arguments);
+ }
+
+ @Override
+ public void trace(String msg, Throwable t) {
+ logger.trace(msg, t);
+ }
+
+ @Override
+ public void traceId(String etjId, String msg, Throwable t) {
+ logger.trace(getAiravataLogMessage(etjId, msg), t);
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return logger.isDebugEnabled();
+ }
+
+ @Override
+ public void debug(String msg) {
+ logger.debug(msg);
+ }
+
+ @Override
+ public void debugId(String etjId, String msg) {
+ logger.debug(getAiravataLogMessage(etjId, msg));
+ }
+
+ @Override
+ public void debug(String format, Object arg) {
+ logger.debug(format, arg);
+ }
+
+ @Override
+ public void debugId(String etjId, String format, Object arg) {
+ logger.debug(getAiravataLogMessage(etjId, format), arg);
+ }
+
+ @Override
+ public void debug(String format, Object arg1, Object arg2) {
+ logger.debug(format, arg1, arg2);
+ }
+
+ @Override
+ public void debugId(String etjId, String format, Object arg1, Object arg2) {
+ logger.debug(getAiravataLogMessage(etjId, format), arg1, arg2);
+ }
+
+ @Override
+ public void debug(String format, Object... arguments) {
+ logger.debug(format, arguments);
+ }
+
+ @Override
+ public void debugId(String etjId, String format, Object... arguments) {
+ logger.debug(getAiravataLogMessage(etjId, format), arguments);
+ }
+
+ @Override
+ public void debug(String msg, Throwable t) {
+ logger.debug(msg, t);
+ }
+
+ @Override
+ public void debugId(String etjId, String msg, Throwable t) {
+ logger.debug(getAiravataLogMessage(etjId, msg), t);
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return logger.isInfoEnabled();
+ }
+
+ @Override
+ public void info(String msg) {
+ logger.info(msg);
+ }
+
+ @Override
+ public void infoId(String etjId, String msg) {
+ logger.info(getAiravataLogMessage(etjId, msg));
+ }
+
+ @Override
+ public void info(String format, Object arg) {
+ logger.info(format, arg);
+ }
+
+ @Override
+ public void infoId(String etjId, String format, Object arg) {
+ logger.info(getAiravataLogMessage(etjId, format), arg);
+ }
+
+ @Override
+ public void info(String format, Object arg1, Object arg2) {
+ logger.info(format, arg1, arg2);
+ }
+
+ @Override
+ public void infoId(String etjId, String format, Object arg1, Object arg2) {
+ logger.info(getAiravataLogMessage(etjId, format), arg1, arg2);
+ }
+
+ @Override
+ public void info(String format, Object... arguments) {
+ logger.info(format, arguments);
+ }
+
+ @Override
+ public void infoId(String etjId, String format, Object... arguments) {
+ logger.info(getAiravataLogMessage(etjId, format), arguments);
+ }
+
+ @Override
+ public void info(String msg, Throwable t) {
+ logger.info(msg, t);
+ }
+
+ @Override
+ public void infoId(String etjId, String msg, Throwable t) {
+ logger.info(getAiravataLogMessage(etjId, msg), t);
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return logger.isWarnEnabled();
+ }
+
+ @Override
+ public void warn(String msg) {
+ logger.warn(msg);
+ }
+
+ @Override
+ public void warnId(String etjId, String msg) {
+ logger.warn(getAiravataLogMessage(etjId, msg));
+ }
+
+ @Override
+ public void warn(String format, Object arg) {
+ logger.warn(format, arg);
+ }
+
+ @Override
+ public void warnId(String etjId, String format, Object arg) {
+ logger.warn(getAiravataLogMessage(etjId, format), arg);
+ }
+
+ @Override
+ public void warn(String format, Object... arguments) {
+ logger.warn(format, arguments);
+ }
+
+ @Override
+ public void warnId(String etjId, String format, Object... arguments) {
+ logger.warn(getAiravataLogMessage(etjId, format), arguments);
+ }
+
+ @Override
+ public void warn(String format, Object arg1, Object arg2) {
+ logger.warn(format, arg1, arg2);
+ }
+
+ @Override
+ public void warnId(String etjId, String format, Object arg1, Object arg2) {
+ logger.warn(getAiravataLogMessage(etjId, format), arg1, arg2);
+ }
+
+ @Override
+ public void warn(String msg, Throwable t) {
+ logger.warn(msg, t);
+ }
+
+ @Override
+ public void warnId(String etjId, String msg, Throwable t) {
+ logger.warn(getAiravataLogMessage(etjId, msg), t);
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return logger.isErrorEnabled();
+ }
+
+ @Override
+ public void error(String msg) {
+ logger.error(msg);
+ }
+
+ @Override
+ public void errorId(String etjId, String msg) {
+ logger.error(getAiravataLogMessage(etjId, msg));
+ }
+
+ @Override
+ public void error(String format, Object arg) {
+ logger.error(format, arg);
+ }
+
+ @Override
+ public void errorId(String etjId, String format, Object arg) {
+ logger.error(getAiravataLogMessage(etjId, format), arg);
+ }
+
+ @Override
+ public void error(String format, Object arg1, Object arg2) {
+ logger.error(format, arg1, arg2);
+ }
+
+ @Override
+ public void errorId(String etjId, String format, Object arg1, Object arg2) {
+ logger.error(getAiravataLogMessage(etjId, format), arg1, arg2);
+ }
+
+ @Override
+ public void error(String format, Object... arguments) {
+ logger.error(format, arguments);
+ }
+
+ @Override
+ public void errorId(String etjId, String format, Object... arguments) {
+ logger.error(getAiravataLogMessage(etjId, format), arguments);
+ }
+
+ @Override
+ public void error(String msg, Throwable t) {
+ logger.error(msg, t);
+ }
+
+ @Override
+ public void errorId(String etjId, String msg, Throwable t) {
+ logger.error(getAiravataLogMessage(etjId, msg), t);
+ }
+
+ private String getAiravataLogMessage(String etjId, String msg) {
+ return new StringBuilder("Id:").append(etjId).append(" : ").append(msg).toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java
new file mode 100644
index 0000000..83e4218
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java
@@ -0,0 +1,117 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.common.utils;
+
+/*
+These are the job statuses shared in database level between orchestrator and
+gfac instances
+ */
+public class AiravataJobState {
+
+ private State jobState;
+
+ public State getJobState() {
+ return jobState;
+ }
+
+ public void setJobState(State jobState) {
+ this.jobState = jobState;
+ }
+
+
+ public enum State {
+ CREATED {
+ public String toString() {
+ return "CREATED";
+ }
+ },
+ ACCEPTED {
+ public String toString() {
+ return "ACCEPTED";
+ }
+ },
+ FETCHED {
+ public String toString() {
+ return "FETCHED";
+ }
+ },
+ INHANDLERSDONE {
+ public String toString() {
+ return "INHANDLERSDONE";
+ }
+ },
+ SUBMITTED {
+ public String toString() {
+ return "SUBMITTED";
+ }
+ },
+ OUTHANDLERSDONE {
+ public String toString() {
+ return "OUTHANDLERSDONE";
+ }
+ },
+ RUNNING {
+ public String toString() {
+ return "RUNNING";
+ }
+ },
+ FAILED {
+ public String toString() {
+ return "FAILED";
+ }
+ },
+ PAUSED {
+ public String toString() {
+ return "PAUSED";
+ }
+ },
+ PENDING {
+ public String toString() {
+ return "PENDING";
+ }
+ },
+ ACTIVE {
+ public String toString() {
+ return "ACTIVE";
+ }
+ },
+ DONE {
+ public String toString() {
+ return "DONE";
+ }
+ },
+ CANCELLED {
+ public String toString() {
+ return "CANCELLED";
+ }
+ },
+ UNKNOWN {
+ public String toString() {
+ return "UNKNOWN";
+ }
+ },
+ HANGED {
+ public String toString() {
+ return "HANGED";
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java
new file mode 100644
index 0000000..52d114f
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.common.utils;
+
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.UUID;
+
+public class AiravataUtils {
+
+ public static Timestamp getCurrentTimestamp() {
+ Calendar calender = Calendar.getInstance();
+ java.util.Date d = calender.getTime();
+ return new Timestamp(d.getTime());
+ }
+
+ public static Timestamp getTime(long time) {
+ if (time == 0 || time < 0){
+ return getCurrentTimestamp();
+ }
+ return new Timestamp(time);
+ }
+
+ public static String getId (String name){
+ String id = name.replaceAll("\\s", "");
+ return id + "_" + UUID.randomUUID();
+ }
+}