Author: keith Date: Fri Jun 20 05:00:21 2008 New Revision: 18520 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=18520
Log: Fixing Mashup-861 Modified: trunk/mashup/java/modules/core/src/org/wso2/mashup/requestprocessor/TryItProcessor.java Modified: trunk/mashup/java/modules/core/src/org/wso2/mashup/requestprocessor/TryItProcessor.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/core/src/org/wso2/mashup/requestprocessor/TryItProcessor.java?rev=18520&r1=18519&r2=18520&view=diff ============================================================================== --- trunk/mashup/java/modules/core/src/org/wso2/mashup/requestprocessor/TryItProcessor.java (original) +++ trunk/mashup/java/modules/core/src/org/wso2/mashup/requestprocessor/TryItProcessor.java Fri Jun 20 05:00:21 2008 @@ -18,10 +18,15 @@ import org.apache.axiom.om.OMException; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.TransportInDescription; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.engine.AxisConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.mashup.utils.MashupUtils; import org.wso2.wsas.transport.HttpGetRequestProcessor; +import org.wso2.wsas.ServerConstants; +import org.wso2.wsas.ServerManager; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -36,9 +41,53 @@ String requestURI = request.getRequestURI(); String contextPath = configurationContext.getServiceContextPath(); String serviceName = MashupUtils.getServiceName(requestURI, contextPath); - AxisService axisService = configurationContext.getAxisConfiguration() + AxisConfiguration configuration = configurationContext.getAxisConfiguration(); + AxisService axisService = configuration .getServiceForActivation(serviceName); + // This is a fix for Mashup-861. If the transport is disabled we redirect the user to + // the alternative transport + StringBuffer url = request.getRequestURL(); + int index = url.indexOf(":"); + String protocol = url.substring(0, index); + if (!axisService.isEnableAllTransports() && !axisService.isExposedTransport(protocol)) { + ServerManager serverManager = ServerManager.getInstance(); + String redirectURL = ""; + if (ServerConstants.HTTP_TRANSPORT.equals(protocol)) { + TransportInDescription httpsTransport = + configuration.getTransportIn(ServerConstants.HTTPS_TRANSPORT); + Parameter parameter = httpsTransport.getParameter("proxyPort"); + String port = ""; + if (parameter != null) { + String value = (String) parameter.getValue(); + if (!"443".equals(value)) { + port = ":" + value; + } + } else { + port = ":" + serverManager.getHttpsPort(); + } + redirectURL = "https://" + request.getServerName() + port + requestURI + "?" + + request.getQueryString(); + } else if (ServerConstants.HTTPS_TRANSPORT.equals(protocol)) { + TransportInDescription httpsTransport = + configuration.getTransportIn(ServerConstants.HTTP_TRANSPORT); + Parameter parameter = httpsTransport.getParameter("proxyPort"); + String port = ""; + if (parameter != null) { + String value = (String) parameter.getValue(); + if (!"80".equals(value)) { + port = ":" + value; + } + } else { + port = ":" + serverManager.getHttpPort(); + } + redirectURL = "http://" + request.getServerName() + port + requestURI + "?" + + request.getQueryString(); + } + response.sendRedirect(redirectURL); + return; + } + OutputStream outputStream = response.getOutputStream(); if (axisService != null) { if (!axisService.isActive()) { _______________________________________________ Mashup-dev mailing list [email protected] http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev
