Author: heshan
Date: Mon Oct 15 15:14:09 2012
New Revision: 1398327

URL: http://svn.apache.org/viewvc?rev=1398327&view=rev
Log:
Adding host registration.

Added:
    
airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/HostDescriptorBean.java
    airavata/sandbox/client-api-demo/src/main/webapp/register_host.jsp
    airavata/sandbox/client-api-demo/src/main/webapp/register_host_result.jsp
Modified:
    
airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/DescriptorRegistrationSample.java
    
airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/WorkflowExecutionSample.java
    airavata/sandbox/client-api-demo/src/main/webapp/execute_workflow_result.jsp
    airavata/sandbox/client-api-demo/src/main/webapp/index.jsp
    airavata/sandbox/client-api-demo/src/main/webapp/register_app_result.jsp
    airavata/sandbox/client-api-demo/src/main/webapp/server_info_result.jsp

Modified: 
airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/DescriptorRegistrationSample.java
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/DescriptorRegistrationSample.java?rev=1398327&r1=1398326&r2=1398327&view=diff
==============================================================================
--- 
airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/DescriptorRegistrationSample.java
 (original)
+++ 
airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/DescriptorRegistrationSample.java
 Mon Oct 15 15:14:09 2012
@@ -98,6 +98,27 @@ public class DescriptorRegistrationSampl
 
     }
 
