portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r813881 - in /portals/jetspeed-2/portal/trunk: ./ applications/jetspeed-dependencies/ applications/jetspeed/src/main/webapp/WEB-INF/ components/ components/jetspeed-db-tools/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipe...
Date Fri, 11 Sep 2009 15:32:26 GMT
Author: woonsan
Date: Fri Sep 11 15:32:25 2009
New Revision: 813881

URL: http://svn.apache.org/viewvc?rev=813881&view=rev
Log:
JS2-1063: Adding web content proxy component to allow cross-domain script retrieval from desktop page.
By default configuration, the following page visit from the browser will serve reverse proxied content from the jetspeed-2 project web site:

    http://localhost:8080/jetspeed/webcontent/portals.apache.org/jetspeed-2/features.html
    -->
    http://portals.apache.org/jetspeed-2/features.html

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/WebContentProxyingValve.java   (with props)
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/WebContentProxyingValveImpl.java   (with props)
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/pom.xml   (with props)
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpProxyPathMapperImpl.java   (with props)
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpReverseProxyPathMapperProviderImpl.java   (with props)
    portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/RewritableHttpReverseProxyServiceImpl.java   (with props)
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapper.java   (with props)
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapperProvider.java   (with props)
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyService.java   (with props)
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/webcontent-proxy.xml   (with props)
Modified:
    portals/jetspeed-2/portal/trunk/applications/jetspeed-dependencies/pom.xml
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/web.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-db-tools/pom.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/   (props changed)
    portals/jetspeed-2/portal/trunk/components/pom.xml
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pipelines.xml
    portals/jetspeed-2/portal/trunk/pom.xml

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed-dependencies/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed-dependencies/pom.xml?rev=813881&r1=813880&r2=813881&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed-dependencies/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed-dependencies/pom.xml Fri Sep 11 15:32:25 2009
@@ -65,6 +65,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.portals.jetspeed-2</groupId>
+      <artifactId>jetspeed-proxy</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.portals.jetspeed-2</groupId>
       <artifactId>jetspeed-id-generator</artifactId>
     </dependency>
     <dependency>

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/web.xml?rev=813881&r1=813880&r2=813881&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/web.xml (original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/web.xml Fri Sep 11 15:32:25 2009
@@ -86,36 +86,37 @@
     <load-on-startup>1</load-on-startup>
   </servlet>
 
-  	<!-- Define Velocity template compiler -->
-	<servlet>
-		<servlet-name>velocity</servlet-name>
-		<servlet-class>org.apache.jetspeed.velocity.JetspeedVelocityViewServlet</servlet-class>
-		<init-param>
-			<param-name>org.apache.velocity.toolbox</param-name>
-			<param-value>/WEB-INF/toolbox.xml</param-value>
-		</init-param>
-		<init-param>
-			<param-name>org.apache.velocity.properties</param-name>
-			<param-value>/WEB-INF/velocity.properties</param-value>
-		</init-param>
-		<init-param>
-			<param-name>org.apache.jetspeed.cache.size</param-name>
-			<param-value>50</param-value>
-		</init-param>
-		<init-param>
-			<param-name>org.apache.jetspeed.cache.validation.interval</param-name>
-			<param-value>-1</param-value>
-		</init-param>
-		<load-on-startup>10</load-on-startup>
-	</servlet>
-    
+  <!-- Define Velocity template compiler -->
+  <servlet>
+    <servlet-name>velocity</servlet-name>
+    <servlet-class>
+      org.apache.jetspeed.velocity.JetspeedVelocityViewServlet</servlet-class>
+    <init-param>
+      <param-name>org.apache.velocity.toolbox</param-name>
+      <param-value>/WEB-INF/toolbox.xml</param-value>
+    </init-param>
+    <init-param>
+      <param-name>org.apache.velocity.properties</param-name>
+      <param-value>/WEB-INF/velocity.properties</param-value>
+    </init-param>
+    <init-param>
+      <param-name>org.apache.jetspeed.cache.size</param-name>
+      <param-value>50</param-value>
+    </init-param>
+    <init-param>
+      <param-name>org.apache.jetspeed.cache.validation.interval</param-name>
+      <param-value>-1</param-value>
+    </init-param>
+    <load-on-startup>10</load-on-startup>
+  </servlet>
+
   <servlet>
     <servlet-name>LoginProxyServlet</servlet-name>
     <servlet-class>org.apache.jetspeed.login.LoginProxyServlet</servlet-class>
-	<init-param>
-		<param-name>credentialsFromRequest</param-name>
-		<param-value>true</param-value>
-	</init-param>        
+    <init-param>
+      <param-name>credentialsFromRequest</param-name>
+      <param-value>true</param-value>
+    </init-param>
   </servlet>
 
   <servlet>
@@ -152,127 +153,107 @@
       <servlet-name>DiagnosticsServlet</servlet-name>
        <url-pattern>/diagnostics/*</url-pattern>  	   
   </servlet-mapping>
-    
+
   <servlet-mapping>
-       <servlet-name>
-          jetspeed
-       </servlet-name>
-       <url-pattern>/portal/*</url-pattern>
-    </servlet-mapping>
-    <servlet-mapping>
-       <servlet-name>
-          jetspeed
-       </servlet-name>
-       <url-pattern>/portlet/*</url-pattern>
-    </servlet-mapping>            
-    <servlet-mapping>
-       <servlet-name>
-          jetspeed
-       </servlet-name>
-       <url-pattern>/jetspeed/*</url-pattern>
-    </servlet-mapping>
-    <servlet-mapping>
-       <servlet-name>
-          jetspeed
-       </servlet-name>
-       <url-pattern>/fileserver/*</url-pattern>
-    </servlet-mapping>            
-    <servlet-mapping>
-       <servlet-name>
-          jetspeed
-       </servlet-name>
-       <url-pattern>/ajaxapi/*</url-pattern>
-    </servlet-mapping>            
-    <servlet-mapping>
-       <servlet-name>
-          jetspeed
-       </servlet-name>
-       <url-pattern>/ajax/*</url-pattern>
-    </servlet-mapping>            
-    <servlet-mapping>
-       <servlet-name>
-          jetspeed
-       </servlet-name>
-       <url-pattern>/desktop/*</url-pattern>
-    </servlet-mapping>            
-    <servlet-mapping>
-       <servlet-name>
-          jetspeed
-       </servlet-name>
-       <url-pattern>/action/*</url-pattern>
-    </servlet-mapping>            
-    <servlet-mapping>
-       <servlet-name>
-          jetspeed
-       </servlet-name>
-       <url-pattern>/render/*</url-pattern>
-    </servlet-mapping>
-    <servlet-mapping>
-       <servlet-name>
-          jetspeed
-       </servlet-name>
-       <url-pattern>/configure/*</url-pattern>
-    </servlet-mapping>
-    <servlet-mapping>
-       <servlet-name>
-          jetspeed
-       </servlet-name>
-       <url-pattern>/dtconfigure/*</url-pattern>
-    </servlet-mapping>
-    <servlet-mapping>
-       <servlet-name>
-          jetspeed
-       </servlet-name>
-       <url-pattern>/healthcheck/*</url-pattern>
-    </servlet-mapping>
-    
-    <!-- Map *.vm files to Velocity  -->
-	<servlet-mapping>
-		<servlet-name>velocity</servlet-name>
-		<url-pattern>*.vm</url-pattern>
-	</servlet-mapping>	
-    
-    <servlet-mapping>
-        <servlet-name>LoginProxyServlet</servlet-name>
-        <url-pattern>/login/proxy</url-pattern>
-    </servlet-mapping>
-
-    <servlet-mapping>
-        <servlet-name>LoginServlet</servlet-name>
-        <url-pattern>/login/login</url-pattern>
-    </servlet-mapping>
-    
-    <servlet-mapping>
-        <servlet-name>LoginErrorServlet</servlet-name>
-        <url-pattern>/login/error</url-pattern>
-    </servlet-mapping>
-    
-    <servlet-mapping>
-        <servlet-name>LoginRedirectorServlet</servlet-name>
-        <url-pattern>/login/redirector</url-pattern>
-    </servlet-mapping>
-
-    <servlet-mapping>
-        <servlet-name>LogoutServlet</servlet-name>
-        <url-pattern>/login/logout</url-pattern>
-    </servlet-mapping>
-
-    <servlet-mapping>
-        <servlet-name>ManagerServlet</servlet-name>
-        <url-pattern>/manager/*</url-pattern>
-    </servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/portal/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/portlet/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/jetspeed/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/fileserver/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/ajaxapi/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/ajax/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/desktop/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/action/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/render/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/configure/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/dtconfigure/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/healthcheck/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>jetspeed</servlet-name>
+    <url-pattern>/webcontent/*</url-pattern>
+  </servlet-mapping>
+
+  <!-- Map *.vm files to Velocity  -->
+  <servlet-mapping>
+    <servlet-name>velocity</servlet-name>
+    <url-pattern>*.vm</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>LoginProxyServlet</servlet-name>
+    <url-pattern>/login/proxy</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>LoginServlet</servlet-name>
+    <url-pattern>/login/login</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>LoginErrorServlet</servlet-name>
+    <url-pattern>/login/error</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>LoginRedirectorServlet</servlet-name>
+    <url-pattern>/login/redirector</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>LogoutServlet</servlet-name>
+    <url-pattern>/login/logout</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>ManagerServlet</servlet-name>
+    <url-pattern>/manager/*</url-pattern>
+  </servlet-mapping>
 
   <!-- The Usual Welcome File List -->
   <welcome-file-list>
     <welcome-file>index.jsp</welcome-file>
   </welcome-file-list>
-  
+
   <!-- JNDI Db resource -->
-   <resource-ref>
-      <description>DB Connection</description>
-      <res-ref-name>jdbc/jetspeed</res-ref-name>
-      <res-type>javax.sql.DataSource</res-type>
-      <res-auth>Container</res-auth>
+  <resource-ref>
+    <description>DB Connection</description>
+    <res-ref-name>jdbc/jetspeed</res-ref-name>
+    <res-type>javax.sql.DataSource</res-type>
+    <res-auth>Container</res-auth>
   </resource-ref>
   
   <!-- JNDI CommonJ WorkManager resource -->

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-db-tools/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-db-tools/pom.xml?rev=813881&r1=813880&r2=813881&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-db-tools/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-db-tools/pom.xml Fri Sep 11 15:32:25 2009
@@ -100,6 +100,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.portals.jetspeed-2</groupId>
+      <artifactId>jetspeed-proxy</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.portals.jetspeed-2</groupId>
       <artifactId>jetspeed-id-generator</artifactId>
     </dependency>
     <dependency>

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/WebContentProxyingValve.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/WebContentProxyingValve.java?rev=813881&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/WebContentProxyingValve.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/WebContentProxyingValve.java Fri Sep 11 15:32:25 2009
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.pipeline.valve;
+
+/**
+ * Invokes <CODE>HttpRerverseProxyService</CODE> to serve remote web contents.
+ * 
+ * @version $Id$
+ */
+public interface WebContentProxyingValve extends Valve
+{
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/WebContentProxyingValve.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/WebContentProxyingValve.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/WebContentProxyingValve.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Sep 11 15:32:25 2009
@@ -1,2 +1,2 @@
-target
+target
 surefire*.properties

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/WebContentProxyingValveImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/WebContentProxyingValveImpl.java?rev=813881&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/WebContentProxyingValveImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/WebContentProxyingValveImpl.java Fri Sep 11 15:32:25 2009
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.pipeline.valve.impl;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.jetspeed.pipeline.PipelineException;
+import org.apache.jetspeed.pipeline.valve.AbstractValve;
+import org.apache.jetspeed.pipeline.valve.ValveContext;
+import org.apache.jetspeed.pipeline.valve.WebContentProxyingValve;
+import org.apache.jetspeed.proxy.HttpReverseProxyService;
+import org.apache.jetspeed.request.RequestContext;
+
+public class WebContentProxyingValveImpl extends AbstractValve  implements WebContentProxyingValve
+{
+    
+    private HttpReverseProxyService reverseProxyService;
+    
+    public WebContentProxyingValveImpl(HttpReverseProxyService reverseProxyService)
+    {
+        this.reverseProxyService = reverseProxyService;
+    }
+
+    public void invoke(RequestContext request, ValveContext context) throws PipelineException
+    {
+        HttpServletRequest servletRequest = request.getRequest();
+        HttpServletResponse servletResponse = request.getResponse();
+        
+        boolean alreadyCommitted = servletResponse.isCommitted();
+        
+        try
+        {
+            if (!alreadyCommitted)
+            {
+                reverseProxyService.invoke(servletRequest, servletResponse);
+            }
+        }
+        catch (IOException e)
+        {
+            new PipelineException(e);
+        }
+        finally
+        {
+            context.invokeNext(request);
+        }
+    }
+    
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/WebContentProxyingValveImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/WebContentProxyingValveImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/WebContentProxyingValveImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/pom.xml?rev=813881&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/pom.xml (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/pom.xml Fri Sep 11 15:32:25 2009
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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. $Id$
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>2.0.9</maven>
+  </prerequisites>
+
+  <artifactId>jetspeed-proxy</artifactId>
+  <name>Jetspeed-2 Proxy Components</name>
+  <description>Jetspeed-2 Proxy Components</description>
+  <parent>
+    <groupId>org.apache.portals.jetspeed-2</groupId>
+    <artifactId>components</artifactId>
+    <version>2.2.1-SNAPSHOT</version>
+  </parent>
+  <packaging>jar</packaging>
+
+  <!-- Dependencies -->
+
+  <dependencies>
+
+    <!-- Build Dependencies -->
+
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>jetspeed-api</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.portals.applications</groupId>
+      <artifactId>apa-webcontent-jar</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>junit</groupId>
+          <artifactId>junit</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    
+    <dependency>
+      <groupId>commons-fileupload</groupId>
+      <artifactId>commons-fileupload</artifactId>
+    </dependency>
+
+    <!-- Test Dependencies -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+  </dependencies>
+
+</project>

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpProxyPathMapperImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpProxyPathMapperImpl.java?rev=813881&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpProxyPathMapperImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpProxyPathMapperImpl.java Fri Sep 11 15:32:25 2009
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.proxy.impl;
+
+import java.util.Map;
+
+import org.apache.jetspeed.proxy.HttpReverseProxyPathMapper;
+
+/**
+ * Default implementation of <CODE>HttpProxyPathMapper</CODE> interface.
+ * 
+ * @version $Id$
+ */
+public class DefaultHttpProxyPathMapperImpl implements HttpReverseProxyPathMapper
+{
+    private String localBasePath;
+    private String remoteBaseURL;
+    private Map<String, Object> attributes;
+    
+    public DefaultHttpProxyPathMapperImpl(String localBasePath, String remoteBaseURL, Map<String, Object> attributes)
+    {
+        this.localBasePath = localBasePath;
+        this.remoteBaseURL = remoteBaseURL;
+        this.attributes = attributes;
+    }
+    
+    public String getLocalBasePath()
+    {
+        return localBasePath;
+    }
+
+    public String getRemoteBaseURL()
+    {
+        return remoteBaseURL;
+    }
+
+    public String getRemoteURL(String localPath)
+    {
+        if (localPath.startsWith(localBasePath))
+        {
+            return remoteBaseURL + localPath.substring(localBasePath.length());
+        }
+        
+        throw new IllegalArgumentException("The localPath should start with '" + localBasePath + "'.");
+    }
+    
+    public String getLocalPath(String remoteURL)
+    {
+        if (remoteURL.startsWith(remoteBaseURL))
+        {
+            return localBasePath + remoteURL.substring(remoteBaseURL.length());
+        }
+        
+        throw new IllegalArgumentException("The remoteURL should start with '" + remoteBaseURL + "'.");
+    }
+    
+    public Object getAttribute(String attrName)
+    {
+        if (attributes != null)
+        {
+            return attributes.get(attrName);
+        }
+        else
+        {
+            return null;
+        }
+    }
+    
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpProxyPathMapperImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpProxyPathMapperImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpProxyPathMapperImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpReverseProxyPathMapperProviderImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpReverseProxyPathMapperProviderImpl.java?rev=813881&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpReverseProxyPathMapperProviderImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpReverseProxyPathMapperProviderImpl.java Fri Sep 11 15:32:25 2009
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.proxy.impl;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.jetspeed.proxy.HttpReverseProxyPathMapper;
+import org.apache.jetspeed.proxy.HttpReverseProxyPathMapperProvider;
+
+public class DefaultHttpReverseProxyPathMapperProviderImpl implements HttpReverseProxyPathMapperProvider
+{
+    
+    /**
+     * Proxy path mappers
+     */
+    private List<HttpReverseProxyPathMapper> proxyPathMappers;
+    
+    public DefaultHttpReverseProxyPathMapperProviderImpl(List<HttpReverseProxyPathMapper> proxyPathMappers)
+    {
+        this.proxyPathMappers = proxyPathMappers;
+    }
+    
+    public HttpReverseProxyPathMapper findMapper(HttpServletRequest request)
+    {
+        String pathInfo = request.getPathInfo();
+        
+        for (HttpReverseProxyPathMapper proxyPathMapper : proxyPathMappers)
+        {
+            if (pathInfo.startsWith(proxyPathMapper.getLocalBasePath()))
+            {
+                return proxyPathMapper;
+            }
+        }
+        
+        return null;
+    }
+    
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpReverseProxyPathMapperProviderImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpReverseProxyPathMapperProviderImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/DefaultHttpReverseProxyPathMapperProviderImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/RewritableHttpReverseProxyServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/RewritableHttpReverseProxyServiceImpl.java?rev=813881&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/RewritableHttpReverseProxyServiceImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/RewritableHttpReverseProxyServiceImpl.java Fri Sep 11 15:32:25 2009
@@ -0,0 +1,470 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.proxy.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.disk.DiskFileItem;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
+import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.methods.multipart.FilePartSource;
+import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
+import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.commons.httpclient.methods.multipart.PartSource;
+import org.apache.commons.httpclient.methods.multipart.StringPart;
+import org.apache.commons.io.IOUtils;
+import org.apache.jetspeed.proxy.HttpReverseProxyPathMapper;
+import org.apache.jetspeed.proxy.HttpReverseProxyPathMapperProvider;
+import org.apache.jetspeed.proxy.HttpReverseProxyService;
+import org.apache.portals.applications.webcontent.rewriter.ParserAdaptor;
+import org.apache.portals.applications.webcontent.rewriter.Rewriter;
+import org.apache.portals.applications.webcontent.rewriter.RewriterController;
+import org.apache.portals.applications.webcontent.rewriter.RewriterException;
+
+/**
+ * HTTP Reverse Proxy Service Implementation
+ * 
+ * @version $Id$
+ */
+public class RewritableHttpReverseProxyServiceImpl implements HttpReverseProxyService
+{
+    
+    public static final String REVERSE_PROXY_PATH_MAPPER_ATTRIBUTE = "org.apache.jetspeed.proxy.reverseProxyPathMapper";
+    
+    public static final String REWRITER_CONTROLLER_ATTRIBUTE = "rewriterController";
+    
+    private static final String LOCATION_HEADER = "Location";
+    
+    private static final String CONTENT_TYPE_HEADER = "Content-Type";
+    
+    private static final String CONTENT_LENGTH_HEADER = "Content-Length";
+    
+    private static final String HOST_HEADER = "Host";
+
+    /**
+     * Proxy path mapper provider
+     */
+    private HttpReverseProxyPathMapperProvider proxyPathMapperProvider;
+    
+    /**
+     * Forced host header value
+     */
+    private String hostHeaderValue;
+    
+    /**
+     * local base url
+     */
+    private String localBaseURL;
+    
+    /**
+     * flag to force to prefix localBaseURL when it redirects
+     */
+    private boolean prependLocalBaseURL;
+    
+    /**
+     * Maximum file upload size
+     */
+    private int maxFileUploadSize;
+    
+    /**
+     * File upload directory
+     */
+    private File fileUploadDir;
+
+    public RewritableHttpReverseProxyServiceImpl(HttpReverseProxyPathMapperProvider proxyPathMapperProvider)
+    {
+        this.proxyPathMapperProvider = proxyPathMapperProvider;
+    }
+    
+    public void setHostHeaderValue(String hostHeaderValue)
+    {
+        this.hostHeaderValue = hostHeaderValue;
+    }
+    
+    public void setLocalBaseURL(String localBaseURL)
+    {
+        this.localBaseURL = localBaseURL;
+    }
+    
+    public void setPrependLocalBaseURL(boolean prependLocalBaseURL)
+    {
+        this.prependLocalBaseURL = prependLocalBaseURL;
+    }
+    
+    public void setMaxFileUploadSize(int maxFileUploadSize)
+    {
+        this.maxFileUploadSize = maxFileUploadSize;
+    }
+    
+    public void setFileUploadDir(File fileUploadDir)
+    {
+        this.fileUploadDir = fileUploadDir;
+    }
+    
+    public void invoke(HttpServletRequest request, HttpServletResponse response) throws IOException
+    {
+        // proxyPathMapper can be injected by using request attribute.
+        HttpReverseProxyPathMapper proxyPathMapper = (HttpReverseProxyPathMapper) request.getAttribute(REVERSE_PROXY_PATH_MAPPER_ATTRIBUTE);
+        
+        String pathInfo = request.getPathInfo();
+        
+        if (proxyPathMapper == null)
+        {
+            proxyPathMapper = proxyPathMapperProvider.findMapper(request);
+        }
+        
+        if (proxyPathMapper == null)
+        {
+            throw new IOException("Proxy configuration is not defined for " + pathInfo);
+        }
+        
+        if (hostHeaderValue == null)
+        {
+            if (request.getServerPort() == 80)
+            {
+                hostHeaderValue = request.getServerName();
+            }
+            else
+            {
+                hostHeaderValue = request.getServerName() + ":" + request.getServerPort();
+            }
+        }
+        
+        if (localBaseURL == null)
+        {
+            localBaseURL = request.getScheme() + "://" + hostHeaderValue + request.getServletPath();
+        }
+        
+        String proxyTargetURL = proxyPathMapper.getRemoteURL(pathInfo);
+        
+        String method = request.getMethod();
+        boolean isGetMethod = "GET".equals(method);
+        boolean isPostMethod = "POST".equals(method);
+        boolean isPostMultipartMethod = isPostMethod && ServletFileUpload.isMultipartContent(request);
+        
+        HttpClient httpClient = new HttpClient();
+        HttpMethod httpMethodForProxyRequest = null;
+        
+        if (isGetMethod)
+        {
+            httpMethodForProxyRequest = new GetMethod(proxyTargetURL);
+        }
+        else if (isPostMethod)
+        {
+            httpMethodForProxyRequest = new PostMethod(proxyTargetURL);
+            
+            if (isPostMultipartMethod)
+            {
+                postMultipartParams((PostMethod) httpMethodForProxyRequest, request);
+            }
+            else
+            {
+                postFormParams((PostMethod) httpMethodForProxyRequest, request);
+            }
+        }
+        else
+        {
+            throw new IOException("Unsupported method: " + method);
+        }
+        
+        // redirection should be adjusted with local host header...
+        httpMethodForProxyRequest.setFollowRedirects(false);
+        
+        setProxyRequestHeaders(httpMethodForProxyRequest, request);
+        
+        if (isPostMultipartMethod)
+        {
+            postMultipartParams((PostMethod) httpMethodForProxyRequest, request);
+        }
+        else if (isPostMethod)
+        {
+            postFormParams((PostMethod) httpMethodForProxyRequest, request);
+        }
+        
+        int proxyResponseCode = httpClient.executeMethod(httpMethodForProxyRequest);
+        
+        // Check if the proxy response is a redirect
+        if (proxyResponseCode >= HttpServletResponse.SC_MULTIPLE_CHOICES /* 300 */
+            && proxyResponseCode < HttpServletResponse.SC_NOT_MODIFIED /* 304 */)
+        {
+            String location = httpMethodForProxyRequest.getResponseHeader(LOCATION_HEADER).getValue();
+            
+            if (location == null)
+            {
+                throw new IOException("Recieved status code: " + proxyResponseCode + " but no " + LOCATION_HEADER + " header was found in the response");
+            }
+            
+            // Modify the redirect to go to this proxy servlet rather that the proxied host
+            String localPath = proxyPathMapper.getLocalPath(location);
+            String redirectLocation = null;
+            
+            if (prependLocalBaseURL) {
+                redirectLocation = localBaseURL + localPath;
+            } else {
+                redirectLocation = localPath;
+            }
+            
+            response.sendRedirect(redirectLocation);
+            return;
+        }
+        else if (proxyResponseCode == HttpServletResponse.SC_NOT_MODIFIED)
+        {
+            // 304 needs special handling. See:
+            // http://www.ics.uci.edu/pub/ietf/http/rfc1945.html#Code304
+            // We get a 304 whenever passed an 'If-Modified-Since'
+            // header and the data on disk has not changed; server
+            // responds w/ a 304 saying I'm not going to send the
+            // body because the file has not changed.
+            response.setIntHeader(CONTENT_LENGTH_HEADER, 0);
+            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+            
+            return;
+        }
+        
+        // Pass the response code back to the client
+        response.setStatus(proxyResponseCode);
+        
+        // Pass response headers back to the client
+        Header[] headerArrayResponse = httpMethodForProxyRequest.getResponseHeaders();
+        
+        for (Header header : headerArrayResponse)
+        {
+            response.setHeader(header.getName(), header.getValue());
+        }
+        
+        // Send the content to the client
+        
+        InputStream in = null;
+        Reader reader = null;
+        OutputStream out = null;
+        Writer writer = null;
+        
+        try 
+        {
+            in = httpMethodForProxyRequest.getResponseBodyAsStream();
+            out = response.getOutputStream();
+            
+            RewriterController rewriterController = (RewriterController) proxyPathMapper.getAttribute(REWRITER_CONTROLLER_ATTRIBUTE);
+            
+            if (rewriterController == null)
+            {
+                IOUtils.copy(in, out);
+                out.flush();
+            }
+            else
+            {
+                String contentType = "text/html";
+                Header contentTypeHeader = httpMethodForProxyRequest.getResponseHeader(CONTENT_TYPE_HEADER);
+                
+                if (contentTypeHeader != null && contentTypeHeader.getElements().length > 0)
+                {
+                    contentType = contentTypeHeader.getElements()[0].getValue();
+                    int offset = contentType.indexOf(';');
+                    
+                    if (offset > 0)
+                    {
+                        contentType = contentType.substring(0, offset).trim();
+                    }
+                }
+                
+                Rewriter rewriter = rewriterController.createRewriter();
+                ParserAdaptor parserAdaptor = rewriterController.createParserAdaptor(contentType);
+                reader = new InputStreamReader(in);
+                writer = new OutputStreamWriter(out);
+                rewriter.rewrite(parserAdaptor, reader, writer);
+                writer.flush();
+            }
+        }
+        catch (RewriterException e)
+        {
+            throw new IOException(e.getLocalizedMessage());
+        }
+        catch (IllegalAccessException e)
+        {
+            throw new IOException(e.getLocalizedMessage());
+        }
+        catch (InstantiationException e)
+        {
+            throw new IOException(e.getLocalizedMessage());
+        }
+        finally
+        {
+            if (reader != null)
+            {
+                try { reader.close(); } catch (Exception ce) { }
+            }
+            if (in != null)
+            {
+                try { in.close(); } catch (Exception ce) { }
+            }
+            if (writer != null)
+            {
+                try { writer.close(); } catch (Exception ce) { }
+            }
+            if (out != null)
+            {
+                try { out.close(); } catch (Exception ce) { }
+            }
+        }
+    }
+
+    private void setProxyRequestHeaders(HttpMethod httpMethodForProxyRequest, HttpServletRequest request) 
+    {
+        // Get an Enumeration of all of the header names sent by the client
+        for (Enumeration enumHeaderNames = request.getHeaderNames(); enumHeaderNames.hasMoreElements(); ) 
+        {
+            String headerName = (String) enumHeaderNames.nextElement();
+            
+            if (headerName.equalsIgnoreCase(CONTENT_LENGTH_HEADER))
+                continue;
+            
+            // As per the Java Servlet API 2.5 documentation:
+            //      Some headers, such as Accept-Language can be sent by clients
+            //      as several headers each with a different value rather than
+            //      sending the header as a comma separated list.
+            // Thus, we get an Enumeration of the header values sent by the client
+            
+            for (Enumeration enumHeaderValues = request.getHeaders(headerName); enumHeaderValues.hasMoreElements(); )
+            {
+                String headerValue = (String) enumHeaderValues.nextElement();
+                
+                // In case the proxy host is running multiple virtual servers,
+                // rewrite the Host header to ensure that we get content from
+                // the correct virtual server
+                if (headerName.equalsIgnoreCase(HOST_HEADER))
+                {
+                    headerValue = hostHeaderValue;
+                }
+                
+                Header header = new Header(headerName, headerValue);
+                
+                // Set the same header on the proxy request
+                httpMethodForProxyRequest.setRequestHeader(header);
+            }
+        }
+    }
+    
+    private void postFormParams(PostMethod httpMethodForProxyRequest, HttpServletRequest request)
+    {
+        Map<String, String[]> paramsMap = (Map<String, String[]>) request.getParameterMap();
+        List<NameValuePair> paramNameValuePairs = new ArrayList<NameValuePair>();
+        
+        for (String paramName : paramsMap.keySet())
+        {
+            String [] paramValues = paramsMap.get(paramName);
+            
+            for (String paramValue : paramValues)
+            {
+                NameValuePair nameValuePair = new NameValuePair(paramName, paramValue);
+                paramNameValuePairs.add(nameValuePair);
+            }
+        }
+        
+        httpMethodForProxyRequest.setRequestBody(paramNameValuePairs.toArray(new NameValuePair[] {}));
+    }
+    
+    private void postMultipartParams(PostMethod httpMethodForProxyRequest, HttpServletRequest request) throws IOException
+    {
+        DiskFileItemFactory fileItemFactory = new DiskFileItemFactory();
+        
+        if (maxFileUploadSize > 0)
+        {
+            fileItemFactory.setSizeThreshold(maxFileUploadSize);
+        }
+        
+        if (fileUploadDir != null)
+        {
+            fileItemFactory.setRepository(fileUploadDir);
+        }
+        
+        ServletFileUpload fileUpload = new ServletFileUpload(fileItemFactory);
+        
+        try
+        {
+            List<FileItem> fileItems = (List<FileItem>) fileUpload.parseRequest(request);
+            Part [] parts = new Part[fileItems.size()];
+            int i = 0;
+            
+            for (FileItem fileItem : fileItems)
+            {
+                if (fileItem.isFormField())
+                {
+                    parts[i] = (new StringPart(fileItem.getFieldName(), fileItem.getString()));
+                }
+                else
+                {
+                    PartSource partSource = null;
+                    
+                    if (fileItem.isInMemory())
+                    {
+                        partSource = new ByteArrayPartSource(fileItem.getName(), fileItem.get());
+                    }
+                    else
+                    {
+                        partSource = new FilePartSource(fileItem.getFieldName(), ((DiskFileItem) fileItem).getStoreLocation());
+                    }
+                    
+                    parts[i] = (new FilePart(fileItem.getFieldName(), partSource));
+                }
+                
+                i++;
+            }
+            
+            MultipartRequestEntity multipartRequestEntity = new MultipartRequestEntity(parts, httpMethodForProxyRequest.getParams());
+            httpMethodForProxyRequest.setRequestEntity(multipartRequestEntity);
+            
+            // The current content-type header (received from the client) IS of
+            // type "multipart/form-data", but the content-type header also
+            // contains the chunk boundary string of the chunks. Currently, this
+            // header is using the boundary of the client request, since we
+            // blindly copied all headers from the client request to the proxy
+            // request. However, we are creating a new request with a new chunk
+            // boundary string, so it is necessary that we re-set the
+            // content-type string to reflect the new chunk boundary string
+            httpMethodForProxyRequest.setRequestHeader(CONTENT_TYPE_HEADER, multipartRequestEntity.getContentType());
+        }
+        catch (FileUploadException fileUploadException)
+        {
+            throw new IOException(fileUploadException.getLocalizedMessage());
+        }
+    }
+    
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/RewritableHttpReverseProxyServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/RewritableHttpReverseProxyServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-proxy/src/main/java/org/apache/jetspeed/proxy/impl/RewritableHttpReverseProxyServiceImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/portal/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/pom.xml?rev=813881&r1=813880&r2=813881&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/pom.xml Fri Sep 11 15:32:25 2009
@@ -50,6 +50,7 @@
         <module>jetspeed-profiler</module>
         <module>jetspeed-rdbms</module>
         <module>jetspeed-registry</module>
+        <module>jetspeed-proxy</module>
         <module>jetspeed-search</module>
         <module>jetspeed-security</module>
         <module>jetspeed-serializer</module>

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapper.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapper.java?rev=813881&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapper.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapper.java Fri Sep 11 15:32:25 2009
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.proxy;
+
+/**
+ * proxy path mapper interface for http reverse proxy service.
+ * 
+ * @version $Id$
+ */
+public interface HttpReverseProxyPathMapper
+{
+    
+    /**
+     * Returns the local base path to be mapped to remote base url.
+     * @return
+     */
+    public String getLocalBasePath();
+    
+    /**
+     * Returns the remote base url mapped by the local path.
+     * @return
+     */
+    public String getRemoteBaseURL();
+    
+    /**
+     * Generates a remote url mapped by the path.
+     */
+    public String getRemoteURL(String localPath);
+    
+    /**
+     * Generates a local url mapped by the remote url.
+     */
+    public String getLocalPath(String remoteURL);
+    
+    /**
+     * Returns the attribute object specified by the attrName.
+     * @param attrName
+     * @return
+     */
+    public Object getAttribute(String attrName);
+    
+}

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapper.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapperProvider.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapperProvider.java?rev=813881&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapperProvider.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapperProvider.java Fri Sep 11 15:32:25 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.proxy;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * proxy path mapper provider interface for http reverse proxy service.
+ * 
+ * @version $Id$
+ */
+public interface HttpReverseProxyPathMapperProvider
+{
+    
+    /**
+     * Finds a reverse proxy path mapper based on the request
+     * @return
+     */
+    public HttpReverseProxyPathMapper findMapper(HttpServletRequest request);
+    
+}

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapperProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapperProvider.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyPathMapperProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyService.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyService.java?rev=813881&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyService.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyService.java Fri Sep 11 15:32:25 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.proxy;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * HTTP Reverse Proxy Service interface
+ * 
+ * @version $Id$
+ */
+public interface HttpReverseProxyService
+{
+    
+    public void invoke(HttpServletRequest request, HttpServletResponse response) throws IOException;
+    
+}

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyService.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/proxy/HttpReverseProxyService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pipelines.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pipelines.xml?rev=813881&r1=813880&r2=813881&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pipelines.xml (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pipelines.xml Fri Sep 11 15:32:25 2009
@@ -428,7 +428,15 @@
       <value>true</value>
     </constructor-arg>
   </bean>
-
+  
+  <bean id="webContentProxyingValve"
+    class="org.apache.jetspeed.pipeline.valve.impl.WebContentProxyingValveImpl">
+    <meta key="j2:cat" value="default" />
+    <constructor-arg index="0">
+      <ref bean="webContentProxyService" />
+    </constructor-arg>
+  </bean>
+  
   <bean id="portletApplicationValidator"
     class="org.apache.jetspeed.healthcheck.validators.PortletApplicationAvailableHeathCheckValidator">
     <meta key="j2:cat" value="default" />
@@ -773,7 +781,19 @@
       </list>
     </constructor-arg>
   </bean>
-
+  
+  <bean id="webcontent-pipeline" class="org.apache.jetspeed.pipeline.JetspeedPipeline" init-method="initialize">
+    <meta key="j2:cat" value="default" />
+    <constructor-arg>
+      <value>WebContentPipeline</value>
+    </constructor-arg>
+    <constructor-arg>
+      <list>
+        <ref bean="webContentProxyingValve" />
+      </list>
+    </constructor-arg>
+  </bean>
+  
   <bean id='pipeline-map' class='java.util.HashMap'>
     <meta key="j2:cat" value="default" />
     <constructor-arg>
@@ -819,6 +839,9 @@
         <entry key='/healthcheck'>
           <value>healthcheck-pipeline</value>
         </entry>
+        <entry key='/webcontent'>
+          <value>webcontent-pipeline</value>
+        </entry>
       </map>
     </constructor-arg>
   </bean>

Added: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/webcontent-proxy.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/webcontent-proxy.xml?rev=813881&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/webcontent-proxy.xml (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/webcontent-proxy.xml Fri Sep 11 15:32:25 2009
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+  <bean id="reverseProxyPathMapperProvider" class="org.apache.jetspeed.proxy.impl.DefaultHttpReverseProxyPathMapperProviderImpl">
+    <constructor-arg index="0">
+      <list>
+        <bean class="org.apache.jetspeed.proxy.impl.DefaultHttpProxyPathMapperImpl">
+          <meta key="j2:cat" value="default" />
+          <constructor-arg index="0">
+            <value>/portals.apache.org/jetspeed-2</value>
+          </constructor-arg>
+          <constructor-arg index="1">
+            <value>http://portals.apache.org/jetspeed-2</value>
+          </constructor-arg>
+          <constructor-arg index="2">
+            <null/>
+          </constructor-arg>
+        </bean>
+        <!--
+        WARNING!
+          
+          It could be very dangerous in perspective of security to allow retrieving remote web content
+          by reverse-proxy components used here.
+          Also, if the remote web content provider does not allow content retrieving by reverse proxy, 
+          it could be illegal to serve remote web content by reverse-proxy components used here.
+          Use of any web content with this reverse-proxy components is on your own responsibility. 
+          
+          You have been warned.
+        -->
+        <!--
+        <bean class="org.apache.jetspeed.proxy.impl.DefaultHttpProxyPathMapperImpl">
+          <meta key="j2:cat" value="default" />
+          <constructor-arg index="0">
+            <value>/www.gmodules.com</value>
+          </constructor-arg>
+          <constructor-arg index="1">
+            <value>http://www.gmodules.com</value>
+          </constructor-arg>
+          <constructor-arg index="2">
+            <null/>
+          </constructor-arg>
+        </bean>
+        -->
+      </list>
+    </constructor-arg>
+  </bean>
+    
+  <bean id="webContentProxyService" class="org.apache.jetspeed.proxy.impl.RewritableHttpReverseProxyServiceImpl">
+    <meta key="j2:cat" value="default" />
+    <constructor-arg index="0">
+      <ref bean="reverseProxyPathMapperProvider" />
+    </constructor-arg>
+  </bean>
+  
+</beans>
\ No newline at end of file

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/webcontent-proxy.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/webcontent-proxy.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/webcontent-proxy.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/portal/trunk/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/pom.xml?rev=813881&r1=813880&r2=813881&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/pom.xml Fri Sep 11 15:32:25 2009
@@ -406,6 +406,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.portals.jetspeed-2</groupId>
+        <artifactId>jetspeed-proxy</artifactId>
+        <version>${pom.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.portals.jetspeed-2</groupId>
         <artifactId>jetspeed-id-generator</artifactId>
         <version>${pom.version}</version>
       </dependency>
@@ -482,6 +487,11 @@
         <version>${org.apache.portals.applications.apa-gems.version}</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.portals.applications</groupId>
+        <artifactId>apa-webcontent-jar</artifactId>
+        <version>${org.apache.portals.applications.apa-webcontent.version}</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.portals.jetspeed-2</groupId>
         <artifactId>jetspeed-layout-portlets</artifactId>
         <version>${pom.version}</version>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message