airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject svn commit: r1139550 [5/6] - in /incubator/airavata/core/trunk/gfac: ./ .settings/ src/main/java/org/apache/airavata/core/gfac/context/ src/main/java/org/apache/airavata/core/gfac/context/impl/ src/main/java/org/apache/airavata/core/gfac/context/impl/u...
Date Sat, 25 Jun 2011 15:17:38 GMT
Modified: 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=1139550&r1=1139549&r2=1139550&view=diff
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GFacConstants.java (original)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GFacConstants.java Sat Jun 25 15:17:35 2011
@@ -1,140 +1,161 @@
+/*
+ *
+ * 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.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 GFAC_NAMESPACE = "http://www.extreme.indiana.edu/namespaces/2004/01/gFac";
 
-	public static final String INPUT_DATA_DIR = "inputData";
+    public static final String INPUT_DATA_DIR = "inputData";
 
-	public static final String OUTPUT_DATA_DIR = "outputData";
+    public static final String OUTPUT_DATA_DIR = "outputData";
 
-	public static final String DEFAULT_TMP_DIR = "/tmp";
+    public static final String DEFAULT_TMP_DIR = "/tmp";
 
-	public static final String SHUTDOWN = "Shutdown";
+    public static final String SHUTDOWN = "Shutdown";
 
-	public static final String PING = "Ping";
+    public static final String PING = "Ping";
 
-	public static final String KILL = "Kill";
+    public static final String KILL = "Kill";
 
-	public static final String CREATE_SERVICE = "CreateService";
+    public static final String CREATE_SERVICE = "CreateService";
 
-	public static final String TRANSPORT_LEVEL = "TransportLevel";
+    public static final String TRANSPORT_LEVEL = "TransportLevel";
 
-	public static final String MESSAGE_SIGNATURE = "MessageSignature";
+    public static final String MESSAGE_SIGNATURE = "MessageSignature";
 
-	public static final String SERVICE_URI = "SERVICE_URI";
+    public static final String SERVICE_URI = "SERVICE_URI";
 
-	public static final String METHOD_NAME = "METHOD_NAME";
+    public static final String METHOD_NAME = "METHOD_NAME";
 
-	public static final String SERVICE_NAME = "SERVICE_NAME";
+    public static final String SERVICE_NAME = "SERVICE_NAME";
 
-	public static final String APP_SERVICE_STRING_PARAM = "AFAC_STRING_PARAM";
+    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_RESP_MSG_SUFFIX = "_ResponseMessage";
 
-	public static final String SERVICE_INPUT_PARAMS_TYPE_SUFFIX = "_InputParamsType";
+    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_OUTPUT_PARAMS_TYPE_SUFFIX = "_OutputParamsType";
 
-	public static final String SERVICE_REQ_MSG_SUFFIX = "_RequestMessage";
+    public static final String SERVICE_REQ_MSG_SUFFIX = "_RequestMessage";
 
-	public static final String SERVICE_IN_PARAMS_SUFFIX = "_InputParams";
+    public static final String SERVICE_IN_PARAMS_SUFFIX = "_InputParams";
 
-	public static final String SERVICE_OUT_PARAMS_SUFFIX = "_OutputParams";
+    public static final String SERVICE_OUT_PARAMS_SUFFIX = "_OutputParams";
 
-	public static final String SERVICE_TMP_DIR = "AFAC_TMP_DIR";
+    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 SERVICE_INPUT_MESSAGE_NAME = "AFAC_INPUT_MESSAGE_NAME";
 
-	public static final String BROKER_URL = "http://ogceportal.iu.teragrid.org:12346/";
+    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 String SERVICE_BROKER = "http://tyr14.cs.indiana.edu:7777/axis2/services/HostSchedulerService?wsdl";
 
-	public static final int GSI_FTP_PORT = 2811;
+    public static final int GSI_FTP_PORT = 2811;
 
-	public static final String HOST = "host";
+    public static final String HOST = "host";
 
-	public static final String UTF8 = "UTF-8";
+    public static final String UTF8 = "UTF-8";
 
-	public static final String ARRAY_VALUE = "value";
+    public static final String ARRAY_VALUE = "value";
 
-	public static final String ADMIN_TOPIC = "ADMIN";
+    public static final String ADMIN_TOPIC = "ADMIN";
 
-	public static final String _127_0_0_1 = "127.0.0.1";
+    public static final String _127_0_0_1 = "127.0.0.1";
 
-	public static final String LOCALHOST = "localhost";
+    public static final String LOCALHOST = "localhost";
 
-	// GFac data types
-	public static class Types {
-		public static final String TYPE_STRING = "String";
+    // 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_INT = "Integer";
 
-		public static final String TYPE_FLOAT = "Float";
+        public static final String TYPE_FLOAT = "Float";
 
-		public static final String TYPE_DOUBLE = "Double";
+        public static final String TYPE_DOUBLE = "Double";
 
-		public static final String TYPE_BOOLEAN = "Boolean";
+        public static final String TYPE_BOOLEAN = "Boolean";
 
-		public static final String TYPE_QNAME = "QName";
+        public static final String TYPE_QNAME = "QName";
 
-		public static final String TYPE_URI = "URI";
+        public static final String TYPE_URI = "URI";
 
-		public static final String TYPE_STRING_ARRAY = "StringArray";
+        public static final String TYPE_STRING_ARRAY = "StringArray";
 
-		public static final String TYPE_INT_ARRAY = "IntegerArray";
+        public static final String TYPE_INT_ARRAY = "IntegerArray";
 
-		public static final String TYPE_FLAOT_ARRAY = "FloatArray";
+        public static final String TYPE_FLAOT_ARRAY = "FloatArray";
 
-		public static final String TYPE_DOUBLE_ARRAY = "DoubleArray";
+        public static final String TYPE_DOUBLE_ARRAY = "DoubleArray";
 
-		public static final String TYPE_BOOLEAN_ARRAY = "BooleanArray";
+        public static final String TYPE_BOOLEAN_ARRAY = "BooleanArray";
 
-		public static final String TYPE_QNAME_ARRAY = "QNameArray";
+        public static final String TYPE_QNAME_ARRAY = "QNameArray";
 
-		public static final String TYPE_URI_ARRAY = "URIArray";
+        public static final String TYPE_URI_ARRAY = "URIArray";
 
-		public static final String TYPE_LEADFILEID = "LEADFileID";
+        public static final String TYPE_LEADFILEID = "LEADFileID";
 
-		public static final String TYPE_LEADFILEID_ARRAY = "LEADFileIDArray";
+        public static final String TYPE_LEADFILEID_ARRAY = "LEADFileIDArray";
 
-		public static final String TYPE_STDOUT = "StdOut";
+        public static final String TYPE_STDOUT = "StdOut";
 
-		public static final String TYPE_STDERRORs = "StdErr";
+        public static final String TYPE_STDERRORs = "StdErr";
 
-		public static final String LEAD_NAMELIST_FILE = "LEADNameListFile";
+        public static final String LEAD_NAMELIST_FILE = "LEADNameListFile";
 
-		public static final String LEAD_NAMELIST_PROPERTIES_FILE = "LEADNameListPropertiesFile";
+        public static final String LEAD_NAMELIST_PROPERTIES_FILE = "LEADNameListPropertiesFile";
 
-		public static final String LEAD_CROSSCUT_PARAMETERS = "LeadCrosscutParameters";
+        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 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 interface InbuitOperations {
+        public static final String OP_KILL = "Kill";
 
-		public static final String OP_PING = "Ping";
+        public static final String OP_PING = "Ping";
 
-		public static final String OP_SHUTDOWN = "Shutdown";
+        public static final String OP_SHUTDOWN = "Shutdown";
 
-		public static final String USER_INTERACTION = "UserInteraction";
-	}
+        public static final String USER_INTERACTION = "UserInteraction";
+    }
 
-	public static final String LOGGER_NAME = "gfac.logger";
+    public static final String LOGGER_NAME = "gfac.logger";
 
-	public static String REGISTRY_URL = "https://localhost:6666/xregistry?wsdl";
+    public static String REGISTRY_URL = "https://localhost:6666/xregistry?wsdl";
 
-	public static String HOSTBINDING_EXTENSION_NAME = "resource-mapping";
+    public static String HOSTBINDING_EXTENSION_NAME = "resource-mapping";
 
-	public static int SLEEP_TIME = 1000;
+    public static int SLEEP_TIME = 1000;
 
-	public static String FAULT_NAMESPACE = "http://extreme.indiana.edu/management/faults";
+    public static String FAULT_NAMESPACE = "http://extreme.indiana.edu/management/faults";
 
-	public static String FAULT_DETAILS_NAME = "faultParameters";
+    public static String FAULT_DETAILS_NAME = "faultParameters";
 
-	public static enum TransportSchema {
-		http, ssh, sftp, gsiftp
-	};
+    public static enum TransportSchema {
+        http, ssh, sftp, gsiftp
+    };
 }

Modified: 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=1139550&r1=1139549&r2=1139550&view=diff
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GFacOptions.java (original)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GFacOptions.java Sat Jun 25 15:17:35 2011
@@ -1,14 +1,30 @@
-package org.apache.airavata.core.gfac.utils;
-
-/**
- * 
- * @author hperera
+/*
+ *
+ * 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.core.gfac.utils;
+
 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";
@@ -34,7 +50,10 @@ public interface GFacOptions {
 
     /** file transfer service * */
     public static final String FILE_TRANSFER_SERVICE = "filetransferService";
