You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2011/06/24 13:01:18 UTC

svn commit: r1139241 [3/3] - in /incubator/airavata/core/trunk/gfac: ./ .settings/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/airavata/ src/main/java/org/apache/airavata/core/ src/main/java/org/a...

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,237 @@
+package org.apache.airavata.core.gfac.services.impl;
+
+import java.lang.reflect.Array;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.airavata.core.gfac.context.InvocationContext;
+import org.apache.airavata.core.gfac.exception.GfacException;
+import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
+import org.apache.airavata.core.gfac.extension.DataServiceChain;
+import org.apache.airavata.core.gfac.extension.ExitableChain;
+import org.apache.airavata.core.gfac.extension.PostExecuteChain;
+import org.apache.airavata.core.gfac.extension.PreExecuteChain;
+import org.apache.airavata.core.gfac.registry.RegistryService;
+import org.apache.airavata.core.gfac.registry.impl.XregistryServiceWrapper;
+import org.apache.airavata.core.gfac.scheduler.Scheduler;
+
+/**
+ * This generic service implementation will load Registry service and Data
+ * Catalog from property file. It selects provider and execute it base on
+ * execution context.
+ * 
+ * @author Patanachai Tangchaisin
+ * 
+ */
+public class PropertiesBasedServiceImpl extends AbstractSimpleService {
+
+	private static final String FILENAME = "service.properties";
+	public static final String REGISTY_URL_NAME = "registryURL";
+	public static final String SSL_TRUSTED_CERTS_FILE = "ssl.trustedCertsFile";
+	public static final String SSL_HOSTCERTS_KEY_FILE = "ssl.hostcertsKeyFile";
+	public static final String SCHEDULER_CLASS = "scheduler.class";
+	public static final String DATA_CHAIN_CLASS = "datachain.classes";
+	public static final String PRE_CHAIN_CLASS = "prechain.classes";
+	public static final String POST_CHAIN_CLASS = "postchain.classes";
+
+	private Properties properties;
+	private Scheduler scheduler;
+	private PreExecuteChain[] preChain;
+	private PostExecuteChain[] postChain;
+	private DataServiceChain[] dataChain;
+	
+	private RegistryService registryService;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.airavata.core.gfac.services.GenericService#init(org.apache.airavata.core.gfac.context.
+	 * InvocationContext)
+	 */
+	public void init() throws GfacException {
+		/*
+		 * Load properties and create XRegistry service
+		 */
+		try {
+			URL url = ClassLoader.getSystemResource(FILENAME);
+
+			this.properties = new Properties();
+			this.properties.load(url.openStream());
+
+			String registryURL = loadFromProperty(REGISTY_URL_NAME, true);
+			String trustcerts = loadFromProperty(SSL_TRUSTED_CERTS_FILE, true);
+			String hostcerts = loadFromProperty(SSL_HOSTCERTS_KEY_FILE, true);
+
+			this.registryService = new XregistryServiceWrapper(registryURL, trustcerts, hostcerts);
+
+		} catch (Exception e) {
+			throw new GfacException("Error initialize the generic service", e);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.airavata.core.gfac.services.GenericService#dispose(org.apache.airavata.core.gfac.context.
+	 * InvocationContext)
+	 */
+	public void dispose() throws GfacException {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void preProcess(InvocationContext context) throws GfacException {
+		//set Fix Registry location for every requests 
+		context.getExecutionContext().setRegistryService(this.registryService);		
+	}
+
+	@Override
+	public void postProcess(InvocationContext context) throws GfacException {
+		// TODO Auto-generated method stub		
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.airavata.core.gfac.services.GenericService#getScheduler(org.apache.airavata.core.gfac.context
+	 * .InvocationContext)
+	 */
+	public Scheduler getScheduler(InvocationContext context) throws GfacException {
+		String className = null;
+		if (this.scheduler == null) {
+			/*
+			 * get class names
+			 */
+			className = loadFromProperty(SCHEDULER_CLASS, true);
+
+			/*
+			 * init instance of that class
+			 */
+			try {
+				ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+				Class<? extends Scheduler> spiClass;
+
+				if (classLoader == null) {
+					spiClass = Class.forName(className).asSubclass(Scheduler.class);
+				} else {
+					spiClass = classLoader.loadClass(className).asSubclass(Scheduler.class);
+				}
+
+				this.scheduler = spiClass.newInstance();
+
+			} catch (ClassNotFoundException ex) {
+				throw new GfacException("Scheduler " + className + " not found", ex);
+			} catch (Exception ex) {
+				throw new GfacException("Scheduler " + className + " could not be instantiated: " + ex, ex);
+			}
+		}
+		return this.scheduler;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.airavata.core.gfac.services.GenericService#getPreExecutionSteps(org.ogce.gfac
+	 * .context.InvocationContext)
+	 */
+	public PreExecuteChain[] getPreExecutionSteps(InvocationContext context) throws GfacException {
+		if (this.preChain == null) {
+			this.preChain = loadClassFromProperties(PRE_CHAIN_CLASS, PreExecuteChain.class);
+		}
+		return preChain;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.airavata.core.gfac.services.GenericService#getPostExecuteSteps(org.ogce.gfac
+	 * .context.InvocationContext)
+	 */
+	public PostExecuteChain[] getPostExecuteSteps(InvocationContext context) throws GfacException {
+		if (this.postChain == null) {
+			this.postChain = loadClassFromProperties(POST_CHAIN_CLASS, PostExecuteChain.class);
+		}
+		return postChain;
+	}
+	
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.apache.airavata.core.gfac.services.impl.OGCEGenericService#getDataChains(org.apache.airavata.core.gfac.context.InvocationContext)
+	 */
+	public DataServiceChain[] getDataChains(InvocationContext context) throws GfacException {
+		if(this.dataChain == null){
+			this.dataChain = loadClassFromProperties(DATA_CHAIN_CLASS, DataServiceChain.class);
+		}
+		return dataChain;
+	}
+
+	/**
+	 * 
+	 * @param propertyName
+	 * @param required
+	 * @return
+	 * @throws GfacException
+	 */
+	private String loadFromProperty(String propertyName, boolean required) throws GfacException {
+		String propValue = this.properties.getProperty(propertyName);
+		if (propValue == null) {
+			if (required)
+				throw new GfacException("Property \"" + propertyName + "\" is not found", FaultCode.InvalidConfig);
+			return null;
+		}
+		return propValue;
+	}
+
+	/**
+	 * 
+	 */
+	@SuppressWarnings("unchecked")
+	private <T> T[] loadClassFromProperties(String propertyName, Class<? extends ExitableChain> type) throws GfacException {
+
+		// property is not set
+		String propValue = loadFromProperty(propertyName, false);
+		if (propValue == null) {
+			return null;
+		}
+
+		/*
+		 * get class names
+		 */
+		String classNames[] = this.properties.getProperty(propertyName).split(",");		
+
+		/*
+		 * init instance of that class
+		 */
+		T[] chain = (T[]) Array.newInstance(type, classNames.length);
+		for (int i = 0; i < classNames.length; i++) {
+
+			String className = classNames[i];
+			System.out.println(className);
+
+			try {
+				ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+				Class<? extends ExitableChain> spiClass;
+
+				if (classLoader == null) {
+					spiClass = Class.forName(className).asSubclass(ExitableChain.class);
+				} else {
+					spiClass = classLoader.loadClass(className).asSubclass(ExitableChain.class);
+				}
+
+				chain[i] = (T) spiClass.newInstance();
+			} catch (ClassNotFoundException ex) {
+				ex.printStackTrace();
+				// TODO proper throw out
+			} catch (Exception ex) {
+				ex.printStackTrace();
+				// TODO proper throw out
+			}
+		}
+		return chain;
+	}
+}

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/BooleanParameter.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/BooleanParameter.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/BooleanParameter.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/BooleanParameter.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,29 @@
+package org.apache.airavata.core.gfac.type;
+
+public class BooleanParameter implements Parameter<Boolean> {
+	
+	private final static String TYPE = "Boolean";
+	
+	private Boolean value;
+
+	@Override
+	public void fromString(String val) {
+		this.value = Boolean.parseBoolean(val);
+	}
+
+	@Override
+	public String toString() {
+		return this.value.toString();
+	}
+
+	@Override
+	public Boolean toJavaObject() {
+		return this.value;
+	}
+
+	@Override
+	public String getTypeName() {
+		return TYPE;
+	}
+
+}

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/DoubleParameter.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/DoubleParameter.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/DoubleParameter.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/DoubleParameter.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,28 @@
+package org.apache.airavata.core.gfac.type;
+
+public class DoubleParameter implements Parameter<Double> {
+	
+	private final static String TYPE = "Interger";
+	
+	private Double value;
+
+	@Override
+	public void fromString(String val) {
+		this.value = Double.parseDouble(val);
+	}
+
+	@Override
+	public String toString() {
+		return this.value.toString();
+	}
+
+	@Override
+	public Double toJavaObject() {
+		return this.value;
+	}
+
+	@Override
+	public String getTypeName() {
+		return TYPE;
+	}	
+}

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/FloatParameter.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/FloatParameter.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/FloatParameter.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/FloatParameter.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,28 @@
+package org.apache.airavata.core.gfac.type;
+
+public class FloatParameter implements Parameter<Float> {
+	
+	private final static String TYPE = "Float";
+	
+	private Float value;
+
+	@Override
+	public void fromString(String val) {
+		this.value = Float.parseFloat(val);
+	}
+
+	@Override
+	public String toString() {
+		return this.value.toString();
+	}
+
+	@Override
+	public Float toJavaObject() {
+		return this.value;
+	}
+	
+	@Override
+	public String getTypeName() {
+		return TYPE;
+	}	
+}

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/IntegerParameter.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/IntegerParameter.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/IntegerParameter.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/IntegerParameter.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,29 @@
+package org.apache.airavata.core.gfac.type;
+
+public class IntegerParameter implements Parameter<Integer> {
+	
+	private final static String TYPE = "Interger";
+	
+	private Integer value;
+
+	@Override
+	public void fromString(String val) {
+		this.value = Integer.parseInt(val);
+	}
+
+	@Override
+	public String toString() {
+		return this.value.toString();
+	}
+
+	@Override
+	public Integer toJavaObject() {
+		return this.value;
+	}
+	
+	@Override
+	public String getTypeName() {
+		return TYPE;
+	}	
+
+}

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/Parameter.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/Parameter.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/Parameter.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/Parameter.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,12 @@
+package org.apache.airavata.core.gfac.type;
+
+public interface Parameter<T> {
+	
+	public String getTypeName();
+	
+	public void fromString(String val);
+	
+	public String toString();
+	
+	public T toJavaObject();
+}

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/StringParameter.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/StringParameter.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/StringParameter.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/StringParameter.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,30 @@
+package org.apache.airavata.core.gfac.type;
+
+public class StringParameter implements Parameter<String> {	
+	
+	private final static String TYPE = "String";
+	
+	private String value;
+
+	@Override
+	public void fromString(String val) {
+		this.value = val;
+	}
+
+	@Override
+	public String toString() {
+		return this.value;
+	}
+
+	@Override
+	public String toJavaObject() {
+		return this.value;
+	}
+
+	@Override
+	public String getTypeName() {
+		return TYPE;
+	}	
+	
+}
+

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/URIParameter.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/URIParameter.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/URIParameter.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/type/URIParameter.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,36 @@
+package org.apache.airavata.core.gfac.type;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class URIParameter implements Parameter<URI> {
+	
+	private final static String TYPE = "URI";
+	
+	private URI value;
+
+	@Override
+	public void fromString(String val) {
+		try{
+			this.value = new URI(val);
+		}catch (URISyntaxException ue){
+			//TODO handle exception
+			ue.printStackTrace();			
+		}
+	}
+
+	@Override
+	public String toString() {
+		return this.value.toString();
+	}
+
+	@Override
+	public URI toJavaObject() {
+		return this.value;
+	}
+
+	@Override
+	public String getTypeName() {
+		return TYPE;
+	}			
+}

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/ContactInfo.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/ContactInfo.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/ContactInfo.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/ContactInfo.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,44 @@
+package org.apache.airavata.core.gfac.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * @author Patanachai Tangchaisin
+ */
+public class ContactInfo {
+	protected final static Logger log = LoggerFactory.getLogger(GfacUtils.class);
+	public String hostName;
+	public int port;
+
+	public ContactInfo(String hostName, int port) {
+		if (port <= 0 || port == 80) {
+			log.info(hostName + "port recived " + port + " setting it to " + GFacConstants.GSI_FTP_PORT);
+			port = GFacConstants.GSI_FTP_PORT;
+		}
+		this.hostName = hostName;
+		this.port = port;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (obj instanceof ContactInfo) {
+			return hostName.equals(((ContactInfo) obj).hostName) && port == ((ContactInfo) obj).port;
+		} else {
+			return false;
+		}
+	}
+
+	@Override
+	public int hashCode() {
+		return hostName.hashCode();
+	}
+
+	@Override
+	public String toString() {
+		StringBuffer buf = new StringBuffer();
+		buf.append(hostName).append(":").append(port);
+		return buf.toString();
+	}
+}

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/ErrorCodes.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/ErrorCodes.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/ErrorCodes.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/ErrorCodes.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,13 @@
+
+package org.apache.airavata.core.gfac.utils;
+
+public interface ErrorCodes {
+    public static final String SERVICE_NOT_AVALIBLE = "ServiceNotAvalible";
+    public static final String JOB_CANCELED = "JobCanceled";
+    public static final String JOB_FAILED = "JobFailed";
+    public static final String JOB_TYPE = "JobType";
+    public static final String CONTACT = "JobContact";
+    public static final String SERVICE_CRATION_FAILED = "ServiceCreationFailed";
+    public static enum JobType{Gram,WSGram,Local,Ssh};
+}
+

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GFacConstants.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GFacConstants.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GFacConstants.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GFacConstants.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,140 @@
+package org.apache.airavata.core.gfac.utils;
+
+public class GFacConstants {
+	public static final String GFAC_NAMESPACE = "http://www.extreme.indiana.edu/namespaces/2004/01/gFac";
+
+	public static final String INPUT_DATA_DIR = "inputData";
+
+	public static final String OUTPUT_DATA_DIR = "outputData";
+
+	public static final String DEFAULT_TMP_DIR = "/tmp";
+
+	public static final String SHUTDOWN = "Shutdown";
+
+	public static final String PING = "Ping";
+
+	public static final String KILL = "Kill";
+
+	public static final String CREATE_SERVICE = "CreateService";
+
+	public static final String TRANSPORT_LEVEL = "TransportLevel";
+
+	public static final String MESSAGE_SIGNATURE = "MessageSignature";
+
+	public static final String SERVICE_URI = "SERVICE_URI";
+
+	public static final String METHOD_NAME = "METHOD_NAME";
+
+	public static final String SERVICE_NAME = "SERVICE_NAME";
+
+	public static final String APP_SERVICE_STRING_PARAM = "AFAC_STRING_PARAM";
+
+	public static final String SERVICE_RESP_MSG_SUFFIX = "_ResponseMessage";
+
+	public static final String SERVICE_INPUT_PARAMS_TYPE_SUFFIX = "_InputParamsType";
+
+	public static final String SERVICE_OUTPUT_PARAMS_TYPE_SUFFIX = "_OutputParamsType";
+
+	public static final String SERVICE_REQ_MSG_SUFFIX = "_RequestMessage";
+
+	public static final String SERVICE_IN_PARAMS_SUFFIX = "_InputParams";
+
+	public static final String SERVICE_OUT_PARAMS_SUFFIX = "_OutputParams";
+
+	public static final String SERVICE_TMP_DIR = "AFAC_TMP_DIR";
+
+	public static final String SERVICE_INPUT_MESSAGE_NAME = "AFAC_INPUT_MESSAGE_NAME";
+
+	public static final String BROKER_URL = "http://ogceportal.iu.teragrid.org:12346/";
+
+	public static final String SERVICE_BROKER = "http://tyr14.cs.indiana.edu:7777/axis2/services/HostSchedulerService?wsdl";
+
+	public static final int GSI_FTP_PORT = 2811;
+
+	public static final String HOST = "host";
+
+	public static final String UTF8 = "UTF-8";
+
+	public static final String ARRAY_VALUE = "value";
+
+	public static final String ADMIN_TOPIC = "ADMIN";
+
+	public static final String _127_0_0_1 = "127.0.0.1";
+
+	public static final String LOCALHOST = "localhost";
+
+	// GFac data types
+	public static class Types {
+		public static final String TYPE_STRING = "String";
+
+		public static final String TYPE_INT = "Integer";
+
+		public static final String TYPE_FLOAT = "Float";
+
+		public static final String TYPE_DOUBLE = "Double";
+
+		public static final String TYPE_BOOLEAN = "Boolean";
+
+		public static final String TYPE_QNAME = "QName";
+
+		public static final String TYPE_URI = "URI";
+
+		public static final String TYPE_STRING_ARRAY = "StringArray";
+
+		public static final String TYPE_INT_ARRAY = "IntegerArray";
+
+		public static final String TYPE_FLAOT_ARRAY = "FloatArray";
+
+		public static final String TYPE_DOUBLE_ARRAY = "DoubleArray";
+
+		public static final String TYPE_BOOLEAN_ARRAY = "BooleanArray";
+
+		public static final String TYPE_QNAME_ARRAY = "QNameArray";
+
+		public static final String TYPE_URI_ARRAY = "URIArray";
+
+		public static final String TYPE_LEADFILEID = "LEADFileID";
+
+		public static final String TYPE_LEADFILEID_ARRAY = "LEADFileIDArray";
+
+		public static final String TYPE_STDOUT = "StdOut";
+
+		public static final String TYPE_STDERRORs = "StdErr";
+
+		public static final String LEAD_NAMELIST_FILE = "LEADNameListFile";
+
+		public static final String LEAD_NAMELIST_PROPERTIES_FILE = "LEADNameListPropertiesFile";
+
+		public static final String LEAD_CROSSCUT_PARAMETERS = "LeadCrosscutParameters";
+
+		public static final String TYPE_DATAID = "DataID";
+		public static final String TYPE_DATAID_ARRAY = "DataIDArray";
+
+	};
+
+	public static interface InbuitOperations {
+		public static final String OP_KILL = "Kill";
+
+		public static final String OP_PING = "Ping";
+
+		public static final String OP_SHUTDOWN = "Shutdown";
+
+		public static final String USER_INTERACTION = "UserInteraction";
+	}
+
+	public static final String LOGGER_NAME = "gfac.logger";
+
+	public static String REGISTRY_URL = "https://localhost:6666/xregistry?wsdl";
+
+	public static String HOSTBINDING_EXTENSION_NAME = "resource-mapping";
+
+	public static int SLEEP_TIME = 1000;
+
+	public static String FAULT_NAMESPACE = "http://extreme.indiana.edu/management/faults";
+
+	public static String FAULT_DETAILS_NAME = "faultParameters";
+
+	public static enum TransportSchema {
+		http, ssh, sftp, gsiftp
+	};
+}

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GFacOptions.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GFacOptions.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GFacOptions.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GFacOptions.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,86 @@
+package org.apache.airavata.core.gfac.utils;
+
+/**
+ * 
+ * @author hperera
+ */
+
+public interface GFacOptions {
+    
+    public static final String NOTIFIER_CLASS_NAME = "notifierClass";
+    
+    public static final String OPTION_INSTALLATION = "installation";
+
+    public static final String OPTION_INSTALLATION_LOCAL = "local";
+
+    public static final String REGISTRY_URL_NAME = "registryURL";
+
+    public static final String FACTORY_URL_NAME = "factoryUrl";
+
+    /** My Proxy Parameters */
+    public static final String MYPROXY_USERNAME = "myproxyUserName";
+
+    public static final String MYPROXY_PASSWD = "myproxyPasswd";
+
+    public static final String MYPROXY_SERVER = "myproxyServer";
+
+    public static final String MYPROXY_DEFAULT_SERVER = "rainier.extreme.indiana.edu";
+
+    public static final String MYPROXY_LIFETIME = "myproxyLifetime";
+
+    public static final String MYPROXY_DEFAULT_LIFETIME = "2"; // hours
+
+    public static final String WS_GRAM_PREFERED = "wsgramPrefered";
+
+    /** file transfer service * */
+    public static final String FILE_TRANSFER_SERVICE = "filetransferService";
+    public static enum FileTransferServiceType{DAMN,GridFTP,SSH,SharedFs};
+
+    public static final String DAMN_WSDL_URL = "damn.wsdlUrl";
+
+    /** Service will renew the proxy if it is less than this value * */
+    public static final String MIN_PROXY_LIFETIME_PER_REQUEST_MINUTES = "minProxyLifetimeNeed4RequestMinutes";
+
+    public static final String HOST_SCHEDULER_URL = "hostscheduler.wsdlurl";
+
+    
+    
+    
+    /* Ssh Options */
+    public static final String SSH_USERNAME = "gfac.ssh.username";
+    public static final String SSH_PASSWD = "gfac.ssh.password";
+    public static final String SSH_KEYFILE = "gfac.ssh.keyFileName";
+    public static final String SSH_KNOWN_HOSTFILE = "gfac.ssh.knownHostsFileName";
+    
+    public static final String PREFFERED_PROVIDER = "gfac.prefferedProvider";
+
+    public static final String CUSTOM_MESSAGE_INTERCEPTER = "customMessageIntercepter";
+    
+    public static final String NOTIFICATION_BROKER_URL_NAME = "notificationBrokerURL";
+    public static final String MYLEAD_AGENT_URL_NAME = "myLEADAgentURL";
+    
+    public static enum CurrentProviders{Local,Gram,WSGram,SSH,ResourceBroker,Sigiri,InteractiveLocal,DRMAA};
+    
+    public static final String SCMS_LOCATION = "scms.location";
+    
+    public static final String SSL_TRUSTED_CERTS_FILE = "ssl.trustedCertsFile";
+
+    public static final String SSL_HOSTCERTS_KEY_FILE = "ssl.hostcertsKeyFile";
+
+    public static final String SERVICE_QNAME = "serviceQName";
+
+    public static final String HOST_NAME = "hostName";
+    
+    /** Comma (,) separated list of app descs **/
+    public static final String APP_DESC_LISR = "appDescList";
+    
+    public static final String DEPLOYMENT_HOSTS = "gfac.deploymentHosts";
+    
+    public static final String SIGIRI_LOCATION = "gfac.sigiriLocation";
+    
+    public static final String GFAC_TRANSIENT_SERVICE_PROFILE = "gfac.transientServiceProfile";
+    public static final String GFAC_PERSISTANT_SERVICE_PROFILE = "gfac.persistantServiceProfile";
+   
+    public static final String GFAC_RETRYONJOBERRORCODES = "gfac.retryonJobErrorCodes";
+    
+}

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GfacUtils.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GfacUtils.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GfacUtils.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GfacUtils.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,582 @@
+package org.apache.airavata.core.gfac.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Random;
+import java.util.UUID;
+import java.util.Vector;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.core.gfac.context.ExecutionContext;
+import org.apache.airavata.core.gfac.context.MessageContext;
+import org.apache.airavata.core.gfac.exception.GfacException;
+import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
+import org.globus.gram.Gram;
+import org.globus.gram.GramAttributes;
+import org.globus.gram.GramJob;
+import org.globus.gram.internal.GRAMConstants;
+import org.ietf.jgss.GSSCredential;
+import org.ogce.namespaces.x2010.x08.x30.workflowContextHeader.WorkflowContextHeaderDocument.WorkflowContextHeader;
+import org.ogce.namespaces.x2010.x08.x30.workflowResourceMapping.ResourceMappingDocument.ResourceMapping;
+import org.ogce.schemas.gfac.documents.ApplicationDescriptionDocument;
+import org.ogce.schemas.gfac.documents.ApplicationDescriptionType;
+import org.ogce.schemas.gfac.documents.GlobusGatekeeperType;
+import org.ogce.schemas.gfac.documents.GlobusJobManagerType;
+import org.ogce.schemas.gfac.documents.HostDescriptionDocument;
+import org.ogce.schemas.gfac.documents.HostDescriptionType;
+import org.ogce.schemas.gfac.documents.MethodType;
+import org.ogce.schemas.gfac.documents.PortTypeType;
+import org.ogce.schemas.gfac.documents.ServiceMapType;
+import org.ogce.schemas.gfac.documents.ServiceType.ServiceName;
+import org.ogce.schemas.gfac.validator.SchemaValidator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GfacUtils {
+	protected final static Logger log = LoggerFactory.getLogger(GfacUtils.class);
+	private static AtomicInteger tempFileCount = new AtomicInteger();
+	private static Random random = new Random();
+
+	public static void writeToFile(InputStream is, File file) throws IOException {
+		FileWriter fw = new FileWriter(file);
+
+		// get the standard out of the application and write to file
+
+		Reader reader = new InputStreamReader(is);
+		char[] cbuf = new char[1024];
+		while ((reader.read(cbuf, 0, 1024)) != -1) {
+			fw.write(cbuf);
+		}
+		fw.close();
+		reader.close();
+		is.close();
+	}
+
+	public static void writeToFile(String data, File file) throws IOException {
+		FileWriter fw = null;
+		try {
+			fw = new FileWriter(file);
+			// get the standard out of the application and write to file
+			fw.write(data);
+		} catch (IOException io) {
+			throw io;
+		} finally {
+			if (fw != null) {
+				try {
+					fw.close();
+				} catch (IOException e) {
+					throw e;
+				}
+			}
+		}
+	}
+
+	public static String readFromStream(InputStream in) throws IOException {
+		StringBuffer wsdlStr = new StringBuffer();
+
+		int read;
+
+		byte[] buf = new byte[1024];
+		while ((read = in.read(buf)) > 0) {
+			wsdlStr.append(new String(buf, 0, read));
+		}
+		in.close();
+		return wsdlStr.toString();
+	}
+
+	public static String readFile(String file) throws GfacException {
+		FileInputStream in = null;
+		try {
+			in = new FileInputStream(file);
+			byte[] content = new byte[in.available()];
+			in.read(content);
+			return new String(content);
+		} catch (FileNotFoundException e) {
+			throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+		} catch (IOException e) {
+			throw new GfacException(e, FaultCode.LocalError);
+		} finally {
+			if (in != null) {
+				try {
+					in.close();
+				} catch (IOException e) {
+					throw new GfacException(e, FaultCode.LocalError);
+				}
+			}
+		}
+	}
+
+	public static void syncFileSystem(String host, GSSCredential gssCred) {
+		try {
+			GramAttributes gramAttr = new GramAttributes();
+			gramAttr.setExecutable("/bin/sync");
+			GramJob job = new GramJob(gramAttr.toRSL());
+			job.setCredentials(gssCred);
+			log.info("RSL = " + job.getRSL());
+			try {
+				Gram.request(host, job, false, false);
+			} catch (Exception e) {
+				String error = "Cannot launch GRAM job to sync filesystem. " + e.getMessage();
+				log.error(error, e);
+				throw new Exception(e);
+			}
+
+			int twoMin = 1000 * 60 * 2;
+			long start = System.currentTimeMillis();
+
+			while ((System.currentTimeMillis() - start) < twoMin) {
+				int jobStatus = job.getStatus();
+
+				// job finished successfully
+				if (jobStatus == GRAMConstants.STATUS_DONE) {
+					log.info("Filesystem sync succeeded");
+					return;
+				} else if (jobStatus == GRAMConstants.STATUS_FAILED) {
+					String error = "Filesystem sync failed";
+					log.info(error);
+					throw new Exception(error);
+				}
+				try {
+					Thread.sleep(2000);
+				} catch (InterruptedException ie) {
+					log.error("Thread " + Thread.currentThread().getName() + " interrupted", ie);
+					try {
+						job.cancel();
+					} catch (Exception e) {
+						log.error("Exception cancelling job", e);
+					}
+				}
+			}
+			log.info("Filesystem sync timed out");
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	public static HostDescriptionType parseHostDescirption(String hostDescStr) throws GfacException {
+		try {
+			HostDescriptionType hostDesc = HostDescriptionDocument.Factory.parse(hostDescStr).getHostDescription();
+			SchemaValidator validator = new SchemaValidator(hostDesc);
+			validator.validate();
+			return hostDesc;
+		} catch (Exception e) {
+			throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+		}
+	}
+
+	public static ApplicationDescriptionType parseAppDescirption(Reader reader) throws GfacException {
+		try {
+			ApplicationDescriptionType appDesc = ApplicationDescriptionDocument.Factory.parse(reader).getApplicationDescription();
+			SchemaValidator validator = new SchemaValidator(appDesc);
+			validator.validate();
+			return appDesc;
+		} catch (IOException e) {
+			throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+		} catch (Exception e) {
+			throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+		}
+	}
+
+	public static MethodType findOperationFromServiceMap(String operationName, ServiceMapType serviceMap) throws GfacException {
+		PortTypeType portType = serviceMap.getPortTypeArray()[0];
+		MethodType[] methods = portType.getMethodArray();
+		for (int i = 0; i < methods.length; i++) {
+			if (methods[i].getMethodName().equals(operationName)) {
+				return methods[i];
+			}
+		}
+
+		if (isInbuiltOperation(operationName)) {
+			MethodType method = portType.addNewMethod();
+			method.setMethodName(operationName);
+			return method;
+		}
+
+		throw new GfacException("Method name " + operationName + " not found", FaultCode.InvaliedLocalArgumnet);
+	}
+
+	public static MethodType findOperationWithApplication(ServiceMapType serviceMap) throws GfacException {
+		MethodType[] methods = serviceMap.getPortTypeArray()[0].getMethodArray();
+		for (int i = 0; i < methods.length; i++) {
+			if (methods[i].getApplication() != null) {
+				return methods[i];
+			}
+		}
+		return null;
+	}
+
+	public static boolean isLocalHost(String appHost) throws GfacException {
+		try {
+			String localHost = InetAddress.getLocalHost().getCanonicalHostName();
+
+			if (localHost.equals(appHost) || GFacConstants.LOCALHOST.equals(appHost) || GFacConstants._127_0_0_1.equals(appHost)) {
+				return true;
+			} else {
+				return false;
+			}
+		} catch (UnknownHostException e) {
+			throw new GfacException(e, FaultCode.LocalError);
+		}
+	}
+
+	/**
+	 * This method perpare the arguments to be passed to the invocation
+	 * 
+	 * @param inputMessage
+	 * @param parmsValuesOnly
+	 *            , this is usually true. If it is false, the parameters are
+	 *            passed as Name value pairs. If the parameter name is foo and
+	 *            it is a array type parameters will be passed as foo0,foo1 ....
+	 * @return
+	 * @throws GfacException
+	 */
+	public static ArrayList<String> prepareParameters(MessageContext inputMessage, boolean parmsValuesOnly) throws GfacException {
+		try {
+			ArrayList<String> params = new ArrayList<String>();
+			Iterator<String> names = inputMessage.getParameterNames();
+			while (names.hasNext()) {
+				String name = names.next();
+				String type = inputMessage.getParameterType(name);
+
+				if (GFacConstants.Types.TYPE_DATAID.equals(type)) {
+					// add parameter name if needed
+					if (!parmsValuesOnly) {
+						params.add(name);
+					}
+					params.add(new URI(inputMessage.getStringParameterValue(name)).getPath());
+				} else if (GFacConstants.Types.TYPE_DATAID_ARRAY.equals(type)) {
+					Object value = inputMessage.getParameterValue(name);
+					if (value instanceof Object[]) {
+						Object[] valueArray = (Object[]) value;
+						for (int j = 0; j < valueArray.length; j++) {
+							// add parameter name if needed
+							if (!parmsValuesOnly) {
+								params.add(name + j);
+							}
+							params.add(new URI(valueArray[j].toString()).getPath());
+						}
+					}
+				} else if (GFacConstants.Types.TYPE_LEADFILEID.equals(type) || GFacConstants.Types.TYPE_URI.equals(type)) {
+					// add parameter name if needed
+					if (!parmsValuesOnly) {
+						params.add(name);
+					}
+					params.add(new URI(inputMessage.getStringParameterValue(name)).getPath());
+				} else if (GFacConstants.Types.TYPE_LEADFILEID_ARRAY.equals(type) || GFacConstants.Types.TYPE_URI_ARRAY.equals(type)) {
+					Object value = inputMessage.getParameterValue(name);
+					if (value instanceof Object[]) {
+						Object[] valueArray = (Object[]) value;
+						for (int j = 0; j < valueArray.length; j++) {
+							// add parameter name if needed
+							if (!parmsValuesOnly) {
+								params.add(name + j);
+							}
+							params.add(new URI(valueArray[j].toString()).getPath());
+						}
+					}
+				} else {
+					if (GfacUtils.isArray(type)) {
+						Object value = inputMessage.getParameterValue(name);
+						if (value instanceof Object[]) {
+							Object[] valueArray = (Object[]) value;
+							for (int j = 0; j < valueArray.length; j++) {
+								// add parameter name if needed
+								if (!parmsValuesOnly) {
+									params.add(name + j);
+								}
+								params.add(valueArray[j].toString());
+							}
+						}
+					} else {
+						if (!parmsValuesOnly) {
+							params.add(name);
+						}
+						params.add(inputMessage.getStringParameterValue(name));
+					}
+
+					// add parameter name if needed
+				}
+			}
+			return params;
+		} catch (URISyntaxException e) {
+			throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+		}
+	}
+
+	public static boolean isInbuiltOperation(String name) {
+		return GFacConstants.InbuitOperations.OP_KILL.equals(name) || GFacConstants.InbuitOperations.OP_PING.equals(name) || GFacConstants.InbuitOperations.OP_SHUTDOWN.equals(name);
+	}
+
+	public static void printArray(ArrayList<String> list) {
+		for (Iterator iter = list.iterator(); iter.hasNext();) {
+			System.out.println(iter.next());
+		}
+	}
+
+	public static String createServiceDirName(QName serviceName) {
+		String date = new Date().toString();
+		date = date.replaceAll(" ", "_");
+		date = date.replaceAll(":", "_");
+		return serviceName.getLocalPart() + "_" + date + "_" + UUID.randomUUID();
+	}
+
+	public static String createErrorMessage(Exception e) {
+		StringWriter errStrW = new StringWriter();
+		e.printStackTrace(new PrintWriter(errStrW));
+		return errStrW.getBuffer().toString();
+	}
+
+	// public static String prettyPrint2String(XmlElement ele) {
+	// try {
+	// MXSerializer serializer = new MXSerializer();
+	// StringWriter writer = new StringWriter();
+	// serializer.setOutput(writer);
+	// serializer.setProperty(PROPERTY_SERIALIZER_INDENTATION, INDENT);
+	// XmlConstants.BUILDER.serialize(ele, serializer);
+	// return writer.toString();
+	// } catch (Exception e) {
+	// e.printStackTrace();
+	// return "Error happend pretty printing";
+	// }
+	// }
+
+	// public static void prettyPrint(XmlElement ele) throws GfacException {
+	// try {
+	//
+	// System.out.println(prettyPrint2String(ele));
+	//
+	// } catch (IllegalArgumentException e) {
+	// throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+	// } catch (IllegalStateException e) {
+	// throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+	// } catch (XmlBuilderException e) {
+	// throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+	// }
+	// }
+
+	public static URI createGsiftpURI(ContactInfo host, String localPath) throws GfacException {
+		try {
+			StringBuffer buf = new StringBuffer();
+
+			if (!host.hostName.startsWith("gsiftp://"))
+				buf.append("gsiftp://");
+			buf.append(host).append(":").append(host.port);
+			if (!host.hostName.endsWith("/"))
+				buf.append("/");
+			buf.append(localPath);
+			return new URI(buf.toString());
+		} catch (URISyntaxException e) {
+			throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+		}
+	}
+
+	public static URI createGsiftpURI(String host, String localPath) throws GfacException {
+		try {
+			StringBuffer buf = new StringBuffer();
+			if (!host.startsWith("gsiftp://"))
+				buf.append("gsiftp://");
+			buf.append(host);
+			if (!host.endsWith("/"))
+				buf.append("/");
+			buf.append(localPath);
+			return new URI(buf.toString());
+		} catch (URISyntaxException e) {
+			throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+		}
+	}
+
+	public static Vector<URI> listLocalDir(String dirName, String localhost) throws GfacException {
+		try {
+			Vector<URI> files = new Vector<URI>();
+			File dir = new File(dirName);
+
+			if (dir.exists()) {
+				File[] fileList = dir.listFiles();
+				for (File file : fileList) {
+					if (!file.getName().equals(".") && !file.getName().equals("..")) {
+						URI uri = new URI("gsiftp://" + localhost + "/" + file.getAbsolutePath());
+						files.add(uri);
+					}
+				}
+			} else {
+				throw new GfacException("can not find the output data directory to list files", FaultCode.InvaliedLocalArgumnet);
+			}
+			return files;
+		} catch (URISyntaxException e) {
+			throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+		}
+	}
+
+	public static QName getServiceNameFromServiceMap(ServiceMapType serviceMap) {
+		ServiceName serviceName = serviceMap.getService().getServiceName();
+		return new QName(serviceName.getTargetNamespace(), serviceName.getStringValue());
+	}
+
+	public static URI createWorkflowQName(QName name) throws GfacException {
+		try {
+			return new URI("urn:qname:" + name.getNamespaceURI() + ":" + name.getLocalPart());
+		} catch (URISyntaxException e) {
+			throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+		}
+	}
+
+	public static String findStrProperty(Properties config, String name, String defaultVal) {
+		String value = config.getProperty(name);
+		if (value == null) {
+			return defaultVal;
+		}
+		return value.trim();
+	}
+
+	public static boolean findBooleanProperty(Properties config, String name, boolean defaultVal) {
+		String value = config.getProperty(name);
+		if (value == null) {
+			return defaultVal;
+		}
+		return Boolean.valueOf(value.trim());
+	}
+
+	// public static String buildAnnotations(QName name, String value) {
+	// XmlElement anno = builder.newFragment(name.getNamespaceURI(),
+	// name.getLocalPart());
+	// anno.addChild(value);
+	// return builder.serializeToString(anno);
+	// }
+
+	public static QName findApplcationName(ServiceMapType serviceMap) throws GfacException {
+		MethodType method = GfacUtils.findOperationWithApplication(serviceMap);
+
+		if (method == null) {
+			throw new GfacException("None of the methods has application defined", FaultCode.InvaliedLocalArgumnet);
+		}
+
+		String applicationName = method.getApplication().getApplicationName().getStringValue();
+		String applicationNameNs = method.getApplication().getApplicationName().getTargetNamespace();
+		return new QName(applicationNameNs, applicationName);
+	}
+
+	public static GlobusGatekeeperType findGateKeeper(ExecutionContext appExecContext, boolean wsgram) throws GfacException {
+		WorkflowContextHeader header = appExecContext.getWorkflowHeader();
+		boolean isSpruceEnabled = false;
+		if (header != null) {
+			isSpruceEnabled = (appExecContext.getWorkflowHeader().getURGENCY() != null);
+			ResourceMapping resourceMapping = appExecContext.getWorkflowHeader().getResourceMappings().getResourceMappingArray()[0];
+			if (resourceMapping != null) {
+				URI gatekeeperfromResourceMapping = null;
+				try {
+					gatekeeperfromResourceMapping = new URI(resourceMapping.getGatekeeperEpr());
+				} catch (URISyntaxException e) {
+					throw new GfacException(e.getLocalizedMessage(), e);
+				}
+				if (gatekeeperfromResourceMapping != null) {
+					log.info("Gate keeper selected from resource mapping");
+					GlobusGatekeeperType gatekeeper = GlobusGatekeeperType.Factory.newInstance();
+
+					if (!resourceMapping.getWsgramPreferred()) {
+						if (resourceMapping.getJobManager() != null) {
+							throw new GfacException("Job Manager parameter must not defined for Pre-WSGram in Resource Mapping, " + "include it with your gatekeepr EPR in resource mapping", FaultCode.InternalServiceError);
+						}
+					} else {
+						if (resourceMapping.getJobManager() != null) {
+							gatekeeper.setJobmanagertype(GlobusJobManagerType.Enum.forString(resourceMapping.getJobManager()));
+						}
+					}
+					gatekeeper.setEndPointReference(gatekeeperfromResourceMapping.toString());
+					return gatekeeper;
+				}
+			}
+		}
+
+		HostDescriptionType hostDesc = appExecContext.getExecutionModel().getHostDesc();
+		GlobusGatekeeperType[] gatekeepers = hostDesc.getHostConfiguration().getGlobusGatekeeperArray();
+		for (GlobusGatekeeperType gateKeeper : gatekeepers) {
+			if (gateKeeper.getWsGram() == wsgram && (isSpruceEnabled == gateKeeper.getJobmanagertype().equals(GlobusJobManagerType.SPRUCE))) {
+				log.info((wsgram ? "WSGram" : "Gram ") + (!isSpruceEnabled ? "Non" : "") + " Spruce Gate keeper" + gateKeeper.xmlText() + " selected");
+				return gateKeeper;
+			}
+		}
+		log.warn("Even though urgency header precent, there is no spruce job manager present. Moving on with non spruce job manager");
+		for (GlobusGatekeeperType gateKeeper : gatekeepers) {
+			if (gateKeeper.getWsGram() == wsgram) {
+				log.info((wsgram ? "WSGram" : "Gram ") + (!isSpruceEnabled ? "Non" : "") + " Spruce Gate keeper" + gateKeeper.xmlText() + " selected");
+				return gateKeeper;
+			}
+		}
+		return null;
+	}
+
+	public static String formatJobStatus(String jobid, String jobstatus) {
+		return "Status of job " + jobid + "is " + jobstatus;
+	}
+
+	// public static GlobusGatekeeperType getSpruceGatekeeper(ExecutionContext
+	// appExecContext) {
+	// GlobusGatekeeperType spruceGatekeeper = null;
+	//
+	// HostDescriptionType hostDesc = appExecContext.getHostDesc();
+	// GlobusGatekeeperType[] gatekeepers =
+	// hostDesc.getHostConfiguration().getGlobusGatekeeperArray();
+	//
+	// if (gatekeepers != null && gatekeepers.length > 0) {
+	// for (GlobusGatekeeperType gatekeeper : gatekeepers) {
+	// if (gatekeeper.getJobmanagertype().equals(GlobusJobManagerType.SPRUCE)) {
+	// spruceGatekeeper = gatekeeper;
+	// break;
+	// }
+	// }
+	// }
+	//
+	// return spruceGatekeeper;
+	// }
+
+	// public static String findServiceRegistryUrl(LeadContextHeader header){
+	// if(header == null){
+	// return null;
+	// }else{
+	// URI serviceRegistryUrl = header.getXRegistryUrl();
+	// if(serviceRegistryUrl == null){
+	// serviceRegistryUrl = header.getResourceCatalogUrl();
+	// }
+	// if(serviceRegistryUrl != null){
+	// return serviceRegistryUrl.toString();
+	// }else{
+	// return null;
+	// }
+	// }
+	// }
+
+	public static String createRandomName(String name) {
+		return name + System.currentTimeMillis() + "_" + tempFileCount.incrementAndGet();
+	}
+
+	public static Random getRandom() {
+		return random;
+	}
+
+	public static boolean isArray(String typeName) {
+		if (typeName.endsWith("Array")) {
+			// TODO make it more tigter
+			return true;
+		} else {
+			return false;
+		}
+	}
+}

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GlobalConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GlobalConfiguration.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GlobalConfiguration.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GlobalConfiguration.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,517 @@
+package org.apache.airavata.core.gfac.utils;
+
+import static org.apache.airavata.core.gfac.utils.GfacUtils.findStrProperty;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.core.gfac.exception.GfacException;
+import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
+import org.apache.airavata.core.gfac.registry.RegistryService;
+import org.apache.xmlbeans.XmlException;
+import org.ietf.jgss.GSSCredential;
+import org.ogce.schemas.gfac.documents.ApplicationDescriptionType;
+import org.ogce.schemas.gfac.documents.ConfigurationDocument;
+import org.ogce.schemas.gfac.documents.ConfigurationType;
+import org.ogce.schemas.gfac.documents.HostDescriptionType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import edu.indiana.extreme.lead.workflow_tracking.Notifier;
+
+
+public class GlobalConfiguration  implements GFacOptions {
+
+	private final Logger log = LoggerFactory.getLogger(this.getClass());
+	
+    private Properties config;
+
+    private String registryURL;
+
+    private String capManURL;
+
+    private String notificationBrokerURL;
+ 
+    private String executeLocally;
+
+    private List<String> deploymentHosts;
+
+    private String tempDir = "/tmp";
+
+    private String localHost;
+
+    private Notifier notifier;
+
+    private RegistryService registryService;
+
+    private int port;
+
+    private HashMap<String, HostDescriptionType> hosts = new HashMap<String, HostDescriptionType>();
+
+    private HashMap<String, ApplicationDescriptionType> appNameAndHost2App = new HashMap<String, ApplicationDescriptionType>();
+    private HashMap<String, ApplicationDescriptionType> appName2App = new HashMap<String, ApplicationDescriptionType>();
+
+    private String hostSchedulerUrl = null;
+
+//    private long wait4FirstReq = AppicationLifeTimeManager.HOUR_IN_MS * 3;
+//
+//    private long lifetimeResolution = AppicationLifeTimeManager.HOUR_IN_MS / 12;
+//
+//    private ExtensionRepository extensionRepository;
+//
+//    private LocalJobManager localJobManager;
+//
+//    private MessageBoxService messageBoxService;
+
+    private String topic;
+
+    private boolean tranportSecurity = false;
+
+//    private CompositeMessageIntercepter messageCorrelator;
+
+    private boolean wsGramPrefered = false;
+
+//    private AdminNotifier adminNotifier;
+
+    private String hostcertsKeyFile;
+
+    private String trustedCertsFile;
+
+    private int minimalLifetimePerRequestMinutes = 10;
+
+    private ConfigurationType extensionConfiguration;
+
+//    private CredentialContext credentialContext;
+    
+    private Map<String,OutputStream> stdInMapOfApp = new HashMap<String, OutputStream>();
+    
+    private final ExecutorService threadScheduler = Executors.newCachedThreadPool();
+    
+    private Set<String> retryonErrorCodes = new HashSet<String>(); 
+
+    public GlobalConfiguration(Properties initialconfig) throws GfacException {
+        this(initialconfig, true,false);
+    }
+
+    public GlobalConfiguration(Properties initialconfig, boolean loadFromEnviorment,boolean isPersistant)
+            throws GfacException {
+        try {
+            // build effective properties by merging the properties with the
+            // enviorment
+            this.config = loadEffectiveProperties(initialconfig, loadFromEnviorment);
+            extensionConfiguration = loadExtensionConfiguration(isPersistant);    
+            registryURL = findStrProperty(config, REGISTRY_URL_NAME, registryURL);
+            notificationBrokerURL = findStrProperty(config, NOTIFICATION_BROKER_URL_NAME,
+                    GFacConstants.BROKER_URL);
+            topic = findStrProperty(config, "topic", "gfac-default-topic");
+//            this.myLEADAgentURL = findStrProperty(config, MYLEAD_AGENT_URL_NAME, myLEADAgentURL);
+            executeLocally = findStrProperty(config, "executeLocally", executeLocally);
+            
+            this.tempDir = findStrProperty(config, "GFAC_TMP_DIR", tempDir);
+
+            String tmpDirSuffix = String.valueOf(System.currentTimeMillis()) + "_"
+                    + UUID.randomUUID();
+            File tmpDirF = new File(this.tempDir, tmpDirSuffix);
+            tmpDirF.mkdirs();
+            this.tempDir = tmpDirF.getAbsolutePath();
+            this.localHost = InetAddress.getLocalHost().getCanonicalHostName();
+
+            // These are properties about transport security
+            this.tranportSecurity = GfacUtils.findBooleanProperty(config, "transportSecurity", false);
+            
+            
+            this.hostcertsKeyFile = findStrProperty(config,SSL_HOSTCERTS_KEY_FILE,null);
+            this.trustedCertsFile = findStrProperty(config,SSL_TRUSTED_CERTS_FILE,null);
+
+            String wait4FirstReqStr = config.getProperty("wait4FirstReqMinutes");
+//            if (wait4FirstReqStr != null) {
+//                wait4FirstReq = Long.valueOf(wait4FirstReqStr) * 60 * 1000;
+//            }
+            String lifetimeResolutionStr = config.getProperty("lifetimeResolutionMinutes");
+//            if (lifetimeResolutionStr != null) {
+//                lifetimeResolution = Long.valueOf(lifetimeResolutionStr) * 60 * 1000;
+//            }
+//            credentialContext = new CredentialContext(this);
+//            
+            deploymentHosts = new ArrayList<String>();
+            String deploymentHostsAsStr = config.getProperty(DEPLOYMENT_HOSTS);
+            if(deploymentHostsAsStr != null){
+                //remove whiteapces, and split
+                String[] tempdeploymentHosts = deploymentHostsAsStr.replaceAll("\\s", "").split(",");
+                for (String hostName:tempdeploymentHosts) {
+                    deploymentHosts.add(hostName);
+                }
+            }else{
+                deploymentHosts.add(getLocalHost());
+            }
+
+            wsGramPrefered = GfacUtils.findBooleanProperty(config, WS_GRAM_PREFERED,wsGramPrefered); 
+//            extensionRepository = new ExtensionRepository(this);
+//
+//            // Initialize Message interceptors
+//            messageCorrelator = new CompositeMessageIntercepter();
+//
+//            adminNotifier = new AdminNotifier(notificationBrokerURL, GFacConstants.ADMIN_TOPIC,
+//                    getLocalHost());
+
+            String minimalLifetimePerRequestMinutesStr = config
+                    .getProperty(GFacOptions.MIN_PROXY_LIFETIME_PER_REQUEST_MINUTES);
+            if (minimalLifetimePerRequestMinutesStr != null
+                    && minimalLifetimePerRequestMinutesStr.trim().length() > 0) {
+                minimalLifetimePerRequestMinutes = Integer
+                        .valueOf(minimalLifetimePerRequestMinutesStr);
+            }
+
+            hostSchedulerUrl = findStrProperty(config, HOST_SCHEDULER_URL,hostSchedulerUrl);
+            String[] retryonErrors =  config.getProperty(GFacOptions.GFAC_RETRYONJOBERRORCODES,"").split(",");
+           for (String retryonError : retryonErrors) {
+				getRetryonErrorCodes().add(retryonError);
+			} 
+        } catch (UnknownHostException e) {
+            throw new GfacException(e,FaultCode.InitalizationError);
+        } catch (IOException e) {
+            throw new GfacException(e,FaultCode.InitalizationError);
+        }
+
+    }
+
+    /**
+     * Gfac load properties from following locations
+     * <ol>
+     * <li>Explicit Properties</li>
+     * <li>$HOME/login.properties</li>
+     * <li>conf/gfac.properties</li>
+     * <ol>
+     * 
+     * They take precedence in that order.
+     * 
+     * @param initialProperties
+     * @return
+     * @throws FileNotFoundException
+     * @throws IOException
+     */
+
+    private Properties loadEffectiveProperties(Properties initialProperties,
+            boolean loadFromEnviorment) throws FileNotFoundException, IOException {
+        Properties newProperties = new Properties();
+
+        if (loadFromEnviorment) {
+            String loginDataFile = System.getProperty("login.file");
+            if (loginDataFile == null) {
+                loginDataFile = System.getProperty("user.home") + "/login.properties";
+            }
+            File loginPropertiesFile = new File(loginDataFile);
+            if (loginPropertiesFile.exists()) {
+                InputStream loginPropertiesIn = new FileInputStream(loginPropertiesFile);
+                newProperties.load(loginPropertiesIn);
+                loginPropertiesIn.close();
+            }
+
+            File localConfFile = new File("conf/gfac.properties");
+            if (localConfFile.exists()) {
+                InputStream localPropertiesIn = new FileInputStream(loginPropertiesFile);
+                newProperties.load(localPropertiesIn);
+                localPropertiesIn.close();
+            }
+        }
+        // This will make sure expliceit properties take precedance over
+        // properties defined in enviorment
+        newProperties.putAll(initialProperties);
+        return newProperties;
+    }
+
+//    public RegistryService getRegistryService() throws GfacException {
+//        if (registryURL != null) {
+//            if (registryService == null) {
+//                registryService = ExternalServiceFactory.createRegistryService(registryURL, this,
+//                        null);
+//            }
+//            return registryService;
+//        } else {
+//            throw new GfacException("Registry URL not spcified",FaultCode.InitalizationError);
+//        }
+//    }
+//
+//    public ServiceConfiguration createServiceContext(QName serviceName, ServiceMapType serviceDesc,
+//            String serviceLocation) throws GfacException {
+//        ServiceConfiguration serviceContext = new ServiceConfiguration(this, serviceName,
+//                serviceDesc, serviceLocation);
+//        return serviceContext;
+//    }
+
+    public void setRegistryURL(String registryURL) {
+        this.registryURL = registryURL;
+    }
+
+    public GSSCredential getGssCredentails() throws GfacException {
+        try {
+            return null; // credentialContext.getProxyCredentails();
+        } catch (Exception e) {
+            throw new GfacException(e,FaultCode.InitalizationError);
+        }
+    }
+
+    public ApplicationDescriptionType getApplicationDesc(QName name, String hostName) {
+        if(hostName == null){
+            return appName2App.get(name.toString());
+        }
+        return appNameAndHost2App.get(name.toString()+hostName);
+    }
+
+    public void addApplicationDesc(ApplicationDescriptionType appDesc) {
+        QName appName = new QName(appDesc.getApplicationName().getTargetNamespace(), appDesc
+                .getApplicationName().getStringValue());
+        appNameAndHost2App.put(appName.toString()+appDesc.getDeploymentDescription().getHostName(), appDesc);
+        appName2App.put(appName.toString(), appDesc);
+    }
+
+    public HostDescriptionType getHost(String name) {
+        return hosts.get(name);
+    }
+
+    public void addHost(HostDescriptionType host) {
+        hosts.put(host.getHostName(), host);
+    }
+
+   
+    public String getCapManURL() {
+        return capManURL;
+    }
+
+    public String getExecuteLocally() {
+        return executeLocally;
+    }
+
+    public HashMap<String, HostDescriptionType> getHosts() {
+        return hosts;
+    }
+
+ 
+
+//    public String getMyLEADAgentURL() {
+//        return myLEADAgentURL;
+//    }
+
+    // public String getMyproxyLifetime() {
+    // return myproxyLifetime;
+    // }
+    //
+    // public String getMyproxyPasswd() {
+    // return myproxyPasswd;
+    // }
+    //
+    // public String getMyproxyServer() {
+    // return myproxyServer;
+    // }
+    //
+    // public String getMyproxyUserName() {
+    // return myproxyUserName;
+    // }
+
+    public String getRegistryURL() {
+        return registryURL;
+    }
+
+    public boolean isTranportSecurityEnabled() {
+        return tranportSecurity;
+    }
+
+    public Notifier getNotifier() {
+//        if (notifier == null && notificationBrokerURL != null) {
+//            notifier = GfacUtils.createNotifier(notificationBrokerURL, topic);
+//        }
+//        return notifier;
+    	return null;
+    }
+
+    public String getTempDir() {
+        return tempDir;
+    }
+
+    public String getLocalHost() {
+        return localHost;
+    }
+
+    public Properties getConfigurations() {
+        Properties copy = new Properties();
+        copy.putAll(config);
+        return copy;
+    }
+
+    public String getProperty(String name) {
+        return config.getProperty(name);
+    }
+
+//    public long getLifetimeResolution() {
+//        return lifetimeResolution;
+//    }
+//
+//    public long getWait4FirstReq() {
+//        return wait4FirstReq;
+//    }
+//
+//    public ExtensionRepository getExtensionRepository() {
+//        return extensionRepository;
+//    }
+//
+//    public LocalJobManager getLocalJobManager() {
+//        if (localJobManager == null) {
+//            localJobManager = new LocalJobManager();
+//        }
+//        return localJobManager;
+//    }
+//
+//    public MessageBoxService getMessageBoxService() throws GfacException {
+//        if (messageBoxService == null) {
+//            messageBoxService = ExternalServiceFactory.createMessageBoxService(null);
+//        }
+//        return messageBoxService;
+//    }
+//
+//    public CompositeMessageIntercepter getMessageCorrelator() {
+//        return messageCorrelator;
+//    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    boolean isWsGramPrefered() {
+        return wsGramPrefered;
+    }
+
+    void setWsGramPrefered(boolean wsGramPrefered) {
+        this.wsGramPrefered = wsGramPrefered;
+    }
+
+//    public AdminNotifier getAdminNotifier() {
+//        return adminNotifier;
+//    }
+
+    public String getHostcertsKeyFile() {
+        return hostcertsKeyFile;
+    }
+
+    public String getTrustedCertsFile() {
+        return trustedCertsFile;
+    }
+
+    public int getMinimalLifetimePerRequestMinutes() {
+        return minimalLifetimePerRequestMinutes;
+    }
+
+    public String getHostSchedulerUrl() {
+        return hostSchedulerUrl;
+    }
+
+    public ConfigurationType getExtensionConfiguration() {
+        return extensionConfiguration;
+    }
+
+    /**
+     * We load the configuration from local direcotry or from gfac classpath in
+     * that order
+     * 
+     * @return
+     * @throws GfacException
+     */
+    private ConfigurationType loadExtensionConfiguration(boolean isPersistant) throws GfacException {
+        try {
+            String gfacProfile;
+            if(isPersistant){
+                gfacProfile = config.getProperty(GFacOptions.GFAC_PERSISTANT_SERVICE_PROFILE);
+            }else{
+                gfacProfile = config.getProperty(GFacOptions.GFAC_TRANSIENT_SERVICE_PROFILE);
+            }
+            
+            if(gfacProfile == null){
+                return null;
+//                throw new GfacException("Properties " + GFacOptions.GFAC_PERSISTANT_SERVICE_PROFILE 
+//                        +" and "+ GFacOptions.GFAC_TRANSIENT_SERVICE_PROFILE 
+//                        +" must be specified ",FaultCode.InitalizationError);
+            }
+            
+            File xmlConfigurationFile = new File(gfacProfile);
+            InputStream input;
+            if (xmlConfigurationFile.exists()) {
+                input = new FileInputStream(xmlConfigurationFile);
+            } else {
+                input = Thread.currentThread().getContextClassLoader().getResourceAsStream(gfacProfile);
+            }
+            ConfigurationDocument configurationDoc = ConfigurationDocument.Factory.parse(input);
+            return configurationDoc.getConfiguration();
+        } catch (FileNotFoundException e) {
+            throw new GfacException(e,FaultCode.InitalizationError);
+        } catch (XmlException e) {
+            throw new GfacException(e,FaultCode.InitalizationError);
+        } catch (IOException e) {
+            throw new GfacException(e,FaultCode.InitalizationError);
+        }
+    }
+
+//    public void setRuntimeProperty(String name, Object value) throws GfacException {
+//        if (REGISTRY_URL_NAME.equals(name)) {
+//            registryService = ExternalServiceFactory.createRegistryService((String) value, this,
+//                    null);
+//        } else if (NOTIFICATION_BROKER_URL_NAME.equals(name)) {
+//            notifier = GfacUtils.createNotifier((XmlElement) value, null);
+//        } else if (MYLEAD_AGENT_URL_NAME.equals(name)) {
+//            myLEADAgentURL = (String) value;
+//        } else {
+//            if (value instanceof LangStringImpl) {
+//                config.setProperty(name, ((LangStringImpl) value).getLang());
+//            } else {
+//                config.setProperty(name, (String) value);
+//            }
+//
+//        }
+//    }
+    
+    public Map<String, OutputStream> getStdInMapOfApp() {
+        return stdInMapOfApp;
+    }
+
+    public ExecutorService getThreadScheduler() {
+        return threadScheduler;
+    }
+
+    public List<String> getDeploymentHosts() {
+        return deploymentHosts;
+    }
+
+    public boolean isLocal() {
+        return OPTION_INSTALLATION_LOCAL.equals(config.getProperty(OPTION_INSTALLATION));
+    }
+
+	public void setRetryonErrorCodes(Set<String> retryonErrorCodes) {
+		this.retryonErrorCodes = retryonErrorCodes;
+	}
+
+	public Set<String> getRetryonErrorCodes() {
+		return retryonErrorCodes;
+	}
+
+	
+}

Added: incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java (added)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,42 @@
+package org.apache.airavata.core.gfac.utils;
+
+import java.util.Iterator;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.airavata.core.gfac.context.MessageContext;
+import org.apache.airavata.core.gfac.type.Parameter;
+
+public class OutputUtils {
+
+	public static void fillOutputFromStdout(MessageContext<Parameter> outMessage, String stdout, String stderr) {
+
+		for (Iterator<String> iterator = outMessage.getParameterNames(); iterator.hasNext();) {
+			String parameterName = iterator.next();
+
+			// if parameter value is not already set, we let it go
+			if (outMessage.getParameterValue(parameterName) == null) {
+				continue;
+			}
+			
+			Parameter x = outMessage.getParameterValue(parameterName);
+			x.fromString(parseStdout(stdout, parameterName));										
+		}
+	}
+
+	private static String parseStdout(String stdout, String outParam) {
+		String regex = Pattern.quote(outParam) + "\\s*=\\s*([^\\[\\s'\"][^\\s]*|\"[^\"]*\"|'[^']*'|\\[[^\\[]*\\])";
+		String match = null;
+		Pattern pattern = Pattern.compile(regex);
+		Matcher matcher = pattern.matcher(stdout);
+		while (matcher.find()) {
+			match = matcher.group(1);
+		}
+		if (match != null) {
+			match = match.trim();
+			return match;
+		} else {
+			return null;
+		}
+	}
+}

Added: incubator/airavata/core/trunk/gfac/src/main/resources/service.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/main/resources/service.properties?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/resources/service.properties (added)
+++ incubator/airavata/core/trunk/gfac/src/main/resources/service.properties Fri Jun 24 11:01:15 2011
@@ -0,0 +1,7 @@
+ssl.hostcertsKeyFile=/home/ptangcha/ogce-workspace/sgfac/target/dist-bin/conf/ogce_services_key.pem
+ssl.trustedCertsFile=/home/ptangcha/ogce-workspace/sgfac/target/dist-bin/certificates 
+registryURL=https://ogceportal.iu.teragrid.org:19443/xregistry
+scheduler.class= org.apache.airavata.core.gfac.scheduler.impl.SchedulerImpl
+datachain.classes=org.apache.airavata.core.gfac.extension.data.RegistryDataService
+#prechain.classes=
+#postchain.classes
\ No newline at end of file

Added: incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/factory/OGCEGenericFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/factory/OGCEGenericFactoryTest.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/factory/OGCEGenericFactoryTest.java (added)
+++ incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/factory/OGCEGenericFactoryTest.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,15 @@
+package org.apache.airavata.core.gfac.factory;
+
+import org.junit.Test;
+
+public class OGCEGenericFactoryTest {
+
+	@Test
+	public void testGetGenericService() {
+	}
+
+	@Test
+	public void testCreateService() {		
+	}
+
+}

Added: incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java (added)
+++ incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,83 @@
+package org.apache.airavata.core.gfac.services.impl;
+
+import static org.junit.Assert.fail;
+
+import org.apache.airavata.core.gfac.context.InvocationContext;
+import org.apache.airavata.core.gfac.context.impl.ExecutionContextImpl;
+import org.apache.airavata.core.gfac.context.impl.GSISecurityContext;
+import org.apache.airavata.core.gfac.context.impl.ParameterContextImpl;
+import org.apache.airavata.core.gfac.notification.DummyNotification;
+import org.apache.airavata.core.gfac.services.impl.PropertiesBasedServiceImpl;
+import org.apache.airavata.core.gfac.type.StringParameter;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PropertiesBasedServiceImplTest {
+
+	@Test
+	public void testInit() {
+		try{
+			InvocationContext ct = new InvocationContext();
+			ct.setExecutionContext(new ExecutionContextImpl());
+			
+			PropertiesBasedServiceImpl service = new PropertiesBasedServiceImpl();
+			service.init();
+		}catch(Exception e){
+			e.printStackTrace();
+			fail("ERROR");
+		}
+	}
+
+	@Test
+	public void testExecute() {
+		try{
+			InvocationContext ct = new InvocationContext();
+			ct.setExecutionContext(new ExecutionContextImpl());
+						
+			ct.getExecutionContext().setNotificationService(new DummyNotification());
+
+			GSISecurityContext gsiSecurityContext = new GSISecurityContext();
+			gsiSecurityContext.setMyproxyServer("myproxy.teragrid.org");
+			gsiSecurityContext.setMyproxyUserName("ogce");
+			gsiSecurityContext.setMyproxyPasswd("Jdas7wph");
+			gsiSecurityContext.setMyproxyLifetime(14400);			
+			ct.addSecurityContext("myproxy", gsiSecurityContext);			
+			
+			ct.setServiceName("{http://www.extreme.indiana.edu/namespaces/2004/01/gFac}Echo_Service");
+			
+			//parameter
+			ParameterContextImpl x = new ParameterContextImpl();
+			StringParameter parameter = new StringParameter();
+			parameter.fromString("Hello");
+			x.addParameter("echo", parameter.getTypeName(), parameter);
+			ct.addMessageContext("input", x);
+			
+			PropertiesBasedServiceImpl service = new PropertiesBasedServiceImpl();
+			service.init();
+			service.execute(ct);
+			
+			Assert.assertNotNull(ct.getMessageContext("output"));
+			Assert.assertNotNull(ct.getMessageContext("output").getParameterValue("Echoed_Output"));
+			Assert.assertEquals("\"Hello\"", ct.getMessageContext("output").getParameterValue("Echoed_Output").toString());
+			
+		}catch(Exception e){
+			e.printStackTrace();
+			fail("ERROR");
+		}
+	}
+
+	@Test
+	public void testDispose() {
+		try{
+			InvocationContext ct = new InvocationContext();
+			ct.setExecutionContext(new ExecutionContextImpl());			
+
+			PropertiesBasedServiceImpl service = new PropertiesBasedServiceImpl();
+			service.dispose();
+		}catch(Exception e){
+			e.printStackTrace();
+			fail("ERROR");
+		}
+	}
+
+}

Added: incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/type/StringParameterTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/type/StringParameterTest.java?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/type/StringParameterTest.java (added)
+++ incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/type/StringParameterTest.java Fri Jun 24 11:01:15 2011
@@ -0,0 +1,14 @@
+package org.apache.airavata.core.gfac.type;
+
+import org.apache.airavata.core.gfac.type.StringParameter;
+import org.junit.Test;
+
+
+public class StringParameterTest {
+	@Test
+	public void getName() {
+		StringParameter x = new StringParameter();
+		x.fromString("xxx");
+		System.out.println(x.getTypeName());
+	}
+}

Added: incubator/airavata/core/trunk/gfac/src/test/resources/service.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/core/trunk/gfac/src/test/resources/service.properties?rev=1139241&view=auto
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/test/resources/service.properties (added)
+++ incubator/airavata/core/trunk/gfac/src/test/resources/service.properties Fri Jun 24 11:01:15 2011
@@ -0,0 +1,7 @@
+ssl.hostcertsKeyFile=/home/ptangcha/ogce-workspace/sgfac/target/dist-bin/conf/ogce_services_key.pem
+ssl.trustedCertsFile=/home/ptangcha/ogce-workspace/sgfac/target/dist-bin/certificates 
+registryURL=https://ogceportal.iu.teragrid.org:19443/xregistry
+scheduler.class= org.apache.airavata.core.gfac.scheduler.impl.SchedulerImpl
+datachain.classes=org.apache.airavata.core.gfac.extension.data.RegistryDataService
+#prechain.classes=
+#postchain.classes
\ No newline at end of file