airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject svn commit: r1407723 [1/2] - in /airavata/sandbox/grid-tools/gram-client: ./ src/main/java/org/apache/airavata/jobsubmission/ src/main/java/org/apache/airavata/jobsubmission/context/ src/main/java/org/apache/airavata/jobsubmission/gram/ src/main/java/o...
Date Sat, 10 Nov 2012 03:25:45 GMT
Author: smarru
Date: Sat Nov 10 03:25:44 2012
New Revision: 1407723

URL: http://svn.apache.org/viewvc?rev=1407723&view=rev
Log:
adding the rat headers

Modified:
    airavata/sandbox/grid-tools/gram-client/pom.xml
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/CancelJob.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobListener.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobStatus.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobSubmission.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/ApplicationContext.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/CertificateManager.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/MyProxyCredentials.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExectionContext.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/FileTransfer.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmission.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmissionListener.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmittionListener.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/GridFTPContactInfo.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/GridFtp.java
    airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/ServiceConstants.java

Modified: airavata/sandbox/grid-tools/gram-client/pom.xml
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/pom.xml?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/pom.xml (original)
+++ airavata/sandbox/grid-tools/gram-client/pom.xml Sat Nov 10 03:25:44 2012
@@ -1,3 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+	license agreements. See the NOTICE file distributed with this work for additional 
+	information regarding copyright ownership. The ASF licenses this file to 
+	you under the Apache License, Version 2.0 (theÏ "License"); you may not use 
+	this file except in compliance with the License. You may obtain a copy of 
+	the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
+	by applicable law or agreed to in writing, software distributed under the 
+	License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
+	OF ANY ~ KIND, either express or implied. See the License for the specific 
+	language governing permissions and limitations under the License. -->
+
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 	<!-- the version of maven's project object model -->
@@ -84,115 +97,7 @@
 					<target>1.5</target>
 				</configuration>
 			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-dependency-plugin</artifactId>
-				<executions>
-					<execution>
-						<id>copy-dependencies</id>
-						<phase>package</phase>
-						<goals>
-							<goal>copy-dependencies</goal>
-						</goals>
-						<configuration>
-							<outputDirectory>target/lib</outputDirectory>
-							<overWriteReleases>false</overWriteReleases>
-							<overWriteSnapshots>true</overWriteSnapshots>
-						</configuration>
-					</execution>
-				</executions>
-			</plugin>
-			<plugin>
-				<artifactId>maven-antrun-plugin</artifactId>
-				<executions>
-					<execution>
-						<id>deleteCACerts</id>
-						<phase>clean</phase>
-						<goals>
-							<goal>run</goal>
-						</goals>
-						<inherited>false</inherited>
-						<configuration>
-							<tasks>
-								<delete dir="${trustedCertsLocation}" />
-							</tasks>
-						</configuration>
-					</execution>
-					<execution>
-						<id>installCACerts</id>
-						<goals>
-							<goal>run</goal>
-						</goals>
-						<phase>process-resources</phase>
-						<inherited>false</inherited>
-						<configuration>
-							<tasks>
-								<mkdir dir="${trustedCertsLocation}" />
-								<echo message="Downloading file" />
-								<get src="http://software.xsede.org/security/xsede-certs.tar.gz"
-									dest="${trustedCertsLocation}/xsede-certs.tar.gz" ignoreerrors="yes"
-									verbose="on" />
-								<echo message="Unzipping the certs" />
-								<gunzip src="${trustedCertsLocation}/xsede-certs.tar.gz"
-									dest="${trustedCertsLocation}/" />
-
-								<echo message="Downloading file" />
-								<get
-									src="http://www.collab-ogce.org/ogce/images/d/d1/IUCerts.tar.gz"
-									dest="${trustedCertsLocation}/IUCerts.tar.gz" ignoreerrors="yes"
-									verbose="on" />
-								<echo message="Unzipping the certs" />
-								<gunzip src="${trustedCertsLocation}/IUCerts.tar.gz"
-									dest="${trustedCertsLocation}/" />
-								<echo message="Untarring" />
-								<untar dest="${trustedCertsLocation}/../">
-									<fileset dir="${trustedCertsLocation}/">
-										<include name="**/*.tar" />
-									</fileset>
-								</untar>
-
-							</tasks>
-						</configuration>
-					</execution>
-				</executions>
-			</plugin>
 		</plugins>
-		<pluginManagement>
-			<plugins>
-				<!--This plugin's configuration is used to store Eclipse m2e settings 
-					only. It has no influence on the Maven build itself. -->
-				<plugin>
-					<groupId>org.eclipse.m2e</groupId>
-					<artifactId>lifecycle-mapping</artifactId>
-					<version>1.0.0</version>
-					<configuration>
-						<lifecycleMappingMetadata>
-							<pluginExecutions>
-								<pluginExecution>
-									<pluginExecutionFilter>
-										<groupId>
-											org.apache.maven.plugins
-										</groupId>
-										<artifactId>
-											maven-antrun-plugin
-										</artifactId>
-										<versionRange>
-											[1.3,)
-										</versionRange>
-										<goals>
-											<goal>run</goal>
-										</goals>
-									</pluginExecutionFilter>
-									<action>
-										<ignore></ignore>
-									</action>
-								</pluginExecution>
-							</pluginExecutions>
-						</lifecycleMappingMetadata>
-					</configuration>
-				</plugin>
-			</plugins>
-		</pluginManagement>
 	</build>
 
 </project>

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/CancelJob.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/CancelJob.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/CancelJob.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/CancelJob.java Sat Nov 10 03:25:44 2012
@@ -1,3 +1,24 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
 package org.apache.airavata.jobsubmission;
 
 import org.apache.airavata.jobsubmission.context.ApplicationContext;

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobListener.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobListener.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobListener.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobListener.java Sat Nov 10 03:25:44 2012
@@ -1,3 +1,24 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
 package org.apache.airavata.jobsubmission;
 
 import org.globus.gram.GramException;
@@ -8,48 +29,48 @@ import org.ietf.jgss.GSSException;
 
 public class JobListener implements GramJobListener {
 
-	private boolean finished;
-	private int error;
-	private int status;
-	private GSSCredential credential;
-	private GramJob job;
-	
-	public JobListener(GramJob job, GSSCredential credential) {
-		this.job = job;
-		this.credential = credential;
-	}
-	public void waitFor() throws InterruptedException, GSSException, GramException {
-		while (!finished) {
-			
-		// job status is changed but method isn't invoked
-		if (status != 0) {
-			if (job.getStatus() != status) {
-				System.out.println("invoke method manually");
-				statusChanged(job);
-				}
-			}
-		 else {
-			statusChanged(job);
-			 System.out.println("Status is zero");
-		}
-		synchronized (this) {
-			wait(1000l);
-		}		
-		}
-	}
-
-	public void statusChanged(GramJob job) {
-		int jobStatus = job.getStatus();
-		String jobId = job.getIDAsString();
-		String statusString = job.getStatusAsString();
-		System.out.println("Status " + statusString);
-		if (jobStatus == GramJob.STATUS_DONE) {
-			finished = true;
-		} else if (jobStatus == GramJob.STATUS_FAILED) {
-			finished = true;
-			error = job.getError();
-			System.out.println("Job Error Code: " + error);
-		}
-	}
+    private boolean finished;
+    private int error;
+    private int status;
+    private GSSCredential credential;
+    private GramJob job;
+
+    public JobListener(GramJob job, GSSCredential credential) {
+        this.job = job;
+        this.credential = credential;
+    }
+
+    public void waitFor() throws InterruptedException, GSSException, GramException {
+        while (!finished) {
+
+            // job status is changed but method isn't invoked
+            if (status != 0) {
+                if (job.getStatus() != status) {
+                    System.out.println("invoke method manually");
+                    statusChanged(job);
+                }
+            } else {
+                statusChanged(job);
+                System.out.println("Status is zero");
+            }
+            synchronized (this) {
+                wait(1000l);
+            }
+        }
+    }
+
+    public void statusChanged(GramJob job) {
+        int jobStatus = job.getStatus();
+        String jobId = job.getIDAsString();
+        String statusString = job.getStatusAsString();
+        System.out.println("Status " + statusString);
+        if (jobStatus == GramJob.STATUS_DONE) {
+            finished = true;
+        } else if (jobStatus == GramJob.STATUS_FAILED) {
+            finished = true;
+            error = job.getError();
+            System.out.println("Job Error Code: " + error);
+        }
+    }
 
 }
\ No newline at end of file

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobStatus.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobStatus.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobStatus.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobStatus.java Sat Nov 10 03:25:44 2012
@@ -1,3 +1,24 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
 package org.apache.airavata.jobsubmission;
 
 import org.apache.airavata.jobsubmission.context.ApplicationContext;
