incubator-hise-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r.@apache.org
Subject svn commit: r984307 - in /incubator/hise/trunk: hise-bundle/src/main/resources/META-INF/spring/hise.xml hise-web-client/ hise-web-client/README.txt hise-web-client/taskOperations.html
Date Wed, 11 Aug 2010 06:52:13 GMT
Author: rr
Date: Wed Aug 11 06:52:13 2010
New Revision: 984307

URL: http://svn.apache.org/viewvc?rev=984307&view=rev
Log:
HISE-71: Implement simple JavaScript client for taskOperations web service

Added:
    incubator/hise/trunk/hise-web-client/
    incubator/hise/trunk/hise-web-client/README.txt
    incubator/hise/trunk/hise-web-client/taskOperations.html
Modified:
    incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml

Modified: incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml?rev=984307&r1=984306&r2=984307&view=diff
==============================================================================
--- incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml (original)
+++ incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml Wed Aug 11
06:52:13 2010
@@ -115,6 +115,27 @@
       </bean>
     </jaxws:inInterceptors>
   </jaxws:endpoint>
+  
+  <jaxws:endpoint id="taskOperationsEndpointPlainAuth" name="taskOperationsEndpointPlainAuth"
address="/taskOperationsPlainAuth/" implementor="#taskOperations" serviceName="htdaw:taskOperations"
publish="true" wsdlLocation="classpath:ws-humantask.wsdl">
+  <!-- 
+    <jaxws:handlers>
+      <ref bean="transactionHandler"/>
+    </jaxws:handlers>
+     -->
+    <jaxws:inInterceptors>
+      <bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
+        <constructor-arg>
+          <map>
+            <entry key="action" value="UsernameToken"/>
+            <entry key="passwordType" value="PasswordText"/>
+            <entry key="passwordCallbackRef">
+              <ref bean="hisePasswordCallback"/>
+            </entry>
+          </map>
+        </constructor-arg>
+      </bean>
+    </jaxws:inInterceptors>
+  </jaxws:endpoint>
 
 <!--
   <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>

Added: incubator/hise/trunk/hise-web-client/README.txt
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-web-client/README.txt?rev=984307&view=auto
==============================================================================
--- incubator/hise/trunk/hise-web-client/README.txt (added)
+++ incubator/hise/trunk/hise-web-client/README.txt Wed Aug 11 06:52:13 2010
@@ -0,0 +1,10 @@
+Apache 2 server config:
+* Enable mod-proxy by copying proxy files from /etc/apache2/mods-available to /etc/apache2/mods-enabled
+* Put into /etc/apache2/httpd.conf following contents:
+
+ProxyPass         /taskOperations.html-location/cxf  http://localhost:8181/cxf
+<Proxy *>
+                Order deny,allow
+                Allow from all
+</Proxy>
+