-    public static enum FileTransferServiceType{DAMN,GridFTP,SSH,SharedFs};
+
+    public static enum FileTransferServiceType {
+        DAMN, GridFTP, SSH, SharedFs
+    };
 
     public static final String DAMN_WSDL_URL = "damn.wsdlUrl";
 
@@ -43,26 +62,25 @@ public interface GFacOptions {
 
     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 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";
@@ -70,17 +88,17 @@ public interface GFacOptions {
     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";
-    
+
 }

Modified: 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=1139550&r1=1139549&r2=1139550&view=diff
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GfacUtils.java (original)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GfacUtils.java Sat Jun 25 15:17:35 2011
@@ -1,3 +1,24 @@
+/*
+ *
+ * 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.core.gfac.utils;
 
 import java.io.File;
@@ -51,532 +72,549 @@ 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;
-		}
-	}
+    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;
+        }
+    }
 }

Modified: 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=1139550&r1=1139549&r2=1139550&view=diff
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GlobalConfiguration.java (original)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/GlobalConfiguration.java Sat Jun 25 15:17:35 2011
@@ -1,3 +1,24 @@
+/*
+ *
+ * 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.core.gfac.utils;
 
 import static org.apache.airavata.core.gfac.utils.GfacUtils.findStrProperty;
@@ -37,11 +58,10 @@ import org.slf4j.LoggerFactory;
 
 import edu.indiana.extreme.lead.workflow_tracking.Notifier;
 
+public class GlobalConfiguration implements GFacOptions {
 
-public class GlobalConfiguration  implements GFacOptions {
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
 
-	private final Logger log = LoggerFactory.getLogger(this.getClass());
-	
     private Properties config;
 
     private String registryURL;
@@ -49,7 +69,7 @@ public class GlobalConfiguration  implem
     private String capManURL;
 
     private String notificationBrokerURL;
- 
+
     private String executeLocally;
 
     private List<String> deploymentHosts;
@@ -71,25 +91,25 @@ public class GlobalConfiguration  implem
 
     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 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 CompositeMessageIntercepter messageCorrelator;
 
     private boolean wsGramPrefered = false;
 
-//    private AdminNotifier adminNotifier;
+    // private AdminNotifier adminNotifier;
 
     private String hostcertsKeyFile;
 
@@ -99,36 +119,34 @@ public class GlobalConfiguration  implem
 
     private ConfigurationType extensionConfiguration;
 
-//    private CredentialContext credentialContext;
-    
-    private Map<String,OutputStream> stdInMapOfApp = new HashMap<String, OutputStream>();
-    
+    // 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>(); 
+
+    private Set<String> retryonErrorCodes = new HashSet<String>();
 
     public GlobalConfiguration(Properties initialconfig) throws GfacException {
-        this(initialconfig, true,false);
+        this(initialconfig, true, false);
     }
 
-    public GlobalConfiguration(Properties initialconfig, boolean loadFromEnviorment,boolean isPersistant)
+    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);    
+            extensionConfiguration = loadExtensionConfiguration(isPersistant);
             registryURL = findStrProperty(config, REGISTRY_URL_NAME, registryURL);
-            notificationBrokerURL = findStrProperty(config, NOTIFICATION_BROKER_URL_NAME,
-                    GFacConstants.BROKER_URL);
+            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);
+            // 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();
+            String tmpDirSuffix = String.valueOf(System.currentTimeMillis()) + "_" + UUID.randomUUID();
             File tmpDirF = new File(this.tempDir, tmpDirSuffix);
             tmpDirF.mkdirs();
             this.tempDir = tmpDirF.getAbsolutePath();
@@ -136,59 +154,53 @@ public class GlobalConfiguration  implem
 
             // 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);
-//            
+
+            this.hostcertsKeyFile = findStrProperty(config, SSL_HOSTCERTS_KEY_FILE, null);
+            this.trustedCertsFile = findStrProperty(config, SSL_TRUSTED_CERTS_FILE, null);
+
+            config.getProperty("wait4FirstReqMinutes");
+            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
+            if (deploymentHostsAsStr != null) {
+                // remove whiteapces, and split
                 String[] tempdeploymentHosts = deploymentHostsAsStr.replaceAll("\\s", "").split(",");
-                for (String hostName:tempdeploymentHosts) {
+                for (String hostName : tempdeploymentHosts) {
                     deploymentHosts.add(hostName);
                 }
-            }else{
+            } 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());
+            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);
+            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);
-			} 
+            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);
+            throw new GfacException(e, FaultCode.InitalizationError);
         } catch (IOException e) {
-            throw new GfacException(e,FaultCode.InitalizationError);
+            throw new GfacException(e, FaultCode.InitalizationError);
         }
 
     }
@@ -209,8 +221,8 @@ public class GlobalConfiguration  implem
      * @throws IOException
      */
 
-    private Properties loadEffectiveProperties(Properties initialProperties,
-            boolean loadFromEnviorment) throws FileNotFoundException, IOException {
+    private Properties loadEffectiveProperties(Properties initialProperties, boolean loadFromEnviorment)
+            throws FileNotFoundException, IOException {
         Properties newProperties = new Properties();
 
         if (loadFromEnviorment) {
@@ -238,24 +250,24 @@ public class GlobalConfiguration  implem
         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 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;
@@ -265,21 +277,21 @@ public class GlobalConfiguration  implem
         try {
             return null; // credentialContext.getProxyCredentails();
         } catch (Exception e) {
-            throw new GfacException(e,FaultCode.InitalizationError);
+            throw new GfacException(e, FaultCode.InitalizationError);
         }
     }
 
     public ApplicationDescriptionType getApplicationDesc(QName name, String hostName) {
-        if(hostName == null){
+        if (hostName == null) {
             return appName2App.get(name.toString());
         }
-        return appNameAndHost2App.get(name.toString()+hostName);
+        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);
+        QName appName = new QName(appDesc.getApplicationName().getTargetNamespace(), appDesc.getApplicationName()
+                .getStringValue());
+        appNameAndHost2App.put(appName.toString() + appDesc.getDeploymentDescription().getHostName(), appDesc);
         appName2App.put(appName.toString(), appDesc);
     }
 
@@ -291,7 +303,6 @@ public class GlobalConfiguration  implem
         hosts.put(host.getHostName(), host);
     }
 
-   
     public String getCapManURL() {
         return capManURL;
     }
@@ -304,11 +315,9 @@ public class GlobalConfiguration  implem
         return hosts;
     }
 
- 
-
-//    public String getMyLEADAgentURL() {
-//        return myLEADAgentURL;
-//    }
+    // public String getMyLEADAgentURL() {
+    // return myLEADAgentURL;
+    // }
 
     // public String getMyproxyLifetime() {
     // return myproxyLifetime;
@@ -335,11 +344,11 @@ public class GlobalConfiguration  implem
     }
 
     public Notifier getNotifier() {
-//        if (notifier == null && notificationBrokerURL != null) {
-//            notifier = GfacUtils.createNotifier(notificationBrokerURL, topic);
-//        }
-//        return notifier;
-    	return null;
+        // if (notifier == null && notificationBrokerURL != null) {
+        // notifier = GfacUtils.createNotifier(notificationBrokerURL, topic);
+        // }
+        // return notifier;
+        return null;
     }
 
     public String getTempDir() {
@@ -360,35 +369,35 @@ public class GlobalConfiguration  implem
         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 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;
@@ -406,9 +415,9 @@ public class GlobalConfiguration  implem
         this.wsGramPrefered = wsGramPrefered;
     }
 
