airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject [19/51] [abbrv] git commit: changing package names of gfac implementations
Date Wed, 21 May 2014 17:56:33 GMT
changing package names of gfac implementations


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

Branch: refs/heads/temp
Commit: 9bb8c2befdfb242706c6bfe28e28b40e91227ff5
Parents: 0da5982
Author: lahiru <lahiru@apache.org>
Authored: Mon May 5 10:44:07 2014 -0400
Committer: lahiru <lahiru@apache.org>
Committed: Mon May 5 10:44:07 2014 -0400

----------------------------------------------------------------------
 .../server/src/main/resources/gfac-config.xml   |  40 +-
 .../gfac-bes/src/test/resources/gfac-config.xml |   9 +-
 .../context/security/GSISecurityContext.java    | 275 ---------
 .../apache/airavata/gfac/external/GridFtp.java  | 558 -------------------
 .../airavata/gfac/gram/external/GridFtp.java    | 558 +++++++++++++++++++
 .../gram/handler/GramDirectorySetupHandler.java | 139 +++++
 .../gfac/gram/handler/GridFTPInputHandler.java  | 207 +++++++
 .../gfac/gram/handler/GridFTPOutputHandler.java | 349 ++++++++++++
 .../airavata/gfac/gram/impl/GramProvider.java   | 527 ++++++++++++++++++
 .../persistence/DBJobPersistenceManager.java    | 225 ++++++++
 .../gfac/gram/security/GSISecurityContext.java  | 275 +++++++++
 .../gram/util/GramJobSubmissionListener.java    | 141 +++++
 .../gfac/gram/util/GramProviderUtils.java       | 113 ++++
 .../gfac/gram/util/GramRSLGenerator.java        | 211 +++++++
 .../gfac/gram/util/GridFTPContactInfo.java      |  61 ++
 .../gfac/handler/GramDirectorySetupHandler.java | 137 -----
 .../gfac/handler/GridFTPInputHandler.java       | 204 -------
 .../gfac/handler/GridFTPOutputHandler.java      | 347 ------------
 .../persistence/DBJobPersistenceManager.java    | 223 --------
 .../gfac/provider/impl/GramProvider.java        | 527 ------------------
 .../gfac/util/GramJobSubmissionListener.java    | 141 -----
 .../airavata/gfac/util/GramProviderUtils.java   | 114 ----
 .../airavata/gfac/util/GramRSLGenerator.java    | 211 -------
 .../airavata/gfac/util/GridFTPContactInfo.java  |  61 --
 .../impl/GFacBaseTestWithMyProxyAuth.java       |   2 +-
 .../impl/GramProviderTestWithMyProxyAuth.java   |   6 +-
 .../src/test/resources/gfac-config.xml          |  13 +-
 .../context/security/GSISecurityContext.java    | 288 ----------
 .../handler/GSISSHDirectorySetupHandler.java    | 103 ++++
 .../gfac/gsissh/handler/GSISSHInputHandler.java | 138 +++++
 .../gsissh/handler/GSISSHOutputHandler.java     | 221 ++++++++
 .../gfac/gsissh/impl/GSISSHProvider.java        | 138 +++++
 .../gsissh/security/GSISecurityContext.java     | 288 ++++++++++
 .../gfac/gsissh/util/GFACGSISSHUtils.java       | 192 +++++++
 .../handler/GSISSHDirectorySetupHandler.java    | 101 ----
 .../gfac/handler/GSISSHInputHandler.java        | 136 -----
 .../gfac/handler/GSISSHOutputHandler.java       | 219 --------
 .../gfac/provider/impl/GSISSHProvider.java      | 138 -----
 .../airavata/gfac/util/GFACGSISSHUtils.java     | 192 -------
 .../impl/GSISSHProviderTestWithMyProxyAuth.java |   2 +-
 .../GSISecurityContextTestWithMyProxyAuth.java  |   2 +-
 .../hadoop/handler/HDFSDataMovementHandler.java | 103 ++++
 .../hadoop/handler/HadoopDeploymentHandler.java | 276 +++++++++
 .../hadoop/provider/impl/HadoopProvider.java    | 154 +++++
 .../gfac/hadoop/provider/utils/HadoopUtils.java |  60 ++
 .../gfac/handler/HDFSDataMovementHandler.java   | 101 ----
 .../gfac/handler/HadoopDeploymentHandler.java   | 274 ---------
 .../gfac/provider/impl/HadoopProvider.java      | 154 -----
 .../gfac/provider/utils/HadoopUtils.java        |  60 --
 .../src/test/resources/gfac-config.xml          |  16 +-
 .../handler/LocalDirectorySetupHandler.java     |  61 --
 .../handler/LocalDirectorySetupHandler.java     |  63 +++
 .../airavata/gfac/local/impl/LocalProvider.java | 239 ++++++++
 .../local/utils/InputStreamToFileWriter.java    |  68 +++
 .../airavata/gfac/local/utils/InputUtils.java   |  39 ++
 .../gfac/local/utils/LocalProviderUtil.java     |  54 ++
 .../gfac/provider/impl/LocalProvider.java       | 239 --------
 .../gfac/utils/InputStreamToFileWriter.java     |  68 ---
 .../apache/airavata/gfac/utils/InputUtils.java  |  39 --
 .../airavata/gfac/utils/LocalProviderUtil.java  |  54 --
 .../gfac/services/impl/LocalProviderTest.java   |   4 +-
 .../src/test/resources/gfac-config.xml          |   4 +-
 .../impl/pull/qstat/ResourceConnection.java     |   8 +-
 .../context/security/SSHSecurityContext.java    | 120 ----
 .../gfac/handler/AdvancedSCPInputHandler.java   | 150 -----
 .../gfac/handler/AdvancedSCPOutputHandler.java  | 128 -----
 .../gfac/handler/SSHDirectorySetupHandler.java  | 105 ----
 .../airavata/gfac/handler/SSHInputHandler.java  | 141 -----
 .../airavata/gfac/handler/SSHOutputHandler.java | 218 --------
 .../gfac/provider/impl/SSHProvider.java         | 310 -----------
 .../ssh/handler/AdvancedSCPInputHandler.java    | 152 +++++
 .../ssh/handler/AdvancedSCPOutputHandler.java   | 130 +++++
 .../ssh/handler/SSHDirectorySetupHandler.java   | 107 ++++
 .../gfac/ssh/handler/SSHInputHandler.java       | 143 +++++
 .../gfac/ssh/handler/SSHOutputHandler.java      | 220 ++++++++
 .../airavata/gfac/ssh/impl/SSHProvider.java     | 310 +++++++++++
 .../gfac/ssh/security/SSHSecurityContext.java   | 120 ++++
 .../airavata/gfac/ssh/util/GFACSSHUtils.java    | 179 ++++++
 .../apache/airavata/gfac/util/GFACSSHUtils.java | 180 ------
 .../services/impl/BigRed2TestWithSSHAuth.java   |   3 +-
 .../impl/SSHProviderTestWithSSHAuth.java        |   2 +-
 .../gfac-ssh/src/test/resources/gfac-config.xml |  36 +-
 .../src/test/resources/gfac-config.xml          |  82 +--
 .../src/main/resources/gfac-config.xml          |  82 +--
 .../src/test/resources/gfac-config.xml          |  82 +--
 85 files changed, 6522 insertions(+), 6448 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/configuration/server/src/main/resources/gfac-config.xml
----------------------------------------------------------------------
diff --git a/modules/configuration/server/src/main/resources/gfac-config.xml b/modules/configuration/server/src/main/resources/gfac-config.xml
index 5b80367..0e95bc4 100644
--- a/modules/configuration/server/src/main/resources/gfac-config.xml
+++ b/modules/configuration/server/src/main/resources/gfac-config.xml
@@ -24,24 +24,24 @@
         </InHandlers>
         <OutHandlers></OutHandlers>
     </GlobalHandlers>
-    <Provider class="org.apache.airavata.gfac.provider.impl.LocalProvider" host="org.apache.airavata.schemas.gfac.impl.HostDescriptionTypeImpl">
+    <Provider class="org.apache.airavata.gfac.local.impl.LocalProvider" host="org.apache.airavata.schemas.gfac.impl.HostDescriptionTypeImpl">
         <InHandlers>