Added: incubator/hise/trunk/hise-web-client/taskOperations.html
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-web-client/taskOperations.html?rev=984307&view=auto
==============================================================================
--- incubator/hise/trunk/hise-web-client/taskOperations.html (added)
+++ incubator/hise/trunk/hise-web-client/taskOperations.html Wed Aug 11 06:52:13 2010
@@ -0,0 +1,241 @@
+<html>
+<head>
+<script type="text/javascript">
+    function getText(n){
+        var strings = [];
+        getStrings(n, strings);
+        return strings.join("");
+
+        function getStrings(n, strings){
+            if (n != null) {
+            if (n.nodeType == 3 /* Node.TEXT_NODE */)
+                strings.push(n.data);
+            else if (n.nodeType == 1 /* Node.ELEMENT_NODE */) {
+                    for (var m = n.firstChild; m != null; m = m.nextSibling) {
+                        getStrings(m, strings);
+                    }
+            }
+}
+        }
+    }
+
+function sendRequest(content,soapAction) {
+    //alert(content);
+    var req;
+    if (window.XMLHttpRequest)
+      {// code for IE7+, Firefox, Chrome, Opera, Safari
+      req=new XMLHttpRequest();
+      }
+    else
+      {// code for IE6, IE5
+      req=new ActiveXObject("Microsoft.XMLHTTP");
+      }
+    
+    //req.open("GET", "http://localhost:8181/cxf/taskOperations/", false);   
+    //req.open("GET", "c.xml", false);   
+    req.open("POST", "cxf/taskOperationsPlainAuth/", false);   
+    req.setRequestHeader("Content-Type", "application/xml");
+    req.setRequestHeader("SOAPAction", soapAction);
+    //req.setRequestHeader("Content-Length", content.length);
+    //req.setRequestHeader("Connection", "close");
+    try {
+        req.send(content);  
+        var v=req.responseXML;       
+
+        var d = v.getElementsByTagNameNS("http://schemas.xmlsoap.org/soap/envelope/", "Envelope")[0];
+        if (d != null) {
+            d = d.getElementsByTagNameNS("http://schemas.xmlsoap.org/soap/envelope/", "Fault")[0];
+            if (d != null) {
+                throw "SOAP Fault occurred: " + getText(d);
+            }
+        }
+
+        return v;
+    } catch (e) {
+        alert(e);
+        throw e;
+    }
+}
+
+function displaySoap(response) {
+//    var s = new XMLSerializer().serializeToString(
+//            response, "application/xhtml+xml");
+//    alert(s);
+}
+
+function securityHeader() {
+    var u = document.getElementById('userName').value;
+    var p = document.getElementById('userPassword').value;
+var v =
+'  <soapenv:Header>'+
+'    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
soapenv:mustUnderstand="1">'+
+'      <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
wsu:Id="UsernameToken-1">'+
+'        <wsse:Username>' + u  + '</wsse:Username>'+
+'        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">'+p+'</wsse:Password>'+
+'      </wsse:UsernameToken>'+
+'    </wsse:Security>'+
+'  </soapenv:Header>';
+//alert(u+";"+p+";"+v);
+return v;
+}
+
+function claim(id) {
+    displaySoap(sendRequest(
+'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.example.org/WS-HT/api/xsd">'+
+securityHeader()+
+'   <soapenv:Body>'+
+'      <xsd:claim>'+
+'         <xsd:identifier>'+id+'</xsd:identifier>'+
+'      </xsd:claim>'+
+'   </soapenv:Body>'+
+'</soapenv:Envelope>'
+
+,"http://www.example.org/WS-HT/api/wsdl/claim"));
+    getMyTasks();
+}
+
+function start(id) {
+    displaySoap(sendRequest(
+'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.example.org/WS-HT/api/xsd">'+
+securityHeader()+
+'   <soapenv:Body>'+
+'      <xsd:start>'+
+'         <xsd:identifier>'+id+'</xsd:identifier>'+
+'      </xsd:start>'+
+'   </soapenv:Body>'+
+'</soapenv:Envelope>'
+
+,"http://www.example.org/WS-HT/api/wsdl/start"));
+    getMyTasks();
+}
+
+function release(id) {
+    displaySoap(sendRequest(
+'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.example.org/WS-HT/api/xsd">'+
+securityHeader()+
+'   <soapenv:Body>'+
+'      <xsd:release>'+
+'         <xsd:identifier>'+id+'</xsd:identifier>'+
+'      </xsd:release>'+
+'   </soapenv:Body>'+
+'</soapenv:Envelope>'
+
+,"http://www.example.org/WS-HT/api/wsdl/release"));
+    getMyTasks();
+}
+
+function complete(id) {
+    displaySoap(sendRequest(
+'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.example.org/WS-HT/api/xsd">'+
+securityHeader()+
+'   <soapenv:Body>'+
+'      <xsd:complete>'+
+'         <xsd:identifier>'+id+'</xsd:identifier>'+
+'      </xsd:complete>'+
+'   </soapenv:Body>'+
+'</soapenv:Envelope>'
+
+,"http://www.example.org/WS-HT/api/wsdl/complete"));
+    getMyTasks();
+}
+
+function fail(id) {
+    displaySoap(sendRequest(
+'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.example.org/WS-HT/api/xsd">'+
+securityHeader()+
+'   <soapenv:Body>'+
+'      <xsd:fail>'+
+'         <xsd:identifier>'+id+'</xsd:identifier>'+
+'      </xsd:fail>'+
+'   </soapenv:Body>'+
+'</soapenv:Envelope>'
+
+,"http://www.example.org/WS-HT/api/wsdl/fail"));
+    getMyTasks();
+}
+
+
+function getMyTasks()
+{
+    var xmlDoc = sendRequest(
+    '<?xml version="1.0"?>'+
+    '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.example.org/WS-HT/api/xsd">'+
+securityHeader()+
+    '  <soapenv:Body>'+
+    '    <xsd:getMyTasks>'+
+    '      <xsd:taskType>ALL</xsd:taskType>'+
+    '      <xsd:genericHumanRole>POTENTIALOWNERS</xsd:genericHumanRole>'+
+    '      <xsd:maxTasks>500</xsd:maxTasks>'+
+    '    </xsd:getMyTasks>'+
+    '  </soapenv:Body>'+
+    '</soapenv:Envelope>', 
+
+    "http://www.example.org/WS-HT/api/wsdl/getMyTasks"
+    );
+
+    var d = xmlDoc.getElementsByTagNameNS("http://schemas.xmlsoap.org/soap/envelope/", "Envelope")[0];
+    d = d.getElementsByTagNameNS("http://schemas.xmlsoap.org/soap/envelope/", "Body")[0];
+    d = d.getElementsByTagNameNS("http://www.example.org/WS-HT/api/xsd", "getMyTasksResponse")[0];
+    d = d.getElementsByTagNameNS("http://www.example.org/WS-HT/api/xsd", "taskAbstract");
+   
+    var e="";
+        e=e+"<tr>"
+        e=e+"<td>id</td>";
+        e=e+"<td>taskType</td>";
+        e=e+"<td>name</td>";
+        e=e+"<td>status</td>";
+        e=e+"<td>priority</td>";
+        e=e+"<td>actualOwner</td>";
+        e=e+"<td>createdOn</td>";
+        e=e+"<td>createdBy</td>";
+        e=e+"<td>presentationName</td>";
+        e=e+"<td>presentationSubject</td>";
+        e=e+"<td>operations</td>";
+        e=e+"</tr>"
+    for (var i=0;i<d.length;i++) {
+        e=e+"<tr>"
+        var id=getText(d[i].getElementsByTagNameNS("http://www.example.org/WS-HT/api", "id")[0]);
+        e=e+"<td>"+id+"</td>";
+        e=e+"<td>"+getText(d[i].getElementsByTagNameNS("http://www.example.org/WS-HT/api",
"taskType")[0])+"</td>";
+        e=e+"<td>"+getText(d[i].getElementsByTagNameNS("http://www.example.org/WS-HT/api",
"name")[0])+"</td>";
+        var status = getText(d[i].getElementsByTagNameNS("http://www.example.org/WS-HT/api",
"status")[0]);
+        e=e+"<td>"+status+"</td>";
+        e=e+"<td>"+getText(d[i].getElementsByTagNameNS("http://www.example.org/WS-HT/api",
"priority")[0])+"</td>";
+        e=e+"<td>"+getText(d[i].getElementsByTagNameNS("http://www.example.org/WS-HT/api",
"actualOwner")[0])+"</td>";
+        e=e+"<td>"+getText(d[i].getElementsByTagNameNS("http://www.example.org/WS-HT/api",
"createdOn")[0])+"</td>";
+        e=e+"<td>"+getText(d[i].getElementsByTagNameNS("http://www.example.org/WS-HT/api",
"createdBy")[0])+"</td>";
+        e=e+"<td>"+getText(d[i].getElementsByTagNameNS("http://www.example.org/WS-HT/api",
"presentationName")[0])+"</td>";
+        e=e+"<td>"+getText(d[i].getElementsByTagNameNS("http://www.example.org/WS-HT/api",
"presentationSubject")[0])+"</td>";
+        e=e+'<td>';
+        if (status=='READY') { e=e+'<input type="button" onclick="claim('+id+')" value="claim"/>';
}
+        if (status=='RESERVED') { e=e+'<input type="button" onclick="start('+id+')" value="start"/>';
}
+        if (status=='IN_PROGRESS') { 
+            e=e+'<input type="button" onclick="release('+id+')" value="release"/>';

+            e=e+'<input type="button" onclick="complete('+id+')" value="complete"/>';

+            e=e+'<input type="button" onclick="fail('+id+')" value="fail"/>'; 
+        }
+        e=e+'</td>';
+        e=e+"</tr>"
+    }
+
+//    var s = new XMLSerializer().serializeToString(
+//            xmlDoc, "application/xhtml+xml");
+//    document.getElementById('myTable').innerHTML='<tr><td>'+s+'</td></tr><tr>';
+    document.getElementById('myTable').innerHTML=e;
+}
+</script>
+</head>
+<body>
+
+Task operator:<br/>
+User name: <input id="userName" type="text" value="someUser"><br/>
+Password: <input id="userPassword" type="text" value="someUser"><br/>
+<input type="button" onclick="getMyTasks()" value="getMyTasks">
+<br />
+<table id="myTable" border="1">
+</table>
+
+</body>
+</html>
+
+



Mime
View raw message