[Mashup-dev] svn commit r20326 - trunk/mashup/java/modules/core/src/org/wso2/mashup/requestprocessor

keith at wso2.com keith at wso2.com
Sun Aug 3 22:35:12 PDT 2008


Author: keith
Date: Sun Aug  3 22:35:12 2008
New Revision: 20326
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=20326

Log:
Displaying a error message when tryit is accessed when both http and https transports are dibadled


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=20326&r1=20325&r2=20326&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	Sun Aug  3 22:35:12 2008
@@ -60,53 +60,64 @@
             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();
-                } else {
-                    // There is no point showing the tryit if both http and https transports are
-                    // disabled on this service
+            if (!axisService.isEnableAllTransports()) {
+                if (!(axisService.isExposedTransport(ServerConstants.HTTP_TRANSPORT) ||
+                        axisService.isExposedTransport(ServerConstants.HTTPS_TRANSPORT))) {
                     response.setContentType("text/html");
                     response.setStatus(HttpServletResponse.SC_NOT_FOUND);
                     outputStream
-                            .write(("<h4>Service " + serviceName +
-                                    " is not exposed over http or https transports. Cannot display <em>TryIt</em>.</h4>")
-                                    .getBytes());
+                            .write(("<h4>The http and https transports are disabled on this service. The <em>TryIt</em> uses either of these transports to access the service and hence the <em>TryIt</em> page cannot be displayed.</h4>").getBytes());
                     outputStream.flush();
                     return;
                 }
-                response.sendRedirect(redirectURL);
-                return;
+                if (!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();
+                    } else {
+                        // There is no point showing the tryit if both http and https transports are
+                        // disabled on this service
+                        response.setContentType("text/html");
+                        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
+                        outputStream
+                                .write(("<h4>Service " + serviceName +
+                                        " is not exposed over http or https transports. Cannot display <em>TryIt</em>.</h4>")
+                                        .getBytes());
+                        outputStream.flush();
+                        return;
+                    }
+                    response.sendRedirect(redirectURL);
+                    return;
+                }
             }
 
             if (!axisService.isActive()) {



More information about the Mashup-dev mailing list