[esb-java-dev] svn commit r751 - in trunk/esb/java/modules:
core/src/main/java/org/wso2/esb/services
distribution/src/main/www/extensions/core/js
distribution/src/main/www/extensions/core/xslt/proxyservices
svn at wso2.org
svn at wso2.org
Mon Feb 5 19:51:06 PST 2007
Author: ruwan
Date: Mon Feb 5 19:50:35 2007
New Revision: 751
Modified:
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/services/ProxyServiceAdmin.java
trunk/esb/java/modules/distribution/src/main/www/extensions/core/js/_proxyservices.js
trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_edit.xsl
trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_view.xsl
trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_transport_edit.xsl
Log:
proxy edit done
Modified: trunk/esb/java/modules/core/src/main/java/org/wso2/esb/services/ProxyServiceAdmin.java
==============================================================================
--- trunk/esb/java/modules/core/src/main/java/org/wso2/esb/services/ProxyServiceAdmin.java (original)
+++ trunk/esb/java/modules/core/src/main/java/org/wso2/esb/services/ProxyServiceAdmin.java Mon Feb 5 19:50:35 2007
@@ -96,25 +96,6 @@
}
}
- public void saveProxyServiceNew(OMElement proxyServiceElement) throws AxisFault {
- try {
- if (proxyServiceElement.getFirstElement().getQName().getLocalPart()
- .equals(org.apache.synapse.config.xml.Constants.PROXY_ELT.getLocalPart())) {
-// String proxyName = proxyServiceElement.getFirstElement().getAttributeValue(new QName("name"));
-// if (getSynapseConfiguration().getProxyService(proxyName) == null) {
-// throw new AxisFault("Proxy service name " + proxyName + " doesn't exists");
-// } else {
- ProxyService proxy = ProxyServiceFactory.createProxy(proxyServiceElement);
- getSynapseConfiguration().addProxyService(proxy.getName(), proxy);
-// }
- } else {
- throw new AxisFault("Invalid proxy service element");
- }
- } catch (SynapseException syne) {
- throw new AxisFault("Unable to save the proxy service ", syne);
- }
- }
-
/**
* Add a proxy service described by the given OMElement
*
@@ -124,180 +105,214 @@
*/
public void addProxyService(OMElement proxyServiceElement) throws AxisFault {
try {
- if (proxyServiceElement.getFirstElement().getQName().getLocalPart()
+ if (proxyServiceElement.getQName().getLocalPart()
.equals(org.apache.synapse.config.xml.Constants.PROXY_ELT.getLocalPart())) {
- String proxyName = proxyServiceElement.getFirstElement().getAttributeValue(
- new QName("name"));
+ String proxyName = proxyServiceElement.getAttributeValue(new QName("name"));
if (getSynapseConfiguration().getProxyService(proxyName) != null) {
- throw new AxisFault("Proxy Service name " + proxyName + " already exists");
+ throw new AxisFault("Proxy service with a given name " + proxyName + " already exists");
} else {
- OMElement proxyElement = proxyServiceElement.getFirstElement();
- OMFactory fac = proxyElement.getOMFactory();
- OMNamespace synNameSpace = fac.createOMNamespace(
- Constants.SYNAPSE_NAMESPACE, "ns2");
- OMNamespace nullNamespace = fac.createOMNamespace(
- Constants.NULL_NAMESPACE, "ns3");
-
- if (proxyElement.getFirstChildWithName(new QName(
- Constants.SYNAPSE_NAMESPACE, "wsdl")) != null) {
- OMElement wsdl = (OMElement) proxyElement.getFirstChildWithName(
- new QName(Constants.SYNAPSE_NAMESPACE, "wsdl")).detach();
- String type = wsdl.getAttributeValue(
- new QName(Constants.NULL_NAMESPACE, "type"));
- String value = wsdl.getAttributeValue(
- new QName(Constants.NULL_NAMESPACE, "key"));
- Property prop = null;
- OMElement wsdlElement = fac.createOMElement("wsdl", synNameSpace);
- if (type.equalsIgnoreCase("Registry Key")) {
- if (getSynapseConfiguration().getPropertyObject(value) != null &&
- getSynapseConfiguration().getPropertyObject(value).getType()
- == Property.DYNAMIC_TYPE) {
- wsdlElement.addAttribute(
- fac.createOMAttribute("key", nullNamespace, value));
- } else {
- throw new AxisFault("The given Registry key for wsdl doesnt " +
- "refer to a proper property");
- }
- }
- if (type.equalsIgnoreCase("URL Source")) {
- prop = new Property();
- prop.setName(proxyName + "_wsdl");
- prop.setType(Property.SRC_TYPE);
- prop.setSrc(new URL(value));
- getSynapseConfiguration().addProperty(proxyName + "_wsdl", prop);
- wsdlElement.addAttribute(fac.createOMAttribute(
- "key", nullNamespace, proxyName + "_wsdl"));
- }
- if (type.equalsIgnoreCase("Existing Property")) {
- if(getSynapseConfiguration().getProperty(value) != null) {
- wsdlElement.addAttribute(fac.createOMAttribute(
- "key", nullNamespace, value));
- } else {
- throw new AxisFault("Given property is incorrect");
- }
- }
- proxyElement.addChild(wsdlElement);
- }
-
- if (proxyElement.getChildrenWithName(new QName(
- Constants.SYNAPSE_NAMESPACE, "policy")).hasNext()) {
- Iterator policies = proxyElement.getChildrenWithName(
- new QName(Constants.SYNAPSE_NAMESPACE, "policy"));
- ArrayList policyList = new ArrayList();
- int i = 0;
- while (policies.hasNext()) {
- i++;
- OMElement policy = (OMElement) ((OMElement) policies.next()).detach();
- String type = policy.getAttributeValue(
- new QName(Constants.NULL_NAMESPACE, "type"));
- String key = policy.getAttributeValue(
- new QName(Constants.NULL_NAMESPACE, "key"));
- Property prop = null;
- OMElement policyElement = fac.createOMElement("policy", synNameSpace);
- if (type.equalsIgnoreCase("Registry Key")) {
- if (getSynapseConfiguration().getPropertyObject(key) != null &&
- getSynapseConfiguration().getPropertyObject(key).getType()
- == Property.DYNAMIC_TYPE) {
- policyElement.addAttribute(fac.createOMAttribute(
- "key", nullNamespace, key));
- } else {
- throw new AxisFault("The given Registry key for wsdl doesnt " +
- "refer to a proper property");
- }
- }
- if (type.equalsIgnoreCase("URL Source")) {
- prop = new Property();
- prop.setName(proxyName + "_policy" + i);
- prop.setType(Property.SRC_TYPE);
- prop.setSrc(new URL(key));
- getSynapseConfiguration().addProperty(
- proxyName + "_policy" + i, prop);
- policyElement.addAttribute(fac.createOMAttribute(
- "key", nullNamespace, proxyName + "_policy" + i));
- }
- if (type.equalsIgnoreCase("Inline XML")) {
- prop = new Property();
- prop.setName(proxyName + "_policy" + i);
- prop.setType(Property.INLINE_XML_TYPE);
- prop.setValue(policy.getFirstElement());
- getSynapseConfiguration().addProperty(
- proxyName + "_policy" + i, prop);
- policyElement.addAttribute(fac.createOMAttribute(
- "key", nullNamespace, proxyName + "_policy" + i));
- }
- if (type.equalsIgnoreCase("Existing Property")) {
- if(getSynapseConfiguration().getProperty(key) != null) {
- policyElement.addAttribute(fac.createOMAttribute(
- "key", nullNamespace, key));
- } else {
- throw new AxisFault("Given property is incorrect");
- }
- }
- policyList.add(policyElement);
- }
- Iterator itr = policyList.iterator();
- while (itr.hasNext()) {
- proxyElement.addChild((OMElement) itr.next());
- }
- }
-
- ProxyService proxy = ProxyServiceFactory.createProxy(proxyElement);
- getSynapseConfiguration().addProxyService(proxyName, proxy);
- proxy.buildAxisService(getSynapseConfiguration(), getSynapseConfiguration()
- .getAxisConfiguration());
- if (!proxy.isStartOnLoad()) {
- proxy.stop(getSynapseConfiguration());
- }
+ ProxyService proxy = ProxyServiceFactory.createProxy(proxyServiceElement);
+ getSynapseConfiguration().addProxyService(proxy.getName(), proxy);
+ proxy.buildAxisService(getSynapseConfiguration(), getSynapseConfiguration().getAxisConfiguration());
}
} else {
throw new AxisFault("Invalid proxy service element");
}
} catch (SynapseException syne) {
- throw new AxisFault("Unable to add the proxy service ", syne);
- } catch (MalformedURLException e) {
- throw new AxisFault("Can not load the wsdl for the Proxy Service");
+ throw new AxisFault("Unable to save the proxy service ", syne);
}
}
/**
+ * Add a proxy service described by the given OMElement
+ *
+ * @param proxyServiceElement
+ * @throws AxisFault if the element is not an proxy service or if a proxy service wiht the
+ * same name exists
+ */
+// public void addProxyService(OMElement proxyServiceElement) throws AxisFault {
+// try {
+// if (proxyServiceElement.getFirstElement().getQName().getLocalPart()
+// .equals(org.apache.synapse.config.xml.Constants.PROXY_ELT.getLocalPart())) {
+// String proxyName = proxyServiceElement.getFirstElement().getAttributeValue(
+// new QName("name"));
+// if (getSynapseConfiguration().getProxyService(proxyName) != null) {
+// throw new AxisFault("Proxy Service name " + proxyName + " already exists");
+// } else {
+// OMElement proxyElement = proxyServiceElement.getFirstElement();
+// OMFactory fac = proxyElement.getOMFactory();
+// OMNamespace synNameSpace = fac.createOMNamespace(
+// Constants.SYNAPSE_NAMESPACE, "ns2");
+// OMNamespace nullNamespace = fac.createOMNamespace(
+// Constants.NULL_NAMESPACE, "ns3");
+//
+// if (proxyElement.getFirstChildWithName(new QName(
+// Constants.SYNAPSE_NAMESPACE, "wsdl")) != null) {
+// OMElement wsdl = (OMElement) proxyElement.getFirstChildWithName(
+// new QName(Constants.SYNAPSE_NAMESPACE, "wsdl")).detach();
+// String type = wsdl.getAttributeValue(
+// new QName(Constants.NULL_NAMESPACE, "type"));
+// String value = wsdl.getAttributeValue(
+// new QName(Constants.NULL_NAMESPACE, "key"));
+// Property prop = null;
+// OMElement wsdlElement = fac.createOMElement("wsdl", synNameSpace);
+// if (type.equalsIgnoreCase("Registry Key")) {
+// if (getSynapseConfiguration().getPropertyObject(value) != null &&
+// getSynapseConfiguration().getPropertyObject(value).getType()
+// == Property.DYNAMIC_TYPE) {
+// wsdlElement.addAttribute(
+// fac.createOMAttribute("key", nullNamespace, value));
+// } else {
+// throw new AxisFault("The given Registry key for wsdl doesnt " +
+// "refer to a proper property");
+// }
+// }
+// if (type.equalsIgnoreCase("URL Source")) {
+// prop = new Property();
+// prop.setName(proxyName + "_wsdl");
+// prop.setType(Property.SRC_TYPE);
+// prop.setSrc(new URL(value));
+// getSynapseConfiguration().addProperty(proxyName + "_wsdl", prop);
+// wsdlElement.addAttribute(fac.createOMAttribute(
+// "key", nullNamespace, proxyName + "_wsdl"));
+// }
+// if (type.equalsIgnoreCase("Existing Property")) {
+// if(getSynapseConfiguration().getProperty(value) != null) {
+// wsdlElement.addAttribute(fac.createOMAttribute(
+// "key", nullNamespace, value));
+// } else {
+// throw new AxisFault("Given property is incorrect");
+// }
+// }
+// proxyElement.addChild(wsdlElement);
+// }
+//
+// if (proxyElement.getChildrenWithName(new QName(
+// Constants.SYNAPSE_NAMESPACE, "policy")).hasNext()) {
+// Iterator policies = proxyElement.getChildrenWithName(
+// new QName(Constants.SYNAPSE_NAMESPACE, "policy"));
+// ArrayList policyList = new ArrayList();
+// int i = 0;
+// while (policies.hasNext()) {
+// i++;
+// OMElement policy = (OMElement) ((OMElement) policies.next()).detach();
+// String type = policy.getAttributeValue(
+// new QName(Constants.NULL_NAMESPACE, "type"));
+// String key = policy.getAttributeValue(
+// new QName(Constants.NULL_NAMESPACE, "key"));
+// Property prop = null;
+// OMElement policyElement = fac.createOMElement("policy", synNameSpace);
+// if (type.equalsIgnoreCase("Registry Key")) {
+// if (getSynapseConfiguration().getPropertyObject(key) != null &&
+// getSynapseConfiguration().getPropertyObject(key).getType()
+// == Property.DYNAMIC_TYPE) {
+// policyElement.addAttribute(fac.createOMAttribute(
+// "key", nullNamespace, key));
+// } else {
+// throw new AxisFault("The given Registry key for wsdl doesnt " +
+// "refer to a proper property");
+// }
+// }
+// if (type.equalsIgnoreCase("URL Source")) {
+// prop = new Property();
+// prop.setName(proxyName + "_policy" + i);
+// prop.setType(Property.SRC_TYPE);
+// prop.setSrc(new URL(key));
+// getSynapseConfiguration().addProperty(
+// proxyName + "_policy" + i, prop);
+// policyElement.addAttribute(fac.createOMAttribute(
+// "key", nullNamespace, proxyName + "_policy" + i));
+// }
+// if (type.equalsIgnoreCase("Inline XML")) {
+// prop = new Property();
+// prop.setName(proxyName + "_policy" + i);
+// prop.setType(Property.INLINE_XML_TYPE);
+// prop.setValue(policy.getFirstElement());
+// getSynapseConfiguration().addProperty(
+// proxyName + "_policy" + i, prop);
+// policyElement.addAttribute(fac.createOMAttribute(
+// "key", nullNamespace, proxyName + "_policy" + i));
+// }
+// if (type.equalsIgnoreCase("Existing Property")) {
+// if(getSynapseConfiguration().getProperty(key) != null) {
+// policyElement.addAttribute(fac.createOMAttribute(
+// "key", nullNamespace, key));
+// } else {
+// throw new AxisFault("Given property is incorrect");
+// }
+// }
+// policyList.add(policyElement);
+// }
+// Iterator itr = policyList.iterator();
+// while (itr.hasNext()) {
+// proxyElement.addChild((OMElement) itr.next());
+// }
+// }
+//
+// ProxyService proxy = ProxyServiceFactory.createProxy(proxyElement);
+// getSynapseConfiguration().addProxyService(proxyName, proxy);
+// proxy.buildAxisService(getSynapseConfiguration(), getSynapseConfiguration()
+// .getAxisConfiguration());
+// if (!proxy.isStartOnLoad()) {
+// proxy.stop(getSynapseConfiguration());
+// }
+// }
+// } else {
+// throw new AxisFault("Invalid proxy service element");
+// }
+// } catch (SynapseException syne) {
+// throw new AxisFault("Unable to add the proxy service ", syne);
+// } catch (MalformedURLException e) {
+// throw new AxisFault("Can not load the wsdl for the Proxy Service");
+// }
+// }
+
+ /**
* Saves the proxy service to the SynapseConfiguration
*
* @param proxyServiceElement
* @throws AxisFault
*/
public void saveProxyService(OMElement proxyServiceElement) throws AxisFault {
+
try {
-// XMLConfigurationBuilder xmlBuilder = new XMLConfigurationBuilder();
- if (proxyServiceElement.getFirstElement().getQName().getLocalPart()
+
+ if (proxyServiceElement.getQName().getLocalPart()
.equals(org.apache.synapse.config.xml.Constants.PROXY_ELT.getLocalPart())) {
- String proxyName = proxyServiceElement.getFirstElement().getAttributeValue(new QName("name"));
+
+ String proxyName = proxyServiceElement.getAttributeValue(new QName("name"));
ProxyService currentProxy = getSynapseConfiguration().getProxyService(proxyName);
if (currentProxy == null) {
throw new AxisFault("Proxy service name " + proxyName + " doesn't exists");
} else {
-// ProxyService proxy = ProxyServiceFactory.createProxy(proxyServiceElement.getFirstElement());
-// getSynapseConfiguration().addProxyService(proxy.getName(), proxy);
+
deleteProxyService(proxyName);
try {
+
addProxyService(proxyServiceElement);
if(!currentProxy.isRunning()) {
getSynapseConfiguration().getProxyService(proxyName).stop(getSynapseConfiguration());
}
} catch (Exception e) {
+
getSynapseConfiguration().addProxyService(proxyName, currentProxy);
currentProxy.buildAxisService(getSynapseConfiguration(),
getSynapseConfiguration().getAxisConfiguration());
if (!currentProxy.isRunning()) {
currentProxy.stop(getSynapseConfiguration());
}
+
throw new AxisFault("Unable to save the changes of the proxy. Restored " +
"the existing proxy...");
}
}
+
} else {
+
throw new AxisFault("Invalid proxy service element");
}
+
} catch (SynapseException syne) {
throw new AxisFault("Unable to save the proxy service ", syne);
}
Modified: trunk/esb/java/modules/distribution/src/main/www/extensions/core/js/_proxyservices.js
==============================================================================
--- trunk/esb/java/modules/distribution/src/main/www/extensions/core/js/_proxyservices.js (original)
+++ trunk/esb/java/modules/distribution/src/main/www/extensions/core/js/_proxyservices.js Mon Feb 5 19:50:35 2007
@@ -255,14 +255,29 @@
showgetproxynamediv(1);
} else {
- var body_xml = new XMLSerializer().serializeToString(internalmodel.proxy);
- var callURL = serverURL + "/" + PROXY_ADMIN + "/" + "saveProxyServiceNew";
- send("saveProxyServiceNew", body_xml, "", callURL, "", false, showProxyServices);
+ var body_xml = "<ns1:saveProxyService xmlns:ns1='http://org.apache.synapse/xsd'>"
+ + new XMLSerializer().serializeToString(internalmodel.proxy)
+ + "</ns1:saveProxyService>";
+ var callURL = serverURL + "/" + PROXY_ADMIN + "/" + "saveProxyService";
+ send("saveProxyService", body_xml, "", callURL, "", false, proxysavecallback);
}
}
+function proxysavecallback() {
+ if(!onError()) {
+ return;
+ }
+
+ showProxyServices();
+}
+
function addproxysave() {
- // todo: construct add proxy soap message and invoke service
+
+ var body_xml = "<ns1:addProxyService xmlns:ns1='http://org.apache.synapse/xsd'>"
+ + new XMLSerializer().serializeToString(internalmodel.proxy)
+ + "</ns1:addProxyService>";
+ var callURL = serverURL + "/" + PROXY_ADMIN + "/" + "addProxyService";
+ send("addProxyService", body_xml, "", callURL, "", false, proxysavecallback);
}
function proxysaveas() {
@@ -280,7 +295,9 @@
function getvalueofproxyname(type) {
internalmodel.proxyname = document.getElementById("proxyname").value;
- if(type == 0) {
+ internalmodel.proxy.setAttribute("name", document.getElementById("proxyname").value);
+
+ if(type == 1) {
addproxysave();
} else {
proxysave();
@@ -345,7 +362,7 @@
+ "<td></td>"
+ "<td><input type='button' id='buttonpanel11' class='panelbutton' onmouseover='javascript: showbutton(11); "
+ "return false;' onmouseout='javascript: normalbutton(11); return false;' "
- + "onclick='javascript: proxysaveas(); return false;' value='Save As'/></td>"
+ + "onclick='javascript: proxysaveas(); return false;' value='Clone'/></td>"
+ "<td></td>"
+ "<td><input type='button' id='buttonpanel12' class='panelbutton' onmouseover='javascript: showbutton(12); "
+ "return false;' onmouseout='javascript: normalbutton(12); return false;' "
Modified: trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_edit.xsl
==============================================================================
--- trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_edit.xsl (original)
+++ trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_edit.xsl Mon Feb 5 19:50:35 2007
@@ -44,7 +44,7 @@
<label style="margin-left: 50px;">Start On Load</label>
<label style="margin-left: 100px;">
<xsl:choose>
- <xsl:when test="not(@startOnLoad) or @startOnLoad != 'true'">
+ <xsl:when test="@startOnLoad != 'true'">
<input type="checkbox" id="startOnLoad"/>
</xsl:when>
<xsl:otherwise>
Modified: trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_view.xsl
==============================================================================
--- trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_view.xsl (original)
+++ trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_view.xsl Mon Feb 5 19:50:35 2007
@@ -36,7 +36,7 @@
<label style="margin-left: 50px;">Start On Load</label>
<label style="margin-left: 100px;">
<xsl:choose>
- <xsl:when test="not(@startOnLoad) or @startOnLoad != 'true'">
+ <xsl:when test="@startOnLoad != 'true'">
<xsl:text>Desabled</xsl:text>
</xsl:when>
<xsl:otherwise>
Modified: trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_transport_edit.xsl
==============================================================================
--- trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_transport_edit.xsl (original)
+++ trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_transport_edit.xsl Mon Feb 5 19:50:35 2007
@@ -36,10 +36,20 @@
<tr><th>Availabel Transports</th><th>Exposed</th></tr>
</thead>
<tbody>
- <xsl:call-template name="transport_td">
- <xsl:with-param name="a_tp_string" select="@a_tp"/>
- <xsl:with-param name="tp_string" select="@transports"/>
- </xsl:call-template>
+ <xsl:choose>
+ <xsl:when test="@transports">
+ <xsl:call-template name="transport_td">
+ <xsl:with-param name="a_tp_string" select="@a_tp"/>
+ <xsl:with-param name="tp_string" select="@transports"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="transport_td">
+ <xsl:with-param name="a_tp_string" select="@a_tp"/>
+ <xsl:with-param name="tp_string" select="@a_tp"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
</tbody>
</table>
More information about the Esb-java-dev
mailing list