airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msme...@apache.org
Subject git commit: updated bes and gram code
Date Fri, 26 Sep 2014 15:43:34 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 7a4f2021d -> 2b73d478b


updated bes and gram code 

Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/2b73d478
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/2b73d478
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/2b73d478

Branch: refs/heads/master
Commit: 2b73d478b155e6d437a7240fe6db924d7ca635bf
Parents: 7a4f202
Author: msmemon <shahbaz.memon@gmail.com>
Authored: Fri Sep 26 17:43:45 2014 +0200
Committer: msmemon <shahbaz.memon@gmail.com>
Committed: Fri Sep 26 17:43:45 2014 +0200

----------------------------------------------------------------------
 .../main/resources/schemas/HostDescription.xsd  | 330 ++++++++-------
 .../gfac/bes/handlers/SMSByteIOInHandler.java   |  28 +-
 .../gfac/bes/handlers/SMSByteIOOutHandler.java  |  64 ++-
 .../gfac/bes/provider/impl/BESProvider.java     | 409 +++++--------------
 .../airavata/gfac/bes/utils/JSDLGenerator.java  | 105 ++++-
 .../airavata/gfac/bes/utils/JSDLUtils.java      |   8 +-
 .../gfac/gram/provider/impl/GramProvider.java   |  18 +-
 7 files changed, 480 insertions(+), 482 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/2b73d478/modules/commons/gfac-schema/src/main/resources/schemas/HostDescription.xsd
----------------------------------------------------------------------
diff --git a/modules/commons/gfac-schema/src/main/resources/schemas/HostDescription.xsd b/modules/commons/gfac-schema/src/main/resources/schemas/HostDescription.xsd
index c4052d9..504636b 100644
--- a/modules/commons/gfac-schema/src/main/resources/schemas/HostDescription.xsd
+++ b/modules/commons/gfac-schema/src/main/resources/schemas/HostDescription.xsd
@@ -1,168 +1,196 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--Licensed to the Apache Software
-	Foundation (ASF) under one or more contributor license agreements. See the
-	NOTICE file distributed with this work for additional information regarding
-	copyright ownership. The ASF licenses this file to you under the Apache License,
-	Version 2.0 (theÏ "License"); you may not use this file except in compliance
-	with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-	Unless required by applicable law or agreed to in writing, software distributed
-	under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
-	OR CONDITIONS OF ANY ~ KIND, either express or implied. See the License for
-	the specific language governing permissions and limitations under the License. -->
+<!--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. -->
 
 <schema targetNamespace="http://airavata.apache.org/schemas/gfac/2012/12"
-        xmlns:gfac="http://airavata.apache.org/schemas/gfac/2012/12" xmlns="http://www.w3.org/2001/XMLSchema"
-        xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+	xmlns:gfac="http://airavata.apache.org/schemas/gfac/2012/12" xmlns="http://www.w3.org/2001/XMLSchema"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
 
-    <include schemaLocation="BasicTypes.xsd"/>
+	<include schemaLocation="BasicTypes.xsd" />
 
-    <element name="hostDescription" type="gfac:hostDescriptionType"/>
+	<element name="hostDescription" type="gfac:hostDescriptionType" />
 
-    <!-- Host Description -->
-    <complexType name="hostDescriptionType">
-        <sequence>
-            <element name="authorInfo" type="gfac:authorInfoType"
-                     minOccurs="0" maxOccurs="unbounded"/>
-            <element name="documentInfo" type="gfac:documentInfoType"
-                     minOccurs="0" maxOccurs="1"/>
-            <element name="hostName" type="xsd:string" minOccurs="1"
-                     maxOccurs="1"/>
-            <element name="hostAddress" type="xsd:string" minOccurs="1"
-                     maxOccurs="1"/>
-        </sequence>
-    </complexType>
+	<!-- Host Description -->
+	<complexType name="hostDescriptionType">
+		<sequence>
+			<element name="authorInfo" type="gfac:authorInfoType"
+				minOccurs="0" maxOccurs="unbounded" />
+			<element name="documentInfo" type="gfac:documentInfoType"
+				minOccurs="0" maxOccurs="1" />
+			<element name="hostName" type="xsd:string" minOccurs="1"
+				maxOccurs="1" />
+			<element name="hostAddress" type="xsd:string" minOccurs="1"
+				maxOccurs="1" />
+		</sequence>
+	</complexType>
 
 
-    <complexType name="preJobCommands">
-        <sequence>
-            <element name="command" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
-        </sequence>
-    </complexType>
+	<complexType name="preJobCommands">
+		<sequence>
+			<element name="command" type="xsd:string" minOccurs="0"
+				maxOccurs="unbounded" />
+		</sequence>
+	</complexType>
 
-    <complexType name="postJobCommands">
-        <sequence>
-            <element name="command" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
-        </sequence>
-    </complexType>
+	<complexType name="postJobCommands">
+		<sequence>
+			<element name="command" type="xsd:string" minOccurs="0"
+				maxOccurs="unbounded" />
+		</sequence>
+	</complexType>
 
-    <complexType name="exportProperties">
-        <sequence>
-            <element name="name" minOccurs="1" maxOccurs="unbounded">
-                <complexType>
-                    <simpleContent>
-                        <extension base="xsd:string">
-                            <attribute name="value" type="xsd:string" use="required"/>
-                        </extension>
-                    </simpleContent>
-                </complexType>
-            </element>
-        </sequence>
-    </complexType>
+	<complexType name="exportProperties">
+		<sequence>
+			<element name="name" minOccurs="1" maxOccurs="unbounded">
+				<complexType>
+					<simpleContent>
+						<extension base="xsd:string">
+							<attribute name="value" type="xsd:string" use="required" />
+						</extension>
+					</simpleContent>
+				</complexType>
+			</element>
+		</sequence>
+	</complexType>
 
-    <!-- Globus Host Description -->
-    <complexType name="globusHostType">
-        <complexContent>
-            <extension base="gfac:hostDescriptionType">
-                <sequence>
-                    <element name="gridFTPEndPoint" type="xsd:string"
-                             minOccurs="1" maxOccurs="unbounded"/>
-                    <element name="globusGateKeeperEndPoint" type="xsd:string"
-                             minOccurs="1" maxOccurs="unbounded"/>
-                </sequence>
-            </extension>
-        </complexContent>
-    </complexType>
+	<!-- Globus Host Description -->
+	<complexType name="globusHostType">
+		<complexContent>
+			<extension base="gfac:hostDescriptionType">
+				<sequence>
+					<element name="gridFTPEndPoint" type="xsd:string"
+						minOccurs="1" maxOccurs="unbounded" />
+					<element name="globusGateKeeperEndPoint" type="xsd:string"
+						minOccurs="1" maxOccurs="unbounded" />
+				</sequence>
+			</extension>
+		</complexContent>
+	</complexType>
 
