airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From patanac...@apache.org
Subject svn commit: r1166875 [1/2] - in /incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac: context/message/impl/ context/security/impl/ context/security/impl/utils/ exception/ extension/ extension/data/ extension/post/ ext...
Date Thu, 08 Sep 2011 19:46:03 GMT
Author: patanachai
Date: Thu Sep  8 19:46:01 2011
New Revision: 1166875

URL: http://svn.apache.org/viewvc?rev=1166875&view=rev
Log:
Redefine Exception

Added:
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ExtensionException.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ProviderException.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/SchedulerException.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/SecurityException.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ServiceException.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ToolsException.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/GridFTPContactInfo.java
      - copied, changed from r1166775, incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/ContactInfo.java
Modified:
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/ParameterContextImpl.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/security/impl/GSISecurityContext.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/security/impl/utils/MyProxyManager.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/GfacException.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/JobSubmissionFault.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/Chain.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/ExitableChain.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/post/GridFtpOutputStaging.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/pre/GridFtpInputStaging.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/pre/HttpInputStaging.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/external/GridFtp.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/factory/AbstractServiceFactory.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/EC2Provider.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/GramProvider.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/LocalProvider.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/Provider.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/SSHProvider.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/GramRSLGenerator.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/JobSubmissionListener.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/registry/
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/Scheduler.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/POJOSchedulerImpl.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/AbstractSimpleService.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/POJOServiceImpl.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/ContactInfo.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/GFacConstants.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/utils/GfacUtils.java

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/ParameterContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/ParameterContextImpl.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/ParameterContextImpl.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/ParameterContextImpl.java Thu Sep  8 19:46:01 2011
@@ -28,6 +28,9 @@ import java.util.Map;
 import org.apache.airavata.commons.gfac.type.parameter.AbstractParameter;
 import org.apache.airavata.core.gfac.context.message.MessageContext;
 
+/**
+ * This class contains actual parameters in service invocation.
+ */
 public class ParameterContextImpl implements MessageContext<AbstractParameter> {
 
     private Map<String, AbstractParameter> value;

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/security/impl/GSISecurityContext.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/security/impl/GSISecurityContext.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/security/impl/GSISecurityContext.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/security/impl/GSISecurityContext.java Thu Sep  8 19:46:01 2011
@@ -23,11 +23,9 @@ package org.apache.airavata.core.gfac.co
 
 import org.apache.airavata.core.gfac.context.security.SecurityContext;
 import org.apache.airavata.core.gfac.context.security.impl.utils.MyProxyManager;
-import org.apache.airavata.core.gfac.exception.GfacException;
-import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
+import org.apache.airavata.core.gfac.exception.SecurityException;
 import org.globus.tools.MyProxy;
 import org.ietf.jgss.GSSCredential;
-import org.ietf.jgss.GSSException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -53,7 +51,7 @@ public class GSISecurityContext implemen
 
     }
 
-    public GSSCredential getGssCredentails() throws GfacException, GSSException {
+    public GSSCredential getGssCredentails() throws SecurityException {
         try {
             System.out.println(gssCredentails);
             if (gssCredentails == null || gssCredentails.getRemainingLifetime() < 10 * 90) {
@@ -68,7 +66,7 @@ public class GSISecurityContext implemen
             }
             return gssCredentails;
         } catch (Exception e) {
-            throw new GfacException(e, FaultCode.ErrorAtDependentService);
+            throw new SecurityException(e.getMessage(), e);
         }
     }
 

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/security/impl/utils/MyProxyManager.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/security/impl/utils/MyProxyManager.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/security/impl/utils/MyProxyManager.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/security/impl/utils/MyProxyManager.java Thu Sep  8 19:46:01 2011
@@ -22,18 +22,13 @@
 package org.apache.airavata.core.gfac.context.security.impl.utils;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
-import java.io.IOException;
 import java.util.UUID;
 
-import org.apache.airavata.core.gfac.exception.GfacException;
-import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
 import org.globus.gsi.GlobusCredential;
 import org.globus.gsi.TrustedCertificates;
 import org.globus.gsi.gssapi.GlobusGSSCredentialImpl;
 import org.globus.myproxy.MyProxy;
-import org.globus.myproxy.MyProxyException;
 import org.ietf.jgss.GSSCredential;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -75,51 +70,43 @@ public class MyProxyManager {
         }
     }
 