-            <Handler class="org.apache.airavata.gfac.handler.LocalDirectorySetupHandler"/>
+            <Handler class="org.apache.airavata.gfac.local.handler.LocalDirectorySetupHandler"/>
         </InHandlers>
     </Provider>
-   <Provider class="org.apache.airavata.gfac.provider.impl.GramProvider" host="org.apache.airavata.schemas.gfac.impl.GlobusHostTypeImpl">
+   <Provider class="org.apache.airavata.gfac.gram.provider.impl.GramProvider" host="org.apache.airavata.schemas.gfac.impl.GlobusHostTypeImpl">
         <property name="name" value="value"/>
         <InHandlers>
-            <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler">
+            <Handler class="org.apache.airavata.gfac..gram.handler.GramDirectorySetupHandler">
                     <property name="name" value="value"/>
             </Handler>
-            <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
+            <Handler class="org.apache.airavata.gfac..gram.handler.GridFTPInputHandler"/>
         </InHandlers>
         <OutHandlers>
-            <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
+            <Handler class="org.apache.airavata.gfac..gram.handler.GridFTPOutputHandler"/>
         </OutHandlers>
     </Provider>
-    <Provider class="org.apache.airavata.gfac.provider.impl.BESProvider" host="org.apache.airavata.schemas.gfac.impl.UnicoreHostTypeImpl">
+    <Provider class="org.apache.airavata.gfac.bes.provider.impl.BESProvider" host="org.apache.airavata.schemas.gfac.impl.UnicoreHostTypeImpl">
     </Provider>
 
     <Provider class="org.apache.airavata.gfac.ec2.EC2Provider" host="org.apache.airavata.schemas.gfac.impl.Ec2HostTypeImpl">
@@ -49,10 +49,10 @@
         <OutHandlers/>
     </Provider>
 
-    <Provider class="org.apache.airavata.gfac.provider.impl.HadoopProvider" host="org.apache.airavata.schemas.gfac.impl.HadoopHostTypeImpl">
+    <Provider class="org.apache.airavata.gfac.hadoop.provider.impl.HadoopProvider" host="org.apache.airavata.schemas.gfac.impl.HadoopHostTypeImpl">
         <InHandlers>
-        	<Handler class="org.apache.airavata.gfac.handler.HadoopDeploymentHandler"/>
-            <Handler class="org.apache.airavata.gfac.handler.HDFSDataMovementHandler"/>
+        	<Handler class="org.apache.airavata.gfac.hadoop.handler.HadoopDeploymentHandler"/>
+            <Handler class="org.apache.airavata.gfac.hadoop.handler.HDFSDataMovementHandler"/>
         </InHandlers>
         <OutHandlers/>
     </Provider>
@@ -60,25 +60,25 @@
     <Application name="UltraScan">
         <InHandlers>
             <Handler class="org.apache.airavata.gfac.handler.GfacDirectorySetupHandler"/>
-            <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
+            <Handler class="org.apache.airavata.gfac.gram.handler.GridFTPInputHandler"/>
         </InHandlers>
         <OutHandlers>
-            <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
+            <Handler class="org.apache.airavata.gfac.gram.handler.GridFTPOutputHandler"/>
         </OutHandlers>
     </Application>
 
-     <Provider class="org.apache.airavata.gfac.provider.impl.SSHProvider" host="org.apache.airavata.schemas.gfac.impl.SSHHostTypeImpl">
+     <Provider class="org.apache.airavata.gfac.ssh.provider.impl.SSHProvider" host="org.apache.airavata.schemas.gfac.impl.SSHHostTypeImpl">
          <InHandlers>
-            <Handler class="org.apache.airavata.gfac.handler.SSHDirectorySetupHandler"/>
-            <Handler class="org.apache.airavata.gfac.handler.SSHInputHandler"/>
+            <Handler class="org.apache.airavata.gfac.ssh.handler.SSHDirectorySetupHandler"/>
+            <Handler class="org.apache.airavata.gfac.ssh.handler.SSHInputHandler"/>
         </InHandlers>
         <OutHandlers>
-            <Handler class="org.apache.airavata.gfac.handler.SSHOutputHandler"/>
+            <Handler class="org.apache.airavata.gfac.ssh.handler.SSHOutputHandler"/>
         </OutHandlers>
     </Provider>
-    <Provider class="org.apache.airavata.gfac.provider.impl.GSISSHProvider" host="org.apache.airavata.schemas.gfac.impl.GsisshHostTypeImpl" executionMode="async">
+    <Provider class="org.apache.airavata.gfac.gsissh.provider.impl.GSISSHProvider" host="org.apache.airavata.schemas.gfac.impl.GsisshHostTypeImpl" executionMode="async">
              <InHandlers>
-                <Handler class="org.apache.airavata.gfac.handler.GSISSHDirectorySetupHandler"/>
+                <Handler class="org.apache.airavata.gfac.gsissh.handler.GSISSHDirectorySetupHandler"/>
                  <!--Handler class="org.apache.airavata.gfac.handler.AdvancedSCPInputHandler">
                             <property name="privateKeyPath" value="/Users/lahirugunathilake/.ssh/id_dsa"/>
                             <property name="publicKeyPath" value="/Users/lahirugunathilake/.ssh/id_dsa.pub"/>
@@ -88,10 +88,10 @@
                         <property name="passPhrase" value="/home/airavata/outputData"/>
                         <property name="password" value="/home/airavata/outputData"/> <either we have to set password or keys, password has higher preference>
                 </Handler-->
-                <Handler class="org.apache.airavata.gfac.handler.GSISSHInputHandler"/>
+                <Handler class="org.apache.airavata.gfac.gsissh.handler.GSISSHInputHandler"/>
             </InHandlers>
             <OutHandlers>
-                <Handler class="org.apache.airavata.gfac.handler.GSISSHOutputHandler"/>
+                <Handler class="org.apache.airavata.gfac.gsissh.handler.GSISSHOutputHandler"/>
                 <!--Handler class="org.apache.airavata.gfac.handler.AdvancedSCPOutputHandler">
                             <property name="privateKeyPath" value="/Users/lahirugunathilake/.ssh/id_dsa"/>
                             <property name="publicKeyPath" value="/Users/lahirugunathilake/.ssh/id_dsa.pub"/>

http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-bes/src/test/resources/gfac-config.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/test/resources/gfac-config.xml b/modules/gfac/gfac-bes/src/test/resources/gfac-config.xml
index 85d148d..0598356 100644
--- a/modules/gfac/gfac-bes/src/test/resources/gfac-config.xml
+++ b/modules/gfac/gfac-bes/src/test/resources/gfac-config.xml
@@ -21,13 +21,6 @@
     </GlobalHandlers>
 
 
-     <Provider class="org.apache.airavata.gfac.provider.impl.SSHProvider" host="org.apache.airavata.schemas.gfac.impl.SSHHostTypeImpl">
-         <InHandlers>
-            <Handler class="org.apache.airavata.gfac.handler.SSHDirectorySetupHandler"/>
-            <Handler class="org.apache.airavata.gfac.handler.SSHInputHandler"/>
-        </InHandlers>
-        <OutHandlers>
-            <Handler class="org.apache.airavata.gfac.handler.SSHOutputHandler"/>
-        </OutHandlers>
+     <Provider class="org.apache.airavata.gfac.bes.provider.impl.BESProvider" host="org.apache.airavata.schemas.gfac.impl.UnicoreHostTypeImpl">
     </Provider>
 </GFac>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java