-    <!-- EC2 Host Description -->
-    <complexType name="ec2HostType">
-        <complexContent>
-            <extension base="gfac:hostDescriptionType">
-                <sequence>
-                    <element name="imageID" type="xsd:string"
-                             minOccurs="1" maxOccurs="unbounded"/>
-                    <element name="instanceID" type="xsd:string"
-                             minOccurs="1" maxOccurs="unbounded"/>
-                </sequence>
-            </extension>
-        </complexContent>
-    </complexType>
+	<!-- EC2 Host Description -->
+	<complexType name="ec2HostType">
+		<complexContent>
+			<extension base="gfac:hostDescriptionType">
+				<sequence>
+					<element name="imageID" type="xsd:string" minOccurs="1"
+						maxOccurs="unbounded" />
+					<element name="instanceID" type="xsd:string" minOccurs="1"
+						maxOccurs="unbounded" />
+				</sequence>
+			</extension>
+		</complexContent>
+	</complexType>
 
-    <complexType name="UnicoreHostType">
-        <complexContent>
-            <extension base="gfac:hostDescriptionType">
-                <sequence>
-                    <sequence>
-                        <element name="gridFTPEndPoint" type="xsd:string"
-                                 minOccurs="0" maxOccurs="unbounded"/>
-                        <element name="unicoreBESEndPoint" type="xsd:string"
-                                 minOccurs="1" maxOccurs="unbounded"/>
-                    </sequence>
-                </sequence>
-            </extension>
-        </complexContent>
-    </complexType>
+	<complexType name="UnicoreHostType">
+		<complexContent>
+			<extension base="gfac:hostDescriptionType">
+				<sequence>
+					<sequence>
+						<element name="unicoreBESEndPoint" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
+						<!-- jobDirectoryMode allows gateway to specify how data will be accessed 
+							to an GFAC instance. It includes the directory interface and a file transfer 
+							protocol. The allowable protocols are, "SMS-ByteIO" / "GridFTP" / "RNS-ByteIO" -->
+						<element ref="gfac:jobDirectoryMode" minOccurs="1" />
+						<!-- gridFTPEndpoint only needs to be provided when using GridFTP as 
+							jobDirectoryMode -->
+						<element name="gridFTPEndPoint" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
+					</sequence>
+				</sequence>
+			</extension>
+		</complexContent>
+	</complexType>
+	
+	<!-- some more comments -->
+	<element name="jobDirectoryMode">
+		<simpleType>
+			<restriction base="string">
+				<enumeration value="GridFTP" />
+				<enumeration value="SMSByteIO" />
+				<enumeration value="RNSByteIO" />
+			</restriction>
+		</simpleType>
+	</element>
 
-    <complexType name="gsisshHostType">
-        <complexContent>
-            <extension base="gfac:hostDescriptionType">
-                <sequence>
-                    <element name="port" type="xsd:int" minOccurs="0" maxOccurs="1"/>
-                    <element name="exports" type="gfac:exportProperties" minOccurs="0" maxOccurs="1"/>
-                    <element name="preJobCommands" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
-                    <element name="postJobCommands" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
-                    <element name="installedPath" type="xsd:string" minOccurs="0" maxOccurs="1" default="/opt/torque/bin"/>
-                    <element name="jobManager" type="xsd:string" minOccurs="0" maxOccurs="1"/>
-                    <element name="monitorMode" type="xsd:string" minOccurs="0" maxOccurs="1"/>
-                </sequence>
-            </extension>
-        </complexContent>
-    </complexType>
-    <!-- SSH Host Description -->
-    <complexType name="SSHHostType">
-        <complexContent>
-            <extension base="gfac:hostDescriptionType">
-                <sequence>
-                    <element name="fileEndPointPrefix" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
-                    <element name="hpcResource" type="xsd:boolean" minOccurs="1" maxOccurs="1"/>
-                </sequence>
-            </extension>
-        </complexContent>
-    </complexType>
+	<complexType name="gsisshHostType">
+		<complexContent>
+			<extension base="gfac:hostDescriptionType">
+				<sequence>
+					<element name="port" type="xsd:int" minOccurs="0"
+						maxOccurs="1" />
+					<element name="exports" type="gfac:exportProperties"
+						minOccurs="0" maxOccurs="1" />
+					<element name="preJobCommands" type="xsd:string" minOccurs="0"
+						maxOccurs="unbounded" />
+					<element name="postJobCommands" type="xsd:string"
+						minOccurs="0" maxOccurs="unbounded" />
+					<element name="installedPath" type="xsd:string" minOccurs="0"
+						maxOccurs="1" default="/opt/torque/bin" />
+					<element name="jobManager" type="xsd:string" minOccurs="0"
+						maxOccurs="1" />
+					<element name="monitorMode" type="xsd:string" minOccurs="0"
+						maxOccurs="1" />
+				</sequence>
+			</extension>
+		</complexContent>
+	</complexType>
+	<!-- SSH Host Description -->
+	<complexType name="SSHHostType">
+		<complexContent>
+			<extension base="gfac:hostDescriptionType">
+				<sequence>
+					<element name="fileEndPointPrefix" type="xsd:string"
+						minOccurs="0" maxOccurs="unbounded" />
+					<element name="hpcResource" type="xsd:boolean" minOccurs="1"
+						maxOccurs="1" />
+				</sequence>
+			</extension>
+		</complexContent>
+	</complexType>
 