-    public GSSCredential renewProxy() throws GfacException {
+    public GSSCredential renewProxy() throws Exception {
 
-        try {
-            init();
-            String proxyloc = null;
-            MyProxy myproxy = new MyProxy(hostname, port);
-            GSSCredential proxy = myproxy.get(username, password, lifetime);
-            GlobusCredential globusCred = null;
-            if (proxy instanceof GlobusGSSCredentialImpl) {
-                globusCred = ((GlobusGSSCredentialImpl) proxy).getGlobusCredential();
-                log.info("got proxy from myproxy for " + username + " with " + lifetime + " lifetime.");
-                String uid = username;
-                if (proxyloc == null) {
-                    // uid = XpolaUtil.getSysUserid();
-                    log.info("uid: " + uid);
-                    proxyloc = "/tmp/x509up_u" + uid + UUID.randomUUID().toString();
-                }
-                log.info("proxy location: " + proxyloc);
-                File proxyfile = new File(proxyloc);
-                if (proxyfile.exists() == false) {
-                    String dirpath = proxyloc.substring(0, proxyloc.lastIndexOf('/'));
-                    File dir = new File(dirpath);
-                    if (dir.exists() == false) {
-                        dir.mkdirs();
-                        log.info("new directory " + dirpath + " is created.");
-                    }
-                    proxyfile.createNewFile();
-                    log.info("new proxy file " + proxyloc + " is created.");
+        init();
+        String proxyloc = null;
+        MyProxy myproxy = new MyProxy(hostname, port);
+        GSSCredential proxy = myproxy.get(username, password, lifetime);
+        GlobusCredential globusCred = null;
+        if (proxy instanceof GlobusGSSCredentialImpl) {
+            globusCred = ((GlobusGSSCredentialImpl) proxy).getGlobusCredential();
+            log.info("got proxy from myproxy for " + username + " with " + lifetime + " lifetime.");
+            String uid = username;
+            if (proxyloc == null) {
+                // uid = XpolaUtil.getSysUserid();
+                log.info("uid: " + uid);
+                proxyloc = "/tmp/x509up_u" + uid + UUID.randomUUID().toString();
+            }
+            log.info("proxy location: " + proxyloc);
+            File proxyfile = new File(proxyloc);
+            if (proxyfile.exists() == false) {
+                String dirpath = proxyloc.substring(0, proxyloc.lastIndexOf('/'));
+                File dir = new File(dirpath);
+                if (dir.exists() == false) {
+                    dir.mkdirs();
+                    log.info("new directory " + dirpath + " is created.");
                 }
-                FileOutputStream fout = new FileOutputStream(proxyfile);
-                globusCred.save(fout);
-                fout.close();
-                Runtime.getRuntime().exec("/bin/chmod 600 " + proxyloc);
-                log.info("Proxy file renewed to " + proxyloc + " for the user " + username + " with " + lifetime
-                        + " lifetime.");
-
+                proxyfile.createNewFile();
+                log.info("new proxy file " + proxyloc + " is created.");
             }
-            return proxy;
-        } catch (MyProxyException e) {
-            throw new GfacException(e, FaultCode.ErrorAtDependentService);
-        } catch (FileNotFoundException e) {
-            throw new GfacException(e, FaultCode.LocalError);
-        } catch (IOException e) {
-            throw new GfacException(e, FaultCode.LocalError);
+            FileOutputStream fout = new FileOutputStream(proxyfile);
+            globusCred.save(fout);
+            fout.close();
+            Runtime.getRuntime().exec("/bin/chmod 600 " + proxyloc);
+            log.info("Proxy file renewed to " + proxyloc + " for the user " + username + " with " + lifetime
+                    + " lifetime.");
+
         }
+        return proxy;
     }
 
 }

Added: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ExtensionException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ExtensionException.java?rev=1166875&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ExtensionException.java (added)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ExtensionException.java Thu Sep  8 19:46:01 2011
@@ -0,0 +1,33 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.core.gfac.exception;
+
+public class ExtensionException extends GfacException {
+
+    public ExtensionException(String message) {
+        super(message);
+    }
+    
+    public ExtensionException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/GfacException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/GfacException.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/GfacException.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/GfacException.java Thu Sep  8 19:46:01 2011
@@ -21,45 +21,17 @@
 
 package org.apache.airavata.core.gfac.exception;
 
-
 public class GfacException extends Exception {
 
-    public static enum FaultCode {
-        ServiceNotReachable, InvalidRequest, InternalServiceError, ErrorAtDependentService, ErrorAtClientBeforeWsCall, ErrorAtClientWhileWsCall, ErrorAtClientAfterWsCall, InitalizationError, UnsupportedMessage, InvaliedLocalArgumnet, LocalError, CmdAppError, ErrorAtCreatedService, InvalidConfig, Unknown, InvaliedResponse, JobSubmissionFailed
-    };
-
     private static final long serialVersionUID = 1L;
 
     protected String faultCode;
 
-    public GfacException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public GfacException(String message, Throwable cause, FaultCode faultCode) {
-        super(message, cause);
-        this.faultCode = faultCode.toString();
-    }
-
-    public GfacException(String message, FaultCode faultCode) {
+    public GfacException(String message) {
         super(message);
-        this.faultCode = faultCode.toString();
-    }
-
-    public GfacException(Throwable cause, FaultCode faultCode) {
-        super(cause);
-        if (cause instanceof GfacException) {
-            GfacException gfacExeption = (GfacException) cause;
-            setFaultCode(gfacExeption.getFaultCode());
-        }
-        this.faultCode = faultCode.toString();
     }
-
-    public String getFaultCode() {
-        return faultCode != null ? faultCode : getMessage();
+    
+    public GfacException(String message, Throwable cause) {
+        super(message, cause);
     }
-
-    public void setFaultCode(String faultCode) {
-        this.faultCode = faultCode;
-    }   
 }

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/JobSubmissionFault.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/JobSubmissionFault.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/JobSubmissionFault.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/JobSubmissionFault.java Thu Sep  8 19:46:01 2011
@@ -23,8 +23,19 @@ package org.apache.airavata.core.gfac.ex
 
 import org.apache.airavata.core.gfac.provider.Provider;
 
-public class JobSubmissionFault extends GfacException {
-    public JobSubmissionFault(Throwable cause, String submitHost, String contact, String rsl, Provider api) {
-        super(cause, FaultCode.ErrorAtDependentService);
+public class JobSubmissionFault extends ProviderException {
+    
+    public static final String JOB_CANCEL = "JOB_CANCEL";
+    
+    public static final String JOB_FAILED = "JOB_FAILED";
+    
+    private String reason;
+    
+    public JobSubmissionFault(Provider provider, Throwable cause, String submitHost, String contact, String rsl) {
+        super(cause.getMessage(), cause);
+    }
+    
+    public void setReason(String reason){
+        this.reason = reason;
     }
 }

Added: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ProviderException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ProviderException.java?rev=1166875&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ProviderException.java (added)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ProviderException.java Thu Sep  8 19:46:01 2011
@@ -0,0 +1,33 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.core.gfac.exception;
+
+public class ProviderException extends GfacException {
+    
+    public ProviderException(String message){
+        super(message);
+    }
+    
+    public ProviderException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Added: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/SchedulerException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/SchedulerException.java?rev=1166875&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/SchedulerException.java (added)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/SchedulerException.java Thu Sep  8 19:46:01 2011
@@ -0,0 +1,33 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.core.gfac.exception;
+
+public class SchedulerException extends GfacException {
+
+    public SchedulerException(String message){
+        super(message);
+    }
+    
+    public SchedulerException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Added: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/SecurityException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/SecurityException.java?rev=1166875&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/SecurityException.java (added)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/SecurityException.java Thu Sep  8 19:46:01 2011
@@ -0,0 +1,29 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.core.gfac.exception;
+
+public class SecurityException extends GfacException {
+
+    public SecurityException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Added: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ServiceException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ServiceException.java?rev=1166875&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ServiceException.java (added)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ServiceException.java Thu Sep  8 19:46:01 2011
@@ -0,0 +1,33 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.core.gfac.exception;
+
+public class ServiceException extends GfacException {
+
+    public ServiceException(String message) {
+        super(message);
+    }
+    
+    public ServiceException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Added: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ToolsException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ToolsException.java?rev=1166875&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ToolsException.java (added)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/exception/ToolsException.java Thu Sep  8 19:46:01 2011
@@ -0,0 +1,33 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.core.gfac.exception;
+
+public class ToolsException extends GfacException {
+
+    public ToolsException(String message) {
+        super(message);
+    }
+    
+    public ToolsException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/Chain.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/Chain.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/Chain.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/Chain.java Thu Sep  8 19:46:01 2011
@@ -22,20 +22,25 @@
 package org.apache.airavata.core.gfac.extension;
 
 import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
-import org.apache.airavata.core.gfac.exception.GfacException;
+import org.apache.airavata.core.gfac.exception.ExtensionException;
 
 public abstract class Chain<T> {
-    protected T next;
+    private T next;
 
     public T setNext(T nextChain) {
         this.next = nextChain;
         return this.next;
     }
+    
+    protected T getNext(){
+        return next;
+    }
 
     /**
      * Start the chain
      * 
      * @param context
+     * @throws ExtensionException
      */
-    public abstract void start(InvocationContext context) throws GfacException;
+    public abstract void start(InvocationContext context) throws ExtensionException;
 }

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/ExitableChain.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/ExitableChain.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/ExitableChain.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/ExitableChain.java Thu Sep  8 19:46:01 2011
@@ -22,13 +22,13 @@
 package org.apache.airavata.core.gfac.extension;
 
 import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
-import org.apache.airavata.core.gfac.exception.GfacException;
+import org.apache.airavata.core.gfac.exception.ExtensionException;
 
 public abstract class ExitableChain extends Chain<ExitableChain> {
-    public final void start(InvocationContext context) throws GfacException {
+    public final void start(InvocationContext context) throws ExtensionException {
         boolean breakTheChain = this.execute(context);
-        if (next != null && !breakTheChain) {
-            this.next.start(context);
+        if (getNext() != null && !breakTheChain) {
+            this.getNext().start(context);
         }
     }
 
@@ -36,6 +36,7 @@ public abstract class ExitableChain exte
      * 
      * @param context
      * @return true if no need for further processing
+     * @throws ExtensionException TODO
      */
-    protected abstract boolean execute(InvocationContext context) throws GfacException;
+    protected abstract boolean execute(InvocationContext context) throws ExtensionException;
 }

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java Thu Sep  8 19:46:01 2011
@@ -30,13 +30,12 @@ import org.apache.airavata.commons.gfac.
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
 import org.apache.airavata.commons.gfac.type.app.ShellApplicationDeployment;
 import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
-import org.apache.airavata.core.gfac.exception.GfacException;
-import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
+import org.apache.airavata.core.gfac.exception.ExtensionException;
 import org.apache.airavata.core.gfac.extension.DataServiceChain;
 
 public class RegistryDataService extends DataServiceChain {
 
-	public boolean execute(InvocationContext context) throws GfacException {
+	public boolean execute(InvocationContext context) throws ExtensionException {
 
 		ServiceDescription serviceDesc = context.getExecutionDescription().getService();
 		HostDescription hostDesc = context.getExecutionDescription().getHost();
@@ -66,7 +65,7 @@ public class RegistryDataService extends
 			}
 
 			/*
-			 * Input and Output Dir
+			 * Input and Output Directory
 			 */
 			if (appDesc.getInputDir() == null) {
 				appDesc.setInputDir(appDesc.getWorkingDir() + File.separator
@@ -93,11 +92,10 @@ public class RegistryDataService extends
 			}
 
 		} else {
-			throw new GfacException("Service Map for "
+			throw new ExtensionException("Service Map for "
 					+ context.getServiceName()
 					+ " does not found on resource Catalog "
-					+ context.getExecutionContext().getRegistryService(),
-					FaultCode.InvalidRequest);
+					+ context.getExecutionContext().getRegistryService());
 		}
 
 		return false;

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/post/GridFtpOutputStaging.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/post/GridFtpOutputStaging.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/post/GridFtpOutputStaging.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/post/GridFtpOutputStaging.java Thu Sep  8 19:46:01 2011
@@ -23,6 +23,8 @@ package org.apache.airavata.core.gfac.ex
 
 import java.io.File;
 import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
 import java.util.Iterator;
 
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
@@ -35,60 +37,76 @@ import org.apache.airavata.commons.gfac.
 import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
 import org.apache.airavata.core.gfac.context.message.MessageContext;
 import org.apache.airavata.core.gfac.context.security.impl.GSISecurityContext;
-import org.apache.airavata.core.gfac.exception.GfacException;
-import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
+import org.apache.airavata.core.gfac.exception.ExtensionException;
+import org.apache.airavata.core.gfac.exception.SecurityException;
+import org.apache.airavata.core.gfac.exception.ToolsException;
 import org.apache.airavata.core.gfac.extension.PostExecuteChain;
 import org.apache.airavata.core.gfac.external.GridFtp;
 import org.apache.airavata.core.gfac.utils.GfacUtils;
 import org.ietf.jgss.GSSCredential;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class GridFtpOutputStaging extends PostExecuteChain {
+    
+    public static final Logger log = LoggerFactory.getLogger(GridFtpOutputStaging.class);
 
-    public static final String MYPROXY_SECURITY_CONTEXT = "myproxy";
+    public static final String MYPROXY_SECURITY_CONTEXT = "myproxy";        
 
-    public boolean execute(InvocationContext context) throws GfacException {
+    public boolean execute(InvocationContext context) throws ExtensionException {
         try {
-            MessageContext<AbstractParameter> x = context.getOutput();
+            MessageContext<AbstractParameter> outputContext = context.getOutput();
 
-            for (Iterator<String> iterator = x.getNames(); iterator.hasNext();) {
-                String key = iterator.next();
-                if (x.getValue(key).getType() == DataType.File) {
-                    FileParameter fileParameter = (FileParameter) x.getValue(key);
-
-                    /*
-                     * Determine scheme
-                     */
-                    URI uri = URI.create(fileParameter.toStringVal());
-                    if (uri.getScheme().equalsIgnoreCase(GridFtp.GSIFTP_SCHEME)) {
-                        HostDescription hostDescription = context.getExecutionDescription().getHost();
+            if (outputContext != null) {
+
+                for (Iterator<String> iterator = outputContext.getNames(); iterator.hasNext();) {
+                    String key = iterator.next();
+                    if (outputContext.getValue(key).getType() == DataType.File) {
+                        FileParameter fileParameter = (FileParameter) outputContext.getValue(key);
 
                         /*
-                         * src complete URI
+                         * Determine scheme
                          */
-                        File file = new File(uri.getPath());
-                        String srcFilePath = file.getName();
-
-                        ApplicationDeploymentDescription app = context.getExecutionDescription().getApp();
-                        if (app instanceof ShellApplicationDeployment) {
-                            srcFilePath = app.getOutputDir() + File.separator + srcFilePath;
-                        }
-
-                        if (hostDescription instanceof GlobusHost) {
-                            gridFTPTransfer(context, uri, srcFilePath);
-                        } else if (GfacUtils.isLocalHost(hostDescription.getName())) {
-                            updateFile(context, uri, srcFilePath);
+                        URI uri = URI.create(fileParameter.toStringVal());
+                        if (uri.getScheme().equalsIgnoreCase(GridFtp.GSIFTP_SCHEME)) {
+                            HostDescription hostDescription = context.getExecutionDescription().getHost();
+
+                            /*
+                             * src complete URI
+                             */
+                            File file = new File(uri.getPath());
+                            String srcFilePath = file.getName();
+
+                            ApplicationDeploymentDescription app = context.getExecutionDescription().getApp();
+                            if (app instanceof ShellApplicationDeployment) {
+                                srcFilePath = app.getOutputDir() + File.separator + srcFilePath;
+                            }
+
+                            if (hostDescription instanceof GlobusHost) {
+                                gridFTPTransfer(context, uri, srcFilePath);
+                            } else if (GfacUtils.isLocalHost(hostDescription.getName())) {
+                                updateFile(context, uri, srcFilePath);
+                            }
                         }
                     }
                 }
+            }else{
+                log.debug("Output Context is null");
             }
-
-        } catch (Exception e) {
-            throw new GfacException(e, FaultCode.Unknown);
+        } catch (UnknownHostException e) {
+            throw new ExtensionException("Cannot find IP Address for current host", e);
+        } catch (URISyntaxException e) {
+            throw new ExtensionException("URI is in the wrong format:" + e.getMessage(), e);
+        } catch (ToolsException e) {
+            throw new ExtensionException(e.getMessage(), e);
+        } catch (SecurityException e) {
+            throw new ExtensionException(e.getMessage(), e);
         }
         return false;
     }
 
-    private void gridFTPTransfer(InvocationContext context, URI dest, String remoteSrcFile) throws Exception {
+    private void gridFTPTransfer(InvocationContext context, URI dest, String remoteSrcFile) throws SecurityException,
+            ToolsException, URISyntaxException {
         GridFtp ftp = new GridFtp();
         GSSCredential gssCred = ((GSISecurityContext) context.getSecurityContext(MYPROXY_SECURITY_CONTEXT))
                 .getGssCredentails();
@@ -97,7 +115,8 @@ public class GridFtpOutputStaging extend
         ftp.transfer(srcURI, dest, gssCred, true);
     }
 
-    private void updateFile(InvocationContext context, URI dest, String localFile) throws Exception {
+    private void updateFile(InvocationContext context, URI dest, String localFile) throws SecurityException,
+            ToolsException {
         GridFtp ftp = new GridFtp();
         GSSCredential gssCred = ((GSISecurityContext) context.getSecurityContext(MYPROXY_SECURITY_CONTEXT))
                 .getGssCredentails();

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/pre/GridFtpInputStaging.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/pre/GridFtpInputStaging.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/pre/GridFtpInputStaging.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/pre/GridFtpInputStaging.java Thu Sep  8 19:46:01 2011
@@ -23,6 +23,8 @@ package org.apache.airavata.core.gfac.ex
 
 import java.io.File;
 import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
 import java.util.Iterator;
 
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
@@ -35,66 +37,83 @@ import org.apache.airavata.commons.gfac.
 import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
 import org.apache.airavata.core.gfac.context.message.MessageContext;
 import org.apache.airavata.core.gfac.context.security.impl.GSISecurityContext;
-import org.apache.airavata.core.gfac.exception.GfacException;
-import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
+import org.apache.airavata.core.gfac.exception.ExtensionException;
+import org.apache.airavata.core.gfac.exception.SecurityException;
+import org.apache.airavata.core.gfac.exception.ToolsException;
 import org.apache.airavata.core.gfac.extension.PreExecuteChain;
 import org.apache.airavata.core.gfac.external.GridFtp;
 import org.apache.airavata.core.gfac.utils.GfacUtils;
 import org.ietf.jgss.GSSCredential;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class GridFtpInputStaging extends PreExecuteChain {
 
+    public static final Logger log = LoggerFactory.getLogger(GridFtpInputStaging.class);
+
     public static final String MYPROXY_SECURITY_CONTEXT = "myproxy";
 
-    public boolean execute(InvocationContext context) throws GfacException {
+    public boolean execute(InvocationContext context) throws ExtensionException {
         try {
 
-            MessageContext<AbstractParameter> x = context.getInput();
-
-            for (Iterator<String> iterator = x.getNames(); iterator.hasNext();) {
-                String key = iterator.next();
-                if (x.getValue(key).getType() == DataType.File) {
-                    FileParameter fileParameter = (FileParameter) x.getValue(key);
-
-                    /*
-                     * Determine scheme
-                     */
-                    URI uri = URI.create(fileParameter.toStringVal());
-                    if (uri.getScheme().equalsIgnoreCase(GridFtp.GSIFTP_SCHEME)) {
-                        HostDescription hostDescription = context.getExecutionDescription().getHost();
-
-                        /*
-                         * Desctination complete URI
-                         */
-                        File file = new File(uri.getPath());
-                        String destFilePath = file.getName();
+            MessageContext<AbstractParameter> inputContext = context.getInput();
 
-                        ApplicationDeploymentDescription app = context.getExecutionDescription().getApp();
-                        if (app instanceof ShellApplicationDeployment) {
-                            destFilePath = app.getInputDir() + File.separator + destFilePath;
-                        }
+            if (inputContext != null) {
 
-                        if (hostDescription instanceof GlobusHost) {
-                            gridFTPTransfer(context, uri, destFilePath);
-                        } else if (GfacUtils.isLocalHost(hostDescription.getName())) {
-                            downloadFile(context, uri, destFilePath);
-                        }
+                for (Iterator<String> iterator = inputContext.getNames(); iterator.hasNext();) {
+                    String key = iterator.next();
+                    if (inputContext.getValue(key).getType() == DataType.File) {
+                        FileParameter fileParameter = (FileParameter) inputContext.getValue(key);
 
                         /*
-                         * Replace parameter
+                         * Determine scheme
                          */
-                        fileParameter.parseStringVal(destFilePath);
+                        URI uri = URI.create(fileParameter.toStringVal());
+                        if (uri.getScheme().equalsIgnoreCase(GridFtp.GSIFTP_SCHEME)) {
+                            HostDescription hostDescription = context.getExecutionDescription().getHost();
+
+                            /*
+                             * Desctination complete URI
+                             */
+                            File file = new File(uri.getPath());
+                            String destFilePath = file.getName();
+
+                            ApplicationDeploymentDescription app = context.getExecutionDescription().getApp();
+                            if (app instanceof ShellApplicationDeployment) {
+                                destFilePath = app.getInputDir() + File.separator + destFilePath;
+                            }
+
+                            if (hostDescription instanceof GlobusHost) {
+                                gridFTPTransfer(context, uri, destFilePath);
+                            } else if (GfacUtils.isLocalHost(hostDescription.getName())) {
+                                downloadFile(context, uri, destFilePath);
+                            }
+
+                            /*
+                             * Replace parameter
+                             */
+                            fileParameter.parseStringVal(destFilePath);
+                        }
                     }
                 }
+            } else {
+                log.debug("Input Context is null");
             }
 
-        } catch (Exception e) {
-            throw new GfacException(e, FaultCode.Unknown);
+        } catch (UnknownHostException e) {
+            throw new ExtensionException("Cannot find IP Address for current host", e);
+        } catch (URISyntaxException e) {
+            throw new ExtensionException("URI is in the wrong format:" + e.getMessage(), e);
+        } catch (ToolsException e) {
+            throw new ExtensionException(e.getMessage(), e);
+        } catch (SecurityException e) {
+            throw new ExtensionException(e.getMessage(), e);
         }
         return false;
     }
 
-    private void gridFTPTransfer(InvocationContext context, URI src, String remoteFile) throws Exception {
+    private void gridFTPTransfer(InvocationContext context, URI src, String remoteFile) throws SecurityException,
+            ToolsException, URISyntaxException {
         GridFtp ftp = new GridFtp();
         GSSCredential gssCred = ((GSISecurityContext) context.getSecurityContext(MYPROXY_SECURITY_CONTEXT))
                 .getGssCredentails();
@@ -103,7 +122,8 @@ public class GridFtpInputStaging extends
         ftp.transfer(src, inputURI, gssCred, true);
     }
 
-    private void downloadFile(InvocationContext context, URI src, String localFile) throws Exception {
+    private void downloadFile(InvocationContext context, URI src, String localFile) throws SecurityException,
+            ToolsException {
         GridFtp ftp = new GridFtp();
         GSSCredential gssCred = ((GSISecurityContext) context.getSecurityContext(MYPROXY_SECURITY_CONTEXT))
                 .getGssCredentails();

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/pre/HttpInputStaging.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/pre/HttpInputStaging.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/pre/HttpInputStaging.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/pre/HttpInputStaging.java Thu Sep  8 19:46:01 2011
@@ -28,6 +28,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.Iterator;
 
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
@@ -40,65 +41,82 @@ import org.apache.airavata.commons.gfac.
 import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
 import org.apache.airavata.core.gfac.context.message.MessageContext;
 import org.apache.airavata.core.gfac.context.security.impl.GSISecurityContext;
-import org.apache.airavata.core.gfac.exception.GfacException;
-import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
+import org.apache.airavata.core.gfac.exception.ExtensionException;
+import org.apache.airavata.core.gfac.exception.SecurityException;
+import org.apache.airavata.core.gfac.exception.ToolsException;
 import org.apache.airavata.core.gfac.extension.PreExecuteChain;
 import org.apache.airavata.core.gfac.external.GridFtp;
 import org.apache.airavata.core.gfac.utils.GfacUtils;
 import org.ietf.jgss.GSSCredential;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class HttpInputStaging extends PreExecuteChain {
 
-    public static final String MYPROXY_SECURITY_CONTEXT = "myproxy";
+    public static final Logger log = LoggerFactory.getLogger(HttpInputStaging.class);
 
-    public boolean execute(InvocationContext context) throws GfacException {
-        try {
-            MessageContext<AbstractParameter> x = context.getInput();
+    public static final String MYPROXY_SECURITY_CONTEXT = "myproxy";
 
-            for (Iterator<String> iterator = x.getNames(); iterator.hasNext();) {
-                String key = iterator.next();
-                if (x.getValue(key).getType() == DataType.File) {
-                    FileParameter fileParameter = (FileParameter) x.getValue(key);
-
-                    /*
-                     * Determine scheme
-                     */
-                    URI uri = URI.create(fileParameter.toStringVal());
-                    if (uri.getScheme().equalsIgnoreCase("http")) {
-                        HostDescription hostDescription = context.getExecutionDescription().getHost();
+    public boolean execute(InvocationContext context) throws ExtensionException {
 
-                        /*
-                         * Desctination complete URI
-                         */
-                        File file = new File(uri.getPath());
-                        String destFilePath = file.getName();
+        try {
+            MessageContext<AbstractParameter> inputContext = context.getInput();
 
-                        ApplicationDeploymentDescription app = context.getExecutionDescription().getApp();
-                        if (app instanceof ShellApplicationDeployment) {
-                            destFilePath = app.getInputDir() + File.separator + destFilePath;
-                        }
+            if (inputContext != null) {
 
-                        if (hostDescription instanceof GlobusHost) {
-                            uploadToGridFTPFromHttp(context, uri, destFilePath);
-                        } else {
-                            downloadFile(context, uri, destFilePath);
-                        }
+                for (Iterator<String> iterator = inputContext.getNames(); iterator.hasNext();) {
+                    String key = iterator.next();
+                    if (inputContext.getValue(key).getType() == DataType.File) {
+                        FileParameter fileParameter = (FileParameter) inputContext.getValue(key);
 
                         /*
-                         * Replace parameter
+                         * Determine scheme
                          */
-                        fileParameter.parseStringVal(destFilePath);
+                        URI uri = URI.create(fileParameter.toStringVal());
+                        if (uri.getScheme().equalsIgnoreCase("http")) {
+                            HostDescription hostDescription = context.getExecutionDescription().getHost();
+
+                            /*
+                             * Desctination complete URI
+                             */
+                            File file = new File(uri.getPath());
+                            String destFilePath = file.getName();
+
+                            ApplicationDeploymentDescription app = context.getExecutionDescription().getApp();
+                            if (app instanceof ShellApplicationDeployment) {
+                                destFilePath = app.getInputDir() + File.separator + destFilePath;
+                            }
+
+                            if (hostDescription instanceof GlobusHost) {
+                                uploadToGridFTPFromHttp(context, uri, destFilePath);
+                            } else {
+                                downloadFile(context, uri, destFilePath);
+                            }
+
+                            /*
+                             * Replace parameter
+                             */
+                            fileParameter.parseStringVal(destFilePath);
+                        }
                     }
                 }
+            } else {
+                log.debug("Input Context is null");
             }
-
-        } catch (Exception e) {
-            throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
+        } catch (SecurityException e) {
+            throw new ExtensionException(e.getMessage(), e);
+        } catch (ToolsException e) {
+            throw new ExtensionException(e.getMessage(), e);
+        } catch (URISyntaxException e) {
+            throw new ExtensionException("URI is in the wrong format:" + e.getMessage(), e);
+        } catch (IOException e) {
+            throw new ExtensionException("Cannot load from HTTP", e);
         }
         return false;
     }
 
-    private void uploadToGridFTPFromHttp(InvocationContext context, URI src, String remoteLocation) throws Exception {
+    private void uploadToGridFTPFromHttp(InvocationContext context, URI src, String remoteLocation)
+            throws SecurityException, ToolsException, URISyntaxException, IOException {
         GridFtp ftp = new GridFtp();
         GSSCredential gssCred = ((GSISecurityContext) context.getSecurityContext(MYPROXY_SECURITY_CONTEXT))
                 .getGssCredentails();
@@ -116,12 +134,12 @@ public class HttpInputStaging extends Pr
                     in.close();
                 }
             } catch (Exception e) {
-
+                log.warn("Cannot close URL inputstream");
             }
         }
     }
 
-    private void downloadFile(InvocationContext context, URI src, String localFile) throws Exception {
+    private void downloadFile(InvocationContext context, URI src, String localFile) throws IOException {
         OutputStream out = null;
         InputStream in = null;
         try {
@@ -138,16 +156,26 @@ public class HttpInputStaging extends Pr
             while ((numRead = in.read(buffer)) != -1) {
                 out.write(buffer, 0, numRead);
             }
+
+            out.flush();
+
         } finally {
-            try {
-                if (in != null) {
+
+            if (in != null) {
+                try {
                     in.close();
+                } catch (IOException ioe) {
+                    log.warn("Cannot close URL inputstream");
                 }
-                if (out != null) {
+            }
+            if (out != null) {
+                try {
                     out.close();
+                } catch (IOException ioe) {
+                    log.warn("Cannot close URL outputstream");
                 }
-            } catch (IOException ioe) {
             }
+
         }
     }
 }

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/external/GridFtp.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/external/GridFtp.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/external/GridFtp.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/external/GridFtp.java Thu Sep  8 19:46:01 2011
@@ -21,15 +21,21 @@
 
 package org.apache.airavata.core.gfac.external;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
+import java.nio.CharBuffer;
 
 import org.apache.airavata.core.gfac.exception.GfacException;
-import org.apache.airavata.core.gfac.utils.ContactInfo;
+import org.apache.airavata.core.gfac.exception.ToolsException;
+import org.apache.airavata.core.gfac.utils.GFacConstants;
+import org.apache.airavata.core.gfac.utils.GridFTPContactInfo;
 import org.globus.ftp.DataChannelAuthentication;
 import org.globus.ftp.DataSourceStream;
 import org.globus.ftp.GridFTPClient;
@@ -41,9 +47,13 @@ import org.globus.ftp.exception.ClientEx
 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;
 
 public class GridFtp {
 
+    public static final Logger log = LoggerFactory.getLogger(GridFtp.class);
+
     public static final String GSIFTP_SCHEME = "gsiftp";
 
     /**
@@ -51,14 +61,16 @@ public class GridFtp {
      * 
      * @param destURI
      * @param gssCred
-     * @throws GfacException
+     * @throws ServerException
+     * @throws IOException
      */
-    public void makeDir(URI destURI, GSSCredential gssCred) throws GfacException {
+    public void makeDir(URI destURI, GSSCredential gssCred) throws ToolsException {
         GridFTPClient destClient = null;
+        GridFTPContactInfo destHost = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
         try {
-            ContactInfo destHost = new ContactInfo(destURI.getHost(), destURI.getPort());
+
             String destPath = destURI.getPath();
-            System.out.println(("Creating Directory = " + destHost + "=" + destPath));
+            log.info(("Creating Directory = " + destHost + "=" + destPath));
 
             destClient = new GridFTPClient(destHost.hostName, destHost.port);
 
@@ -73,27 +85,34 @@ public class GridFtp {
                         destClient.makeDir(destPath);
                     }
                     break;
-                } catch (Exception e) {
+                } 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 GfacException(e.getMessage(), e);
+                        throw new ToolsException(e.getMessage(), e);
                     }
                     Thread.sleep(10000);
                 }
             }
         } catch (ServerException e) {
-            e.printStackTrace();
+            throw new ToolsException("Cannot Create GridFTP Client to:" + destHost.toString(), e);
         } catch (IOException e) {
-            e.printStackTrace();
+            throw new ToolsException("Cannot Create GridFTP Client to:" + destHost.toString(), e);
         } catch (InterruptedException e) {
-            e.printStackTrace();
+            throw new ToolsException("Internal Error cannot sleep", e);
         } finally {
-            if (destClient != null)
+            if (destClient != null) {
                 try {
                     destClient.close();
                 } catch (Exception e) {
-                    // no op
+                    log.warn("Cannot close GridFTP client connection");
                 }
+            }
         }
     }
 
@@ -105,42 +124,48 @@ public class GridFtp {
      * @param localFile
      * @throws GfacException
      */
-    public void updateFile(URI destURI, GSSCredential gsCredential, InputStream io) throws GfacException {       
+    public void updateFile(URI destURI, GSSCredential gsCredential, InputStream io) throws ToolsException {
         GridFTPClient ftpClient = null;
+        GridFTPContactInfo contactInfo = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
 
         try {
-            ContactInfo contactInfo = new ContactInfo(destURI.getHost(), destURI.getPort());
+
             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("host"));
             ftpClient.authenticate(gsCredential);
             ftpClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
 
-            System.out.println("the remote file is " + remoteFile);
+            log.debug("Uploading file");
 
             ftpClient.put(remoteFile, new DataSourceStream(io), new MarkerListener() {
                 public void markerArrived(Marker marker) {
                 }
             });
-            
+
+            log.info("Upload file to:" + remoteFile + " is done");
+
         } catch (ServerException e) {
-            e.printStackTrace();
-        } catch (ClientException e) {
-            e.printStackTrace();
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
+            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
         } catch (IOException e) {
-            e.printStackTrace();
+            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)
+            if (ftpClient != null) {
                 try {
                     ftpClient.close();
                 } catch (Exception e) {
-                    // no op
+                    log.warn("Cannot close GridFTP client connection");
                 }
+            }
         }
     }
+
     /**
      * Upload file to remote location
      * 
@@ -149,37 +174,43 @@ public class GridFtp {
      * @param localFile
      * @throws GfacException
      */
-    public void updateFile(URI destURI, GSSCredential gsCredential, File localFile) throws GfacException {
+    public void updateFile(URI destURI, GSSCredential gsCredential, File localFile) throws ToolsException {
         GridFTPClient ftpClient = null;
-
+        GridFTPContactInfo contactInfo = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
         try {
-            ContactInfo contactInfo = new ContactInfo(destURI.getHost(), destURI.getPort());
+
             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("host"));
             ftpClient.authenticate(gsCredential);
             ftpClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
 
-            System.out.println("the local temp file is " + localFile);
-            System.out.println("the remote file is " + remoteFile);
+            log.debug("Uploading file");
 
             ftpClient.put(localFile, remoteFile, false);
+
+            log.info("Upload file to:" + remoteFile + " is done");
+
         } catch (ServerException e) {
-            e.printStackTrace();
-        } catch (ClientException e) {
-            e.printStackTrace();
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
+            throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
         } catch (IOException e) {
-            e.printStackTrace();
+            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)
+            if (ftpClient != null) {
                 try {
                     ftpClient.close();
                 } catch (Exception e) {
-                    // no op
+                    log.warn("Cannot close GridFTP client connection");
                 }
+            }
         }
     }
 
@@ -191,37 +222,42 @@ public class GridFtp {
      * @param localFile
      * @throws GfacException
      */
-    public void downloadFile(URI destURI, GSSCredential gsCredential, File 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 {
-            ContactInfo contactInfo = new ContactInfo(destURI.getHost(), destURI.getPort());
             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("host"));
             ftpClient.authenticate(gsCredential);
             ftpClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
 
-            System.out.println("the local temp file is " + localFile);
-            System.out.println("the remote file is " + remoteFile);
+            log.debug("Downloading file");
 
             ftpClient.get(remoteFile, localFile);
+
+            log.info("Download file to:" + remoteFile + " is done");
+
         } catch (ServerException e) {
-            e.printStackTrace();
-        } catch (ClientException e) {
-            e.printStackTrace();
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
+            throw new ToolsException("Cannot download file from GridFTP:" + contactInfo.toString(), e);
         } catch (IOException e) {
-            e.printStackTrace();
+            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)
+            if (ftpClient != null) {
                 try {
                     ftpClient.close();
                 } catch (Exception e) {
-                    // no op
+                    log.warn("Cannot close GridFTP client connection");
                 }
+            }
         }
     }
 
@@ -234,34 +270,49 @@ public class GridFtp {
      * @return
      * @throws GfacException
      */
-    public String readRemoteFile(URI destURI, GSSCredential gsCredential, File localFile) throws GfacException {
+    public String readRemoteFile(URI destURI, GSSCredential gsCredential, File localFile) throws ToolsException {
+        BufferedReader instream = null;
+        File localTempfile = null;
         try {
-            File localTempfile;
+
             if (localFile == null) {
                 localTempfile = File.createTempFile("stderr", "err");
             } else {
                 localTempfile = localFile;
             }
+            
+            log.debug("Loca temporary file:" + localTempfile);
 
             downloadFile(destURI, gsCredential, localTempfile);
 
-            FileInputStream instream = new FileInputStream(localTempfile);
-            int size = instream.available();
-            byte[] buf = new byte[size];
-
-            instream.read(buf);
-
-            return new String(buf);
+            instream = new BufferedReader(new FileReader(localTempfile));
+            StringBuffer buff = new StringBuffer();
+            String temp = null;
+            while ((temp = instream.readLine()) != null) {
+                buff.append(temp);
+                buff.append(GFacConstants.NEWLINE);
+            }
+            
+            log.debug("finish read file:" + localTempfile);
+            
+            return buff.toString();
         } catch (FileNotFoundException e) {
-            e.printStackTrace();
+            throw new ToolsException("Cannot read localfile file:" + localTempfile, e);
         } catch (IOException e) {
-            e.printStackTrace();
+            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");
+                }
+            }
         }
-        return null;
     }
 
     /**
-     * Transfer data from one gridFTp endpoint to another gridFTP endpoint
+     * Transfer data from one GridFTp Endpoint to another GridFTP Endpoint
      * 
      * @param srchost
      * @param desthost
@@ -271,8 +322,7 @@ public class GridFtp {
      * @throws ClientException
      * @throws IOException
      */
-    public void transfer(URI srchost, URI desthost, GSSCredential gssCred, boolean srcActive) throws ServerException,
-            ClientException, IOException {
+    public void transfer(URI srchost, URI desthost, GSSCredential gssCred, boolean srcActive) throws ToolsException {
         GridFTPClient destClient = null;
         GridFTPClient srcClient = null;
 
@@ -288,12 +338,16 @@ public class GridFtp {
             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
@@ -301,30 +355,30 @@ public class GridFtp {
              */
             srcClient.transfer(srchost.getPath(), destClient, desthost.getPath(), false, null);
             if (srcClient.getSize(srchost.getPath()) == destClient.getSize(desthost.getPath())) {
-                System.out.println("CHECK SUM OK");
+                log.debug("CHECK SUM OK");
             } else {
-                System.out.println("CHECK SUM FAIL");
+                log.debug("CHECK SUM OK");
             }
 
         } catch (ServerException e) {
-            throw e;
-        } catch (ClientException e) {
-            throw e;
+            throw new ToolsException("Cannot transfer file from GridFTP:" + srchost.toString() + " to " + desthost.toString(), e);
         } catch (IOException e) {
-            throw 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) {
-                    // no op
+                    log.warn("Cannot close GridFTP client connection at Desitnation:" + desthost.toString());
                 }
             }
             if (srcClient != null) {
                 try {
                     srcClient.close();
                 } catch (Exception e) {
-                    // no op
+                    log.warn("Cannot close GridFTP client connection at Source:" + srchost.toString());
                 }
             }
         }

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/factory/AbstractServiceFactory.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/factory/AbstractServiceFactory.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/factory/AbstractServiceFactory.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/factory/AbstractServiceFactory.java Thu Sep  8 19:46:01 2011
@@ -23,13 +23,33 @@ package org.apache.airavata.core.gfac.fa
 
 import org.apache.airavata.core.gfac.exception.GfacException;
 import org.apache.airavata.core.gfac.services.GenericService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public abstract class AbstractServiceFactory {
 
+    protected final Logger log = LoggerFactory.getLogger(AbstractServiceFactory.class);
+        
+    /**
+     * Create and initialize a generic service
+     * 
+     * @return the generic service
+     * @throws GfacException
+     */
     public final GenericService createService() throws GfacException {
-        getGenericService().init();
+        log.debug("Try to get GenericService");
+        GenericService service = getGenericService();
+        log.debug("Done get, Try to init GenericService");
+        service.init();
+        log.debug("Done init GenericService");
         return getGenericService();
     }
 
+    /**
+     * Get a service of specific type
+     * 
+     * @return
+     * @throws GfacException
+     */
     protected abstract GenericService getGenericService() throws GfacException;
 }

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/EC2Provider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/EC2Provider.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/EC2Provider.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/EC2Provider.java Thu Sep  8 19:46:01 2011
@@ -49,10 +49,9 @@ import org.apache.airavata.commons.gfac.
 import org.apache.airavata.commons.gfac.type.app.ShellApplicationDeployment;
 import org.apache.airavata.commons.gfac.type.parameter.AbstractParameter;
 import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
-import org.apache.airavata.core.gfac.context.message.MessageContext;
 import org.apache.airavata.core.gfac.context.security.impl.AmazonSecurityContext;
 import org.apache.airavata.core.gfac.exception.GfacException;
-import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
+import org.apache.airavata.core.gfac.exception.ProviderException;
 import org.apache.airavata.core.gfac.notification.NotificationService;
 import org.apache.airavata.core.gfac.utils.GFacConstants;
 import org.apache.airavata.core.gfac.utils.GfacUtils;
@@ -102,7 +101,7 @@ public class EC2Provider extends Abstrac
         return buff.toString();
     }
 
-    public void initialize(InvocationContext context) throws GfacException {
+    public void initialize(InvocationContext context) throws ProviderException {
         HostDescription host = context.getExecutionDescription().getHost();
         ShellApplicationDeployment app = (ShellApplicationDeployment)context.getExecutionDescription().getApp();
 
@@ -140,15 +139,14 @@ public class EC2Provider extends Abstrac
 
                 if (describeInstancesResult.getReservations().size() == 0
                         || describeInstancesResult.getReservations().get(0).getInstances().size() == 0) {
-                    throw new GfacException("Instance not found:" + ins_id, FaultCode.InvalidRequest);
+                    throw new ProviderException("Instance not found:" + ins_id);
                 }
 
                 this.instance = describeInstancesResult.getReservations().get(0).getInstances().get(0);
 
                 // check instance keypair
                 if (this.instance.getKeyName() == null || !this.instance.getKeyName().equals(KEY_PAIR_NAME))
-                    throw new GfacException("Keypair for instance:" + ins_id + " is not valid",
-                            FaultCode.InvalidRequest);
+                    throw new ProviderException("Keypair for instance:" + ins_id + " is not valid");
             }
 
             // send out instance id
@@ -183,10 +181,8 @@ public class EC2Provider extends Abstrac
             }
 
         } catch (Exception e) {
-            // TODO throw out
-            e.printStackTrace();
             log.error(e.getMessage(), e);
-            throw new GfacException(e, FaultCode.InvalidRequest);
+            throw new ProviderException(e.getMessage(), e);
         }
 
         // set Host location
@@ -226,7 +222,7 @@ public class EC2Provider extends Abstrac
                 }
             }
         } catch (Exception e) {
-            throw new GfacException(e.getMessage(), e);
+            throw new ProviderException(e.getMessage(), e);
         } finally {
             try {
                 ssh.disconnect();
@@ -235,7 +231,7 @@ public class EC2Provider extends Abstrac
         }
     }
 
-    public void execute(InvocationContext context) throws GfacException {
+    public void execute(InvocationContext context) throws ProviderException {
         HostDescription host = context.getExecutionDescription().getHost();
         ShellApplicationDeployment app = (ShellApplicationDeployment)context.getExecutionDescription().getApp();
 
@@ -343,8 +339,8 @@ public class EC2Provider extends Abstrac
                 fileTransfer.download(app.getStdOut(), localStdOutFile.getAbsolutePath());
                 fileTransfer.download(app.getStdErr(), localStdErrFile.getAbsolutePath());
 
-                String stdOutStr = GfacUtils.readFile(localStdOutFile.getAbsolutePath());
-                String stdErrStr = GfacUtils.readFile(localStdErrFile.getAbsolutePath());
+                String stdOutStr = GfacUtils.readFileToString(localStdOutFile.getAbsolutePath());
+                String stdErrStr = GfacUtils.readFileToString(localStdErrFile.getAbsolutePath());
 
                 // set to context
                 OutputUtils.fillOutputFromStdout(context.<AbstractParameter>getOutput(), stdOutStr, stdErrStr);
@@ -358,7 +354,7 @@ public class EC2Provider extends Abstrac
                 }
             }
         } catch (Exception e) {
-            throw new GfacException(e.getMessage(), e);
+            throw new ProviderException(e.getMessage(), e);
         } finally {
             try {
                 ssh.disconnect();

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/GramProvider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/GramProvider.java?rev=1166875&r1=1166874&r2=1166875&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/GramProvider.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/GramProvider.java Thu Sep  8 19:46:01 2011
@@ -23,6 +23,7 @@ package org.apache.airavata.core.gfac.pr
 
 import java.io.File;
 import java.net.URI;
+import java.net.URISyntaxException;
 
 import javax.xml.namespace.QName;
 
@@ -32,11 +33,13 @@ import org.apache.airavata.commons.gfac.
 import org.apache.airavata.commons.gfac.type.host.GlobusHost;
 import org.apache.airavata.commons.gfac.type.parameter.AbstractParameter;
 import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
-import org.apache.airavata.core.gfac.context.message.MessageContext;
 import org.apache.airavata.core.gfac.context.security.impl.GSISecurityContext;
+import org.apache.airavata.core.gfac.exception.ExtensionException;
 import org.apache.airavata.core.gfac.exception.GfacException;
-import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
 import org.apache.airavata.core.gfac.exception.JobSubmissionFault;
+import org.apache.airavata.core.gfac.exception.ProviderException;
+import org.apache.airavata.core.gfac.exception.SecurityException;
+import org.apache.airavata.core.gfac.exception.ToolsException;
 import org.apache.airavata.core.gfac.external.GridFtp;
 import org.apache.airavata.core.gfac.notification.NotificationService;
 import org.apache.airavata.core.gfac.provider.utils.GramRSLGenerator;
@@ -54,7 +57,7 @@ public class GramProvider extends Abstra
 
     public static final String MYPROXY_SECURITY_CONTEXT = "myproxy";
 
-    public void initialize(InvocationContext invocationContext) throws GfacException {
+    public void initialize(InvocationContext invocationContext) throws ProviderException {
         GlobusHost host = (GlobusHost)invocationContext.getExecutionDescription().getHost();
         ShellApplicationDeployment app = (ShellApplicationDeployment)invocationContext.getExecutionDescription().getApp();
     	
@@ -90,7 +93,7 @@ public class GramProvider extends Abstra
         }
     }
 
-    public void execute(InvocationContext invocationContext) throws GfacException {
+    public void execute(InvocationContext invocationContext) throws ProviderException {
     	GlobusHost host = (GlobusHost)invocationContext.getExecutionDescription().getHost();
     	GramApplicationDeployment app = (GramApplicationDeployment)invocationContext.getExecutionDescription().getApp();
         ServiceDescription service = invocationContext.getExecutionDescription().getService();
@@ -160,11 +163,11 @@ public class GramProvider extends Abstra
             if (jobStatus == GramJob.STATUS_FAILED) {
                 errCode = listener.getError();                
                 String errorMsg = "Job " + job.getID() + " on host " + host.getName() + " Error Code = " + errCode;                
-                GfacException error = new JobSubmissionFault(new Exception(errorMsg), "GFAC HOST", gatekeeper, rsl, this);
+                JobSubmissionFault error = new JobSubmissionFault(this, new Exception(errorMsg), "GFAC HOST", gatekeeper, rsl);
                 if (errCode == 8) {
-                	error.setFaultCode(ErrorCodes.JOB_CANCELED);
+                	error.setReason(JobSubmissionFault.JOB_CANCEL);
                 } else {
-                	error.setFaultCode(ErrorCodes.JOB_FAILED);
+                    error.setReason(JobSubmissionFault.JOB_FAILED);
                 }
                 throw error;
             }
@@ -205,17 +208,23 @@ public class GramProvider extends Abstra
 
             jobSucsseful = true;
         } catch (GramException e) {
-            GfacException error = new JobSubmissionFault(e, host.getName(), gatekeeper, rsl, this);
+            JobSubmissionFault error = new JobSubmissionFault(this, e, host.getName(), gatekeeper, rsl);
             if (errCode == 8) {
-                error.setFaultCode(ErrorCodes.JOB_CANCELED);
+                error.setReason(JobSubmissionFault.JOB_CANCEL);
             } else {
-                error.setFaultCode(ErrorCodes.JOB_FAILED);
+                error.setReason(JobSubmissionFault.JOB_FAILED);
             }
             throw error;
         } catch (GSSException e) {
-            throw new JobSubmissionFault(e, "GFAC HOST", gatekeeper, rsl, this);        
+            throw new ProviderException("GFAC HOST", e);        
         } catch (InterruptedException e) {
-            throw new GfacException(e, FaultCode.ErrorAtDependentService);
+            throw new ProviderException("Thread", e);
+        } catch (SecurityException e) {
+            throw new ProviderException(e.getMessage(), e);            
+        } catch (ToolsException e) {
+            throw new ProviderException(e.getMessage(), e);
+        } catch (URISyntaxException e) {
+            throw new ProviderException("URI is in the wrong format:" + e.getMessage(), e);
         } finally {
             if (job != null && !jobSucsseful) {
                 try {



Mime
View raw message