-//    public AdminNotifier getAdminNotifier() {
-//        return adminNotifier;
-//    }
+    // public AdminNotifier getAdminNotifier() {
+    // return adminNotifier;
+    // }
 
     public String getHostcertsKeyFile() {
         return hostcertsKeyFile;
@@ -431,8 +440,7 @@ public class GlobalConfiguration  implem
     }
 
     /**
-     * We load the configuration from local direcotry or from gfac classpath in
-     * that order
+     * We load the configuration from local direcotry or from gfac classpath in that order
      * 
      * @return
      * @throws GfacException
@@ -440,19 +448,19 @@ public class GlobalConfiguration  implem
     private ConfigurationType loadExtensionConfiguration(boolean isPersistant) throws GfacException {
         try {
             String gfacProfile;
-            if(isPersistant){
+            if (isPersistant) {
                 gfacProfile = config.getProperty(GFacOptions.GFAC_PERSISTANT_SERVICE_PROFILE);
-            }else{
+            } else {
                 gfacProfile = config.getProperty(GFacOptions.GFAC_TRANSIENT_SERVICE_PROFILE);
             }
-            
-            if(gfacProfile == null){
+
+            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);
+                // 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()) {
@@ -463,32 +471,32 @@ public class GlobalConfiguration  implem
             ConfigurationDocument configurationDoc = ConfigurationDocument.Factory.parse(input);
             return configurationDoc.getConfiguration();
         } catch (FileNotFoundException e) {
-            throw new GfacException(e,FaultCode.InitalizationError);
+            throw new GfacException(e, FaultCode.InitalizationError);
         } catch (XmlException e) {
-            throw new GfacException(e,FaultCode.InitalizationError);
+            throw new GfacException(e, FaultCode.InitalizationError);
         } catch (IOException e) {
-            throw new GfacException(e,FaultCode.InitalizationError);
+            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 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;
     }
@@ -505,13 +513,12 @@ public class GlobalConfiguration  implem
         return OPTION_INSTALLATION_LOCAL.equals(config.getProperty(OPTION_INSTALLATION));
     }
 
-	public void setRetryonErrorCodes(Set<String> retryonErrorCodes) {
-		this.retryonErrorCodes = retryonErrorCodes;
-	}
-
-	public Set<String> getRetryonErrorCodes() {
-		return retryonErrorCodes;
-	}
+    public void setRetryonErrorCodes(Set<String> retryonErrorCodes) {
+        this.retryonErrorCodes = retryonErrorCodes;
+    }
+
+    public Set<String> getRetryonErrorCodes() {
+        return retryonErrorCodes;
+    }
 
-	
 }

Modified: 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=1139550&r1=1139549&r2=1139550&view=diff
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java (original)
+++ incubator/airavata/core/trunk/gfac/src/main/java/org/apache/airavata/core/gfac/utils/OutputUtils.java Sat Jun 25 15:17:35 2011
@@ -1,3 +1,24 @@
+/*
+ *
+ * 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.core.gfac.utils;
 
 import java.util.Iterator;
@@ -9,34 +30,34 @@ import org.apache.airavata.core.gfac.typ
 
 public class OutputUtils {
 
-	public static void fillOutputFromStdout(MessageContext<Parameter> outMessage, String stdout, String stderr) {
+    public static void fillOutputFromStdout(MessageContext<Parameter> outMessage, String stdout, String stderr) {
 
-		for (Iterator<String> iterator = outMessage.getParameterNames(); iterator.hasNext();) {
-			String parameterName = iterator.next();
+        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;
-		}
-	}
+            // 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;
+        }
+    }
 }

Modified: 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=1139550&r1=1139549&r2=1139550&view=diff
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/main/resources/service.properties (original)
+++ incubator/airavata/core/trunk/gfac/src/main/resources/service.properties Sat Jun 25 15:17:35 2011
@@ -1,7 +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.
+#
+#
+
 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
+#postchain.classes

Modified: 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=1139550&r1=1139549&r2=1139550&view=diff
==============================================================================
--- incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/factory/OGCEGenericFactoryTest.java (original)
+++ incubator/airavata/core/trunk/gfac/src/test/java/org/apache/airavata/core/gfac/factory/OGCEGenericFactoryTest.java Sat Jun 25 15:17:35 2011
@@ -1,15 +1,36 @@
+/*
+ *
+ * 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.core.gfac.factory;
 
 import org.junit.Test;
 
 public class OGCEGenericFactoryTest {
 
-	@Test
-	public void testGetGenericService() {
-	}
-
-	@Test
-	public void testCreateService() {		
-	}
+    @Test
+    public void testGetGenericService() {
+    }
+
+    @Test
+    public void testCreateService() {
+    }
 
 }



Mime
View raw message