Author: phuong_vu
Date: 2011-08-18 22:33:32 -0400 (Thu, 18 Aug 2011)
New Revision: 7186
Added:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/StaticResourceRequestHandler.java
Modified:
portal/trunk/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml
portal/trunk/packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml
portal/trunk/packaging/jetty/pkg/src/main/resources/jetty/gatein/conf/controller.xml
portal/trunk/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/controller.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml
Log:
GTNPORTAL-2032 Add request handler for serving static resources in portal.war
(jpg,ico,css...)
Modified:
portal/trunk/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml
===================================================================
---
portal/trunk/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml 2011-08-18
23:05:31 UTC (rev 7185)
+++
portal/trunk/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml 2011-08-19
02:33:32 UTC (rev 7186)
@@ -67,6 +67,15 @@
</route>
</route>
+ <route path="/{gtn:path}">
+ <route-param qname="gtn:handler">
+ <value>staticResource</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*\.(jpg|png|gif|ico|css)</pattern>
+ </path-param>
+ </route>
+
<route path="/">
<!-- The portal handler -->
Modified:
portal/trunk/packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml
===================================================================
---
portal/trunk/packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml 2011-08-18
23:05:31 UTC (rev 7185)
+++
portal/trunk/packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml 2011-08-19
02:33:32 UTC (rev 7186)
@@ -67,6 +67,15 @@
</route>
</route>
+ <route path="/{gtn:path}">
+ <route-param qname="gtn:handler">
+ <value>staticResource</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*\.(jpg|png|gif|ico|css)</pattern>
+ </path-param>
+ </route>
+
<route path="/">
<!-- The portal handler -->
Modified:
portal/trunk/packaging/jetty/pkg/src/main/resources/jetty/gatein/conf/controller.xml
===================================================================
---
portal/trunk/packaging/jetty/pkg/src/main/resources/jetty/gatein/conf/controller.xml 2011-08-18
23:05:31 UTC (rev 7185)
+++
portal/trunk/packaging/jetty/pkg/src/main/resources/jetty/gatein/conf/controller.xml 2011-08-19
02:33:32 UTC (rev 7186)
@@ -66,6 +66,15 @@
</path-param>
</route>
</route>
+
+ <route path="/{gtn:path}">
+ <route-param qname="gtn:handler">
+ <value>staticResource</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*\.(jpg|png|gif|ico|css)</pattern>
+ </path-param>
+ </route>
<route path="/">
Modified:
portal/trunk/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/controller.xml
===================================================================
---
portal/trunk/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/controller.xml 2011-08-18
23:05:31 UTC (rev 7185)
+++
portal/trunk/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/controller.xml 2011-08-19
02:33:32 UTC (rev 7186)
@@ -67,6 +67,15 @@
</route>
</route>
+ <route path="/{gtn:path}">
+ <route-param qname="gtn:handler">
+ <value>staticResource</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*\.(jpg|png|gif|ico|css)</pattern>
+ </path-param>
+ </route>
+
<route path="/">
<!-- The portal handler -->
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml 2011-08-18
23:05:31 UTC (rev 7185)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml 2011-08-19
02:33:32 UTC (rev 7186)
@@ -109,6 +109,11 @@
<set-method>register</set-method>
<type>org.exoplatform.portal.application.DefaultRequestHandler</type>
</component-plugin>
+ <component-plugin>
+ <name>StaticResourceRequestHandler</name>
+ <set-method>register</set-method>
+
<type>org.exoplatform.portal.application.StaticResourceRequestHandler</type>
+ </component-plugin>
</external-component-plugins>
</configuration>
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml 2011-08-18 23:05:31 UTC (rev
7185)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml 2011-08-19 02:33:32 UTC (rev
7186)
@@ -273,29 +273,7 @@
<url-pattern>/</url-pattern>
</servlet-mapping>
- <!-- Explicit mappings (due to portal servlet on '/') for UIHomePagePortlet,
need to find out how to improve that -->
<servlet-mapping>
- <servlet-name>default</servlet-name>
- <url-pattern>*.jpg</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>default</servlet-name>
- <url-pattern>*.png</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>default</servlet-name>
- <url-pattern>*.gif</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>default</servlet-name>
- <url-pattern>*.ico</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>default</servlet-name>
- <url-pattern>*.css</url-pattern>
- </servlet-mapping>
-
- <servlet-mapping>
<servlet-name>GateInServlet</servlet-name>
<url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
Added:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/StaticResourceRequestHandler.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/StaticResourceRequestHandler.java
(rev 0)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/StaticResourceRequestHandler.java 2011-08-19
02:33:32 UTC (rev 7186)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.application;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.web.ControllerContext;
+import org.exoplatform.web.WebRequestHandler;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:phuong.vu@exoplatform.com">Vu Viet
Phuong</a>
+ */
+public class StaticResourceRequestHandler extends WebRequestHandler
+{
+ @Override
+ public String getHandlerName()
+ {
+ return "staticResource";
+ }
+
+ @Override
+ public void execute(ControllerContext context) throws Exception
+ {
+ PortalContainer portalContainer = PortalContainer.getInstance();
+ ServletContext mergedContext = portalContainer.getPortalContext();
+
+ HttpServletRequest req = context.getRequest();
+ HttpServletResponse res = context.getResponse();
+ mergedContext.getNamedDispatcher("default").forward(req, res);
+ }
+}