Author: indika
Date: Thu Jan 10 01:52:33 2008
New Revision: 12100

Log:

fix for ESB-JAVA 404



Modified:
   
branches/esb/java/1.6/esb/java/modules/core/src/main/java/org/wso2/esb/services/EndpointAdmin.java
   
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/js/mediators/send_mediator.js

Modified: 
branches/esb/java/1.6/esb/java/modules/core/src/main/java/org/wso2/esb/services/EndpointAdmin.java
==============================================================================
--- 
branches/esb/java/1.6/esb/java/modules/core/src/main/java/org/wso2/esb/services/EndpointAdmin.java
  (original)
+++ 
branches/esb/java/1.6/esb/java/modules/core/src/main/java/org/wso2/esb/services/EndpointAdmin.java
  Thu Jan 10 01:52:33 2008
@@ -413,29 +413,33 @@
             if (previousEndpoint == null) {
                 handleFault(log,
                     "The endpoint named '" + endpointName + "' does not 
exist", null);
-            } else {
+            }
+
+            int staisticsState = SynapseConstants.STATISTICS_UNSET;
+            if (previousEndpoint instanceof AddressEndpoint) {
+                staisticsState = ((AddressEndpoint) 
previousEndpoint).getEndpoint()
+                    .getStatisticsState();
+            } else if (previousEndpoint instanceof WSDLEndpoint) {
+                staisticsState = ((WSDLEndpoint) 
previousEndpoint).getEndpoint()
+                    .getStatisticsState();
+            }
 
-                int staisticsState = SynapseConstants.STATISTICS_UNSET;
-                if (previousEndpoint instanceof AddressEndpoint) {
-                    staisticsState = ((AddressEndpoint) 
previousEndpoint).getEndpoint()
-                        .getStatisticsState();
-                } else if (previousEndpoint instanceof WSDLEndpoint) {
-                    staisticsState = ((WSDLEndpoint) 
previousEndpoint).getEndpoint()
-                        .getStatisticsState();
-                }
-
-                Endpoint endpoint = EndpointAbstractFactory.getEndpointFactroy(
-                    endpointElement).createEndpoint(endpointElement, false);
-                if (endpoint instanceof AddressEndpoint) {
-                    ((AddressEndpoint) endpoint).getEndpoint()
-                        .setStatisticsState(staisticsState);
-                } else if (endpoint instanceof WSDLEndpoint) {
-                    ((WSDLEndpoint) endpoint).getEndpoint()
-                        .setStatisticsState(staisticsState);
-                }
+            Endpoint endpoint = EndpointAbstractFactory.getEndpointFactroy(
+                endpointElement).createEndpoint(endpointElement, false);
+            if (endpoint == null) {
+                handleFault(log, "Newly created endpoint is null ", null);
+            }
 
-                getSynapseConfiguration().addEndpoint(endpointName.trim(), 
endpoint);
+            if (endpoint instanceof AddressEndpoint) {
+                ((AddressEndpoint) endpoint).getEndpoint()
+                    .setStatisticsState(staisticsState);
+            } else if (endpoint instanceof WSDLEndpoint) {
+                ((WSDLEndpoint) endpoint).getEndpoint()
+                    .setStatisticsState(staisticsState);
             }
+
+            getSynapseConfiguration().addEndpoint(endpointName.trim(), 
endpoint);
+
             log.info("Updated the definition of the endpoint : " + 
endpointName);
             return true;
         } else {

Modified: 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/js/mediators/send_mediator.js
==============================================================================
--- 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/js/mediators/send_mediator.js
      (original)
+++ 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/js/mediators/send_mediator.js
      Thu Jan 10 01:52:33 2008
@@ -51,9 +51,10 @@
 }
 
 collectdata["send"] = function collectsenddata(mediator) {
+
     if (mediator.childNodes.length > 0) {
         if (currentepobj != undefined && currentepobj != null) {
-            mediator.removeChild(mediator.childNodes[0]);             
+            removepreviousendpoint(mediator);
             
mediator.appendChild(createesbelement(relpaceString(relpaceString(trim(currentepobj),
 "&", "&"), "&", "&")));
         }
     }
@@ -75,13 +76,30 @@
         esbwarning("Cannot find a valid mediator", TYPE_WARN);
         return;
     }
+
     if (mediator.childNodes.length > 0) {
-        var ep = mediator.childNodes[0];
-        if (ep == null || ep == undefined) {
+        var chlimit = mediator.childNodes.length;
+        var cindex = null;
+        for (var i = 0; i < chlimit; i++) {
+            var child = mediator.childNodes[i] ;
+            if (child != null && child != undefined) {
+                var name = child.nodeName;
+                if (name == "syn:endpoint" || name == "endpoint") {
+                    cindex = i;
+                }
+            }
+        }
+        if (cindex != null) {
+            var ep = mediator.childNodes[cindex];
+            if (ep == null || ep == undefined) {
+                esbwarning("Endpoint cannot be found", TYPE_WARN);
+                return;
+            } else {
+                return ep;
+            }
+        } else {
             esbwarning("Endpoint cannot be found", TYPE_WARN);
             return;
-        } else {
-            return ep;
         }
     }
 }
@@ -116,12 +134,7 @@
     if (sendmediator_c_pos != null && sendmediator_c_pos != undefined) {
         var mediator = getnestedmediator(internalmodel.sequence, 
sendmediator_c_pos);
         if (mediator.childNodes.length > 0) {
-            for (var k=0; k<mediator.childNodes.length; k++) {
-                previous_ep_value = mediator.childNodes[k];
-                if (previous_ep_value != null && previous_ep_value != 
undefined && previous_ep_value.nodeName == "syn:endpoint") {
-                    mediator.removeChild(previous_ep_value);
-                }
-            }
+            removepreviousendpoint(mediator);
         }
         if (currentepobj != undefined && currentepobj != null) {
             mediator.appendChild(createesbelement(currentepobj));
@@ -141,10 +154,7 @@
     if (sendmediator_c_pos != null && sendmediator_c_pos != undefined) {
         var mediator = getnestedmediator(internalmodel.sequence, 
sendmediator_c_pos);
         if (mediator.childNodes.length > 0) {
-            previous_ep_value = mediator.childNodes[0];
-            if (previous_ep_value != null && previous_ep_value != undefined) {
-                mediator.removeChild(previous_ep_value);
-            }
+            removepreviousendpoint(mediator);
         }
         var epdiv = document.getElementById("ep");
         if (epdiv != null && mediator != null) {
@@ -153,3 +163,22 @@
     }
 }
 
+function removepreviousendpoint(mediator) {
+    var chlimit = mediator.childNodes.length;
+    var cindex = null;
+    for (var i = 0; i < chlimit; i++) {
+        var child = mediator.childNodes[i] ;
+        if (child != null && child != undefined) {
+            var name = child.nodeName;
+            if (name == "syn:endpoint" || name == "endpoint") {
+                cindex = i;
+            }
+        }
+    }
+    if (cindex != null) {
+        previous_ep_value = mediator.childNodes[cindex];
+        if (previous_ep_value != null && previous_ep_value != undefined) {
+            mediator.removeChild(previous_ep_value);
+        }
+    }
+}
\ No newline at end of file

_______________________________________________
Esb-java-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev

Reply via email to