+    public static void registerHost(HostDescriptorBean hostDescriptorBean) {
+        // Create Host Description
+        HostDescription host = new HostDescription();
+        host.getType().changeType(hostDescriptorBean.getHostType());
+        host.getType().setHostName(hostDescriptorBean.getHostName());
+        host.getType().setHostAddress(hostDescriptorBean.getHostAddress());
+        ((GlobusHostType) host.getType()).
+                setGridFTPEndPointArray(new 
String[]{hostDescriptorBean.getHostEndpoint()});
+        ((GlobusHostType) host.getType()).
+                setGlobusGateKeeperEndPointArray(new 
String[]{hostDescriptorBean.getGateKeeperEndpoint()});
+
+        AiravataAPI airavataAPI = SampleUtil.getAiravataAPI();
+        ApplicationManager applicationManager = 
airavataAPI.getApplicationManager();
+        System.out.println("Saving to Registry");
+        try {
+            applicationManager.saveHostDescription(host);
+        } catch (AiravataAPIInvocationException e) {
+            e.printStackTrace();
+        }
+    }
+
     public static void execute(String username,
                                String password,
                                String registryRMIURI,

Added: 
airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/HostDescriptorBean.java
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/HostDescriptorBean.java?rev=1398327&view=auto
==============================================================================
--- 
airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/HostDescriptorBean.java
 (added)
+++ 
airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/HostDescriptorBean.java
 Mon Oct 15 15:14:09 2012
@@ -0,0 +1,47 @@
+package org.sample.airavata.api;
+
+import org.apache.airavata.schemas.gfac.GlobusHostType;
+import org.apache.xmlbeans.SchemaType;
+
+public class HostDescriptorBean {
+    private final SchemaType hostType;
+    private final String hostName;
+    private final String hostAddress;
+    private final String hostEndpoint;
+    private final String gateKeeperEndpoint;
+    private final boolean isGramEndpoint = false;
+
+    public HostDescriptorBean(String hostType, String hostName, String 
hostAddress,
+                              String hostEndpoint, String gateKeeperEndpoint) {
+        if ("globus".equalsIgnoreCase(hostType)) {
+            this.hostType = GlobusHostType.type;
+        } else {
+            this.hostType = null;
+        }
+        this.hostName = hostName;
+        this.hostAddress = hostAddress;
+        this.hostEndpoint = hostEndpoint;
+        this.gateKeeperEndpoint = gateKeeperEndpoint;
+    }
+
+    public String getGateKeeperEndpoint() {
+        return gateKeeperEndpoint;
+    }
+
+    public String getHostEndpoint() {
+        return hostEndpoint;
+    }
+
+    public String getHostAddress() {
+        return hostAddress;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
+    public SchemaType getHostType() {
+        return hostType;
+    }
+
+}

Modified: 
airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/WorkflowExecutionSample.java
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/WorkflowExecutionSample.java?rev=1398327&r1=1398326&r2=1398327&view=diff
==============================================================================
--- 
airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/WorkflowExecutionSample.java
 (original)
+++ 
airavata/sandbox/client-api-demo/src/main/java/org/sample/airavata/api/WorkflowExecutionSample.java
 Mon Oct 15 15:14:09 2012
@@ -24,33 +24,32 @@ public class WorkflowExecutionSample {
     public static void main(String[] args) throws Exception {
     }
 
-    public static URI getWorkflowInterpreterServiceURL(String username, String 
password, String registryRMIURI) throws AiravataAPIInvocationException {
+    public static URI getWorkflowInterpreterServiceURL() throws 
AiravataAPIInvocationException {
         AiravataAPI airavataAPI = SampleUtil.getAiravataAPI();
         return 
airavataAPI.getAiravataManager().getWorkflowInterpreterServiceURL();
     }
 
-    public static URI getGFaCURL(String username, String password, String 
registryRMIURI) throws AiravataAPIInvocationException {
+    public static URI getGFaCURL() throws AiravataAPIInvocationException {
         AiravataAPI airavataAPI = SampleUtil.getAiravataAPI();
         return airavataAPI.getAiravataManager().getGFaCURL();
     }
 
-    public static URI getRegistryURL(String username, String password, String 
registryRMIURI) throws AiravataAPIInvocationException {
+    public static URI getRegistryURL() throws AiravataAPIInvocationException {
         AiravataAPI airavataAPI = SampleUtil.getAiravataAPI();
         return airavataAPI.getAiravataManager().getRegistryURL();
     }
 
-    public static URI getMessageBoxServiceURL(String username, String 
password, String registryRMIURI) throws AiravataAPIInvocationException {
+    public static URI getMessageBoxServiceURL() throws 
AiravataAPIInvocationException {
         AiravataAPI airavataAPI = SampleUtil.getAiravataAPI();
         return airavataAPI.getAiravataManager().getMessageBoxServiceURL();
     }
 
-    public static URI getEventingServiceURL(String username, String password, 
String registryRMIURI) throws AiravataAPIInvocationException {
+    public static URI getEventingServiceURL() throws 
AiravataAPIInvocationException {
         AiravataAPI airavataAPI = SampleUtil.getAiravataAPI();
         return airavataAPI.getAiravataManager().getEventingServiceURL();
     }
 
-    public static String runWorkflow(String username, String password, String 
registryRMIURI, String workflowTemplateId) {
-
+    public static String runWorkflow(String workflowTemplateId) {
         AiravataAPI airavataAPI = SampleUtil.getAiravataAPI();
         List<WorkflowInput> workflowInputs = null;
         try {
@@ -102,10 +101,7 @@ public class WorkflowExecutionSample {
         return null;
     }*/
 
-    public static WorkflowInstance getWorkflowInstanceData(String username,
-                                                           String password,
-                                                           String 
registryRMIURI,
-                                                           WorkflowInstance 
workflowInstance) {
+    public static WorkflowInstance getWorkflowInstanceData(WorkflowInstance 
workflowInstance) {
         AiravataAPI airavataAPI = SampleUtil.getAiravataAPI();
         try {
             WorkflowInstanceData workflowInstanceData = 
airavataAPI.getProvenanceManager().getWorkflowInstanceData(workflowInstance);
@@ -116,9 +112,7 @@ public class WorkflowExecutionSample {
         return null;
     }
 
-    public static List<String> getUserExperimentsList(String username,
-                                                      String password,
-                                                      String registryRMIURI) {
+    public static List<String> getUserExperimentsList() {
         AiravataAPI airavataAPI = SampleUtil.getAiravataAPI();
         try {
             List<String> experiments = 
airavataAPI.getProvenanceManager().getExperimentIdList(airavataAPI.getCurrentUser());

Modified: 
airavata/sandbox/client-api-demo/src/main/webapp/execute_workflow_result.jsp
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/client-api-demo/src/main/webapp/execute_workflow_result.jsp?rev=1398327&r1=1398326&r2=1398327&view=diff
==============================================================================
--- 
airavata/sandbox/client-api-demo/src/main/webapp/execute_workflow_result.jsp 
(original)
+++ 
airavata/sandbox/client-api-demo/src/main/webapp/execute_workflow_result.jsp 
Mon Oct 15 15:14:09 2012
@@ -9,6 +9,8 @@
 <%@ page import="java.util.List" %>
 <%@ page import="java.util.ArrayList" %>
 
+<%! String result;%>
+
 <html>
     <head>
         <title>Airavata Server Workflow Execution</title>
@@ -49,16 +51,16 @@
                         value = request.getParameter(name);
                     }
 
-//                    System.out.println("Creating workflow input ...");
-//                    System.out.println("input Name  : " + name);
-//                    System.out.println("input Type : " + type);
-//                    System.out.println("input Value : " + value);
+                    System.out.println("Creating workflow input ...");
+                    System.out.println("input Name  : " + name);
+                    System.out.println("input Type : " + type);
+                    System.out.println("input Value : " + value);
                     WorkflowInput workflowInput = new WorkflowInput(name, 
type, null, value, false);
                     workflowInputs.add(workflowInput);
                 }
             }
 
-            String result = null;
+            result = null;
             try {
                 // String workflowTemplateId,List<WorkflowInput> inputs, 
String user, String metadata, String workflowInstanceName
                 // TODO Check this! NOT WORKING
@@ -73,6 +75,8 @@
 
         %>
 
+        Experiment : <%=result%>
+
 
     </body>
 </html>

Modified: airavata/sandbox/client-api-demo/src/main/webapp/index.jsp
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/client-api-demo/src/main/webapp/index.jsp?rev=1398327&r1=1398326&r2=1398327&view=diff
==============================================================================
--- airavata/sandbox/client-api-demo/src/main/webapp/index.jsp (original)
+++ airavata/sandbox/client-api-demo/src/main/webapp/index.jsp Mon Oct 15 
15:14:09 2012
@@ -11,6 +11,7 @@
             <h4><a href="./execute_workflow_list.jsp">Workflow 
Information</a></h4>
             <h4><a href="./monitor_experiment.jsp">Monitor workflow</a></h4>
             <br>
+            <h4><a href="./register_host.jsp">Register a Host</a></h4>
             <h4><a href="./register_app.jsp">Register an Application</a></h4>
             <h4><a href="./execute_app.jsp">Execute an Application</a></h4>
             <br>

Modified: 
airavata/sandbox/client-api-demo/src/main/webapp/register_app_result.jsp
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/client-api-demo/src/main/webapp/register_app_result.jsp?rev=1398327&r1=1398326&r2=1398327&view=diff
==============================================================================
--- airavata/sandbox/client-api-demo/src/main/webapp/register_app_result.jsp 
(original)
+++ airavata/sandbox/client-api-demo/src/main/webapp/register_app_result.jsp 
Mon Oct 15 15:14:09 2012
@@ -69,8 +69,10 @@
 
             System.out.println("Registration was successful");
 
-            System.out.println("Registration DONE!");
+
         %>
 
+        out.print("Registration DONE!");
+
     </body>
 </html>
\ No newline at end of file

Added: airavata/sandbox/client-api-demo/src/main/webapp/register_host.jsp
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/client-api-demo/src/main/webapp/register_host.jsp?rev=1398327&view=auto
==============================================================================
--- airavata/sandbox/client-api-demo/src/main/webapp/register_host.jsp (added)
+++ airavata/sandbox/client-api-demo/src/main/webapp/register_host.jsp Mon Oct 
15 15:14:09 2012
@@ -0,0 +1,32 @@
+<%@ page import="java.io.InputStream" %>
+<%@ page import="java.util.Properties" %>
+
+<%! String username;%>
+<%! String password;%>
+<%! String registryURL;%>
+
+<html>
+<head>
+    <title>Save Application</title>
+</head>
+
+<body>
+
+<h1>Register an Application</h1>
+<form action="register_host_result.jsp" method="POST">
+
+    <table border="0">
+        <b>HOST</b>
+        <tr><td>Host Type           </td><td> <input type="text" 
name="hostType" value="globus" size="50"></td></tr>
+        <tr><td>Host Name           </td><td> <input type="text" 
name="hostName" value="gram" size="50"></td></tr>
+        <tr><td>Host Address        </td><td> <input type="text" 
name="hostAddress" value="gatekeeper2.ranger.tacc.teragrid.org" 
size="50"></td></tr>
+        <tr><td>Host Endpoint       </td><td> <input type="text" 
name="hostEndpoint" value="gsiftp://gridftp.ranger.tacc.teragrid.org:2811/"; 
size="50"></td></tr>
+        <tr><td>Gatekeeper Endpoint </td><td> <input type="text" 
name="gatekeeperEndpoint" 
value="gatekeeper.ranger.tacc.teragrid.org:2119/jobmanager-sge" 
size="50"></td></tr>
+    </table>
+    <br>
+
+    <input type="SUBMIT" value="Submit"><input type="RESET" value="Reset">
+
+</form>
+</body>
+</html>
\ No newline at end of file

Added: airavata/sandbox/client-api-demo/src/main/webapp/register_host_result.jsp
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/client-api-demo/src/main/webapp/register_host_result.jsp?rev=1398327&view=auto
==============================================================================
--- airavata/sandbox/client-api-demo/src/main/webapp/register_host_result.jsp 
(added)
+++ airavata/sandbox/client-api-demo/src/main/webapp/register_host_result.jsp 
Mon Oct 15 15:14:09 2012
@@ -0,0 +1,36 @@
+<%@ page import="java.io.*" %>
+<%@ page import="org.sample.airavata.api.*" %>
+<%@ page import="org.apache.xmlbeans.SchemaType" %>
+<%@ page import="org.apache.airavata.schemas.gfac.GlobusHostType" %>
+
+<html>
+<head>
+    <title>Application registered in Airavata</title>
+</head>
+
+<body>
+
+<br>
+<%
+    String hostName = request.getParameter("hostName");
+
+    String hostType = request.getParameter("hostType");
+    String hostAddress = request.getParameter("hostAddress");
+    String hostEndpoint = request.getParameter("hostEndpoint");
+    String gateKeeperEndpoint = request.getParameter("gatekeeperEndpoint");
+
+    try {
+        DescriptorRegistrationSample.registerHost(
+                new HostDescriptorBean(hostType, hostName, hostAddress,
+                        hostEndpoint, gateKeeperEndpoint));
+    } catch (Exception e) {
+        e.printStackTrace();
+//                  TODO alert()
+    }
+
+    System.out.println("Host Registration was successful");
+%>
+out.print("Registration DONE!");
+
+</body>
+</html>
\ No newline at end of file

Modified: 
airavata/sandbox/client-api-demo/src/main/webapp/server_info_result.jsp
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/client-api-demo/src/main/webapp/server_info_result.jsp?rev=1398327&r1=1398326&r2=1398327&view=diff
==============================================================================
--- airavata/sandbox/client-api-demo/src/main/webapp/server_info_result.jsp 
(original)
+++ airavata/sandbox/client-api-demo/src/main/webapp/server_info_result.jsp Mon 
Oct 15 15:14:09 2012
@@ -20,20 +20,12 @@
 
         <br>
         <%
-            InputStream stream = 
application.getResourceAsStream("/deployment.properties");
-            Properties props = new Properties();
-            props.load(stream);
-
-            String username = props.getProperty("jcr.username");
-            String password = props.getProperty("jcr.password");
-            String registryURL = props.getProperty("jcr.url");
-
             try {
-                eventingServiceURL = 
WorkflowExecutionSample.getEventingServiceURL(username, password, registryURL);
-                messageBoxServiceURL = 
WorkflowExecutionSample.getMessageBoxServiceURL(username, password, 
registryURL);
-                registryRMIURI = 
WorkflowExecutionSample.getRegistryURL(username, password, registryURL);
-                gFaCURL = WorkflowExecutionSample.getGFaCURL(username, 
password, registryURL);
-                workflowInterpreterServiceURL = 
WorkflowExecutionSample.getWorkflowInterpreterServiceURL(username, password, 
registryURL);
+                eventingServiceURL = 
WorkflowExecutionSample.getEventingServiceURL();
+                messageBoxServiceURL = 
WorkflowExecutionSample.getMessageBoxServiceURL();
+                registryRMIURI = WorkflowExecutionSample.getRegistryURL();
+                gFaCURL = WorkflowExecutionSample.getGFaCURL();
+                workflowInterpreterServiceURL = 
WorkflowExecutionSample.getWorkflowInterpreterServiceURL();
 
             } catch (AiravataAPIInvocationException e) {
                 e.printStackTrace();


Reply via email to