-    <!-- Hadoop Host Description -->
-    <complexType name="hadoopHostType">
-        <complexContent>
-            <extension base="gfac:hostDescriptionType">
-                <sequence>
-                    <element name="hadoopConfigurationDirectory" type="xsd:string" minOccurs="0" maxOccurs="1"/>
-                    <element name="whirrConfiguration" maxOccurs="1" minOccurs="0">
-                        <complexType>
-                            <sequence>
-                                <element name="configurationFile" type="xsd:string" minOccurs="0" maxOccurs="1"/>
-                                <element name="byonClusterConfigurationFile" type="xsd:string" minOccurs="0"
-                                         maxOccurs="1"/>
-                                <element name="configuration" minOccurs="0" maxOccurs="1">
-                                    <complexType>
-                                        <sequence>
-                                            <element name="property" maxOccurs="unbounded">
-                                                <complexType>
-                                                    <sequence>
-                                                        <element name="name" type="xsd:string" maxOccurs="1"
-                                                                 minOccurs="1"/>
-                                                        <element name="value" type="xsd:string" maxOccurs="1"
-                                                                 minOccurs="1"/>
-                                                    </sequence>
-                                                </complexType>
-                                            </element>
-                                        </sequence>
-                                    </complexType>
-                                </element>
-                            </sequence>
-                        </complexType>
-                    </element>
-                </sequence>
-            </extension>
-        </complexContent>
-    </complexType>
+	<!-- Hadoop Host Description -->
+	<complexType name="hadoopHostType">
+		<complexContent>
+			<extension base="gfac:hostDescriptionType">
+				<sequence>
+					<element name="hadoopConfigurationDirectory" type="xsd:string"
+						minOccurs="0" maxOccurs="1" />
+					<element name="whirrConfiguration" maxOccurs="1" minOccurs="0">
+						<complexType>
+							<sequence>
+								<element name="configurationFile" type="xsd:string"
+									minOccurs="0" maxOccurs="1" />
+								<element name="byonClusterConfigurationFile" type="xsd:string"
+									minOccurs="0" maxOccurs="1" />
+								<element name="configuration" minOccurs="0" maxOccurs="1">
+									<complexType>
+										<sequence>
+											<element name="property" maxOccurs="unbounded">
+												<complexType>
+													<sequence>
+														<element name="name" type="xsd:string" maxOccurs="1"
+															minOccurs="1" />
+														<element name="value" type="xsd:string" maxOccurs="1"
+															minOccurs="1" />
+													</sequence>
+												</complexType>
+											</element>
+										</sequence>
+									</complexType>
+								</element>
+							</sequence>
+						</complexType>
+					</element>
+				</sequence>
+			</extension>
+		</complexContent>
+	</complexType>
 
 </schema>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/2b73d478/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/handlers/SMSByteIOInHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/handlers/SMSByteIOInHandler.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/handlers/SMSByteIOInHandler.java
index 286637a..9b697aa 100644
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/handlers/SMSByteIOInHandler.java
+++ b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/handlers/SMSByteIOInHandler.java
@@ -1,5 +1,29 @@
 package org.apache.airavata.gfac.bes.handlers;
 
