[wsas-java-dev] svn commit r2652 - in trunk/wsas/java/modules:
core/src/org/wso2/wsas core/src/org/wso2/wsas/transport
www/extensions/core www/extensions/core/js
svn at wso2.org
svn at wso2.org
Tue May 15 08:30:19 PDT 2007
Author: saminda
Date: Tue May 15 08:30:07 2007
New Revision: 2652
Added:
trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/UIInitializerServlet.java
Modified:
trunk/wsas/java/modules/core/src/org/wso2/wsas/MainServlet.java
trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/RequestRedirectionFilter.java
trunk/wsas/java/modules/www/extensions/core/js.html
trunk/wsas/java/modules/www/extensions/core/js/wso2wsas.js
Log:
Fixing the auto discovering of context root and service path
Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/MainServlet.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/MainServlet.java (original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/MainServlet.java Tue May 15 08:30:07 2007
@@ -24,7 +24,6 @@
import org.wso2.utils.FileManipulator;
import org.wso2.utils.ServerConfiguration;
import org.wso2.utils.ServerException;
-import org.wso2.wsas.transport.RequestRedirectionFilter;
import org.wso2.wsas.transport.ServerInfo;
import org.wso2.wsas.transport.ServerPropertyKeys;
import org.wso2.wsas.util.*;
@@ -197,15 +196,12 @@
AdminUIServletFilter adminUIServletFilter =
((AdminUIServletFilter) servletContext
.getAttribute(AdminUIServletFilter.class.getName()));
- adminUIServletFilter.init((Map) configCtx.getProperty(ServerConstants.GENERATED_PAGES),
- configCtx.getContextRoot(),
- Utils.isAdminConsoleEnabled());
-
- // set redirection
- RequestRedirectionFilter requestRedirectionFilter =
- (RequestRedirectionFilter) servletContext.
- getAttribute(RequestRedirectionFilter.class.getName());
- requestRedirectionFilter.init(configCtx.getContextRoot());
+ if (adminUIServletFilter != null) {
+ adminUIServletFilter.init(
+ (Map) configCtx.getProperty(ServerConstants.GENERATED_PAGES),
+ Utils.isAdminConsoleEnabled(), ServerManager.httpsPort,
+ configCtx.getServicePath());
+ }
startServerController();
} catch (Exception e) {
@@ -353,14 +349,9 @@
AdminUIServletFilter adminUIServletFilter = (AdminUIServletFilter) attrib;
Map genPages = (Map) serverManager.configContext.
getProperty(ServerConstants.GENERATED_PAGES);
- adminUIServletFilter.init(genPages,
- serverManager.configContext.getContextRoot(),
- Utils.isAdminConsoleEnabled());
- } else if (attrib instanceof RequestRedirectionFilter) {
- RequestRedirectionFilter requestRedirectionFilter =
- (RequestRedirectionFilter) servletContext.
- getAttribute(RequestRedirectionFilter.class.getName());
- requestRedirectionFilter.init(serverManager.configContext.getContextRoot());
+ adminUIServletFilter.init(genPages, Utils.isAdminConsoleEnabled(),
+ ServerManager.httpsPort,
+ serverManager.configContext.getServicePath());
}
}
}
Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/RequestRedirectionFilter.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/RequestRedirectionFilter.java (original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/RequestRedirectionFilter.java Tue May 15 08:30:07 2007
@@ -28,7 +28,6 @@
public class RequestRedirectionFilter implements Filter {
- private FilterConfig filterConfig;
private String contextRoot;
/**
@@ -39,19 +38,16 @@
* @throws ServletException
*/
public void init(FilterConfig filterConfig) throws ServletException {
- this.filterConfig = filterConfig;
filterConfig.getServletContext().setAttribute(this.getClass().getName(), this);
}
- public void init(String contextRoot) throws ServletException {
- this.contextRoot = contextRoot;
- init(filterConfig);
- }
-
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
HttpServletResponse httpServletResponse = (HttpServletResponse)response;
+
+ initContextRoot(httpServletRequest);
+
if (httpServletRequest.getRequestURL().toString()
.indexOf(NetworkUtils.getLocalHostname()) == -1) {
httpServletResponse.sendRedirect("https://" +
@@ -63,6 +59,19 @@
}
+ private void initContextRoot(HttpServletRequest request) {
+
+ if (contextRoot != null && contextRoot.length() != 0) {
+ return;
+ }
+
+ String contextRoot = request.getContextPath();
+ if (contextRoot != null && contextRoot.length() == 0 ) {
+ contextRoot = "/";
+ }
+ this.contextRoot = contextRoot;
+ }
+
public void destroy() {
// TODO
}
Added: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/UIInitializerServlet.java
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/UIInitializerServlet.java Tue May 15 08:30:07 2007
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.wsas.transport;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.adminui.UIProcessingException;
+import org.wso2.adminui.UIProcessor;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import java.util.Hashtable;
+import java.util.Map;
+
+
+/**
+ *
+ */
+
+public class UIInitializerServlet extends HttpServlet {
+
+ private static Log log = LogFactory.getLog(UIInitializerServlet.class);
+
+ public void init(ServletConfig servletConfig) throws ServletException {
+ // assumes only exploded case
+ ServletContext servletContext = servletConfig.getServletContext();
+ String resourceBase = servletContext.getRealPath(".");
+ try {
+ Map files = new Hashtable();
+
+ UIProcessor.createPages(resourceBase, "ui-extensions-config.xml", files);
+
+ } catch (UIProcessingException e) {
+ log.error(e);
+ throw new ServletException(e);
+ }
+
+ }
+
+}
\ No newline at end of file
Modified: trunk/wsas/java/modules/www/extensions/core/js.html
==============================================================================
--- trunk/wsas/java/modules/www/extensions/core/js.html (original)
+++ trunk/wsas/java/modules/www/extensions/core/js.html Tue May 15 08:30:07 2007
@@ -18,4 +18,5 @@
<script language="javascript" src="extensions/core/js/security.js"></script>
<script language="javascript" src="extensions/core/js/msgflows.js"></script>
<script language="javascript" src="extensions/core/js/graphs.js"></script>
-<script language="javascript" src="extensions/core/js/data_service.js"></script>
\ No newline at end of file
+<script language="javascript" src="extensions/core/js/data_service.js"></script>
+<script language="javascript" src="global_params.js"></script>
\ No newline at end of file
Modified: trunk/wsas/java/modules/www/extensions/core/js/wso2wsas.js
==============================================================================
--- trunk/wsas/java/modules/www/extensions/core/js/wso2wsas.js (original)
+++ trunk/wsas/java/modules/www/extensions/core/js/wso2wsas.js Tue May 15 08:30:07 2007
@@ -22,17 +22,14 @@
var COOKIE_SESSION_MANAGEMENT = true;
var SESSION_COOKIE_NAME = "JSESSIONID";
-var cookieObject;
function init() {
- URL = locationString.substring(0, locationString.lastIndexOf('/'));
+ if (URL == null) {
+ URL = locationString.substring(0, locationString.lastIndexOf('/'));
+ }
defaultURL = URL;
- cookieObject = new Cookie(document,SESSION_COOKIE_NAME);
- //alert(cookieObject.load());
-
-
if (URL.indexOf('https') == -1) {
// alert("You can only access the management console through https. \n The default https port for @server_short_name@ is " + httpsPort + ".");
var newURL = "https" + URL.substring(URL.indexOf('://'), URL.lastIndexOf(':') + 1) +
@@ -44,13 +41,6 @@
"<a href='" + newURL + "'>" + newURL + "</a>";
alertInternal(httpsAlertText, WARNING_MESSAGE);
- // alert(newURL);
- // browser.redirect(newURL);
- }
-
- admIndex = URL.lastIndexOf('/admin');
- if (admIndex != -1) {
- URL = URL.substring(0, URL.lastIndexOf('/admin'));
}
// Service URL parsing
More information about the Wsas-java-dev
mailing list