@@ -5,29 +26,28 @@ import org.globus.gram.GramJob;
 
 public class JobStatus {
 
-	
-	/**
-	 * @param args
-	 */
-	public static void main(String[] args) {
-		try {
-			ApplicationContext context = new ApplicationContext();
-			context.login();
-			
-			String rsl = "";
-			GramJob job = new GramJob(context.getGssCredential(),rsl);
-			job.setID("https://gatekeeper.ranger.tacc.teragrid.org:50388/16073791261988702796/9536223017013632385/");
-			JobListener listener = new JobListener(job, context.getGssCredential());
-			job.addListener(listener);
-			System.out.println("Status 1111111" + job.getStatusAsString());
-		    listener.waitFor();
-			System.out.println("Now Status" + job.getStatusAsString());
-			job.removeListener(listener);
-		} catch (Exception e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+    /**
+     * @param args
+     */
+    public static void main(String[] args) {
+        try {
+            ApplicationContext context = new ApplicationContext();
+            context.login();
+
+            String rsl = "";
+            GramJob job = new GramJob(context.getGssCredential(), rsl);
+            job.setID("https://gatekeeper.ranger.tacc.teragrid.org:50388/16073791261988702796/9536223017013632385/");
+            JobListener listener = new JobListener(job, context.getGssCredential());
+            job.addListener(listener);
+            System.out.println("Status 1111111" + job.getStatusAsString());
+            listener.waitFor();
+            System.out.println("Now Status" + job.getStatusAsString());
+            job.removeListener(listener);
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
 
-	}
+    }
 
 }

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobSubmission.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobSubmission.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobSubmission.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobSubmission.java Sat Nov 10 03:25:44 2012
@@ -1,3 +1,24 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
 package org.apache.airavata.jobsubmission;
 
 import org.apache.airavata.jobsubmission.context.ApplicationContext;
@@ -8,95 +29,95 @@ import org.ietf.jgss.GSSCredential;
 
 public class JobSubmission {
 
-	private static final Logger log = Logger.getLogger(JobSubmission.class);
-	private static ExectionContext contextExectionContext;
-	private static ApplicationContext context;
-	private static String newline = System.getProperty("line.separator");
-
-	public static synchronized ApplicationContext getContext() throws Exception {
-		if (context == null) {
-			context = new ApplicationContext();
-			try {
-				context.login();
-			} catch (Exception e) {
-				context = null;
-				e.printStackTrace();
-				throw e;
-			}
-		}
-		return context;
-	}
-
-	public static ExectionContext getExecutionContext() {
-
-		if (contextExectionContext == null) {
-			try {
-				contextExectionContext = new ExectionContext();
-			} catch (Exception e) {
-				log.error("Error loading configuration file", e);
-				System.err.println("Make sure configuration file is in classpath and has proper values");
-
-				/*
-				 * Set required value to default since property file cannot be
-				 * loaded
-				 */
-				// contextExectionContext.setHost("login5.ranger.tacc.utexas.edu:2120/jobmanager-sge");
-				// contextExectionContext.setHost("gatekeeper.lonestar.tacc.teragrid.org:2120/jobmanager-lsf");
-				// contextExectionContext.setHost("queenbee.loni-lsu.teragrid.org:2120/jobmanager-pbs");
-				contextExectionContext.setHost("gatekeeper.ranger.tacc.teragrid.org:2120/jobmanager-sge");
-				contextExectionContext.setExecutable("/bin/sleep");
-				contextExectionContext.setArguments("30");
-				contextExectionContext.setQueue("checkpt");
-				contextExectionContext.setProjectName("TG-STA060010N");
-				contextExectionContext.setJobType("single");
-				contextExectionContext.setMaxWallTime(1);
-				contextExectionContext.setPcount(1);
-				contextExectionContext.setHostCount(1);
-				e.printStackTrace();
-			}
-		}
-		return contextExectionContext;
-	}
-
-	public static void main(String[] args) {
-		try {
-			ApplicationContext context = new ApplicationContext();
-			context.login();
-
-			StringBuffer jobstatus = new StringBuffer();
-			GramJobSubmission gramJobSubmittion = new GramJobSubmission();
-
-			System.out.println();
-
-			gramJobSubmittion.executeJob(context.getGssCredential(), getExecutionContext(), jobstatus);
-			System.out.println(jobstatus.toString());
-			System.exit(0);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-
-	public String toString() {
-		String result = null;
-		try {
-			StringBuffer x = new StringBuffer();
-			GSSCredential gssCredential = getContext().getGssCredential();
-			x.append(getExecutionContext().getHost() + "#" + getCName(gssCredential.getName().toString()) + newline);
-			log.info("NAME:" + getCName(gssCredential.getName().toString()));
-
-			GramJobSubmission gramJobSubmittion = new GramJobSubmission();
-			gramJobSubmittion.executeJob(gssCredential, getExecutionContext(), x);
-			result = x.toString();
-		} catch (Exception e) {
-			log.error(e.getCause());
-			result = getExecutionContext().getHost() + "#" + "user" + newline + System.currentTimeMillis() + "#" + "id" + "#" + "FAILED" + "#" + e.getMessage();
-
-		}
-		return result;
-	}
-
-	private String getCName(String full) {
-		int index = full.indexOf("/CN=");
-		return full.substring(index + 4);
-	}
+    private static final Logger log = Logger.getLogger(JobSubmission.class);
+    private static ExectionContext contextExectionContext;
+    private static ApplicationContext context;
+    private static String newline = System.getProperty("line.separator");
+
+    public static synchronized ApplicationContext getContext() throws Exception {
+        if (context == null) {
+            context = new ApplicationContext();
+            try {
+                context.login();
+            } catch (Exception e) {
+                context = null;
+                e.printStackTrace();
+                throw e;
+            }
+        }
+        return context;
+    }
+
+    public static ExectionContext getExecutionContext() {
+
+        if (contextExectionContext == null) {
+            try {
+                contextExectionContext = new ExectionContext();
+            } catch (Exception e) {
+                log.error("Error loading configuration file", e);
+                System.err.println("Make sure configuration file is in classpath and has proper values");
+
+                /*
+                 * Set required value to default since property file cannot be loaded
+                 */
+                // contextExectionContext.setHost("login5.ranger.tacc.utexas.edu:2120/jobmanager-sge");
+                // contextExectionContext.setHost("gatekeeper.lonestar.tacc.teragrid.org:2120/jobmanager-lsf");
+                // contextExectionContext.setHost("queenbee.loni-lsu.teragrid.org:2120/jobmanager-pbs");
+                contextExectionContext.setHost("gatekeeper.ranger.tacc.teragrid.org:2120/jobmanager-sge");
+                contextExectionContext.setExecutable("/bin/sleep");
+                contextExectionContext.setArguments("30");
+                contextExectionContext.setQueue("checkpt");
+                contextExectionContext.setProjectName("TG-STA060010N");
+                contextExectionContext.setJobType("single");
+                contextExectionContext.setMaxWallTime(1);
+                contextExectionContext.setPcount(1);
+                contextExectionContext.setHostCount(1);
+                e.printStackTrace();
+            }
+        }
+        return contextExectionContext;
+    }
+
+    public static void main(String[] args) {
+        try {
+            ApplicationContext context = new ApplicationContext();
+            context.login();
+
+            StringBuffer jobstatus = new StringBuffer();
+            GramJobSubmission gramJobSubmittion = new GramJobSubmission();
+
+            System.out.println();
+
+            gramJobSubmittion.executeJob(context.getGssCredential(), getExecutionContext(), jobstatus);
+            System.out.println(jobstatus.toString());
+            System.exit(0);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public String toString() {
+        String result = null;
+        try {
+            StringBuffer x = new StringBuffer();
+            GSSCredential gssCredential = getContext().getGssCredential();
+            x.append(getExecutionContext().getHost() + "#" + getCName(gssCredential.getName().toString()) + newline);
+            log.info("NAME:" + getCName(gssCredential.getName().toString()));
+
+            GramJobSubmission gramJobSubmittion = new GramJobSubmission();
+            gramJobSubmittion.executeJob(gssCredential, getExecutionContext(), x);
+            result = x.toString();
+        } catch (Exception e) {
+            log.error(e.getCause());
+            result = getExecutionContext().getHost() + "#" + "user" + newline + System.currentTimeMillis() + "#" + "id"
+                    + "#" + "FAILED" + "#" + e.getMessage();
+
+        }
+        return result;
+    }
+
+    private String getCName(String full) {
+        int index = full.indexOf("/CN=");
+        return full.substring(index + 4);
+    }
 }

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/ApplicationContext.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/ApplicationContext.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/ApplicationContext.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/ApplicationContext.java Sat Nov 10 03:25:44 2012
@@ -1,9 +1,22 @@
 /*
- * Copyright (c) 2009 Pervasive Lab, Indiana University. All rights reserved.
  *
- * This software is open source. See the bottom of this file for the license.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
- * $Id: $
  */
 
 package org.apache.airavata.jobsubmission.context;
@@ -18,164 +31,161 @@ import org.apache.log4j.Logger;
 import org.globus.myproxy.MyProxy;
 import org.ietf.jgss.GSSCredential;
 
-/**
- * @author Raminderjeet Singh
- */
 public class ApplicationContext {
 
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -2270092298283648553L;
-	public static final String GRAMCLIENT_PROPERTY = "gramclient.properties";
-	private Properties properties;
-	protected GSSCredential gssCredential;
-
-	private MyProxyCredentials credentials;
-	private static final Logger log = Logger.getLogger(ApplicationContext.class);
-
-	/**
-	 * 
-	 * Constructs a ApplicationGlobalContext.
-	 * 
-	 * @throws GfacGUIException
-	 */
-
-	public ApplicationContext() throws Exception {
-		log.setLevel(org.apache.log4j.Level.INFO);
-		loadConfiguration();
-
-	}
-
-	public static void main(String[] args) {
-		try {
-			ApplicationContext context = new ApplicationContext();
-			context.login();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 
-	 * @throws GfacException
-	 */
-	public void login() throws Exception {
-		gssCredential = credentials.getGssCredential();
-	}
-
-	public static String getProperty(String name) {
-		try {
-			ApplicationContext context = new ApplicationContext();
-			return context.getProperties().getProperty(name);
-		} catch (Exception e) {
-			e.printStackTrace();
-			return null;
-		}
-
-	}
-
-	/**
-	 * Load the configration file
-	 * 
-	 * @throws GfacException
-	 */
-	private void loadConfiguration() throws Exception {
-		try {
-			if (properties == null) {
-				ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-				File webinfDir = null;
-				URL propertyFile = classLoader.getResource(GRAMCLIENT_PROPERTY);
-
-				if (propertyFile != null) {
-					File tempFile = new File(propertyFile.getFile());
-					if (tempFile.exists()) {
-						webinfDir = tempFile.getParentFile().getParentFile();
-					}
-				} else {
-					throw new Exception(" Not able to locate " + GRAMCLIENT_PROPERTY);
-				}
-				InputStream propertyStream = classLoader.getResourceAsStream(GRAMCLIENT_PROPERTY);
-				properties = new Properties();
-				if (credentials == null) {
-					this.credentials = new MyProxyCredentials();
-				}
-				if (propertyStream != null) {
-					properties.load(propertyStream);
-					String myproxyServerTmp = properties.getProperty(ServiceConstants.MYPROXY_SERVER);
-					if (myproxyServerTmp != null) {
-						this.credentials.setMyproxyHostname(myproxyServerTmp.trim());
-					}
-					String myproxyPortTemp = properties.getProperty(ServiceConstants.MYPROXY_PORT);
-					if (myproxyPortTemp != null && myproxyPortTemp.trim().length() > 0) {
-						this.credentials.setMyproxyPortNumber(Integer.parseInt(myproxyPortTemp.trim()));
-					} else {
-						this.credentials.setMyproxyPortNumber(MyProxy.DEFAULT_PORT);
-					}
-					String myproxyuser = properties.getProperty(ServiceConstants.MYPROXY_USERNAME);
-					if (myproxyuser != null) {
-						this.credentials.setMyproxyUserName(myproxyuser);
-					}
-					String myproxypass = properties.getProperty(ServiceConstants.MYPROXY_PASSWD);
-					if (myproxypass != null) {
-						this.credentials.setMyproxyPassword(myproxypass);
-					}
-					String myproxytime = properties.getProperty(ServiceConstants.MYPROXY_LIFETIME);
-					if (myproxytime != null) {
-						this.credentials.setMyproxyLifeTime(Integer.parseInt(myproxytime));
-					}
-					this.credentials.setHostcertsKeyFile(properties.getProperty(ServiceConstants.HOSTCERTS_KEY_FILE));
-					this.credentials.setTrustedCertsFile(properties.getProperty(ServiceConstants.TRUSTED_CERTS_FILE));
-				}
-			}
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			log.error(e.getLocalizedMessage());
-			throw new Exception(e);
-		}
-
-	}
-
-	/**
-	 * @return the properties
-	 */
-	public Properties getProperties() {
-		return properties;
-	}
-
-	/**
-	 * @param properties
-	 *            the properties to set
-	 */
-	public void setProperties(Properties properties) {
-		this.properties = properties;
-	}
-
-	/**
-	 * Returns the gssCredential.
-	 * 
-	 * @return The gssCredential
-	 */
-	public GSSCredential getGssCredential() {
-		return this.gssCredential;
-	}
-
-	/**
-	 * Sets gssCredential.
+    /**
 	 * 
-	 * @param gssCredential
-	 *            The gssCredential to set.
 	 */
-	public void setGssCredential(GSSCredential gssCredential) {
-		this.gssCredential = gssCredential;
-	}
-
-	public MyProxyCredentials getCredentials() {
-		return credentials;
-	}
-
-	public void setCredentials(MyProxyCredentials credentials) {
-		this.credentials = credentials;
-	}
+    private static final long serialVersionUID = -2270092298283648553L;
+    public static final String GRAMCLIENT_PROPERTY = "gramclient.properties";
+    private Properties properties;
+    protected GSSCredential gssCredential;
+
+    private MyProxyCredentials credentials;
+    private static final Logger log = Logger.getLogger(ApplicationContext.class);
+
+    /**
+     * 
+     * Constructs a ApplicationGlobalContext.
+     * 
+     * @throws GfacGUIException
+     */
+
+    public ApplicationContext() throws Exception {
+        log.setLevel(org.apache.log4j.Level.INFO);
+        loadConfiguration();
+
+    }
+
+    public static void main(String[] args) {
+        try {
+            ApplicationContext context = new ApplicationContext();
+            context.login();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 
+     * @throws GfacException
+     */
+    public void login() throws Exception {
+        gssCredential = credentials.getGssCredential();
+    }
+
+    public static String getProperty(String name) {
+        try {
+            ApplicationContext context = new ApplicationContext();
+            return context.getProperties().getProperty(name);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+
+    }
+
+    /**
+     * Load the configration file
+     * 
+     * @throws GfacException
+     */
+    private void loadConfiguration() throws Exception {
+        try {
+            if (properties == null) {
+                ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+                File webinfDir = null;
+                URL propertyFile = classLoader.getResource(GRAMCLIENT_PROPERTY);
+
+                if (propertyFile != null) {
+                    File tempFile = new File(propertyFile.getFile());
+                    if (tempFile.exists()) {
+                        webinfDir = tempFile.getParentFile().getParentFile();
+                    }
+                } else {
+                    throw new Exception(" Not able to locate " + GRAMCLIENT_PROPERTY);
+                }
+                InputStream propertyStream = classLoader.getResourceAsStream(GRAMCLIENT_PROPERTY);
+                properties = new Properties();
+                if (credentials == null) {
+                    this.credentials = new MyProxyCredentials();
+                }
+                if (propertyStream != null) {
+                    properties.load(propertyStream);
+                    String myproxyServerTmp = properties.getProperty(ServiceConstants.MYPROXY_SERVER);
+                    if (myproxyServerTmp != null) {
+                        this.credentials.setMyproxyHostname(myproxyServerTmp.trim());
+                    }
+                    String myproxyPortTemp = properties.getProperty(ServiceConstants.MYPROXY_PORT);
+                    if (myproxyPortTemp != null && myproxyPortTemp.trim().length() > 0) {
+                        this.credentials.setMyproxyPortNumber(Integer.parseInt(myproxyPortTemp.trim()));
+                    } else {
+                        this.credentials.setMyproxyPortNumber(MyProxy.DEFAULT_PORT);
+                    }
+                    String myproxyuser = properties.getProperty(ServiceConstants.MYPROXY_USERNAME);
+                    if (myproxyuser != null) {
+                        this.credentials.setMyproxyUserName(myproxyuser);
+                    }
+                    String myproxypass = properties.getProperty(ServiceConstants.MYPROXY_PASSWD);
+                    if (myproxypass != null) {
+                        this.credentials.setMyproxyPassword(myproxypass);
+                    }
+                    String myproxytime = properties.getProperty(ServiceConstants.MYPROXY_LIFETIME);
+                    if (myproxytime != null) {
+                        this.credentials.setMyproxyLifeTime(Integer.parseInt(myproxytime));
+                    }
+                    this.credentials.setHostcertsKeyFile(properties.getProperty(ServiceConstants.HOSTCERTS_KEY_FILE));
+                    this.credentials.setTrustedCertsFile(properties.getProperty(ServiceConstants.TRUSTED_CERTS_FILE));
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getLocalizedMessage());
+            throw new Exception(e);
+        }
+
+    }
+
+    /**
+     * @return the properties
+     */
+    public Properties getProperties() {
+        return properties;
+    }
+
+    /**
+     * @param properties
+     *            the properties to set
+     */
+    public void setProperties(Properties properties) {
+        this.properties = properties;
+    }
+
+    /**
+     * Returns the gssCredential.
+     * 
+     * @return The gssCredential
+     */
+    public GSSCredential getGssCredential() {
+        return this.gssCredential;
+    }
+
+    /**
+     * Sets gssCredential.
+     * 
+     * @param gssCredential
+     *            The gssCredential to set.
+     */
+    public void setGssCredential(GSSCredential gssCredential) {
+        this.gssCredential = gssCredential;
+    }
+
+    public MyProxyCredentials getCredentials() {
+        return credentials;
+    }
+
+    public void setCredentials(MyProxyCredentials credentials) {
+        this.credentials = credentials;
+    }
 }

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/CertificateManager.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/CertificateManager.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/CertificateManager.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/CertificateManager.java Sat Nov 10 03:25:44 2012
@@ -1,10 +1,24 @@
 /*
- * Copyright (c) 2009 Pervasive Lab, Indiana University. All rights reserved.
  *
- * This software is open source. See the bottom of this file for the license.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
- * $Id: $
  */
+
 package org.apache.airavata.jobsubmission.context;
 
 import java.io.InputStream;
@@ -16,15 +30,8 @@ import java.util.List;
 import org.globus.gsi.CertUtil;
 import org.globus.util.ClassLoaderUtils;
 
-
-
-/**
- * @author Raminderjeet Singh
- */
 public class CertificateManager {
 
-  
- 
     private static X509Certificate[] trustedCertificates;
 
     /**
@@ -38,40 +45,36 @@ public class CertificateManager {
         }
 
         List<X509Certificate> extremeTrustedCertificates = getTrustedCertificates(certificate);
- 
+
         List<X509Certificate> allTrustedCertificates = new ArrayList<X509Certificate>();
         allTrustedCertificates.addAll(extremeTrustedCertificates);
- 
-        trustedCertificates = allTrustedCertificates
-                .toArray(new X509Certificate[allTrustedCertificates.size()]);
+
+        trustedCertificates = allTrustedCertificates.toArray(new X509Certificate[allTrustedCertificates.size()]);
         return trustedCertificates;
     }
 
-
     private static List<X509Certificate> getTrustedCertificates(String pass) {
-    	//ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); //**
-    	//InputStream stream = classLoader.getResourceAsStream(pass); //**
-    	InputStream stream = ClassLoaderUtils.getResourceAsStream(pass); //**
+        // ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); //**
+        // InputStream stream = classLoader.getResourceAsStream(pass); //**
+        InputStream stream = ClassLoaderUtils.getResourceAsStream(pass); // **
         if (stream == null) {
-            throw new RuntimeException("Failed to get InputStream to "
-                    + pass);
+            throw new RuntimeException("Failed to get InputStream to " + pass);
         }
         return readTrustedCertificates(stream);
     }
-    
+
     /**
      * @param stream
      * @return List of X509Certificate
      */
-    public static List<X509Certificate> readTrustedCertificates(
-            InputStream stream) {
+    public static List<X509Certificate> readTrustedCertificates(InputStream stream) {
         ArrayList<X509Certificate> certificates = new ArrayList<X509Certificate>();
         while (true) {
             X509Certificate certificate;
             try {
-            	 certificate = CertUtil.loadCertificate(stream);
-//                certificate = CertificateLoadUtil.loadCertificate(stream); //**
-            }catch (GeneralSecurityException e) {
+                certificate = CertUtil.loadCertificate(stream);
+                // certificate = CertificateLoadUtil.loadCertificate(stream); //**
+            } catch (GeneralSecurityException e) {
                 String message = "Certificates are invalid";
                 throw new RuntimeException(message, e);
             }
@@ -84,4 +87,3 @@ public class CertificateManager {
     }
 
 }
-

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/MyProxyCredentials.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/MyProxyCredentials.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/MyProxyCredentials.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/context/MyProxyCredentials.java Sat Nov 10 03:25:44 2012
@@ -1,10 +1,24 @@
 /*
- * Copyright (c) 2009 Pervasive Lab, Indiana University. All rights reserved.
  *
- * This software is open source. See the bottom of this file for the license.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
- * $Id: $
  */
+
 package org.apache.airavata.jobsubmission.context;
 
 import java.io.File;
@@ -20,286 +34,285 @@ import org.globus.gsi.gssapi.GlobusGSSCr
 import org.globus.myproxy.MyProxy;
 import org.ietf.jgss.GSSCredential;
 
-/**
- * @author Raminderjeet Singh
- */
 public class MyProxyCredentials implements Serializable {
 
-	private static final long serialVersionUID = -2471014486509046212L;
-	protected String myproxyHostname;
-	protected String myproxyUserName;
-	protected String myproxyPassword;
-	protected int myproxyPortNumber;
-	protected GSSCredential gssCredential;
-	protected String portalUserName;
-	private String hostcertsKeyFile;
-	private String trustedCertsFile;
-
-	protected int myproxyLifeTime = 14400;
-	final static int SECS_PER_MIN = 60;
-	final static int SECS_PER_HOUR = 3600;
-
-	private boolean initialized = false;
-	private boolean user = true;
-	protected X509Certificate[] trustedCertificates;
-
-	private static final Logger log = Logger.getLogger(MyProxyCredentials.class);
-
-	public MyProxyCredentials() {
-		// default constructor
-	}
-
-	public MyProxyCredentials(String myproxyServer, int myproxyPort, String myproxyUsername, String myproxyPassphrase, int myproxyLifetime) {
-		this.myproxyHostname = myproxyServer;
-		this.myproxyPortNumber = myproxyPort;
-		this.myproxyUserName = myproxyUsername;
-		this.myproxyPassword = myproxyPassphrase;
-		this.myproxyLifeTime = myproxyLifetime;
-
-	}
-
-	public GSSCredential getGssCredential() throws Exception {
-		FileInputStream fis = null;
-		try {
-			if (hostcertsKeyFile != null && !user) {
-				fis = new FileInputStream(hostcertsKeyFile);
-//				X509Credential globusCred = new X509Credential(fis); //**
-				GlobusCredential globusCred = new GlobusCredential(fis);
-				this.gssCredential = new GlobusGSSCredentialImpl(globusCred, GSSCredential.INITIATE_AND_ACCEPT);
-
-			} else {
-				this.gssCredential = getDefaultProxy();
-			}
-			if (gssCredential != null) {
-				return gssCredential;
-			}
-		} catch (Exception e) {
-			log.error("Failed to load proxy credential from ProxyManager");
-			e.printStackTrace();
-			throw e;
-		} finally {
-			if (fis != null) {
-				fis.close();
-			}
-		}
-
-		// then we will try the MyProxy
-		if (getMyproxyUserName() != null && getMyproxyPassword() != null) {
-			gssCredential = renewProxy();
-		}
-		return gssCredential;
-	}
-
-	public GSSCredential getDefaultProxy() throws Exception {
-		init();
-		MyProxy myproxy = new MyProxy(this.myproxyHostname, this.myproxyPortNumber);
-		log.info("USER=" + this.myproxyUserName + ",PASS=" + this.myproxyPassword + ",TIME=" + this.myproxyLifeTime);
-		return myproxy.get(this.myproxyUserName, this.myproxyPassword, this.myproxyLifeTime);
-	}
-
-	private void init() {
-		if (trustedCertsFile != null) {
-			if (new File(trustedCertsFile).isDirectory()) {
-				TrustedCertificates certificates = TrustedCertificates.load(trustedCertsFile);
-				TrustedCertificates.setDefaultTrustedCertificates(certificates);
-			} else {
-				this.trustedCertificates = CertificateManager.getTrustedCertificate(trustedCertsFile);
-
-				TrustedCertificates certificatesArray = new TrustedCertificates(this.trustedCertificates);
-				TrustedCertificates.setDefaultTrustedCertificates(certificatesArray);
-			}
-		}
-	}
-
-	public GSSCredential renewProxy() throws Exception {
-		init();
-
-		FileOutputStream fout = null;
-		try {
-			String proxyloc = null;
-			MyProxy myproxy = new MyProxy(myproxyHostname, myproxyPortNumber);
-			int lifeHours = myproxyLifeTime * SECS_PER_HOUR;
-			GSSCredential proxy = myproxy.get(myproxyUserName, myproxyPassword, lifeHours);
-
-			GlobusCredential globusCred = null; //**
-//			X509Credential globusCred = null; //**
-			if (proxy instanceof GlobusGSSCredentialImpl) {
-				globusCred = ((GlobusGSSCredentialImpl) proxy).getGlobusCredential();//** 
-//				globusCred = ((GlobusGSSCredentialImpl) proxy).getX509Credential();//**
-				log.info("got proxy from myproxy for " + myproxyUserName + " with " + myproxyLifeTime + " lifetime.");
-				String uid = myproxyUserName;
-				if (proxyloc == null) {
-					log.info("uid: " + uid);
-					proxyloc = "/tmp/x509up_u" + uid;
-				}
-				File proxyfile = new File(proxyloc);
-				log.info("proxy location: " + proxyfile.getAbsolutePath());
-				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.");
-				}
-				fout = new FileOutputStream(proxyfile);
-				globusCred.save(fout);
-				String osName = System.getProperty("os.name");
-				if (!osName.contains("Windows")) {
-					Runtime.getRuntime().exec("/bin/chmod 600 " + proxyloc);
-				}
-				log.info("Proxy file renewed to " + proxyloc + " for the user " + myproxyUserName + " with " + myproxyLifeTime + " lifetime.");
-
-			}
-			return proxy;
-		} catch (Exception e) {
-			throw new Exception(e);
-		} finally {
-			if (fout != null) {
-				fout.close();
-			}
-		}
-	}
-
-	/**
-	 * @return the myproxyHostname
-	 */
-	public String getMyproxyHostname() {
-		return myproxyHostname;
-	}
-
-	/**
-	 * @param myproxyHostname
-	 *            the myproxyHostname to set
-	 */
-	public void setMyproxyHostname(String myproxyHostname) {
-		this.myproxyHostname = myproxyHostname;
-	}
-
-	/**
-	 * @return the myproxyUserName
-	 */
-	public String getMyproxyUserName() {
-		return myproxyUserName;
-	}
-
-	/**
-	 * @param myproxyUserName
-	 *            the myproxyUserName to set
-	 */
-	public void setMyproxyUserName(String myproxyUserName) {
-		this.myproxyUserName = myproxyUserName;
-	}
-
-	/**
-	 * @return the myproxyPassword
-	 */
-	public String getMyproxyPassword() {
-		return myproxyPassword;
-	}
-
-	/**
-	 * @param myproxyPassword
-	 *            the myproxyPassword to set
-	 */
-	public void setMyproxyPassword(String myproxyPassword) {
-		this.myproxyPassword = myproxyPassword;
-	}
-
-	/**
-	 * @return the myproxyLifeTime
-	 */
-	public int getMyproxyLifeTime() {
-		return myproxyLifeTime;
-	}
-
-	/**
-	 * @param myproxyLifeTime
-	 *            the myproxyLifeTime to set
-	 */
-	public void setMyproxyLifeTime(int myproxyLifeTime) {
-		this.myproxyLifeTime = myproxyLifeTime;
-	}
-
-	/**
-	 * @return the myproxyPortNumber
-	 */
-	public int getMyproxyPortNumber() {
-		return myproxyPortNumber;
-	}
-
-	/**
-	 * @param myproxyPortNumber
-	 *            the myproxyPortNumber to set
-	 */
-	public void setMyproxyPortNumber(int myproxyPortNumber) {
-		this.myproxyPortNumber = myproxyPortNumber;
-	}
-
-	/**
-	 * @return the portalUserName
-	 */
-	public String getPortalUserName() {
-		return portalUserName;
-	}
-
-	/**
-	 * @param portalUserName
-	 *            the portalUserName to set
-	 */
-	public void setPortalUserName(String portalUserName) {
-		this.portalUserName = portalUserName;
-	}
-
-	/**
-	 * Returns the initialized.
-	 * 
-	 * @return The initialized
-	 */
-	public boolean isInitialized() {
-		return this.initialized;
-	}
-
-	/**
-	 * Sets initialized.
-	 * 
-	 * @param initialized
-	 *            The initialized to set.
-	 */
-	public void setInitialized(boolean initialized) {
-		this.initialized = initialized;
-	}
-
-	/**
-	 * @param hostcertsKeyFile
-	 *            the hostcertsKeyFile to set
-	 */
-	public void setHostcertsKeyFile(String hostcertsKeyFile) {
-		this.hostcertsKeyFile = hostcertsKeyFile;
-	}
-
-	/**
-	 * @return the hostcertsKeyFile
-	 */
-	public String getHostcertsKeyFile() {
-		return hostcertsKeyFile;
-	}
-
-	/**
-	 * @param trustedCertsFile
-	 *            the trustedCertsFile to set
-	 */
-	public void setTrustedCertsFile(String trustedCertsFile) {
-		this.trustedCertsFile = trustedCertsFile;
-	}
-
-	/**
-	 * @return the trustedCertsFile
-	 */
-	public String getTrustedCertsFile() {
-		return trustedCertsFile;
-	}
+    private static final long serialVersionUID = -2471014486509046212L;
+    protected String myproxyHostname;
+    protected String myproxyUserName;
+    protected String myproxyPassword;
+    protected int myproxyPortNumber;
+    protected GSSCredential gssCredential;
+    protected String portalUserName;
+    private String hostcertsKeyFile;
+    private String trustedCertsFile;
+
+    protected int myproxyLifeTime = 14400;
+    final static int SECS_PER_MIN = 60;
+    final static int SECS_PER_HOUR = 3600;
+
+    private boolean initialized = false;
+    private boolean user = true;
+    protected X509Certificate[] trustedCertificates;
+
+    private static final Logger log = Logger.getLogger(MyProxyCredentials.class);
+
+    public MyProxyCredentials() {
+        // default constructor
+    }
+
+    public MyProxyCredentials(String myproxyServer, int myproxyPort, String myproxyUsername, String myproxyPassphrase,
+            int myproxyLifetime) {
+        this.myproxyHostname = myproxyServer;
+        this.myproxyPortNumber = myproxyPort;
+        this.myproxyUserName = myproxyUsername;
+        this.myproxyPassword = myproxyPassphrase;
+        this.myproxyLifeTime = myproxyLifetime;
+
+    }
+
+    public GSSCredential getGssCredential() throws Exception {
+        FileInputStream fis = null;
+        try {
+            if (hostcertsKeyFile != null && !user) {
+                fis = new FileInputStream(hostcertsKeyFile);
+                // X509Credential globusCred = new X509Credential(fis); //**
+                GlobusCredential globusCred = new GlobusCredential(fis);
+                this.gssCredential = new GlobusGSSCredentialImpl(globusCred, GSSCredential.INITIATE_AND_ACCEPT);
+
+            } else {
+                this.gssCredential = getDefaultProxy();
+            }
+            if (gssCredential != null) {
+                return gssCredential;
+            }
+        } catch (Exception e) {
+            log.error("Failed to load proxy credential from ProxyManager");
+            e.printStackTrace();
+            throw e;
+        } finally {
+            if (fis != null) {
+                fis.close();
+            }
+        }
+
+        // then we will try the MyProxy
+        if (getMyproxyUserName() != null && getMyproxyPassword() != null) {
+            gssCredential = renewProxy();
+        }
+        return gssCredential;
+    }
+
+    public GSSCredential getDefaultProxy() throws Exception {
+        init();
+        MyProxy myproxy = new MyProxy(this.myproxyHostname, this.myproxyPortNumber);
+        log.info("USER=" + this.myproxyUserName + ",PASS=" + this.myproxyPassword + ",TIME=" + this.myproxyLifeTime);
+        return myproxy.get(this.myproxyUserName, this.myproxyPassword, this.myproxyLifeTime);
+    }
+
+    private void init() {
+        if (trustedCertsFile != null) {
+            if (new File(trustedCertsFile).isDirectory()) {
+                TrustedCertificates certificates = TrustedCertificates.load(trustedCertsFile);
+                TrustedCertificates.setDefaultTrustedCertificates(certificates);
+            } else {
+                this.trustedCertificates = CertificateManager.getTrustedCertificate(trustedCertsFile);
+
+                TrustedCertificates certificatesArray = new TrustedCertificates(this.trustedCertificates);
+                TrustedCertificates.setDefaultTrustedCertificates(certificatesArray);
+            }
+        }
+    }
+
+    public GSSCredential renewProxy() throws Exception {
+        init();
+
+        FileOutputStream fout = null;
+        try {
+            String proxyloc = null;
+            MyProxy myproxy = new MyProxy(myproxyHostname, myproxyPortNumber);
+            int lifeHours = myproxyLifeTime * SECS_PER_HOUR;
+            GSSCredential proxy = myproxy.get(myproxyUserName, myproxyPassword, lifeHours);
+
+            GlobusCredential globusCred = null; // **
+            // X509Credential globusCred = null; //**
+            if (proxy instanceof GlobusGSSCredentialImpl) {
+                globusCred = ((GlobusGSSCredentialImpl) proxy).getGlobusCredential();// **
+                // globusCred = ((GlobusGSSCredentialImpl) proxy).getX509Credential();//**
+                log.info("got proxy from myproxy for " + myproxyUserName + " with " + myproxyLifeTime + " lifetime.");
+                String uid = myproxyUserName;
+                if (proxyloc == null) {
+                    log.info("uid: " + uid);
+                    proxyloc = "/tmp/x509up_u" + uid;
+                }
+                File proxyfile = new File(proxyloc);
+                log.info("proxy location: " + proxyfile.getAbsolutePath());
+                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.");
+                }
+                fout = new FileOutputStream(proxyfile);
+                globusCred.save(fout);
+                String osName = System.getProperty("os.name");
+                if (!osName.contains("Windows")) {
+                    Runtime.getRuntime().exec("/bin/chmod 600 " + proxyloc);
+                }
+                log.info("Proxy file renewed to " + proxyloc + " for the user " + myproxyUserName + " with "
+                        + myproxyLifeTime + " lifetime.");
+
+            }
+            return proxy;
+        } catch (Exception e) {
+            throw new Exception(e);
+        } finally {
+            if (fout != null) {
+                fout.close();
+            }
+        }
+    }
+
+    /**
+     * @return the myproxyHostname
+     */
+    public String getMyproxyHostname() {
+        return myproxyHostname;
+    }
+
+    /**
+     * @param myproxyHostname
+     *            the myproxyHostname to set
+     */
+    public void setMyproxyHostname(String myproxyHostname) {
+        this.myproxyHostname = myproxyHostname;
+    }
+
+    /**
+     * @return the myproxyUserName
+     */
+    public String getMyproxyUserName() {
+        return myproxyUserName;
+    }
+
+    /**
+     * @param myproxyUserName
+     *            the myproxyUserName to set
+     */
+    public void setMyproxyUserName(String myproxyUserName) {
+        this.myproxyUserName = myproxyUserName;
+    }
+
+    /**
+     * @return the myproxyPassword
+     */
+    public String getMyproxyPassword() {
+        return myproxyPassword;
+    }
+
+    /**
+     * @param myproxyPassword
+     *            the myproxyPassword to set
+     */
+    public void setMyproxyPassword(String myproxyPassword) {
+        this.myproxyPassword = myproxyPassword;
+    }
+
+    /**
+     * @return the myproxyLifeTime
+     */
+    public int getMyproxyLifeTime() {
+        return myproxyLifeTime;
+    }
+
+    /**
+     * @param myproxyLifeTime
+     *            the myproxyLifeTime to set
+     */
+    public void setMyproxyLifeTime(int myproxyLifeTime) {
+        this.myproxyLifeTime = myproxyLifeTime;
+    }
+
+    /**
+     * @return the myproxyPortNumber
+     */
+    public int getMyproxyPortNumber() {
+        return myproxyPortNumber;
+    }
+
+    /**
+     * @param myproxyPortNumber
+     *            the myproxyPortNumber to set
+     */
+    public void setMyproxyPortNumber(int myproxyPortNumber) {
+        this.myproxyPortNumber = myproxyPortNumber;
+    }
+
+    /**
+     * @return the portalUserName
+     */
+    public String getPortalUserName() {
+        return portalUserName;
+    }
+
+    /**
+     * @param portalUserName
+     *            the portalUserName to set
+     */
+    public void setPortalUserName(String portalUserName) {
+        this.portalUserName = portalUserName;
+    }
+
+    /**
+     * Returns the initialized.
+     * 
+     * @return The initialized
+     */
+    public boolean isInitialized() {
+        return this.initialized;
+    }
+
+    /**
+     * Sets initialized.
+     * 
+     * @param initialized
+     *            The initialized to set.
+     */
+    public void setInitialized(boolean initialized) {
+        this.initialized = initialized;
+    }
+
+    /**
+     * @param hostcertsKeyFile
+     *            the hostcertsKeyFile to set
+     */
+    public void setHostcertsKeyFile(String hostcertsKeyFile) {
+        this.hostcertsKeyFile = hostcertsKeyFile;
+    }
+
+    /**
+     * @return the hostcertsKeyFile
+     */
+    public String getHostcertsKeyFile() {
+        return hostcertsKeyFile;
+    }
+
+    /**
+     * @param trustedCertsFile
+     *            the trustedCertsFile to set
+     */
+    public void setTrustedCertsFile(String trustedCertsFile) {
+        this.trustedCertsFile = trustedCertsFile;
+    }
+
+    /**
+     * @return the trustedCertsFile
+     */
+    public String getTrustedCertsFile() {
+        return trustedCertsFile;
+    }
 
 }

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExectionContext.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExectionContext.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExectionContext.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExectionContext.java Sat Nov 10 03:25:44 2012
@@ -1,3 +1,24 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
 package org.apache.airavata.jobsubmission.gram;
 
 import java.io.IOException;
@@ -9,431 +30,429 @@ import org.apache.airavata.jobsubmission
 
 public class ExectionContext {
 
-	private String workingDir;
-	private String tmpDir;
-	private String stdOut;
-	private String stderr;
-	private String host;
-	private String executable;
-	private ArrayList<String[]> env;
-	private String inputDataDir;
-	private String outputDataDir;
-	private boolean parameterNamesNeeded = false;
-	private String stdIn;
-	private String stdoutStr;
-	private String stderrStr;
-	private String queue;
-	private Integer maxWallTime;
-	private Integer pcount;
-	private String projectName;
-	private Integer minMemory;
-	private Integer hostCount;
-	private String jobType;
-	private String arguments;
-	private String gridFTPServerSource;
-	private String sourcedataLocation;
-	private String gridFTPServerDest;
-	private String destdataLocation;
-	
-	
-
-	public static final String PROPERTY_FILE = "gramclient.properties";
-
-	public ExectionContext() throws IOException {
-		loadConfigration();
-	}
-
-	private void loadConfigration() throws IOException {
-		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-		InputStream propertyStream = classLoader.getResourceAsStream(PROPERTY_FILE);
-
-		Properties properties = new Properties();
-		if (propertyStream != null) {
-			properties.load(propertyStream);
-			String gateway = properties.getProperty(ServiceConstants.GATEWAY);
-			String exec = properties.getProperty(ServiceConstants.EXECUTION);
-			String args = properties.getProperty(ServiceConstants.ARGUMENTS);
-			String queueName = properties.getProperty(ServiceConstants.QUEUE);
-			String pn = properties.getProperty(ServiceConstants.PROJECT_NUMBER);
-			String jt = properties.getProperty(ServiceConstants.JOB_TYPE);
-			String mwt = properties.getProperty(ServiceConstants.MAX_WALL_TIME);
-			String pc = properties.getProperty(ServiceConstants.PCOUNT);
-			String hc = properties.getProperty(ServiceConstants.HOSTCOUNT);
-			String gridFTPServerSource =  properties.getProperty(ServiceConstants.GRIDFTPSERVERSOURCE);
-			String gridFTPSourcePath =  properties.getProperty(ServiceConstants.GRIDFTPSOURCEPATH);
-			String gridFTPServerDest =  properties.getProperty(ServiceConstants.GRIDFTPSERVERDEST);
-			String gridFTPDestPath =  properties.getProperty(ServiceConstants.GRIDFTPDESTPATH);
-			if (gateway != null) {
-				this.host = gateway;
-			}
-			if (exec != null) {
-				this.executable = exec;
-			}
-			if (args != null) {
-				this.arguments = args;
-			}
-			if (queueName != null) {
-				this.queue = queueName;
-			}
-			if (pn != null) {
-				this.projectName = pn;
-			}
-			if (jt != null) {
-				this.jobType = jt;
-			}
-			if (mwt != null) {
-				try {
-					this.maxWallTime = Integer.parseInt(mwt);
-				} catch (NumberFormatException e) {
-					this.maxWallTime = 1;
-				}
-			}
-			if (pc != null) {
-				try {
-					this.pcount = Integer.parseInt(pc);
-				} catch (NumberFormatException e) {
-					this.pcount = 1;
-				}
-			}
-			if (hc != null) {
-				try {
-					this.hostCount = Integer.parseInt(hc);
-				} catch (NumberFormatException e) {
-					this.hostCount = 1;
-				}
-			}
-			if(gridFTPServerSource != null && !gridFTPServerSource.isEmpty()){
-				this.gridFTPServerSource = gridFTPServerSource;
-			}
-			if(gridFTPSourcePath != null && !gridFTPSourcePath.isEmpty()){
-				this.sourcedataLocation = gridFTPSourcePath;
-			}
-			if(gridFTPServerDest != null && !gridFTPServerDest.isEmpty()){
-				this.gridFTPServerDest = gridFTPServerDest;
-			}
-			if(gridFTPDestPath != null && !gridFTPDestPath.isEmpty()){
-				this.destdataLocation = gridFTPDestPath;
-			}
-			
-		}
-	}
-
-	/**
-	 * @return the workingDir
-	 */
-	public String getWorkingDir() {
-		return workingDir;
-	}
-
-	/**
-	 * @param workingDir
-	 *            the workingDir to set
-	 */
-	public void setWorkingDir(String workingDir) {
-		this.workingDir = workingDir;
-	}
-
-	/**
-	 * @return the tmpDir
-	 */
-	public String getTmpDir() {
-		return tmpDir;
-	}
-
-	/**
-	 * @param tmpDir
-	 *            the tmpDir to set
-	 */
-	public void setTmpDir(String tmpDir) {
-		this.tmpDir = tmpDir;
-	}
-
-	/**
-	 * @return the stdOut
-	 */
-	public String getStdOut() {
-		return stdOut;
-	}
-
-	/**
-	 * @param stdOut
-	 *            the stdOut to set
-	 */
-	public void setStdOut(String stdOut) {
-		this.stdOut = stdOut;
-	}
-
-	/**
-	 * @return the stderr
-	 */
-	public String getStderr() {
-		return stderr;
-	}
-
-	/**
-	 * @param stderr
-	 *            the stderr to set
-	 */
-	public void setStderr(String stderr) {
-		this.stderr = stderr;
-	}
-
-	/**
-	 * @return the host
-	 */
-	public String getHost() {
-		return host;
-	}
-
-	/**
-	 * @param host
-	 *            the host to set
-	 */
-	public void setHost(String host) {
-		this.host = host;
-	}
-
-	/**
-	 * @return the executable
-	 */
-	public String getExecutable() {
-		return executable;
-	}
-
-	/**
-	 * @param executable
-	 *            the executable to set
-	 */
-	public void setExecutable(String executable) {
-		this.executable = executable;
-	}
-
-	/**
-	 * @return the env
-	 */
-	public ArrayList<String[]> getEnv() {
-		return env;
-	}
-
-	/**
-	 * @param env
-	 *            the env to set
-	 */
-	public void setEnv(ArrayList<String[]> env) {
-		this.env = env;
-	}
-
-	/**
-	 * @return the inputDataDir
-	 */
-	public String getInputDataDir() {
-		return inputDataDir;
-	}
-
-	/**
-	 * @param inputDataDir
-	 *            the inputDataDir to set
-	 */
-	public void setInputDataDir(String inputDataDir) {
-		this.inputDataDir = inputDataDir;
-	}
-
-	/**
-	 * @return the outputDataDir
-	 */
-	public String getOutputDataDir() {
-		return outputDataDir;
-	}
-
-	/**
-	 * @param outputDataDir
-	 *            the outputDataDir to set
-	 */
-	public void setOutputDataDir(String outputDataDir) {
-		this.outputDataDir = outputDataDir;
-	}
-
-	/**
-	 * @return the parameterNamesNeeded
-	 */
-	public boolean isParameterNamesNeeded() {
-		return parameterNamesNeeded;
-	}
-
-	/**
-	 * @param parameterNamesNeeded
-	 *            the parameterNamesNeeded to set
-	 */
-	public void setParameterNamesNeeded(boolean parameterNamesNeeded) {
-		this.parameterNamesNeeded = parameterNamesNeeded;
-	}
-
-	/**
-	 * @return the stdIn
-	 */
-	public String getStdIn() {
-		return stdIn;
-	}
-
-	/**
-	 * @param stdIn
-	 *            the stdIn to set
-	 */
-	public void setStdIn(String stdIn) {
-		this.stdIn = stdIn;
-	}
-
-	/**
-	 * @return the stdoutStr
-	 */
-	public String getStdoutStr() {
-		return stdoutStr;
-	}
-
-	/**
-	 * @param stdoutStr
-	 *            the stdoutStr to set
-	 */
-	public void setStdoutStr(String stdoutStr) {
-		this.stdoutStr = stdoutStr;
-	}
-
-	/**
-	 * @return the stderrStr
-	 */
-	public String getStderrStr() {
-		return stderrStr;
-	}
-
-	/**
-	 * @param stderrStr
-	 *            the stderrStr to set
-	 */
-	public void setStderrStr(String stderrStr) {
-		this.stderrStr = stderrStr;
-	}
-
-	public void setQueue(String queue) {
-		this.queue = queue;
-	}
-
-	public String getQueue() {
-		return queue;
-	}
-
-	public void setMaxWallTime(Integer maxWallTime) {
-		this.maxWallTime = maxWallTime;
-	}
-
-	public Integer getMaxWallTime() {
-		return maxWallTime;
-	}
-
-	/**
-	 * @return the pcount
-	 */
-	public Integer getPcount() {
-		return pcount;
-	}
-
-	/**
-	 * @param pcount
-	 *            the pcount to set
-	 */
-	public void setPcount(Integer pcount) {
-		this.pcount = pcount;
-	}
-
-	/**
-	 * @return the projectName
-	 */
-	public String getProjectName() {
-		return projectName;
-	}
-
-	/**
-	 * @param projectName
-	 *            the projectName to set
-	 */
-	public void setProjectName(String projectName) {
-		this.projectName = projectName;
-	}
-
-	/**
-	 * @return the minMemory
-	 */
-	public Integer getMinMemory() {
-		return minMemory;
-	}
-
-	/**
-	 * @param minMemory
-	 *            the minMemory to set
-	 */
-	public void setMinMemory(Integer minMemory) {
-		this.minMemory = minMemory;
-	}
-
-	/**
-	 * @return the hostCount
-	 */
-	public Integer getHostCount() {
-		return hostCount;
-	}
-
-	/**
-	 * @param hostCount
-	 *            the hostCount to set
-	 */
-	public void setHostCount(Integer hostCount) {
-		this.hostCount = hostCount;
-	}
-
-	public void setJobType(String jobType) {
-		this.jobType = jobType;
-	}
-
-	public String getJobType() {
-		return jobType;
-	}
-
-	public void setArguments(String arguments) {
-		this.arguments = arguments;
-	}
-
-	public String getArguments() {
-		return arguments;
-	}
-
-	public String getGridFTPServerSource() {
-		return gridFTPServerSource;
-	}
-
-	public void setGridFTPServerSource(String gridFTPServerSource) {
-		this.gridFTPServerSource = gridFTPServerSource;
-	}
-
-	public String getSourcedataLocation() {
-		return sourcedataLocation;
-	}
-
-	public void setSourcedataLocation(String sourcedataLocation) {
-		this.sourcedataLocation = sourcedataLocation;
-	}
-
-	public String getGridFTPServerDest() {
-		return gridFTPServerDest;
-	}
-
-	public void setGridFTPServerDest(String gridFTPServerDest) {
-		this.gridFTPServerDest = gridFTPServerDest;
-	}
-
-	public String getDestdataLocation() {
-		return destdataLocation;
-	}
-
-	public void setDestdataLocation(String destdataLocation) {
-		this.destdataLocation = destdataLocation;
-	}
+    private String workingDir;
+    private String tmpDir;
+    private String stdOut;
+    private String stderr;
+    private String host;
+    private String executable;
+    private ArrayList<String[]> env;
+    private String inputDataDir;
+    private String outputDataDir;
+    private boolean parameterNamesNeeded = false;
+    private String stdIn;
+    private String stdoutStr;
+    private String stderrStr;
+    private String queue;
+    private Integer maxWallTime;
+    private Integer pcount;
+    private String projectName;
+    private Integer minMemory;
+    private Integer hostCount;
+    private String jobType;
+    private String arguments;
+    private String gridFTPServerSource;
+    private String sourcedataLocation;
+    private String gridFTPServerDest;
+    private String destdataLocation;
+
+    public static final String PROPERTY_FILE = "gramclient.properties";
+
+    public ExectionContext() throws IOException {
+        loadConfigration();
+    }
+
+    private void loadConfigration() throws IOException {
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        InputStream propertyStream = classLoader.getResourceAsStream(PROPERTY_FILE);
+
+        Properties properties = new Properties();
+        if (propertyStream != null) {
+            properties.load(propertyStream);
+            String gateway = properties.getProperty(ServiceConstants.GATEWAY);
+            String exec = properties.getProperty(ServiceConstants.EXECUTION);
+            String args = properties.getProperty(ServiceConstants.ARGUMENTS);
+            String queueName = properties.getProperty(ServiceConstants.QUEUE);
+            String pn = properties.getProperty(ServiceConstants.PROJECT_NUMBER);
+            String jt = properties.getProperty(ServiceConstants.JOB_TYPE);
+            String mwt = properties.getProperty(ServiceConstants.MAX_WALL_TIME);
+            String pc = properties.getProperty(ServiceConstants.PCOUNT);
+            String hc = properties.getProperty(ServiceConstants.HOSTCOUNT);
+            String gridFTPServerSource = properties.getProperty(ServiceConstants.GRIDFTPSERVERSOURCE);
+            String gridFTPSourcePath = properties.getProperty(ServiceConstants.GRIDFTPSOURCEPATH);
+            String gridFTPServerDest = properties.getProperty(ServiceConstants.GRIDFTPSERVERDEST);
+            String gridFTPDestPath = properties.getProperty(ServiceConstants.GRIDFTPDESTPATH);
+            if (gateway != null) {
+                this.host = gateway;
+            }
+            if (exec != null) {
+                this.executable = exec;
+            }
+            if (args != null) {
+                this.arguments = args;
+            }
+            if (queueName != null) {
+                this.queue = queueName;
+            }
+            if (pn != null) {
+                this.projectName = pn;
+            }
+            if (jt != null) {
+                this.jobType = jt;
+            }
+            if (mwt != null) {
+                try {
+                    this.maxWallTime = Integer.parseInt(mwt);
+                } catch (NumberFormatException e) {
+                    this.maxWallTime = 1;
+                }
+            }
+            if (pc != null) {
+                try {
+                    this.pcount = Integer.parseInt(pc);
+                } catch (NumberFormatException e) {
+                    this.pcount = 1;
+                }
+            }
+            if (hc != null) {
+                try {
+                    this.hostCount = Integer.parseInt(hc);
+                } catch (NumberFormatException e) {
+                    this.hostCount = 1;
+                }
+            }
+            if (gridFTPServerSource != null && !gridFTPServerSource.isEmpty()) {
+                this.gridFTPServerSource = gridFTPServerSource;
+            }
+            if (gridFTPSourcePath != null && !gridFTPSourcePath.isEmpty()) {
+                this.sourcedataLocation = gridFTPSourcePath;
+            }
+            if (gridFTPServerDest != null && !gridFTPServerDest.isEmpty()) {
+                this.gridFTPServerDest = gridFTPServerDest;
+            }
+            if (gridFTPDestPath != null && !gridFTPDestPath.isEmpty()) {
+                this.destdataLocation = gridFTPDestPath;
+            }
+
+        }
+    }
+
+    /**
+     * @return the workingDir
+     */
+    public String getWorkingDir() {
+        return workingDir;
+    }
+
+    /**
+     * @param workingDir
+     *            the workingDir to set
+     */
+    public void setWorkingDir(String workingDir) {
+        this.workingDir = workingDir;
+    }
+
+    /**
+     * @return the tmpDir
+     */
+    public String getTmpDir() {
+        return tmpDir;
+    }
+
+    /**
+     * @param tmpDir
+     *            the tmpDir to set
+     */
+    public void setTmpDir(String tmpDir) {
+        this.tmpDir = tmpDir;
+    }
+
+    /**
+     * @return the stdOut
+     */
+    public String getStdOut() {
+        return stdOut;
+    }
+
+    /**
+     * @param stdOut
+     *            the stdOut to set
+     */
+    public void setStdOut(String stdOut) {
+        this.stdOut = stdOut;
+    }
+
+    /**
+     * @return the stderr
+     */
+    public String getStderr() {
+        return stderr;
+    }
+
+    /**
+     * @param stderr
+     *            the stderr to set
+     */
+    public void setStderr(String stderr) {
+        this.stderr = stderr;
+    }
+
+    /**
+     * @return the host
+     */
+    public String getHost() {
+        return host;
+    }
+
+    /**
+     * @param host
+     *            the host to set
+     */
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    /**
+     * @return the executable
+     */
+    public String getExecutable() {
+        return executable;
+    }
+
+    /**
+     * @param executable
+     *            the executable to set
+     */
+    public void setExecutable(String executable) {
+        this.executable = executable;
+    }
+
+    /**
+     * @return the env
+     */
+    public ArrayList<String[]> getEnv() {
+        return env;
+    }
+
+    /**
+     * @param env
+     *            the env to set
+     */
+    public void setEnv(ArrayList<String[]> env) {
+        this.env = env;
+    }
+
+    /**
+     * @return the inputDataDir
+     */
+    public String getInputDataDir() {
+        return inputDataDir;
+    }
+
+    /**
+     * @param inputDataDir
+     *            the inputDataDir to set
+     */
+    public void setInputDataDir(String inputDataDir) {
+        this.inputDataDir = inputDataDir;
+    }
+
+    /**
+     * @return the outputDataDir
+     */
+    public String getOutputDataDir() {
+        return outputDataDir;
+    }
+
+    /**
+     * @param outputDataDir
+     *            the outputDataDir to set
+     */
+    public void setOutputDataDir(String outputDataDir) {
+        this.outputDataDir = outputDataDir;
+    }
+
+    /**
+     * @return the parameterNamesNeeded
+     */
+    public boolean isParameterNamesNeeded() {
+        return parameterNamesNeeded;
+    }
+
+    /**
+     * @param parameterNamesNeeded
+     *            the parameterNamesNeeded to set
+     */
+    public void setParameterNamesNeeded(boolean parameterNamesNeeded) {
+        this.parameterNamesNeeded = parameterNamesNeeded;
+    }
+
+    /**
+     * @return the stdIn
+     */
+    public String getStdIn() {
+        return stdIn;
+    }
+
+    /**
+     * @param stdIn
+     *            the stdIn to set
+     */
+    public void setStdIn(String stdIn) {
+        this.stdIn = stdIn;
+    }
+
+    /**
+     * @return the stdoutStr
+     */
+    public String getStdoutStr() {
+        return stdoutStr;
+    }
+
+    /**
+     * @param stdoutStr
+     *            the stdoutStr to set
+     */
+    public void setStdoutStr(String stdoutStr) {
+        this.stdoutStr = stdoutStr;
+    }
+
+    /**
+     * @return the stderrStr
+     */
+    public String getStderrStr() {
+        return stderrStr;
+    }
+
+    /**
+     * @param stderrStr
+     *            the stderrStr to set
+     */
+    public void setStderrStr(String stderrStr) {
+        this.stderrStr = stderrStr;
+    }
+
+    public void setQueue(String queue) {
+        this.queue = queue;
+    }
+
+    public String getQueue() {
+        return queue;
+    }
+
+    public void setMaxWallTime(Integer maxWallTime) {
+        this.maxWallTime = maxWallTime;
+    }
+
+    public Integer getMaxWallTime() {
+        return maxWallTime;
+    }
+
+    /**
+     * @return the pcount
+     */
+    public Integer getPcount() {
+        return pcount;
+    }
+
+    /**
+     * @param pcount
+     *            the pcount to set
+     */
+    public void setPcount(Integer pcount) {
+        this.pcount = pcount;
+    }
+
+    /**
+     * @return the projectName
+     */
+    public String getProjectName() {
+        return projectName;
+    }
+
+    /**
+     * @param projectName
+     *            the projectName to set
+     */
+    public void setProjectName(String projectName) {
+        this.projectName = projectName;
+    }
+
+    /**
+     * @return the minMemory
+     */
+    public Integer getMinMemory() {
+        return minMemory;
+    }
+
+    /**
+     * @param minMemory
+     *            the minMemory to set
+     */
+    public void setMinMemory(Integer minMemory) {
+        this.minMemory = minMemory;
+    }
+
+    /**
+     * @return the hostCount
+     */
+    public Integer getHostCount() {
+        return hostCount;
+    }
+
+    /**
+     * @param hostCount
+     *            the hostCount to set
+     */
+    public void setHostCount(Integer hostCount) {
+        this.hostCount = hostCount;
+    }
+
+    public void setJobType(String jobType) {
+        this.jobType = jobType;
+    }
+
+    public String getJobType() {
+        return jobType;
+    }
+
+    public void setArguments(String arguments) {
+        this.arguments = arguments;
+    }
+
+    public String getArguments() {
+        return arguments;
+    }
+
+    public String getGridFTPServerSource() {
+        return gridFTPServerSource;
+    }
+
+    public void setGridFTPServerSource(String gridFTPServerSource) {
+        this.gridFTPServerSource = gridFTPServerSource;
+    }
+
+    public String getSourcedataLocation() {
+        return sourcedataLocation;
+    }
+
+    public void setSourcedataLocation(String sourcedataLocation) {
+        this.sourcedataLocation = sourcedataLocation;
+    }
+
+    public String getGridFTPServerDest() {
+        return gridFTPServerDest;
+    }
+
+    public void setGridFTPServerDest(String gridFTPServerDest) {
+        this.gridFTPServerDest = gridFTPServerDest;
+    }
+
+    public String getDestdataLocation() {
+        return destdataLocation;
+    }
+
+    public void setDestdataLocation(String destdataLocation) {
+        this.destdataLocation = destdataLocation;
+    }
 }

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/FileTransfer.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/FileTransfer.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/FileTransfer.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/FileTransfer.java Sat Nov 10 03:25:44 2012
@@ -1,3 +1,24 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
 package org.apache.airavata.jobsubmission.gram;
 
 import java.net.URI;
@@ -11,52 +32,52 @@ import org.ietf.jgss.GSSCredential;
 
 public class FileTransfer {
 
-	public void makeDir(GSSCredential gssCred, URI destURI) throws Exception {
-		GridFtp ftp = new GridFtp();
-		ftp.makeDir(destURI, gssCred);
-	}
-
-	public void transferData(GSSCredential gssCred, URI srcURI, URI destURI) throws Exception {
-		GridFtp ftp = new GridFtp();
-		ftp.transfer(srcURI, destURI, gssCred, true);
-	}
-
-	public void transferData(GSSCredential gssCred, String sourceERP, String remoteSrcFile, String targetERP,
-			String remoteDestFile) throws Exception {
-		GridFtp ftp = new GridFtp();
-		URI srcURI = GridFtp.createGsiftpURI(sourceERP, remoteSrcFile);
-		URI destURI = GridFtp.createGsiftpURI(targetERP, remoteDestFile);
-		ftp.transfer(srcURI, destURI, gssCred, true);
-	}
-
-	public static void main(String[] args) {
-		try {
-			BasicConfigurator.configure();
-			Logger logger = Logger.getLogger("GridFTPClient");
-			Level lev = Level.toLevel("DEBUG");
-			logger.setLevel(lev);
-			ApplicationContext context = new ApplicationContext();
-			context.login();
-			ExectionContext contextExectionContext = new ExectionContext();
-			FileTransfer fileTransfer = new FileTransfer();
-
-			String sourceERP = contextExectionContext.getGridFTPServerSource();
-			String remoteSrcFile = contextExectionContext.getSourcedataLocation();
-			String targeterp = contextExectionContext.getGridFTPServerDest();
-			String remoteDestFile = contextExectionContext.getDestdataLocation();
-			URI srcURI = GridFtp.createGsiftpURI(sourceERP, remoteSrcFile);
-			URI destURI = GridFtp.createGsiftpURI(targeterp, remoteDestFile);
-			URI dirLocation = GridFtp.createGsiftpURI(targeterp,
-					remoteDestFile.substring(0, remoteDestFile.lastIndexOf("/")));
-			GSSCredential gssCredential = context.getGssCredential();
-			System.out.println(dirLocation);
-			fileTransfer.makeDir(gssCredential, dirLocation);
-			fileTransfer.transferData(gssCredential, srcURI, destURI);
-
-		} catch (Exception e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+    public void makeDir(GSSCredential gssCred, URI destURI) throws Exception {
+        GridFtp ftp = new GridFtp();
+        ftp.makeDir(destURI, gssCred);
+    }
+
+    public void transferData(GSSCredential gssCred, URI srcURI, URI destURI) throws Exception {
+        GridFtp ftp = new GridFtp();
+        ftp.transfer(srcURI, destURI, gssCred, true);
+    }
+
+    public void transferData(GSSCredential gssCred, String sourceERP, String remoteSrcFile, String targetERP,
+            String remoteDestFile) throws Exception {
+        GridFtp ftp = new GridFtp();
+        URI srcURI = GridFtp.createGsiftpURI(sourceERP, remoteSrcFile);
+        URI destURI = GridFtp.createGsiftpURI(targetERP, remoteDestFile);
+        ftp.transfer(srcURI, destURI, gssCred, true);
+    }
+
+    public static void main(String[] args) {
+        try {
+            BasicConfigurator.configure();
+            Logger logger = Logger.getLogger("GridFTPClient");
+            Level lev = Level.toLevel("DEBUG");
+            logger.setLevel(lev);
+            ApplicationContext context = new ApplicationContext();
+            context.login();
+            ExectionContext contextExectionContext = new ExectionContext();
+            FileTransfer fileTransfer = new FileTransfer();
+
+            String sourceERP = contextExectionContext.getGridFTPServerSource();
+            String remoteSrcFile = contextExectionContext.getSourcedataLocation();
+            String targeterp = contextExectionContext.getGridFTPServerDest();
+            String remoteDestFile = contextExectionContext.getDestdataLocation();
+            URI srcURI = GridFtp.createGsiftpURI(sourceERP, remoteSrcFile);
+            URI destURI = GridFtp.createGsiftpURI(targeterp, remoteDestFile);
+            URI dirLocation = GridFtp.createGsiftpURI(targeterp,
+                    remoteDestFile.substring(0, remoteDestFile.lastIndexOf("/")));
+            GSSCredential gssCredential = context.getGssCredential();
+            System.out.println(dirLocation);
+            fileTransfer.makeDir(gssCredential, dirLocation);
+            fileTransfer.transferData(gssCredential, srcURI, destURI);
+
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
 
-	}
+    }
 }
\ No newline at end of file



Mime
View raw message