deleted file mode 100644
index d8f58a1..0000000
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.gfac.context.security;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.credential.store.credential.Credential;
-import org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential;
-import org.apache.airavata.credential.store.store.CredentialReader;
-import org.apache.airavata.gfac.AbstractSecurityContext;
-import org.apache.airavata.gfac.Constants;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.RequestData;
-import org.globus.gsi.X509Credential;
-import org.globus.gsi.gssapi.GlobusGSSCredentialImpl;
-import org.globus.gsi.provider.GlobusProvider;
-import org.globus.myproxy.GetParams;
-import org.globus.myproxy.MyProxy;
-import org.globus.myproxy.MyProxyException;
-import org.gridforum.jgss.ExtendedGSSCredential;
-import org.ietf.jgss.GSSCredential;
-import org.ietf.jgss.GSSException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.security.Security;
-import java.security.cert.X509Certificate;
-
-/**
- * Handles GRID related security.
- */
-public class GSISecurityContext extends AbstractSecurityContext {
-
-    protected static final Logger log = LoggerFactory.getLogger(GSISecurityContext.class);
-    /*
-     * context name
-     */
-    public static final String GSI_SECURITY_CONTEXT = "gsi";
-
-    public static int CREDENTIAL_RENEWING_THRESH_HOLD = 10 * 90;
-
-    private GSSCredential gssCredentials = null;
-
-    // Set trusted cert path and add provider
-    static {
-        Security.addProvider(new GlobusProvider());
-        try {
-			setUpTrustedCertificatePath();
-		} catch (ApplicationSettingsException e) {
-			log.error(e.getLocalizedMessage(), e);
-		}
-    }
-
-    public static void setUpTrustedCertificatePath(String trustedCertificatePath) {
-
-        File file = new File(trustedCertificatePath);
-
-        if (!file.exists() || !file.canRead()) {
-            File f = new File(".");
-            log.info("Current directory " + f.getAbsolutePath());
-            throw new RuntimeException("Cannot read trusted certificate path " + trustedCertificatePath);
-        } else {
-            System.setProperty(Constants.TRUSTED_CERTIFICATE_SYSTEM_PROPERTY, file.getAbsolutePath());
-        }
-    }
-
-    private static void setUpTrustedCertificatePath() throws ApplicationSettingsException {
-
-        String trustedCertificatePath  = ServerSettings.getSetting(Constants.TRUSTED_CERT_LOCATION);
-
-        setUpTrustedCertificatePath(trustedCertificatePath);
-    }
-
-    /**
-     * Gets the trusted certificate path. Trusted certificate path is stored in "X509_CERT_DIR"
-     * system property.
-     * @return The trusted certificate path as a string.
-     */
-    public static String getTrustedCertificatePath() {
-        return System.getProperty(Constants.TRUSTED_CERTIFICATE_SYSTEM_PROPERTY);
-    }
-
-
-    public GSISecurityContext(CredentialReader credentialReader, RequestData requestData) {
-        super(credentialReader, requestData);
-    }
-
-
-
-    /**
-     * Gets GSSCredentials. The process is as follows;
-     * If credentials were queried for the first time create credentials.
-     *   1. Try creating credentials using certificates stored in the credential store
-     *   2. If 1 fails use user name and password to create credentials
-     * If credentials are already created check the remaining life time of the credential. If
-     * remaining life time is less than CREDENTIAL_RENEWING_THRESH_HOLD, then renew credentials.
-     * @return GSSCredentials to be used.
-     * @throws org.apache.airavata.gfac.GFacException If an error occurred while creating credentials.
-     * @throws org.apache.airavata.common.exception.ApplicationSettingsException
-     */
-    public GSSCredential getGssCredentials() throws GFacException, ApplicationSettingsException {
-
-        if (gssCredentials == null) {
-
-            try {
-                gssCredentials = getCredentialsFromStore();
-            } catch (Exception e) {
-                log.error("An exception occurred while retrieving credentials from the credential store. " +
-                        "Will continue with my proxy user name and password.", e);
-            }
-
-            // If store does not have credentials try to get from user name and password
-            if (gssCredentials == null) {
-                gssCredentials = getDefaultCredentials();
-            }
-
-            // if still null, throw an exception
-            if (gssCredentials == null) {
-                throw new GFacException("Unable to retrieve my proxy credentials to continue operation.");
-            }
-        } else {
-            try {
-                if (gssCredentials.getRemainingLifetime() < CREDENTIAL_RENEWING_THRESH_HOLD) {
-                    return renewCredentials();
-                }
-            } catch (GSSException e) {
-                throw new GFacException("Unable to retrieve remaining life time from credentials.", e);
-            }
-        }
-
-        return gssCredentials;
-    }
-
-    /**
-     * Renews credentials. First try to renew credentials as a trusted renewer. If that failed
-     * use user name and password to renew credentials.
-     * @return Renewed credentials.
-     * @throws org.apache.airavata.gfac.GFacException If an error occurred while renewing credentials.
-     * @throws org.apache.airavata.common.exception.ApplicationSettingsException
-     */
-    public GSSCredential renewCredentials() throws GFacException, ApplicationSettingsException {
-
-        // First try to renew credentials as a trusted renewer
-        try {
-            gssCredentials = renewCredentialsAsATrustedHost();
-        } catch (Exception e) {
-            log.warn("Renewing credentials as a trusted renewer failed", e);
-            gssCredentials = getProxyCredentials();
-        }
-
-        return gssCredentials;
-    }
-
-    /**
-     * Reads the credentials from credential store.
-     * @return If token is found in the credential store, will return a valid credential. Else returns null.
-     * @throws Exception If an error occurred while retrieving credentials.
-     */
-    public GSSCredential getCredentialsFromStore() throws Exception {
-
-        if (getCredentialReader() == null) {
-            return null;
-        }
-
-        Credential credential = getCredentialReader().getCredential(getRequestData().getGatewayId(),
-                getRequestData().getTokenId());
-
-        if (credential != null) {
-            if (credential instanceof CertificateCredential) {
-
-                log.info("Successfully found credentials for token id - " + getRequestData().getTokenId() +
-                        " gateway id - " + getRequestData().getGatewayId());
-
-                CertificateCredential certificateCredential = (CertificateCredential) credential;
-
-                X509Certificate[] certificates = certificateCredential.getCertificates();
-                X509Credential newCredential = new X509Credential(certificateCredential.getPrivateKey(), certificates);
-
-                GlobusGSSCredentialImpl cred = new GlobusGSSCredentialImpl(newCredential, GSSCredential.INITIATE_AND_ACCEPT);
-                System.out.print(cred.export(ExtendedGSSCredential.IMPEXP_OPAQUE));
-                return cred;
-                //return new GlobusGSSCredentialImpl(newCredential,
-                //        GSSCredential.INITIATE_AND_ACCEPT);
-            } else {
-                log.info("Credential type is not CertificateCredential. Cannot create mapping globus credentials. " +
-                        "Credential type - " + credential.getClass().getName());
-            }
-        } else {
-            log.info("Could not find credentials for token - " + getRequestData().getTokenId() + " and "
-                    + "gateway id - " + getRequestData().getGatewayId());
-        }
-
-        return null;
-    }
-
-    /**
-     * Gets the default proxy certificate.
-     * @return Default my proxy credentials.
-     * @throws org.apache.airavata.gfac.GFacException If an error occurred while retrieving credentials.
-     * @throws org.apache.airavata.common.exception.ApplicationSettingsException
-     */
-    public GSSCredential getDefaultCredentials() throws GFacException, ApplicationSettingsException{
-        MyProxy myproxy = new MyProxy(getRequestData().getMyProxyServerUrl(), getRequestData().getMyProxyPort());
-        try {
-            return myproxy.get(getRequestData().getMyProxyUserName(), getRequestData().getMyProxyPassword(),
-                    getRequestData().getMyProxyLifeTime());
-        } catch (MyProxyException e) {
-            throw new GFacException("An error occurred while retrieving default security credentials.", e);
-        }
-    }
-
-    /**
-     * Gets a new proxy certificate given current credentials.
-     * @return The short lived GSSCredentials
-     * @throws org.apache.airavata.gfac.GFacException If an error is occurred while retrieving credentials.
-     * @throws org.apache.airavata.common.exception.ApplicationSettingsException
-     */
-    public GSSCredential getProxyCredentials() throws GFacException, ApplicationSettingsException {
-
-        MyProxy myproxy = new MyProxy(getRequestData().getMyProxyServerUrl(), getRequestData().getMyProxyPort());
-        try {
-            return myproxy.get(gssCredentials, getRequestData().getMyProxyUserName(), getRequestData().getMyProxyPassword(),
-                    getRequestData().getMyProxyLifeTime());
-        } catch (MyProxyException e) {
-            throw new GFacException("An error occurred while renewing security credentials using user/password.", e);
-        }
-    }
-
-    /**
-     * Renew GSSCredentials.
-     * Before executing we need to add current host as a trusted renewer. Note to renew credentials
-     * we dont need user name and password.
-     * To do that execute following command
-     * > myproxy-logon -t <LIFETIME></LIFETIME> -s <MY PROXY SERVER> -l <USER NAME>
-     * E.g :- > myproxy-logon -t 264 -s myproxy.teragrid.org -l us3
-     *          Enter MyProxy pass phrase:
-     *          A credential has been received for user us3 in /tmp/x509up_u501.
-     * > myproxy-init -A --cert /tmp/x509up_u501 --key /tmp/x509up_u501 -l ogce -s myproxy.teragrid.org
-     * @return  Renewed credentials.
-     * @throws org.apache.airavata.gfac.GFacException If an error occurred while renewing credentials.
-     * @throws org.apache.airavata.common.exception.ApplicationSettingsException
-     */
-    public GSSCredential renewCredentialsAsATrustedHost() throws GFacException, ApplicationSettingsException {
-        MyProxy myproxy = new MyProxy(getRequestData().getMyProxyServerUrl(), getRequestData().getMyProxyPort());
-        GetParams getParams = new GetParams();
-        getParams.setAuthzCreds(gssCredentials);
-        getParams.setUserName(getRequestData().getMyProxyUserName());
-        getParams.setLifetime(getRequestData().getMyProxyLifeTime());
-        try {
-            return myproxy.get(gssCredentials, getParams);
-        } catch (MyProxyException e) {
-            throw new GFacException("An error occurred while renewing security credentials.", e);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/external/GridFtp.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/external/GridFtp.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/external/GridFtp.java
deleted file mode 100644
index 5be087e..0000000
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/external/GridFtp.java
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.gfac.external;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.Vector;
-
-import org.apache.airavata.gfac.Constants;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.ToolsException;
-import org.apache.airavata.gfac.util.GramProviderUtils;
-import org.apache.airavata.gfac.util.GridFTPContactInfo;
-import org.globus.ftp.DataChannelAuthentication;
-import org.globus.ftp.DataSourceStream;
-import org.globus.ftp.FileInfo;
-import org.globus.ftp.GridFTPClient;
-import org.globus.ftp.HostPort;
-import org.globus.ftp.Marker;
-import org.globus.ftp.MarkerListener;
-import org.globus.ftp.MlsxEntry;
-import org.globus.ftp.Session;
-import org.globus.ftp.exception.ClientException;
-import org.globus.ftp.exception.ServerException;
-import org.globus.gsi.gssapi.auth.HostAuthorization;
-import org.ietf.jgss.GSSCredential;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * GridFTP tools
- */
-public class GridFtp {
-    public static final Logger log = LoggerFactory.getLogger(GridFtp.class);
-
-    public static final String GSIFTP_SCHEME = "gsiftp";
-    public static final String HOST = "host";
-
-    /**
-     * Make directory at remote location
-     *
-     * @param destURI
-     * @param gssCred
-     * @throws ServerException
-     * @throws IOException
-     */
-    public void makeDir(URI destURI, GSSCredential gssCred) throws ToolsException {
-        GridFTPClient destClient = null;
-        GridFTPContactInfo destHost = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
-        try {
-
-            String destPath = destURI.getPath();
-            log.info(("Creating Directory = " + destHost + "=" + destPath));
-
-            destClient = new GridFTPClient(destHost.hostName, destHost.port);
-
-            int tryCount = 0;
-            while (true) {
-                try {
-                    destClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
-                    destClient.authenticate(gssCred);
-                    destClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
-
-                    if (!destClient.exists(destPath)) {
-                        destClient.makeDir(destPath);
-                    }
-                    break;
-                } catch (ServerException e) {
-                    tryCount++;
-                    if (tryCount >= 3) {
-                        throw new ToolsException(e.getMessage(), e);
-                    }
-                    Thread.sleep(10000);
-                } catch (IOException e) {
-                    tryCount++;
-                    if (tryCount >= 3) {
-                        throw new ToolsException(e.getMessage(), e);
-                    }
-                    Thread.sleep(10000);
-                }
-            }
-        } catch (ServerException e) {
-            throw new ToolsException("Cannot Create GridFTP Client to:" + destHost.toString(), e);
-        } catch (IOException e) {
-            throw new ToolsException("Cannot Create GridFTP Client to:" + destHost.toString(), e);
-        } catch (InterruptedException e) {
-            throw new ToolsException("Internal Error cannot sleep", e);
-        } finally {
-            if (destClient != null) {
-                try {
-                    destClient.close();
-                } catch (Exception e) {
-                    log.warn("Cannot close GridFTP client connection",e);
-                }
-            }
-        }
-    }
-
-    /**
-     * Upload file from stream
-     *
-     * @param destURI
-     * @param gsCredential
-     * @param io
-     * @throws GFacException
-     */
-    public void uploadFile(URI destURI, GSSCredential gsCredential, InputStream io) throws ToolsException {
-        GridFTPClient ftpClient = null;
-        GridFTPContactInfo contactInfo = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
-
-        try {
-
-            String remoteFile = destURI.getPath();
-            log.info("The remote file is " + remoteFile);
-
-            log.debug("Setup GridFTP Client");
-
-            ftpClient = new GridFTPClient(contactInfo.hostName, contactInfo.port);
-            ftpClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
-            ftpClient.authenticate(gsCredential);
-            ftpClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
-
-            log.info("Uploading file");
-            if (checkBinaryExtensions(remoteFile)) {
-                log.debug("Transfer mode is set to Binary for a file upload");
-                ftpClient.setType(Session.TYPE_IMAGE);
-            }
-
-            ftpClient.put(remoteFile, new DataSourceStream(io), new MarkerListener() {
-                public void markerArrived(Marker marker) {
-                }
-            });
-
-            log.info("Upload file to:" + remoteFile + " is done");
-
-        } catch (ServerException e) {
-            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
-        } catch (IOException e) {
-            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
-        } catch (ClientException e) {
-            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
-        } finally {
-            if (ftpClient != null) {
-                try {
-                    ftpClient.close();
-                } catch (Exception e) {
-                    log.warn("Cannot close GridFTP client connection",e);
-                }
-            }
-        }
-    }
-
-    public void uploadFile(URI srcURI,  URI destURI, GSSCredential gsCredential) throws ToolsException {
-        GridFTPClient srcClient = null;
-        GridFTPContactInfo destContactInfo = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
-        GridFTPContactInfo srcContactInfo = new GridFTPContactInfo(srcURI.getHost(),srcURI.getPort());
-        try {
-            String remoteFile = destURI.getPath();
-            log.info("The remote file is " + remoteFile);
-            log.debug("Setup GridFTP Client");
-            srcClient = new GridFTPClient(srcContactInfo.hostName, srcContactInfo.port);
-            srcClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
-            srcClient.authenticate(gsCredential);
-            srcClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
-
-            GridFTPClient destClient = new GridFTPClient(destContactInfo.hostName, destContactInfo.port);
-            destClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
-            destClient.authenticate(gsCredential);
-            destClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
-            log.debug("Uploading file");
-            if (checkBinaryExtensions(remoteFile)) {
-                log.debug("Transfer mode is set to Binary for a file upload");
-                srcClient.setType(Session.TYPE_IMAGE);
-            }
-
-            srcClient.transfer(srcURI.getPath(),destClient, remoteFile, false, null);
-
-            log.info("Upload file to:" + remoteFile + " is done");
-
-        } catch (ServerException e) {
-            throw new ToolsException("Cannot upload file to GridFTP:" + destContactInfo.toString(), e);
-        } catch (IOException e) {
-            throw new ToolsException("Cannot upload file to GridFTP:" + destContactInfo.toString(), e);
-        } catch (ClientException e) {
-            throw new ToolsException("Cannot upload file to GridFTP:" + destContactInfo.toString(), e);
-        } finally {
-            if (srcClient != null) {
-                try {
-                    srcClient.close();
-                } catch (Exception e) {
-                    log.warn("Cannot close GridFTP client connection",e);
-                }
-            }
-        }
-    }
-
-    /**
-     * Upload file to remote location
-     *
-     * @param destURI
-     * @param gsCredential
-     * @param localFile
-     * @throws GFacException
-     */
-    public void uploadFile(URI destURI, GSSCredential gsCredential, File localFile) throws ToolsException {
-        GridFTPClient ftpClient = null;
-        GridFTPContactInfo contactInfo = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
-        try {
-
-            String remoteFile = destURI.getPath();
-
-            log.info("The local temp file is " + localFile);
-            log.info("the remote file is " + remoteFile);
-
-            log.debug("Setup GridFTP Client");
-
-            ftpClient = new GridFTPClient(contactInfo.hostName, contactInfo.port);
-            ftpClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
-            ftpClient.authenticate(gsCredential);
-            ftpClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
-
-            log.debug("Uploading file");
-            if (checkBinaryExtensions(remoteFile)) {
-                log.debug("Transfer mode is set to Binary for a file upload");
-                ftpClient.setType(Session.TYPE_IMAGE);
-            }
-
-
-            ftpClient.put(localFile, remoteFile, false);
-
-            log.info("Upload file to:" + remoteFile + " is done");
-
-        } catch (ServerException e) {
-            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
-        } catch (IOException e) {
-            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
-        } catch (ClientException e) {
-            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
-        } finally {
-            if (ftpClient != null) {
-                try {
-                    ftpClient.close();
-                } catch (Exception e) {
-                    log.warn("Cannot close GridFTP client connection",e);
-                }
-            }
-        }
-    }
-
-    /**
-     * Download File from remote location
-     *
-     * @param destURI
-     * @param gsCredential
-     * @param localFile
-     * @throws GFacException
-     */
-    public void downloadFile(URI destURI, GSSCredential gsCredential, File localFile) throws ToolsException {
-        GridFTPClient ftpClient = null;
-        GridFTPContactInfo contactInfo = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
-        try {
-            String remoteFile = destURI.getPath();
-
-            log.info("The local temp file is " + localFile);
-            log.info("the remote file is " + remoteFile);
-
-            log.debug("Setup GridFTP Client");
-
-            ftpClient = new GridFTPClient(contactInfo.hostName, contactInfo.port);
-            ftpClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
-            ftpClient.authenticate(gsCredential);
-            ftpClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
-
-            log.debug("Downloading file");
-            if (checkBinaryExtensions(remoteFile)) {
-                log.debug("Transfer mode is set to Binary to download a file");
-                ftpClient.setType(Session.TYPE_IMAGE);
-            }
-
-            ftpClient.get(remoteFile, localFile);
-
-            log.info("Download file to:" + localFile + " is done");
-
-        } catch (ServerException e) {
-            throw new ToolsException("Cannot download file from GridFTP:" + contactInfo.toString(), e);
-        } catch (IOException e) {
-            throw new ToolsException("Cannot download file from GridFTP:" + contactInfo.toString(), e);
-        } catch (ClientException e) {
-            throw new ToolsException("Cannot download file from GridFTP:" + contactInfo.toString(), e);
-        } finally {
-            if (ftpClient != null) {
-                try {
-                    //ftpClient.close();
-                    ftpClient.close(false);
-                } catch (Exception e) {
-                    log.warn("Cannot close GridFTP client connection",e);
-                }
-            }
-        }
-    }
-
-    /**
-     * Stream remote file
-     *
-     * @param destURI
-     * @param gsCredential
-     * @param localFile
-     * @return
-     * @throws GFacException
-     */
-    public String readRemoteFile(URI destURI, GSSCredential gsCredential, File localFile) throws ToolsException {
-        BufferedReader instream = null;
-        File localTempfile = null;
-        try {
-
-            if (localFile == null) {
-                localTempfile = File.createTempFile("stderr", "err");
-            } else {
-                localTempfile = localFile;
-            }
-
-            log.info("Local temporary file:" + localTempfile);
-
-            downloadFile(destURI, gsCredential, localTempfile);
-
-            instream = new BufferedReader(new FileReader(localTempfile));
-            StringBuffer buff = new StringBuffer();
-            String temp = null;
-            while ((temp = instream.readLine()) != null) {
-                buff.append(temp);
-                buff.append(Constants.NEWLINE);
-            }
-
-            log.info("finish read file:" + localTempfile);
-
-            return buff.toString();
-        } catch (FileNotFoundException e) {
-            throw new ToolsException("Cannot read localfile file:" + localTempfile, e);
-        } catch (IOException e) {
-            throw new ToolsException("Cannot read localfile file:" + localTempfile, e);
-        } finally {
-            if (instream != null) {
-                try {
-                    instream.close();
-                } catch (Exception e) {
-                    log.warn("Cannot close GridFTP client connection",e);
-                }
-            }
-        }
-    }
-
-    /**
-     * Transfer data from one GridFTp Endpoint to another GridFTP Endpoint
-     *
-     * @param srchost
-     * @param desthost
-     * @param gssCred
-     * @param srcActive
-     * @throws ServerException
-     * @throws ClientException
-     * @throws IOException
-     */
-    public void transfer(URI srchost, URI desthost, GSSCredential gssCred, boolean srcActive) throws ToolsException {
-        GridFTPClient destClient = null;
-        GridFTPClient srcClient = null;
-
-        try {
-            destClient = new GridFTPClient(desthost.getHost(), desthost.getPort());
-            destClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
-            destClient.authenticate(gssCred);
-
-            if (checkBinaryExtensions(desthost.getPath())) {
-                log.debug("Transfer mode is set to Binary");
-                destClient.setType(Session.TYPE_IMAGE);
-            }
-
-            srcClient = new GridFTPClient(srchost.getHost(), srchost.getPort());
-            srcClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
-            srcClient.authenticate(gssCred);
-
-            if (checkBinaryExtensions(srchost.getPath())) {
-                log.debug("Transfer mode is set to Binary");
-                srcClient.setType(Session.TYPE_IMAGE);
-            }
-
-            if (srcActive) {
-                log.debug("Set src active");
-                HostPort hp = destClient.setPassive();
-                srcClient.setActive(hp);
-            } else {
-                log.debug("Set dst active");
-                HostPort hp = srcClient.setPassive();
-                destClient.setActive(hp);
-            }
-
-            log.debug("Start transfer file from GridFTP:" + srchost.toString() + " to " + desthost.toString());
-
-            /**
-             * Transfer a file. The transfer() function blocks until the transfer is complete.
-             */
-            srcClient.transfer(srchost.getPath(), destClient, desthost.getPath(), false, null);
-            if (srcClient.getSize(srchost.getPath()) == destClient.getSize(desthost.getPath())) {
-                log.debug("CHECK SUM OK");
-            } else {
-                log.debug("****CHECK SUM FAILED****");
-            }
-
-        } catch (ServerException e) {
-            throw new ToolsException("Cannot transfer file from GridFTP:" + srchost.toString() + " to "
-                    + desthost.toString(), e);
-        } catch (IOException e) {
-            throw new ToolsException("Cannot transfer file from GridFTP:" + srchost.toString() + " to "
-                    + desthost.toString(), e);
-        } catch (ClientException e) {
-            throw new ToolsException("Cannot transfer file from GridFTP:" + srchost.toString() + " to "
-                    + desthost.toString(), e);
-        } finally {
-            if (destClient != null) {
-                try {
-                    destClient.close();
-                } catch (Exception e) {
-                    log.warn("Cannot close GridFTP client connection at Desitnation:" + desthost.toString());
-                }
-            }
-            if (srcClient != null) {
-                try {
-                    srcClient.close();
-                } catch (Exception e) {
-                    log.warn("Cannot close GridFTP client connection at Source:" + srchost.toString(),e);
-                }
-            }
-        }
-    }
-
-	/**
-	 * List files in a GridFTP directory
-	 * @param dirURI
-	 * @param gssCred
-	 * @return
-	 * @throws ToolsException
-	 */
-    @SuppressWarnings("unchecked")
-	public List<String> listDir(URI dirURI, GSSCredential gssCred) throws ToolsException {
-    	List<String> files = new  ArrayList<String>();
-	    GridFTPClient srcClient = null;
-			try {
-				GridFTPContactInfo contactInfo = new GridFTPContactInfo(dirURI.getHost(), dirURI.getPort());
-
-				srcClient = new GridFTPClient(contactInfo.hostName, contactInfo.port);
-				srcClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
-				srcClient.authenticate(gssCred);
-				srcClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
-				srcClient.setType(Session.TYPE_ASCII);
-				srcClient.changeDir(dirURI.getPath());
-
-				Vector<Object> fileInfo = null;
-				try {
-					fileInfo = srcClient.mlsd();
-				} catch (Throwable e) {
-					fileInfo = srcClient.list();
-				}
-
-				if (!fileInfo.isEmpty()) {
-					for (int j = 0; j < fileInfo.size(); ++j) {
-						String name = null;
-						if (fileInfo.get(j) instanceof MlsxEntry) {
-							name = ((MlsxEntry) fileInfo.get(j)).getFileName();
-						} else if (fileInfo.get(j) instanceof FileInfo) {
-							name = ((FileInfo) fileInfo.get(j)).getName();
-						} else {
-							throw new ToolsException("Unsupported type returned by gridftp " + fileInfo.get(j));
-						}
-
-						if (!name.equals(".") && !name.equals("..")) {
-							URI uri = GramProviderUtils.createGsiftpURI(contactInfo.hostName, dirURI.getPath() + File.separator + name);
-							files.add(uri.getPath());
-						}
-					}
-				}
-				return files;
-			} catch (IOException e) {
-				throw new ToolsException("Could not list directory: " + dirURI.toString() ,e);
-			} catch (ServerException e) {
-				throw new ToolsException("Could not list directory: " + dirURI.toString() ,e);
-			} catch (ClientException e) {
-				throw new ToolsException("Could not list directory: " + dirURI.toString() ,e);
-			} catch (URISyntaxException e) {
-				throw new ToolsException("Error creating URL of listed files: " + dirURI.toString() ,e);
-			} finally {
-				if (srcClient != null) {
-	                try {
-	                    srcClient.close();
-	                } catch (Exception e) {
-	                    log.warn("Cannot close GridFTP client connection", e);
-	                }
-	            }
-		}
-	}
-    /**
-     * Method to check file extension as binary to set transfer type
-     * @param filePath
-     * @return
-     */
-    private static boolean checkBinaryExtensions(String filePath){
-        String extension = filePath.substring(filePath.lastIndexOf(".")+1,filePath.length());
-        Set<String> extensions = new HashSet<String>(Arrays.asList(new String[] {"tar","zip","gz","tgz"}));
-        if(extensions.contains(extension)){
-            return true;
-        }else{
-            return false;
-        }
-
-    }
-
-
-
-
-    public String gridFTPFileExist(URI inputDirectory,String fileName,GSSCredential gssCred) throws ToolsException {
-        List<String> strings = listDir(inputDirectory, gssCred);
-        for(String fileExist:strings){
-            if(fileName.equals(fileExist)) {
-                fileName = "duplicate_" + fileName;
-                return fileName;
-            }
-        }
-        return fileName;
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/external/GridFtp.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/external/GridFtp.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/external/GridFtp.java
new file mode 100644
index 0000000..fef9fad
--- /dev/null
+++ b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/external/GridFtp.java
@@ -0,0 +1,558 @@
+/*
+ *
+ * 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.gfac.gram.external;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+
+import org.apache.airavata.gfac.Constants;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.ToolsException;
+import org.apache.airavata.gfac.gram.util.GramProviderUtils;
+import org.apache.airavata.gfac.gram.util.GridFTPContactInfo;
+import org.globus.ftp.DataChannelAuthentication;
+import org.globus.ftp.DataSourceStream;
+import org.globus.ftp.FileInfo;
+import org.globus.ftp.GridFTPClient;
+import org.globus.ftp.HostPort;
+import org.globus.ftp.Marker;
+import org.globus.ftp.MarkerListener;
+import org.globus.ftp.MlsxEntry;
+import org.globus.ftp.Session;
+import org.globus.ftp.exception.ClientException;
+import org.globus.ftp.exception.ServerException;
+import org.globus.gsi.gssapi.auth.HostAuthorization;
+import org.ietf.jgss.GSSCredential;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * GridFTP tools
+ */
+public class GridFtp {
+    public static final Logger log = LoggerFactory.getLogger(GridFtp.class);
+
+    public static final String GSIFTP_SCHEME = "gsiftp";
+    public static final String HOST = "host";
+
+    /**
+     * Make directory at remote location
+     *
+     * @param destURI
+     * @param gssCred
+     * @throws ServerException
+     * @throws IOException
+     */
+    public void makeDir(URI destURI, GSSCredential gssCred) throws ToolsException {
+        GridFTPClient destClient = null;
+        GridFTPContactInfo destHost = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
+        try {
+
+            String destPath = destURI.getPath();
+            log.info(("Creating Directory = " + destHost + "=" + destPath));
+
+            destClient = new GridFTPClient(destHost.hostName, destHost.port);
+
+            int tryCount = 0;
+            while (true) {
+                try {
+                    destClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
+                    destClient.authenticate(gssCred);
+                    destClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
+
+                    if (!destClient.exists(destPath)) {
+                        destClient.makeDir(destPath);
+                    }
+                    break;
+                } catch (ServerException e) {
+                    tryCount++;
+                    if (tryCount >= 3) {
+                        throw new ToolsException(e.getMessage(), e);
+                    }
+                    Thread.sleep(10000);
+                } catch (IOException e) {
+                    tryCount++;
+                    if (tryCount >= 3) {
+                        throw new ToolsException(e.getMessage(), e);
+                    }
+                    Thread.sleep(10000);
+                }
+            }
+        } catch (ServerException e) {
+            throw new ToolsException("Cannot Create GridFTP Client to:" + destHost.toString(), e);
+        } catch (IOException e) {
+            throw new ToolsException("Cannot Create GridFTP Client to:" + destHost.toString(), e);
+        } catch (InterruptedException e) {
+            throw new ToolsException("Internal Error cannot sleep", e);
+        } finally {
+            if (destClient != null) {
+                try {
+                    destClient.close();
+                } catch (Exception e) {
+                    log.warn("Cannot close GridFTP client connection",e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Upload file from stream
+     *
+     * @param destURI
+     * @param gsCredential
+     * @param io
+     * @throws GFacException
+     */
+    public void uploadFile(URI destURI, GSSCredential gsCredential, InputStream io) throws ToolsException {
+        GridFTPClient ftpClient = null;
+        GridFTPContactInfo contactInfo = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
+
+        try {
+
+            String remoteFile = destURI.getPath();
+            log.info("The remote file is " + remoteFile);
+
+            log.debug("Setup GridFTP Client");
+
+            ftpClient = new GridFTPClient(contactInfo.hostName, contactInfo.port);
+            ftpClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
+            ftpClient.authenticate(gsCredential);
+            ftpClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
+
+            log.info("Uploading file");
+            if (checkBinaryExtensions(remoteFile)) {
+                log.debug("Transfer mode is set to Binary for a file upload");
+                ftpClient.setType(Session.TYPE_IMAGE);
+            }
+
+            ftpClient.put(remoteFile, new DataSourceStream(io), new MarkerListener() {
+                public void markerArrived(Marker marker) {
+                }
+            });
+
+            log.info("Upload file to:" + remoteFile + " is done");
+
+        } catch (ServerException e) {
+            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
+        } catch (IOException e) {
+            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
+        } catch (ClientException e) {
+            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
+        } finally {
+            if (ftpClient != null) {
+                try {
+                    ftpClient.close();
+                } catch (Exception e) {
+                    log.warn("Cannot close GridFTP client connection",e);
+                }
+            }
+        }
+    }
+
+    public void uploadFile(URI srcURI,  URI destURI, GSSCredential gsCredential) throws ToolsException {
+        GridFTPClient srcClient = null;
+        GridFTPContactInfo destContactInfo = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
+        GridFTPContactInfo srcContactInfo = new GridFTPContactInfo(srcURI.getHost(),srcURI.getPort());
+        try {
+            String remoteFile = destURI.getPath();
+            log.info("The remote file is " + remoteFile);
+            log.debug("Setup GridFTP Client");
+            srcClient = new GridFTPClient(srcContactInfo.hostName, srcContactInfo.port);
+            srcClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
+            srcClient.authenticate(gsCredential);
+            srcClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
+
+            GridFTPClient destClient = new GridFTPClient(destContactInfo.hostName, destContactInfo.port);
+            destClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
+            destClient.authenticate(gsCredential);
+            destClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
+            log.debug("Uploading file");
+            if (checkBinaryExtensions(remoteFile)) {
+                log.debug("Transfer mode is set to Binary for a file upload");
+                srcClient.setType(Session.TYPE_IMAGE);
+            }
+
+            srcClient.transfer(srcURI.getPath(),destClient, remoteFile, false, null);
+
+            log.info("Upload file to:" + remoteFile + " is done");
+
+        } catch (ServerException e) {
+            throw new ToolsException("Cannot upload file to GridFTP:" + destContactInfo.toString(), e);
+        } catch (IOException e) {
+            throw new ToolsException("Cannot upload file to GridFTP:" + destContactInfo.toString(), e);
+        } catch (ClientException e) {
+            throw new ToolsException("Cannot upload file to GridFTP:" + destContactInfo.toString(), e);
+        } finally {
+            if (srcClient != null) {
+                try {
+                    srcClient.close();
+                } catch (Exception e) {
+                    log.warn("Cannot close GridFTP client connection",e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Upload file to remote location
+     *
+     * @param destURI
+     * @param gsCredential
+     * @param localFile
+     * @throws GFacException
+     */
+    public void uploadFile(URI destURI, GSSCredential gsCredential, File localFile) throws ToolsException {
+        GridFTPClient ftpClient = null;
+        GridFTPContactInfo contactInfo = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
+        try {
+
+            String remoteFile = destURI.getPath();
+
+            log.info("The local temp file is " + localFile);
+            log.info("the remote file is " + remoteFile);
+
+            log.debug("Setup GridFTP Client");
+
+            ftpClient = new GridFTPClient(contactInfo.hostName, contactInfo.port);
+            ftpClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
+            ftpClient.authenticate(gsCredential);
+            ftpClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
+
+            log.debug("Uploading file");
+            if (checkBinaryExtensions(remoteFile)) {
+                log.debug("Transfer mode is set to Binary for a file upload");
+                ftpClient.setType(Session.TYPE_IMAGE);
+            }
+
+
+            ftpClient.put(localFile, remoteFile, false);
+
+            log.info("Upload file to:" + remoteFile + " is done");
+
+        } catch (ServerException e) {
+            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
+        } catch (IOException e) {
+            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
+        } catch (ClientException e) {
+            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
+        } finally {
+            if (ftpClient != null) {
+                try {
+                    ftpClient.close();
+                } catch (Exception e) {
+                    log.warn("Cannot close GridFTP client connection",e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Download File from remote location
+     *
+     * @param destURI
+     * @param gsCredential
+     * @param localFile
+     * @throws GFacException
+     */
+    public void downloadFile(URI destURI, GSSCredential gsCredential, File localFile) throws ToolsException {
+        GridFTPClient ftpClient = null;
+        GridFTPContactInfo contactInfo = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
+        try {
+            String remoteFile = destURI.getPath();
+
+            log.info("The local temp file is " + localFile);
+            log.info("the remote file is " + remoteFile);
+
+            log.debug("Setup GridFTP Client");
+
+            ftpClient = new GridFTPClient(contactInfo.hostName, contactInfo.port);
+            ftpClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
+            ftpClient.authenticate(gsCredential);
+            ftpClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
+
+            log.debug("Downloading file");
+            if (checkBinaryExtensions(remoteFile)) {
+                log.debug("Transfer mode is set to Binary to download a file");
+                ftpClient.setType(Session.TYPE_IMAGE);
+            }
+
+            ftpClient.get(remoteFile, localFile);
+
+            log.info("Download file to:" + localFile + " is done");
+
+        } catch (ServerException e) {
+            throw new ToolsException("Cannot download file from GridFTP:" + contactInfo.toString(), e);
+        } catch (IOException e) {
+            throw new ToolsException("Cannot download file from GridFTP:" + contactInfo.toString(), e);
+        } catch (ClientException e) {
+            throw new ToolsException("Cannot download file from GridFTP:" + contactInfo.toString(), e);
+        } finally {
+            if (ftpClient != null) {
+                try {
+                    //ftpClient.close();
+                    ftpClient.close(false);
+                } catch (Exception e) {
+                    log.warn("Cannot close GridFTP client connection",e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Stream remote file
+     *
+     * @param destURI
+     * @param gsCredential
+     * @param localFile
+     * @return
+     * @throws GFacException
+     */
+    public String readRemoteFile(URI destURI, GSSCredential gsCredential, File localFile) throws ToolsException {
+        BufferedReader instream = null;
+        File localTempfile = null;
+        try {
+
+            if (localFile == null) {
+                localTempfile = File.createTempFile("stderr", "err");
+            } else {
+                localTempfile = localFile;
+            }
+
+            log.info("Local temporary file:" + localTempfile);
+
+            downloadFile(destURI, gsCredential, localTempfile);
+
+            instream = new BufferedReader(new FileReader(localTempfile));
+            StringBuffer buff = new StringBuffer();
+            String temp = null;
+            while ((temp = instream.readLine()) != null) {
+                buff.append(temp);
+                buff.append(Constants.NEWLINE);
+            }
+
+            log.info("finish read file:" + localTempfile);
+
+            return buff.toString();
+        } catch (FileNotFoundException e) {
+            throw new ToolsException("Cannot read localfile file:" + localTempfile, e);
+        } catch (IOException e) {
+            throw new ToolsException("Cannot read localfile file:" + localTempfile, e);
+        } finally {
+            if (instream != null) {
+                try {
+                    instream.close();
+                } catch (Exception e) {
+                    log.warn("Cannot close GridFTP client connection",e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Transfer data from one GridFTp Endpoint to another GridFTP Endpoint
+     *
+     * @param srchost
+     * @param desthost
+     * @param gssCred
+     * @param srcActive
+     * @throws ServerException
+     * @throws ClientException
+     * @throws IOException
+     */
+    public void transfer(URI srchost, URI desthost, GSSCredential gssCred, boolean srcActive) throws ToolsException {
+        GridFTPClient destClient = null;
+        GridFTPClient srcClient = null;
+
+        try {
+            destClient = new GridFTPClient(desthost.getHost(), desthost.getPort());
+            destClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
+            destClient.authenticate(gssCred);
+
+            if (checkBinaryExtensions(desthost.getPath())) {
+                log.debug("Transfer mode is set to Binary");
+                destClient.setType(Session.TYPE_IMAGE);
+            }
+
+            srcClient = new GridFTPClient(srchost.getHost(), srchost.getPort());
+            srcClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
+            srcClient.authenticate(gssCred);
+
+            if (checkBinaryExtensions(srchost.getPath())) {
+                log.debug("Transfer mode is set to Binary");
+                srcClient.setType(Session.TYPE_IMAGE);
+            }
+
+            if (srcActive) {
+                log.debug("Set src active");
+                HostPort hp = destClient.setPassive();
+                srcClient.setActive(hp);
+            } else {
+                log.debug("Set dst active");
+                HostPort hp = srcClient.setPassive();
+                destClient.setActive(hp);
+            }
+
+            log.debug("Start transfer file from GridFTP:" + srchost.toString() + " to " + desthost.toString());
+
+            /**
+             * Transfer a file. The transfer() function blocks until the transfer is complete.
+             */
+            srcClient.transfer(srchost.getPath(), destClient, desthost.getPath(), false, null);
+            if (srcClient.getSize(srchost.getPath()) == destClient.getSize(desthost.getPath())) {
+                log.debug("CHECK SUM OK");
+            } else {
+                log.debug("****CHECK SUM FAILED****");
+            }
+
+        } catch (ServerException e) {
+            throw new ToolsException("Cannot transfer file from GridFTP:" + srchost.toString() + " to "
+                    + desthost.toString(), e);
+        } catch (IOException e) {
+            throw new ToolsException("Cannot transfer file from GridFTP:" + srchost.toString() + " to "
+                    + desthost.toString(), e);
+        } catch (ClientException e) {
+            throw new ToolsException("Cannot transfer file from GridFTP:" + srchost.toString() + " to "
+                    + desthost.toString(), e);
+        } finally {
+            if (destClient != null) {
+                try {
+                    destClient.close();
+                } catch (Exception e) {
+                    log.warn("Cannot close GridFTP client connection at Desitnation:" + desthost.toString());
+                }
+            }
+            if (srcClient != null) {
+                try {
+                    srcClient.close();
+                } catch (Exception e) {
+                    log.warn("Cannot close GridFTP client connection at Source:" + srchost.toString(),e);
+                }
+            }
+        }
+    }
+
+	/**
+	 * List files in a GridFTP directory
+	 * @param dirURI
+	 * @param gssCred
+	 * @return
+	 * @throws ToolsException
+	 */
+    @SuppressWarnings("unchecked")
+	public List<String> listDir(URI dirURI, GSSCredential gssCred) throws ToolsException {
+    	List<String> files = new  ArrayList<String>();
+	    GridFTPClient srcClient = null;
+			try {
+				GridFTPContactInfo contactInfo = new GridFTPContactInfo(dirURI.getHost(), dirURI.getPort());
+
+				srcClient = new GridFTPClient(contactInfo.hostName, contactInfo.port);
+				srcClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
+				srcClient.authenticate(gssCred);
+				srcClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
+				srcClient.setType(Session.TYPE_ASCII);
+				srcClient.changeDir(dirURI.getPath());
+
+				Vector<Object> fileInfo = null;
+				try {
+					fileInfo = srcClient.mlsd();
+				} catch (Throwable e) {
+					fileInfo = srcClient.list();
+				}
+
+				if (!fileInfo.isEmpty()) {
+					for (int j = 0; j < fileInfo.size(); ++j) {
+						String name = null;
+						if (fileInfo.get(j) instanceof MlsxEntry) {
+							name = ((MlsxEntry) fileInfo.get(j)).getFileName();
+						} else if (fileInfo.get(j) instanceof FileInfo) {
+							name = ((FileInfo) fileInfo.get(j)).getName();
+						} else {
+							throw new ToolsException("Unsupported type returned by gridftp " + fileInfo.get(j));
+						}
+
+						if (!name.equals(".") && !name.equals("..")) {
+							URI uri = GramProviderUtils.createGsiftpURI(contactInfo.hostName, dirURI.getPath() + File.separator + name);
+							files.add(uri.getPath());
+						}
+					}
+				}
+				return files;
+			} catch (IOException e) {
+				throw new ToolsException("Could not list directory: " + dirURI.toString() ,e);
+			} catch (ServerException e) {
+				throw new ToolsException("Could not list directory: " + dirURI.toString() ,e);
+			} catch (ClientException e) {
+				throw new ToolsException("Could not list directory: " + dirURI.toString() ,e);
+			} catch (URISyntaxException e) {
+				throw new ToolsException("Error creating URL of listed files: " + dirURI.toString() ,e);
+			} finally {
+				if (srcClient != null) {
+	                try {
+	                    srcClient.close();
+	                } catch (Exception e) {
+	                    log.warn("Cannot close GridFTP client connection", e);
+	                }
+	            }
+		}
+	}
+    /**
+     * Method to check file extension as binary to set transfer type
+     * @param filePath
+     * @return
+     */
+    private static boolean checkBinaryExtensions(String filePath){
+        String extension = filePath.substring(filePath.lastIndexOf(".")+1,filePath.length());
+        Set<String> extensions = new HashSet<String>(Arrays.asList(new String[] {"tar","zip","gz","tgz"}));
+        if(extensions.contains(extension)){
+            return true;
+        }else{
+            return false;
+        }
+
+    }
+
+
+
+
+    public String gridFTPFileExist(URI inputDirectory,String fileName,GSSCredential gssCred) throws ToolsException {
+        List<String> strings = listDir(inputDirectory, gssCred);
+        for(String fileExist:strings){
+            if(fileName.equals(fileExist)) {
+                fileName = "duplicate_" + fileName;
+                return fileName;
+            }
+        }
+        return fileName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/handler/GramDirectorySetupHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/handler/GramDirectorySetupHandler.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/handler/GramDirectorySetupHandler.java
new file mode 100644
index 0000000..76fa2db
--- /dev/null
+++ b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/handler/GramDirectorySetupHandler.java
@@ -0,0 +1,139 @@
+/*
+ *
+ * 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.gfac.gram.handler;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.gram.security.GSISecurityContext;
+import org.apache.airavata.gfac.gram.external.GridFtp;
+import org.apache.airavata.gfac.gram.util.GramProviderUtils;
+import org.apache.airavata.gfac.handler.AbstractHandler;
+import org.apache.airavata.gfac.handler.GFacHandlerException;
+import org.apache.airavata.gfac.utils.GFacUtils;
+import org.apache.airavata.model.workspace.experiment.CorrectiveAction;
+import org.apache.airavata.model.workspace.experiment.DataTransferDetails;
+import org.apache.airavata.model.workspace.experiment.ErrorCategory;
+import org.apache.airavata.model.workspace.experiment.TransferState;
+import org.apache.airavata.model.workspace.experiment.TransferStatus;
+import org.apache.airavata.registry.cpi.ChildDataType;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.apache.airavata.schemas.gfac.GlobusHostType;
+import org.apache.airavata.schemas.gfac.HostDescriptionType;
+import org.apache.airavata.schemas.gfac.UnicoreHostType;
+import org.ietf.jgss.GSSCredential;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class  GramDirectorySetupHandler extends AbstractHandler {
+    private static final Logger log = LoggerFactory.getLogger(GramDirectorySetupHandler.class);
+   
+    public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
+        log.info("Invoking GramDirectorySetupHandler ...");
+        super.invoke(jobExecutionContext);
+        String[] gridFTPEndpointArray = null;
+
+        //TODO: why it is tightly coupled with gridftp
+//        GlobusHostType host = (GlobusHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType();
+
+        //TODO: make it more reusable
+        HostDescriptionType hostType = jobExecutionContext.getApplicationContext().getHostDescription().getType();
+
+
+
+        if(hostType instanceof GlobusHostType){
+        	gridFTPEndpointArray = ((GlobusHostType) hostType).getGridFTPEndPointArray();
+        }
+        else if (hostType instanceof UnicoreHostType){
+        	gridFTPEndpointArray = ((UnicoreHostType) hostType).getGridFTPEndPointArray();
+        }
+        
+
+
+        ApplicationDescription applicationDeploymentDescription = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription();
+        ApplicationDeploymentDescriptionType app = applicationDeploymentDescription.getType();
+        GridFtp ftp = new GridFtp();
+
+        try {
+
+            GSSCredential gssCred = ((GSISecurityContext)jobExecutionContext.
+                    getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getGssCredentials();
+
+            if (gridFTPEndpointArray == null || gridFTPEndpointArray.length == 0) {
+            	gridFTPEndpointArray = new String[]{hostType.getHostAddress()};
+            }
+            boolean success = false;
+            GFacHandlerException pe = null;// = new ProviderException("");
+            for (String endpoint : gridFTPEndpointArray) {
+                try {
+
+                    URI tmpdirURI = GramProviderUtils.createGsiftpURI(endpoint, app.getScratchWorkingDirectory());
+                    URI workingDirURI = GramProviderUtils.createGsiftpURI(endpoint, app.getStaticWorkingDirectory());
+                    URI inputURI = GramProviderUtils.createGsiftpURI(endpoint, app.getInputDataDirectory());
+                    URI outputURI = GramProviderUtils.createGsiftpURI(endpoint, app.getOutputDataDirectory());
+
+                    log.info("Host FTP = " + gridFTPEndpointArray[0]);
+                    log.info("temp directory = " + tmpdirURI);
+                    log.info("Working directory = " + workingDirURI);
+                    log.info("Input directory = " + inputURI);
+                    log.info("Output directory = " + outputURI);
+                    ftp.makeDir(tmpdirURI, gssCred);
+                    ftp.makeDir(workingDirURI, gssCred);
+                    ftp.makeDir(inputURI, gssCred);
+                    ftp.makeDir(outputURI, gssCred);
+                    success = true;
+                    DataTransferDetails detail = new DataTransferDetails();
+                    TransferStatus status = new TransferStatus();
+                    status.setTransferState(TransferState.DIRECTORY_SETUP);
+                    detail.setTransferStatus(status);
+                    detail.setTransferDescription("Working directory = " + workingDirURI);
+                    registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
+                                  
+                    break;
+                } catch (URISyntaxException e) {
+                    pe = new GFacHandlerException("URI is malformatted:" + e.getMessage(), e);
+
+                } catch (Exception e) {
+              	pe = new GFacHandlerException(e.getMessage(), e);
+                }
+            }
+            if (success == false) {
+            	GFacUtils.saveErrorDetails(jobExecutionContext, pe.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
+        		throw pe;
+            }
+        } catch (SecurityException e) {
+            throw new GFacHandlerException(e.getMessage(), e);
+        } catch (ApplicationSettingsException e1) {
+        	throw new GFacHandlerException(e1.getMessage(), e1);
+		} catch (GFacException e) {
+            throw new GFacHandlerException(e);
+        }
+    }
+
+    public void initProperties(Map<String, String> properties) throws GFacHandlerException {
+
+    }
+}


Mime
View raw message