-public class SMSByteIOInHandler {
 
-}
+import org.apache.airavata.gfac.core.context.JobExecutionContext;
+import org.apache.airavata.gfac.core.handler.GFacHandler;
+import org.apache.airavata.gfac.core.handler.GFacHandlerException;
+import org.apache.airavata.gfac.core.provider.GFacProviderException;
+
+/**
+ * Download upload job's input files to the temporary SMS directory.
+ * 
+ * */
+public class SMSByteIOInHandler extends AbstractSMSHandler implements GFacHandler {
+
+
+	@Override
+	public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException	{
+		super.invoke(jobExecutionContext);
+    try{    
+        	if(jobExecutionContext.getInMessageContext().getParameters().size() < 1) return;
+        	dataTransferrer.uploadLocalFiles();
+	} catch (GFacProviderException e) {
+		throw new GFacHandlerException("Cannot upload local data",e);
+	}
+
+ 	}
+	
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/2b73d478/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/handlers/SMSByteIOOutHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/handlers/SMSByteIOOutHandler.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/handlers/SMSByteIOOutHandler.java
index 63787bc..1a0d2ef 100644
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/handlers/SMSByteIOOutHandler.java
+++ b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/handlers/SMSByteIOOutHandler.java
@@ -1,5 +1,67 @@
 package org.apache.airavata.gfac.bes.handlers;
 
-public class SMSByteIOOutHandler {
 
+
+import org.apache.airavata.gfac.bes.utils.ActivityInfo;
+import org.apache.airavata.gfac.core.context.JobExecutionContext;
+import org.apache.airavata.gfac.core.handler.GFacHandler;
+import org.apache.airavata.gfac.core.handler.GFacHandlerException;
+import org.apache.airavata.gfac.core.provider.GFacProviderException;
+import org.ggf.schemas.bes.x2006.x08.besFactory.ActivityStateEnumeration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SMSByteIOOutHandler extends AbstractSMSHandler implements GFacHandler{
+
+	// TODO: later use AbstractHandler, which cannot be used due to error in RegistryFactory
+		private final Logger log = LoggerFactory.getLogger(this.getClass());
+		
+		@Override
+		public void invoke(JobExecutionContext jobExecutionContext)
+				throws GFacHandlerException {
+			super.invoke(jobExecutionContext);
+			
+			ActivityInfo activityInfo = (ActivityInfo)jobExecutionContext.getProperty(PROP_ACTIVITY_INFO);
+			try {
+			if(activityInfo == null) {
+				log.error("No ActivityInfo instance found. The activity execution is ended due to an exception, see provider logs");
+				return;
+			}
+			
+			if ((activityInfo.getActivityStatus().getState() == ActivityStateEnumeration.FAILED)) {
+	            try {Thread.sleep(5000);}catch (InterruptedException e){}
+	            
+	            try {
+					dataTransferrer.downloadStdOuts();
+				} catch (GFacProviderException e) {
+					throw new GFacHandlerException("Cannot download stdout data",e);
+				}
+			}
+	        else if (activityInfo.getActivityStatus().getState() == ActivityStateEnumeration.FINISHED) {
+	        	try {Thread.sleep(5000);}catch (InterruptedException e){}
+	        	
+	        	try {
+						if (activityInfo.getActivityStatus().getExitCode() == 0) {
+							dataTransferrer.downloadRemoteFiles();
+						} else {
+							dataTransferrer.downloadStdOuts();
+						}
+					} catch (GFacProviderException e) {
+						throw new GFacHandlerException(
+								"Cannot download stdout data", e);
+					}
+				}
+			} finally {
+				try {
+					if (storageClient != null) {
+						storageClient.destroy();
+					}
+				} catch (Exception e) {
+					log.warn("Cannot destroy temporary SMS instance", e);
+				}
+
+			}		
+
+	 	}
 }
+

http://git-wip-us.apache.org/repos/asf/airavata/blob/2b73d478/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/provider/impl/BESProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/provider/impl/BESProvider.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/provider/impl/BESProvider.java
index 207e076..9578dd5 100644
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/provider/impl/BESProvider.java
+++ b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/provider/impl/BESProvider.java
@@ -20,80 +20,82 @@
 */
 package org.apache.airavata.gfac.bes.provider.impl;
 
-import de.fzj.unicore.bes.client.FactoryClient;
-import de.fzj.unicore.bes.faults.UnknownActivityIdentifierFault;
-import de.fzj.unicore.uas.client.StorageClient;
-import de.fzj.unicore.wsrflite.xmlbeans.WSUtilities;
-import eu.emi.security.authn.x509.helpers.CertificateHelpers;
-import eu.emi.security.authn.x509.helpers.proxy.X509v3CertificateBuilder;
-import eu.emi.security.authn.x509.impl.CertificateUtils;
-import eu.emi.security.authn.x509.impl.CertificateUtils.Encoding;
-import eu.emi.security.authn.x509.impl.DirectoryCertChainValidator;
-import eu.emi.security.authn.x509.impl.KeyAndCertCredential;
-import eu.emi.security.authn.x509.impl.X500NameUtils;
-import eu.unicore.util.httpclient.DefaultClientConfiguration;
+import java.util.Calendar;
+import java.util.Map;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
 import org.apache.airavata.gfac.Constants;
 import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.bes.security.GSISecurityContext;
-import org.apache.airavata.gfac.bes.utils.DataTransferrer;
+import org.apache.airavata.gfac.bes.security.UNICORESecurityContext;
+import org.apache.airavata.gfac.bes.utils.ActivityInfo;
+import org.apache.airavata.gfac.bes.utils.BESConstants;
+import org.apache.airavata.gfac.bes.utils.DataServiceInfo;
 import org.apache.airavata.gfac.bes.utils.JSDLGenerator;
-import org.apache.airavata.gfac.bes.utils.StorageCreator;
 import org.apache.airavata.gfac.core.context.JobExecutionContext;
-import org.apache.airavata.gfac.core.notification.events.StatusChangeEvent;
-import org.apache.airavata.gfac.core.notification.events.UnicoreJobIDEvent;
 import org.apache.airavata.gfac.core.provider.AbstractProvider;
+import org.apache.airavata.gfac.core.provider.GFacProvider;
 import org.apache.airavata.gfac.core.provider.GFacProviderException;
 import org.apache.airavata.gfac.core.utils.GFacUtils;
+import org.apache.airavata.model.workspace.experiment.JobDetails;
 import org.apache.airavata.model.workspace.experiment.JobState;
 import org.apache.airavata.schemas.gfac.UnicoreHostType;
 import org.apache.xmlbeans.XmlCursor;
-import org.bouncycastle.asn1.ASN1InputStream;
-import org.bouncycastle.asn1.x500.X500Name;
 import org.bouncycastle.asn1.x500.style.BCStyle;
-import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
-import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
-import org.ggf.schemas.bes.x2006.x08.besFactory.*;
+import org.ggf.schemas.bes.x2006.x08.besFactory.ActivityStateEnumeration;
 import org.ggf.schemas.bes.x2006.x08.besFactory.ActivityStateEnumeration.Enum;
+import org.ggf.schemas.bes.x2006.x08.besFactory.ActivityStatusType;
+import org.ggf.schemas.bes.x2006.x08.besFactory.CreateActivityDocument;
+import org.ggf.schemas.bes.x2006.x08.besFactory.CreateActivityResponseDocument;
+import org.ggf.schemas.bes.x2006.x08.besFactory.GetActivityStatusesDocument;
+import org.ggf.schemas.bes.x2006.x08.besFactory.GetActivityStatusesResponseDocument;
 import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
 import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3.x2005.x08.addressing.EndpointReferenceType;
 
-import javax.security.auth.x500.X500Principal;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.PrivateKey;
-import java.security.cert.X509Certificate;
-import java.util.*;
+import de.fzj.unicore.bes.client.FactoryClient;
+import de.fzj.unicore.bes.faults.UnknownActivityIdentifierFault;
+import de.fzj.unicore.wsrflite.xmlbeans.WSUtilities;
+import eu.emi.security.authn.x509.impl.X500NameUtils;
+import eu.unicore.util.httpclient.DefaultClientConfiguration;
 
 
 
-public class BESProvider extends AbstractProvider {
+public class BESProvider extends AbstractProvider implements GFacProvider, BESConstants{
     protected final Logger log = LoggerFactory.getLogger(this.getClass());
 
     private DefaultClientConfiguration secProperties;
 
     private String jobId;
     
-    
-        
 	public void initialize(JobExecutionContext jobExecutionContext)
 			throws GFacProviderException, GFacException {
-		log.info("Initializing UNICORE Provider");
+		log.info("Initializing UNICORE Provider..");
 		super.initialize(jobExecutionContext);
-    	initSecurityProperties(jobExecutionContext);
-    	log.debug("initialized security properties");
+		secProperties = (DefaultClientConfiguration)jobExecutionContext.getProperty(PROP_CLIENT_CONF);
+        if (secProperties != null) {
+        	secProperties = secProperties.clone();
+        	return;
+        }
+            
+        UNICORESecurityContext unicoreContext = (UNICORESecurityContext) jobExecutionContext.getSecurityContext(UNICORESecurityContext.UNICORE_SECURITY_CONTEXT);
+        if(log.isDebugEnabled()) {
+        	log.debug("Generating default configuration.");
+        }
+        //TODO: check what credential mode should be used
+        try {
+			secProperties = unicoreContext.getDefaultConfiguration();
+		} catch (ApplicationSettingsException e) {
+			throw new GFacProviderException(e.getMessage(), e);
+		}
+        if(log.isDebugEnabled()) {
+        	log.debug("Security properties initialized.");
+        }
     }
 
 
-	public void execute(JobExecutionContext jobExecutionContext)
-			throws GFacProviderException {
+	public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
         UnicoreHostType host = (UnicoreHostType) jobExecutionContext.getApplicationContext().getHostDescription()
                 .getType();
 
@@ -101,59 +103,52 @@ public class BESProvider extends AbstractProvider {
 
         EndpointReferenceType eprt = EndpointReferenceType.Factory.newInstance();
         eprt.addNewAddress().setStringValue(factoryUrl);
+        
+//		WSUtilities.addServerIdentity(eprt, serverDN);
 
-        String userDN = getUserName(jobExecutionContext);
 
+        String userDN = getUserName(jobExecutionContext);
+        
+        //TODO: to be removed
         if (userDN == null || userDN.equalsIgnoreCase("admin")) {
             userDN = "CN=zdv575, O=Ultrascan Gateway, C=DE";
         }
-
-        String xlogin = getCNFromUserDN(userDN);
-        // create storage
-        StorageCreator storageCreator = new StorageCreator(secProperties, factoryUrl, 5, xlogin);
-
-        StorageClient sc = null;
+        
         try {
-            try {
-                sc = storageCreator.createStorage();
-            } catch (Exception e2) {
-                log.error("Cannot create storage..");
-                throw new GFacProviderException("Cannot create storage..", e2);
-            }
-
+            
+            DataServiceInfo dsInfo = new DataServiceInfo(jobExecutionContext);
+            
             CreateActivityDocument cad = CreateActivityDocument.Factory.newInstance();
             JobDefinitionDocument jobDefDoc = JobDefinitionDocument.Factory.newInstance();
 
             JobDefinitionType jobDefinition = jobDefDoc.addNewJobDefinition();
             try {
-                jobDefinition = JSDLGenerator.buildJSDLInstance(jobExecutionContext, sc.getUrl()).getJobDefinition();
+                jobDefinition = JSDLGenerator.buildJSDLInstance(jobExecutionContext, dsInfo).getJobDefinition();
                 cad.addNewCreateActivity().addNewActivityDocument().setJobDefinition(jobDefinition);
-
                 log.info("JSDL" + jobDefDoc.toString());
             } catch (Exception e1) {
                 throw new GFacProviderException("Cannot generate JSDL instance from the JobExecutionContext.", e1);
             }
 
-            // upload files if any
-            DataTransferrer dt = new DataTransferrer(jobExecutionContext, sc);
-            dt.uploadLocalFiles();
-
-            FactoryClient factory = null;
-            try {
+           FactoryClient factory = null;
+           JobDetails jobDetails = new JobDetails();
+           
+           try {
                 factory = new FactoryClient(eprt, secProperties);
             } catch (Exception e) {
                 throw new GFacProviderException(e.getLocalizedMessage(), e);
             }
-
             CreateActivityResponseDocument response = null;
             try {
                 log.info(String.format("Activity Submitting to %s ... \n", factoryUrl));
                 response = factory.createActivity(cad);
+                
                 log.info(String.format("Activity Submitted to %s \n", factoryUrl));
             } catch (Exception e) {
                 throw new GFacProviderException("Cannot create activity.", e);
             }
             EndpointReferenceType activityEpr = response.getCreateActivityResponse().getActivityIdentifier();
+           	
 
             log.info("Activity : " + activityEpr.getAddress().getStringValue() + " Submitted.");
 
@@ -163,98 +158,30 @@ public class BESProvider extends AbstractProvider {
                 jobId = new Long(Calendar.getInstance().getTimeInMillis()).toString();
             }
             log.info("JobID: " + jobId);
-            jobExecutionContext.getNotifier().publish(new UnicoreJobIDEvent(jobId));
-            saveApplicationJob(jobExecutionContext, jobDefinition, activityEpr.toString());
-
-            factory.getActivityStatus(activityEpr);
+//            jobExecutionContext.getNotifier().publish(new UnicoreJobIDEvent(jobId));
+            //TODO: not working
+//            saveApplicationJob(jobExecutionContext, jobDefinition, activityEpr.toString());
+            jobDetails.setJobID(activityEpr.toString());
+            jobDetails.setJobDescription(activityEpr.toString());
+            
+            jobExecutionContext.setJobDetails(jobDetails);
+            
             log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(),
                     factory.getActivityStatus(activityEpr).toString()));
 
             // TODO publish the status messages to the message bus
-            while ((factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FINISHED)
-                    && (factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FAILED)
-                    && (factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.CANCELLED)) {
-
-                ActivityStatusType activityStatus = null;
-                try {
-                    activityStatus = getStatus(factory, activityEpr);
-                    JobState jobStatus = getApplicationJobStatus(activityStatus);
-                    String jobStatusMessage = "Status of job " + jobId + "is " + jobStatus;
-                    jobExecutionContext.getNotifier().publish(new StatusChangeEvent(jobStatusMessage));
-                    details.setJobID(jobId);
-                    GFacUtils.updateJobStatus(jobExecutionContext, details, jobStatus);
-                } catch (UnknownActivityIdentifierFault e) {
-                    throw new GFacProviderException(e.getMessage(), e.getCause());
-                }catch (GFacException e) {
-                    throw new GFacProviderException(e.getMessage(), e.getCause());
-                }
-
-                try {
-                    Thread.sleep(5000);
-                } catch (InterruptedException e) {
-                }
-                continue;
-            }
-
             ActivityStatusType activityStatus = null;
-            try {
-                activityStatus = getStatus(factory, activityEpr);
-            } catch (UnknownActivityIdentifierFault e) {
-                throw new GFacProviderException(e.getMessage(), e.getCause());
-            }
-
-            log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(), activityStatus.getState()
-                    .toString()));
-
-            if ((activityStatus.getState() == ActivityStateEnumeration.FAILED)) {
-                String error = activityStatus.getFault().getFaultcode().getLocalPart() + "\n"
-                        + activityStatus.getFault().getFaultstring() + "\n EXITCODE: " + activityStatus.getExitCode();
-                log.info(error);
-                try {
-                    Thread.sleep(5000);
-                } catch (InterruptedException e) {
-                }
-                dt.downloadStdOuts();
-            } else if (activityStatus.getState() == ActivityStateEnumeration.CANCELLED) {
-                String experimentID = (String) jobExecutionContext.getProperty(Constants.PROP_TOPIC);
-                JobState jobStatus = JobState.CANCELED;
-                String jobStatusMessage = "Status of job " + jobId + "is " + jobStatus;
-                jobExecutionContext.getNotifier().publish(new StatusChangeEvent(jobStatusMessage));
-                details.setJobID(jobId);
-                try {
-					GFacUtils.saveJobStatus(jobExecutionContext,details, jobStatus);
-				} catch (GFacException e) {
-					 throw new GFacProviderException(e.getLocalizedMessage(),e);
-				}
-                throw new GFacProviderException(experimentID + "Job Canceled");
-            }
-
-            else if (activityStatus.getState() == ActivityStateEnumeration.FINISHED) {
-                try {
-                    Thread.sleep(5000);
-                } catch (InterruptedException e) {
-                }
-                if (activityStatus.getExitCode() == 0) {
-                    dt.downloadRemoteFiles();
-                } else {
-                    dt.downloadStdOuts();
-                }
-            }
-
+            ActivityInfo activityInfo;
+            activityInfo = new ActivityInfo();
+            activityInfo.setActivityEPR(activityEpr);
+            activityInfo.setActivityStatusDoc(activityStatus);
+            jobExecutionContext.setProperty(PROP_ACTIVITY_INFO, activityInfo);
         } catch (UnknownActivityIdentifierFault e1) {
             throw new GFacProviderException(e1.getLocalizedMessage(), e1);
-        } finally {
-            // destroy sms instance
-            try {
-                if (sc != null) {
-                    sc.destroy();
-                }
-            } catch (Exception e) {
-                log.warn("Cannot destroy temporary SMS instance:" + sc.getUrl(), e);
-            }
         }
     }
-
+	
+	
 	private JobState getApplicationJobStatus(ActivityStatusType activityStatus){
         if (activityStatus == null) {
             return JobState.UNKNOWN;
@@ -302,8 +229,10 @@ public class BESProvider extends AbstractProvider {
     }
 
     private void saveApplicationJob(JobExecutionContext jobExecutionContext, JobDefinitionType jobDefinition,
-                                    String metadata) {
-//        ApplicationJob appJob = GFacUtils.createApplicationJob(jobExecutionContext);
+                                    String metadata) throws GFacException {
+
+    	
+//    	ApplicationJob appJob = GFacUtils.createApplicationJob(jobExecutionContext);
 //        appJob.setJobId(jobId);
 //        appJob.setJobData(jobDefinition.toString());
 //        appJob.setSubmittedTime(Calendar.getInstance().getTime());
@@ -311,22 +240,23 @@ public class BESProvider extends AbstractProvider {
 //        appJob.setStatusUpdateTime(appJob.getSubmittedTime());
 //        appJob.setMetadata(metadata);
 //        GFacUtils.recordApplicationJob(jobExecutionContext, appJob);
-    }
-
-    public void dispose(JobExecutionContext jobExecutionContext) throws GFacProviderException {
-        secProperties = null;
+        
+        details.setJobID(jobId);
+        GFacUtils.saveJobStatus(jobExecutionContext, details, JobState.SUBMITTED);
+        
     }
 
     /**
      * EndpointReference need to be saved to make cancel work.
      *
+     * @param activityEpr
      * @param jobExecutionContext
      * @throws GFacProviderException
      */
-    public void cancelJob(JobExecutionContext jobExecutionContext) throws GFacProviderException {
+    public void cancelJob(String activityEpr, JobExecutionContext jobExecutionContext) throws GFacProviderException {
         try {
-            initSecurityProperties(jobExecutionContext);
-            EndpointReferenceType eprt = EndpointReferenceType.Factory.parse(jobExecutionContext.getJobDetails().getJobID());
+//            initSecurityProperties(jobExecutionContext);
+            EndpointReferenceType eprt = EndpointReferenceType.Factory.parse(activityEpr);
             UnicoreHostType host = (UnicoreHostType) jobExecutionContext.getApplicationContext().getHostDescription()
                     .getType();
 
@@ -342,87 +272,6 @@ public class BESProvider extends AbstractProvider {
 
     }
 
-    protected void downloadOffline(String smsEpr, JobExecutionContext jobExecutionContext) throws GFacProviderException {
-        try {
-            initSecurityProperties(jobExecutionContext);
-            EndpointReferenceType eprt = EndpointReferenceType.Factory.parse(smsEpr);
-            StorageClient sms = new StorageClient(eprt, secProperties);
-            DataTransferrer dt = new DataTransferrer(jobExecutionContext, sms);
-            // there must be output files there
-            // this is also possible if client is re-connected, the jobs are
-            // still
-            // running and no output is produced
-            dt.downloadRemoteFiles();
-
-            // may be use the below method before downloading for checking
-            // the number of entries
-            // sms.listDirectory(".");
-
-        } catch (Exception e) {
-            throw new GFacProviderException(e.getLocalizedMessage(), e);
-        }
-    }
-
-    protected void initSecurityProperties(JobExecutionContext jobExecutionContext) throws GFacProviderException,
-            GFacException {
-
-        if (secProperties != null)
-            return;
-
-        GSISecurityContext gssContext = (GSISecurityContext) jobExecutionContext
-                .getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT);
-
-        try {
-            String certLocation = gssContext.getTrustedCertificatePath();
-            List<String> trustedCert = new ArrayList<String>();
-            trustedCert.add(certLocation + "/*.0");
-            trustedCert.add(certLocation + "/*.pem");
-
-            DirectoryCertChainValidator dcValidator = new DirectoryCertChainValidator(trustedCert, Encoding.PEM, -1,
-                    60000, null);
-
-            String userID = getUserName(jobExecutionContext);
-
-            if ( userID == null || "".equals(userID) || userID.equalsIgnoreCase("admin") ) {
-                userID = "CN=zdv575, O=Ultrascan Gateway, C=DE";
-            }
-
-            String userDN = userID.replaceAll("^\"|\"$", "");
-
-            // TODO: should be changed to default airavata server locations
-            KeyAndCertCredential cred = generateShortLivedCertificate(userDN, certLocation
-                    + "/cacert.pem", certLocation
-                    + "/cakey.pem", "ultrascan3");
-            secProperties = new DefaultClientConfiguration(dcValidator, cred);
-
-            // secProperties.doSSLAuthn();
-            secProperties.getETDSettings().setExtendTrustDelegation(true);
-
-            secProperties.setDoSignMessage(true);
-
-            String[] outHandlers = secProperties.getOutHandlerClassNames();
-
-            Set<String> outHandlerLst = null;
-
-            // timeout in milliseconds
-            Properties p = secProperties.getExtraSettings();
-            p.setProperty("http.connection.timeout", "300000");
-            p.setProperty("http.socket.timeout", "300000");
-
-            if (outHandlers == null) {
-                outHandlerLst = new HashSet<String>();
-            } else {
-                outHandlerLst = new HashSet<String>(Arrays.asList(outHandlers));
-            }
-
-            outHandlerLst.add("de.fzj.unicore.uas.security.ProxyCertOutHandler");
-
-            secProperties.setOutHandlerClassNames(outHandlerLst.toArray(new String[outHandlerLst.size()]));
-
-        } catch (Exception e) {
-            throw new GFacProviderException(e.getMessage(), e);
-        }
-    }
 
     //FIXME: Get user details
     private String getUserName(JobExecutionContext context) {
@@ -474,76 +323,36 @@ public class BESProvider extends AbstractProvider {
 
     }
 
-    public void initProperties(Map<String, String> properties) throws GFacProviderException, GFacException {
-
-    }
-
-    protected KeyAndCertCredential generateShortLivedCertificate(String userDN, String caCertPath, String caKeyPath,
-                                                                 String caPwd) throws Exception {
-        final long CredentialGoodFromOffset = 1000L * 60L * 15L; // 15 minutes
-        // ago
-
-        final long startTime = System.currentTimeMillis() - CredentialGoodFromOffset;
-        final long endTime = startTime + 30 * 3600 * 1000;
-
-        String keyLengthProp = "1024";
-        int keyLength = Integer.parseInt(keyLengthProp);
-        String signatureAlgorithm = "SHA1withRSA";
-
-        KeyAndCertCredential caCred = getCACredential(caCertPath, caKeyPath, caPwd);
-
-        KeyPairGenerator kpg = KeyPairGenerator.getInstance(caCred.getKey().getAlgorithm());
-        kpg.initialize(keyLength);
-        KeyPair pair = kpg.generateKeyPair();
-
-        X500Principal subjectDN = new X500Principal(userDN);
-        Random rand = new Random();
-
-        SubjectPublicKeyInfo publicKeyInfo;
-        try {
-            publicKeyInfo = SubjectPublicKeyInfo.getInstance(new ASN1InputStream(pair.getPublic().getEncoded())
-                    .readObject());
-        } catch (IOException e) {
-            throw new InvalidKeyException("Can not parse the public key"
-                    + "being included in the short lived certificate", e);
-        }
-
-        X500Name issuerX500Name = CertificateHelpers.toX500Name(caCred.getCertificate().getSubjectX500Principal());
-
-        X500Name subjectX500Name = CertificateHelpers.toX500Name(subjectDN);
 
-        X509v3CertificateBuilder certBuilder = new X509v3CertificateBuilder(issuerX500Name, new BigInteger(20, rand),
-                new Date(startTime), new Date(endTime), subjectX500Name, publicKeyInfo);
-
-        AlgorithmIdentifier sigAlgId = X509v3CertificateBuilder.extractAlgorithmId(caCred.getCertificate());
+    private String getCNFromUserDN(String userDN) {
+        return X500NameUtils.getAttributeValues(userDN, BCStyle.CN)[0];
 
-        X509Certificate certificate = certBuilder.build(caCred.getKey(), sigAlgId, signatureAlgorithm, null, null);
+    }
 
-        certificate.checkValidity(new Date());
-        certificate.verify(caCred.getCertificate().getPublicKey());
-        KeyAndCertCredential result = new KeyAndCertCredential(pair.getPrivate(), new X509Certificate[] { certificate,
-                caCred.getCertificate() });
 
-        return result;
-    }
+	@Override
+	public void initProperties(Map<String, String> properties)
+			throws GFacProviderException, GFacException {
+		// TODO Auto-generated method stub
+		
+	}
 
-    private KeyAndCertCredential getCACredential(String caCertPath, String caKeyPath, String password) throws Exception {
-        InputStream isKey = new FileInputStream(caKeyPath);
-        PrivateKey pk = CertificateUtils.loadPrivateKey(isKey, Encoding.PEM, password.toCharArray());
 
-        InputStream isCert = new FileInputStream(caCertPath);
-        X509Certificate caCert = CertificateUtils.loadCertificate(isCert, Encoding.PEM);
+	
 
-        if (isKey != null)
-            isKey.close();
-        if (isCert != null)
-            isCert.close();
 
-        return new KeyAndCertCredential(pk, new X509Certificate[] { caCert });
-    }
+	@Override
+	public void dispose(JobExecutionContext jobExecutionContext)
+			throws GFacProviderException, GFacException {
+		secProperties = null;
+		
+	}
 
-    private String getCNFromUserDN(String userDN) {
-        return X500NameUtils.getAttributeValues(userDN, BCStyle.CN)[0];
 
-    }
-}
+	@Override
+	public void cancelJob(JobExecutionContext jobExecutionContext)
+			throws GFacProviderException, GFacException {
+		// TODO Auto-generated method stub
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/2b73d478/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/JSDLGenerator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/JSDLGenerator.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/JSDLGenerator.java
index 185c958..d46aef9 100644
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/JSDLGenerator.java
+++ b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/JSDLGenerator.java
@@ -28,19 +28,21 @@ import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+
 /**
  * 
  * Utility class generates a JSDL instance from JobExecutionContext instance
+ * 
  * @author shahbaz memon
  * 
  * */
 
-public class JSDLGenerator {
-	
+public class JSDLGenerator implements BESConstants {
+
 	protected final Logger log = LoggerFactory.getLogger(this.getClass());
-	
-	
-	public synchronized static JobDefinitionDocument buildJSDLInstance(JobExecutionContext context) throws Exception {
+
+	public synchronized static JobDefinitionDocument buildJSDLInstance(
+			JobExecutionContext context) throws Exception {
 
 		JobDefinitionDocument jobDefDoc = JobDefinitionDocument.Factory
 				.newInstance();
@@ -52,19 +54,78 @@ public class JSDLGenerator {
 
 		// build Identification
 		createJobIdentification(value, appDepType);
-		
+
 		ResourceProcessor.generateResourceElements(value, context);
-		
+
 		ApplicationProcessor.generateJobSpecificAppElements(value, context);
-		
+
 		DataStagingProcessor.generateDataStagingElements(value, context);
-		
-		
+
 		return jobDefDoc;
 	}
 
+	public synchronized static JobDefinitionDocument buildJSDLInstance(
+			JobExecutionContext context, String smsUrl) throws Exception {
+
+		JobDefinitionDocument jobDefDoc = JobDefinitionDocument.Factory
+				.newInstance();
+		JobDefinitionType value = jobDefDoc.addNewJobDefinition();
+
+		HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) context
+				.getApplicationContext().getApplicationDeploymentDescription()
+				.getType();
+
+		// build Identification
+		createJobIdentification(value, appDepType);
+
+		ResourceProcessor.generateResourceElements(value, context);
+
+		ApplicationProcessor.generateJobSpecificAppElements(value, context);
+
+		UASDataStagingProcessor.generateDataStagingElements(value, context,
+				smsUrl);
+
+		return jobDefDoc;
+	}
 
-	public synchronized static JobDefinitionDocument buildJSDLInstance(JobExecutionContext context, String smsUrl) throws Exception {
+	public synchronized static JobDefinitionDocument buildJSDLInstance(
+			JobExecutionContext context, DataServiceInfo dataInfo)
+			throws Exception {
+
+		JobDefinitionDocument jobDefDoc = JobDefinitionDocument.Factory
+				.newInstance();
+		JobDefinitionType value = jobDefDoc.addNewJobDefinition();
+
+		HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) context
+				.getApplicationContext().getApplicationDeploymentDescription()
+				.getType();
+
+		createJobIdentification(value, appDepType);
+
+		ResourceProcessor.generateResourceElements(value, context);
+
+		ApplicationProcessor.generateJobSpecificAppElements(value, context);
+
+		switch (dataInfo.getDirectoryAccesMode()) {
+		case SMSBYTEIO:
+			if(null == dataInfo.getDataServiceUrl() || "".equals(dataInfo.getDataServiceUrl()))
+				throw new Exception("No SMS address found");
+			UASDataStagingProcessor.generateDataStagingElements(value, context,
+					dataInfo.getDataServiceUrl());
+			break;
+		case RNSBYTEIO:
+		case GridFTP:
+		default:
+			DataStagingProcessor.generateDataStagingElements(value, context);
+			break;
+
+		}
+		return jobDefDoc;
+	}
+
+	public synchronized static JobDefinitionDocument buildJSDLInstance(
+			JobExecutionContext context, String smsUrl, Object jobDirectoryMode)
+			throws Exception {
 
 		JobDefinitionDocument jobDefDoc = JobDefinitionDocument.Factory
 				.newInstance();
@@ -76,19 +137,21 @@ public class JSDLGenerator {
 
 		// build Identification
 		createJobIdentification(value, appDepType);
-		
+
 		ResourceProcessor.generateResourceElements(value, context);
-		
+
 		ApplicationProcessor.generateJobSpecificAppElements(value, context);
-		
-		UASDataStagingProcessor.generateDataStagingElements(value, context, smsUrl);
-		
+
+		UASDataStagingProcessor.generateDataStagingElements(value, context,
+				smsUrl);
+
 		return jobDefDoc;
 	}
 
-	private static void createJobIdentification(JobDefinitionType value, HpcApplicationDeploymentType appDepType){
-		if( appDepType.getProjectAccount() != null ){
-			
+	private static void createJobIdentification(JobDefinitionType value,
+			HpcApplicationDeploymentType appDepType) {
+		if (appDepType.getProjectAccount() != null) {
+
 			if (appDepType.getProjectAccount().getProjectAccountNumber() != null)
 				JSDLUtils.addProjectName(value, appDepType.getProjectAccount()
 						.getProjectAccountNumber());
@@ -99,5 +162,5 @@ public class JSDLGenerator {
 								.getProjectAccountDescription());
 		}
 	}
-	
-}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/2b73d478/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/JSDLUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/JSDLUtils.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/JSDLUtils.java
index a5cd2a2..d2474f0 100644
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/JSDLUtils.java
+++ b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/JSDLUtils.java
@@ -74,7 +74,7 @@ public class JSDLUtils
 	public static final String NUMBEROFPROCESSES = "NumberOfProcesses";
 	public static final String THREADSPERHOST = "ThreadsPerHost";
 
-	
+
 	
 	public static EnvironmentType addEnvVariable(JobDefinitionType def,String name, String value) {
 		POSIXApplicationType posixApp = getOrCreatePOSIXApplication(def);
@@ -107,7 +107,7 @@ public class JSDLUtils
 
 	}
 	public static void addDataStagingTargetElement(JobDefinitionType value, String fileSystem, String file, String uri) {
-		addDataStagingTargetElement(value,fileSystem, file, uri, 0);
+		addDataStagingTargetElement(value,fileSystem, file, uri, 1);
 	}
 
 	public static void addDataStagingTargetElement(JobDefinitionType value, String fileSystem, String file, String uri, int flags) {
@@ -133,7 +133,7 @@ public class JSDLUtils
 	}
 
 	public static void addDataStagingSourceElement(JobDefinitionType value, String uri, String fileSystem, String file) {
-		addDataStagingSourceElement(value, uri, fileSystem, file, 0);
+		addDataStagingSourceElement(value, uri, fileSystem, file, 1);
 	}
 
 	public static void addDataStagingSourceElement(JobDefinitionType value, String uri, String fileSystem, String file, int flags) {
@@ -537,4 +537,4 @@ public class JSDLUtils
 		org.ggf.schemas.jsdl.x2005.x11.jsdl.RangeValueType totalCount = getOrCreateTotalResourceCount(value);   
 		setRangeValue(resourceCount, totalCount);
 	}
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/2b73d478/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/provider/impl/GramProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/provider/impl/GramProvider.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/provider/impl/GramProvider.java
index 142e492..2f22e0d 100644
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/provider/impl/GramProvider.java
+++ b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/provider/impl/GramProvider.java
@@ -186,8 +186,14 @@ public class GramProvider extends AbstractProvider {
                  * batch.
                 * The third boolean is to specify to use the full proxy and not delegate a limited proxy.
                 */
-                job.request(true, gateKeeper, false, false);
-
+//                job.request(true, gateKeeper, false, false);
+                
+            	
+            	// first boolean -> to run job as batch
+            	// second boolean -> to use limited proxy
+            	//TODO: need review?
+                job.request(gateKeeper, false, false);
+                
                 // Single boolean to track all authentication failures, therefore we need to re-initialize
                 // this here
                 renewCredentialsAttempt = false;
@@ -259,8 +265,14 @@ public class GramProvider extends AbstractProvider {
             * The third boolean is to specify to use the full proxy and not delegate a limited proxy.
             */
             try {
+                  
+//                job.request(true, gateKeeper, false, false);
+                
+            	// first boolean -> to run job as batch
+            	// second boolean -> to use limited proxy
+            	//TODO: need review?
+                job.request(gateKeeper, false, false);
 
-                job.request(true, gateKeeper, false, false);
                 renewCredentialsAttempt = false;
 
             } catch (GramException e) {


Mime
View raw message