Author: tyrell
Date: Fri Apr 25 03:20:17 2008
New Revision: 16156
Log:
Fixing MASHUP-642
Modified:
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
trunk/mashup/java/modules/www/js/services.js
trunk/mashup/java/modules/www/mashup.jsp
Modified:
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java
==============================================================================
---
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java
(original)
+++
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java
Fri Apr 25 03:20:17 2008
@@ -50,6 +50,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.List;
public class MashupAdminService {
@@ -133,7 +134,8 @@
try {
UserRegistry systemRegistry =
embeddedRegistry.getSystemRegistry();
wwwDir = new File(
-
systemRegistry.get(path).getProperty(JavaScriptEngineConstants.RESOURCES_FOLDER)
+
+ systemRegistry.get(path)
+
.getProperty(JavaScriptEngineConstants.RESOURCES_FOLDER) +
"/www");
} catch (RegistryException e) {
//If the service is not in registry, let's figure out the path
manually
@@ -231,8 +233,9 @@
persistenceMgr.updateService(serviceDO);
//Updating the registry
- EmbeddedRegistry embeddedRegistry = (EmbeddedRegistry)
currentMessageContext.getConfigurationContext()
-
.getAxisConfiguration().getParameterValue(RegistryConstants.REGISTRY);
+ EmbeddedRegistry embeddedRegistry =
+ (EmbeddedRegistry)
currentMessageContext.getConfigurationContext()
+
.getAxisConfiguration().getParameterValue(RegistryConstants.REGISTRY);
UserRegistry systemRegistry = embeddedRegistry.getSystemRegistry();
Parameter myRegistryPath =
axisService.getParameter(MashupConstants.REGISTRY_MASHUP_PATH);
@@ -344,15 +347,16 @@
File serviceReources;
EmbeddedRegistry embeddedRegistry =
- (EmbeddedRegistry)
configContext.getAxisConfiguration().getParameterValue(
- RegistryConstants.REGISTRY);
+ (EmbeddedRegistry)
configContext.getAxisConfiguration().getParameterValue(
+ RegistryConstants.REGISTRY);
- try {
- UserRegistry systemRegistry =
embeddedRegistry.getSystemRegistry();
+ try {
+ UserRegistry systemRegistry = embeddedRegistry.getSystemRegistry();
serviceJs = new File(
systemRegistry.get(path).getProperty(JavaScriptEngineConstants.SERVICE_JS));
serviceReources = new File(
-
systemRegistry.get(path).getProperty(JavaScriptEngineConstants.RESOURCES_FOLDER));
+ systemRegistry.get(path).getProperty(
+ JavaScriptEngineConstants.RESOURCES_FOLDER));
//Removing this service from the registry
systemRegistry.delete(path);
@@ -486,5 +490,29 @@
wsasAdmnin.stopService(serviceName);
}
+ public Boolean enableServiceTransport(String serviceName, String
transportName)
+ throws AxisFault {
+ boolean success = false;
+
+ ServerManager serverManager = ServerManager.getInstance();
+ ConfigurationContext configContext = serverManager.configContext;
+
+
configContext.getAxisConfiguration().getService(serviceName).addExposedTransport(transportName);
+ success = true;
+
+ return Boolean.valueOf(success);
+ }
+
+ public Boolean disableServiceTransport(String serviceName, String
transportName)
+ throws AxisFault {
+ boolean success = false;
+
+ ServerManager serverManager = ServerManager.getInstance();
+ ConfigurationContext configContext = serverManager.configContext;
+
+
configContext.getAxisConfiguration().getService(serviceName).removeExposedTransport(transportName);
+ success = true;
+ return Boolean.valueOf(success);
+ }
}
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
Fri Apr 25 03:20:17 2008
@@ -30,6 +30,7 @@
import org.apache.axis2.deployment.repository.util.DeploymentFileData;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportInDescription;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;
@@ -89,8 +90,10 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.List;
import java.util.Properties;
public class MashupUtils {
@@ -947,4 +950,23 @@
return username;
}
+ public static HashMap getAvailableAxisTransports(){
+ ServerManager serverManager = ServerManager.getInstance();
+ ConfigurationContext configContext = serverManager.configContext;
+ return configContext.getAxisConfiguration().getTransportsIn();
+ }
+
+ public static boolean isTransportExposed(String serviceName, String
transportName) throws AxisFault {
+ ServerManager serverManager = ServerManager.getInstance();
+ ConfigurationContext configContext = serverManager.configContext;
+
+ // If all transports in te Axis configuration is enabled for this
service, just returning true.
+
if(configContext.getAxisConfiguration().getService(serviceName).isEnableAllTransports()){
+ return true;
+ }else{
+ return
configContext.getAxisConfiguration().getService(serviceName).isExposedTransport(transportName);
+ }
+ }
+
+
}
Modified: trunk/mashup/java/modules/www/js/services.js
==============================================================================
--- trunk/mashup/java/modules/www/js/services.js (original)
+++ trunk/mashup/java/modules/www/js/services.js Fri Apr 25 03:20:17 2008
@@ -436,6 +436,42 @@
};
/**
+ * @description Enables a transport for a named service
+ * @param {String} serviceName
+ * @param {String} transportName
+ * @param {Array} params
+ * @param {callback} callback
+ */
+wso2.mashup.services.enableServiceTransport = function (serviceName,
transportName, params, callback) {
+ var callURL = serverURL + "/" + "MashupAdminService" + "/" ;
+
+ var body_xml = '<req:enableServiceTransport
xmlns:req="http://service.admin.mashup.wso2.org/xsd">\n' +
+ ' <req:serviceName>' + serviceName + '</req:serviceName>\n'
+
+ ' <req:transportName>' + transportName +
'</req:transportName>\n' +
+ ' </req:enableServiceTransport>\n';
+
+ new wso2.wsf.WSRequest(callURL, "enableServiceTransport", body_xml,
callback, params, wso2.mashup.services.defaultErrHandler);
+};
+
+/**
+ * @description Disables a transport for a named service
+ * @param {String} serviceName
+ * @param {String} transportName
+ * @param {Array} params
+ * @param {callback} callback
+ */
+wso2.mashup.services.disableServiceTransport = function (serviceName,
transportName, params, callback) {
+ var callURL = serverURL + "/" + "MashupAdminService" + "/" ;
+
+ var body_xml = '<req:disableServiceTransport
xmlns:req="http://service.admin.mashup.wso2.org/xsd">\n' +
+ ' <req:serviceName>' + serviceName + '</req:serviceName>\n'
+
+ ' <req:transportName>' + transportName +
'</req:transportName>\n' +
+ ' </req:disableServiceTransport>\n';
+
+ new wso2.wsf.WSRequest(callURL, "disableServiceTransport", body_xml,
callback, params, wso2.mashup.services.defaultErrHandler);
+};
+
+/**
* @description Gets a list of faulty services and possible reasons
* @param {callback} callback User-defined callback function or object
*/
Modified: trunk/mashup/java/modules/www/mashup.jsp
==============================================================================
--- trunk/mashup/java/modules/www/mashup.jsp (original)
+++ trunk/mashup/java/modules/www/mashup.jsp Fri Apr 25 03:20:17 2008
@@ -14,7 +14,9 @@
* limitations under the License.
--%>
<%@ page errorPage="error.jsp" %>
+<%@ page import="org.apache.axis2.description.TransportInDescription" %>
<%@ page import="org.wso2.mashup.MashupConstants" %>
+<%@ page import="org.wso2.mashup.utils.MashupUtils" %>
<%@ page import="org.wso2.mashup.utils.QueryResults" %>
<%@ page import="org.wso2.mashup.webapp.utils.QueryParamUtils" %>
<%@ page import="org.wso2.mashup.webapp.utils.RegistryUtils" %>
@@ -23,7 +25,7 @@
<%@ page import="org.wso2.registry.RegistryException" %>
<%@ page import="org.wso2.registry.Resource" %>
<%@ page import="org.wso2.registry.Tag" %>
-<%@ page import="org.wso2.registry.session.UserRegistry" %>
+<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.ResourceBundle" %>
<!--Required to keep a user logged in if 'Remember Me' option is selected-->
@@ -262,6 +264,66 @@
var isEnter = (key == 13);
if (isEnter) addComment();
}
+
+ function enableTransportCallback(){
+ var response;
+
+ var browser = WSRequest.util._getBrowser();
+ if (browser == "ie" || browser == "ie7") {
+ response =
+
this.req.responseXML.getElementsByTagName("ns:return")[0].firstChild.nodeValue;
+ } else {
+ response =
this.req.responseXML.getElementsByTagName("return")[0].firstChild.nodeValue;
+ }
+
+ if (response == "true") {
+ var element = document.getElementById(this.params[0]);
+ element.innerHTML = "";
+ element.innerHTML =
document.getElementById(this.params[0]).innerHTML = '<font color="green"><b>' +
this.params[1] + '</b> transport is enabled for this Mashup.</font> [ <a
href="#" onclick="disableTransport(\'' + this.params[2] + '\', \'' +
this.params[1] + '\', \'' + this.params[0] + '\');">Disable</a> ]';
+ }else{
+ wso2.wsf.Util.alertMessage("Sorry!! Failed to enable transport.
Please try again.");
+ }
+ }
+
+ function enableTransport(serviceName, transportName, pageElementId){
+ var params = new Array();
+ params[0] = pageElementId;
+ params[1] = transportName;
+ params[2] = serviceName;
+
+ wso2.mashup.services.enableServiceTransport(serviceName,
transportName, params, enableTransportCallback);
+ }
+
+ function disableTransportCallback(){
+ var response;
+
+ var browser = WSRequest.util._getBrowser();
+ if (browser == "ie" || browser == "ie7") {
+ response =
+
this.req.responseXML.getElementsByTagName("ns:return")[0].firstChild.nodeValue;
+ } else {
+ response =
this.req.responseXML.getElementsByTagName("return")[0].firstChild.nodeValue;
+ }
+
+ if (response == "true") {
+ var element = document.getElementById(this.params[0]);
+ element.innerHTML = "";
+ element.innerHTML =
document.getElementById(this.params[0]).innerHTML = '<font color="orange"><b>'
+ this.params[1] + '</b> transport is disabled for this Mashup.</font> [ <a
href="#" onclick="enableTransport(\'' + this.params[2] + '\', \'' +
this.params[1] + '\', \'' + this.params[0] + '\');">Enable</a> ]';
+ }else{
+ wso2.wsf.Util.alertMessage("Sorry!! Failed to disable transport.
Please try again.");
+ }
+ }
+
+ function disableTransport(serviceName, transportName, pageElementId){
+ var params = new Array();
+ params[0] = pageElementId;
+ params[1] = transportName;
+ params[2] = serviceName;
+
+ wso2.mashup.services.disableServiceTransport(serviceName,
transportName, params, disableTransportCallback);
+ }
+
+
</script>
</head>
@@ -455,6 +517,47 @@
<br/>
</tr>
+<%
+ //Service transports handling will only be available to the service author
and admins
+ if((author.equals(currentUser)) ||
(RegistryUtils.isAdminRole(userRegistry))){%>
+<tr>
+ <td class="mashup_label">
+ <nobr>Transports:</nobr>
+ </td>
+ <td id="transports_area">
+ <div>
+ <ul>
+ <%
+ Iterator availableTransports =
MashupUtils.getAvailableAxisTransports().values().iterator();
+ TransportInDescription currentTransport;
+ int transportCount = 0;
+ while(availableTransports.hasNext()){
+ currentTransport =
(TransportInDescription)availableTransports.next();
+ if(MashupUtils.isTransportExposed(mashupServiceName,
currentTransport.getName())){
+ %>
+ <li>
+ <div id="transport_<%=transportCount%>">
+ <font
color="green"><b><%=(currentTransport).getName()%></b> transport is enabled for
this Mashup.</font> [ <a href="#"
onclick="disableTransport('<%=mashupServiceName%>',
'<%=(currentTransport).getName()%>',
'transport_<%=transportCount%>');">Disable</a> ]
+ </div>
+ </li>
+ <%
+ }else{
+ %>
+ <li>
+ <div id="transport_<%=transportCount%>">
+ <font
color="orange"><b><%=(currentTransport).getName()%></b> transport is disabled
for this Mashup.</font> [ <a href="#"
onclick="enableTransport('<%=mashupServiceName%>',
'<%=(currentTransport).getName()%>',
'transport_<%=transportCount%>');">Enable</a> ]
+ </div>
+ </li>
+ <%
+ }
+ transportCount++;
+ }
+ %>
+ </ul>
+ </div>
+ </td>
+</tr>
+<%}%>
</table>
</div>
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev