Author: tyrell
Date: Fri Jul 18 04:51:16 2008
New Revision: 19581
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19581

Log:
Fixing MASHUP-978 by harvesting the returned messagethrough string manipulation.

Modified:
   trunk/mashup/java/modules/www/cert_manager.jsp

Modified: trunk/mashup/java/modules/www/cert_manager.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/cert_manager.jsp?rev=19581&r1=19580&r2=19581&view=diff
==============================================================================
--- trunk/mashup/java/modules/www/cert_manager.jsp      (original)
+++ trunk/mashup/java/modules/www/cert_manager.jsp      Fri Jul 18 04:51:16 2008
@@ -77,14 +77,39 @@
         upload:handleUpload
     };
 
+    function harvestMessage(response) {
+        // response = "<ns:blah xmlns:'blahblah'> <ns:return>Sample response 
message</ns:return> </ns:blah>"
+
+        var markerElem = "<ns:return>";
+        var markerElemEnd = "</ns:return>";
+        var firstOccIndex = response.indexOf(markerElem);
+
+        if (firstOccIndex == -1) {
+            return response;
+        } else {
+            // Removing all the text before the first occurence of markerElem 
+            response = response.substring(firstOccIndex + markerElem.length);
+
+            // Searching for the second occurence
+            var secondOccIndex = response.indexOf(markerElemEnd);
+            if (secondOccIndex == -1) {
+                return response;
+            } else {
+                response = response.substring(0, secondOccIndex);
+                return response;
+            }
+        }
+    }
+
     function handleUpload(o) {
-        var responseText = o.responseText;
+        var responseText = harvestMessage(o.responseText);
         if (responseText == null) {
             WSO2.MashupUtils.dialog("Exception occured", "Could not connect to 
backend service.<br><input type='button' value='Close' 
onclick='WSO2.MashupUtils.dialog.close();'", 300, 70);
         } else {
             if (responseText.indexOf("Exception occured") != -1) {
                 WSO2.MashupUtils.dialog("Exception occured", responseText + 
"<br><input type='button' value='Close' 
onclick='WSO2.MashupUtils.dialog.close();'", 300, 70);
             } else {
+                
                 WSO2.MashupUtils.dialog("Operation successfull", responseText 
+ "<br><input type='button' value='Close' onclick='handleSuccess();'", 300, 
70);                
             }
         }

_______________________________________________
Mashup-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to