You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by he...@apache.org on 2012/10/30 20:16:00 UTC

svn commit: r1403821 - /airavata/sandbox/client-api-demo/src/main/webapp/x_host_descriptor_save_jason.html

Author: heshan
Date: Tue Oct 30 19:16:00 2012
New Revision: 1403821

URL: http://svn.apache.org/viewvc?rev=1403821&view=rev
Log:
Saving Jason request.

Added:
    airavata/sandbox/client-api-demo/src/main/webapp/x_host_descriptor_save_jason.html

Added: airavata/sandbox/client-api-demo/src/main/webapp/x_host_descriptor_save_jason.html
URL: http://svn.apache.org/viewvc/airavata/sandbox/client-api-demo/src/main/webapp/x_host_descriptor_save_jason.html?rev=1403821&view=auto
==============================================================================
--- airavata/sandbox/client-api-demo/src/main/webapp/x_host_descriptor_save_jason.html (added)
+++ airavata/sandbox/client-api-demo/src/main/webapp/x_host_descriptor_save_jason.html Tue Oct 30 19:16:00 2012
@@ -0,0 +1,142 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+        "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+    <title></title>
+</head>
+<body>
+
+<b> Register Host Description </b>
+<br/>
+
+Host Name           : <input type="text" name="hostName" id="hostName1" size="75">
+<br/>
+Host Address        : <input type="text" name="hostAddress" id="hostAddress1" size="75">
+<br/>
+Host Type           : <select name="drop1">
+    <option selected="true">Local</option>
+    <option>Globus</option>
+</select>
+<br/>
+<div id="div">
+    Host Endpoint       : <input type="text" name="hostEndpoint" id="hostEndpoint1" size="75">
+    <br/>
+    Gatekeeper Endpoint : <input type="text" name="gatekeeperEndpoint" id="gatekeeperEndpoint1" size="75">
+    <br/>
+</div>
+
+<button name="btn2">Save Host</button>
+
+<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
+<script>
+    function xmlToString(xml) {
+        var xmlData = $(xml);
+        var xmlString;
+        if (window.ActiveXObject) {
+            xmlString = xmlData.xml;
+        } else {
+            var oSerializer = new XMLSerializer();
+            xmlString = oSerializer.serializeToString(xmlData[0]);
+        }
+        console.log(xmlString);
+        return xmlString;
+    }
+
+    $(document).ready(function(){
+        $(window).load(function () {
+            $("div").hide();
+        });
+
+        $("select[name='drop1']").change(function() {
+            //alert($(this).val());
+            if("Local" == $(this).val()) {
+                $("div").hide();
+            } else {
+                $("div").show();
+            }
+        });
+
+        $('[name="btn2"]').click(function(){
+            //alert($(this).val());
+            var hostName = $("#hostName1").val();
+            var hostAddress = $("#hostAddress1").val();
+            var hostEndpoint = $("#hostEndpoint1").val();
+            alert(hostEndpoint);
+            alert(hostEndpoint);
+            alert("hostEndpoint null  :" + hostEndpoint == null);
+            alert("hostEndpoint empty :" + hostEndpoint == "");
+            var gatekeeperEndpoint = $("#gatekeeperEndpoint1").val();
+            var xml = $('<type:hostDescription xmlns:type="http://schemas.airavata.apache.org/gfac/type"><type:hostName>' + hostName + '</type:hostName><type:hostAddress>' + hostAddress + '</type:hostAddress></type:hostDescription>');
+
+            var xmlData= $(xml);
+            var xmlString;
+            if (window.ActiveXObject){
+                xmlString = xmlData.xml;
+            } else {
+                var oSerializer = new XMLSerializer();
+                xmlString = oSerializer.serializeToString(xmlData[0]);
+            }
+            console.log(xmlString);
+
+            alert(hostName);
+            alert(hostAddress);
+            alert(xmlString);
+
+//            if ($("select[name='drop1']").val() == "Local") {
+            if (("" == hostEndpoint) || ("" == gatekeeperEndpoint)) {
+                alert("if Case");
+                $.ajax({
+//                    headers: {
+//                        Accept : "text/plain; charset=utf-8"
+//                    },
+                    beforeSend: function(x) {
+                        if (x && x.overrideMimeType) {
+                            x.overrideMimeType("application/j-son;charset=UTF-8");
+                        }
+                    },
+
+                    type: "POST",
+                    dataType: "json",
+                    contentType: "application/json;charset=utf-8",
+//                    url: "http://localhost:7080/airavata-registry-rest-services/registry/api/hostdescriptor/save/jason",
+                    url: "http://localhost:6060/airavata-registry-rest-services/registry/api/hostdescriptor/save/jason",
+                    data: JSON.stringify({
+                        "hostName": hostName,
+                        "hostAddress": hostAddress
+                    })
+                }).done(function( msg ) {
+                            alert( "Data Saved: " + msg );
+                        });
+            } else {
+                alert("end Case");
+                $.ajax({
+//                    headers: {
+//                        Accept : "text/plain; charset=utf-8"
+//                    },
+                    beforeSend: function(x) {
+                        if (x && x.overrideMimeType) {
+                            x.overrideMimeType("application/j-son;charset=UTF-8");
+                        }
+                    },
+                    type: "POST",
+                    dataType: "json",
+                    contentType: "application/json;charset=utf-8",
+//                    url: "http://localhost:7080/airavata-registry-rest-services/registry/api/hostdescriptor/save/jason",
+                    url: "http://localhost:6060/airavata-registry-rest-services/registry/api/hostdescriptor/save/jason",
+                    data: JSON.stringify({
+                        "hostName": hostName,
+                        "hostAddress": hostAddress,
+                        "hostEndpoint" : hostEndpoint,
+                        "gatekeeperEndpoint" : gatekeeperEndpoint
+                    })
+                }).done(function( msg ) {
+                            alert( "Data Saved: " + msg );
+                        });
+            }
+
+        });
+    });
+</script>
+
+</body>
+</html>