committing https://issues.apache.org/jira/browse/AIRAVATA-657.
authorLahiru Gunathilake <lahiru@apache.org>
Mon, 21 Jan 2013 16:36:08 +0000 (16:36 +0000)
committerLahiru Gunathilake <lahiru@apache.org>
Mon, 21 Jan 2013 16:36:08 +0000 (16:36 +0000)
git-svn-id: https://svn.apache.org/repos/asf/airavata/sandbox@1436465 13f79535-47bb-0310-9956-ffa450edef68

grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/HPCPUtils.java
grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/RunBESJob.java
grid-tools/bes-client/src/test/java/org/apache/airavata/sample/bes/TestInterop.java

index 2b127c1..e0e55bf 100644 (file)
@@ -6,6 +6,11 @@ import javax.xml.namespace.QName;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlCursor.TokenType;
 import org.apache.xmlbeans.XmlObject;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.DataStagingType;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.SourceTargetType;
+
+import de.fzj.unicore.wsrflite.xmlbeans.WSUtilities;
+
 import eu.unicore.security.util.Log;
 
 /**
@@ -112,5 +117,24 @@ public class HPCPUtils {
                }
                return null;
        }
-
+       
+       
+       public static XmlObject createCredentialsElement(String userName, String password){
+               XmlObject newXml = XmlObject.Factory.newInstance();
+               
+               XmlCursor cursor = newXml.newCursor();
+               cursor.toNextToken();
+               cursor.beginElement(AC_QNAME);
+               cursor.insertElementWithText(AC_USERNAME, userName);
+               cursor.insertElementWithText(AC_PASSWD, password);
+               cursor.dispose();
+               
+               return newXml;
+       }
+       
+       
+       public static void appendDataStagingWithCredentials(DataStagingType dsType, String userName, String password){
+               WSUtilities.append(createCredentialsElement(userName, password), dsType);
+       }
+       
 }
index 40d26e0..0b07504 100644 (file)
@@ -2,26 +2,19 @@ package org.apache.airavata.sample.bes;
 
 import java.io.File;
 import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
-import de.fzj.unicore.uas.security.ClientProperties;
-import eu.unicore.security.util.client.IClientProperties;
 
-public class RunBESJob {
+public class RunBESJob extends AbstractJobCommand{
 
-       protected IClientProperties securityProperties;
-
-       static final String factoryUrl = "https://zam1161v01.zam.kfa-juelich.de:8002/INTEROP1/services/BESFactory?res=default_bes_factory";
-
-       static final String jsdlPath = "src/test/resources/date.xml";
 
        public RunBESJob() {
-               securityProperties = initSecurityProperties();
+               super();
        }
 
        public void runJob() {
 
                JobDefinitionDocument jobDoc = null;
                try {
-                       jobDoc = JobDefinitionDocument.Factory.parse(new File(jsdlPath));
+                       jobDoc = JobDefinitionDocument.Factory.parse(new File(dateJsdlPath));
                } catch (Exception e) {
                        System.err.println("Error parsing JSDL instance. " + e);
                }
@@ -39,26 +32,5 @@ public class RunBESJob {
                }
 
        }
-
-       protected ClientProperties initSecurityProperties() {
-
-               ClientProperties sp = new ClientProperties();
-
-               sp.setSslEnabled(true);
-               sp.setSignMessage(true);
-
-               sp.setKeystore("src/test/resources/demo-keystore.jks");
-               sp.setKeystorePassword("654321");
-               sp.setKeystoreAlias("demouser-new");
-               sp.setKeystoreType("JKS");
-
-//             sp.setTruststore("src/test/resources/demo-keystore.jks");
-//             sp.setTruststorePassword("654321");
-//             sp.setKeystoreType("JKS");
-
-               return sp;
-
-       }
-
        
 }
index 3bbab65..d0e4dce 100644 (file)
@@ -13,5 +13,10 @@ public class TestInterop {
                besJob.runJob();
        }
        
+       @Test
+       public void testRunAndTerminateJob(){
+               RunAndTerminateJob besJob = new RunAndTerminateJob();
+               besJob.runAndTerminate();
+       }
        
 }