You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ne...@apache.org on 2007/11/07 20:35:06 UTC

svn commit: r592863 - in /lenya/trunk/src: modules-core/usecase/usecases.js pubs/default/config/publication.xml pubs/default/sitemap.xmap webapp/global-sitemap.xmap webapp/lenya/config/sitemap/pipelines.xmap

Author: nettings
Date: Wed Nov  7 11:35:05 2007
New Revision: 592863

URL: http://svn.apache.org/viewvc?rev=592863&view=rev
Log:
fixes for redirects in non-root contexts and proxied environments.
added appropriate {proxy:} calls around redirect uris and added
proxyModule link rewriting to usecases redirector.

please test thoroughly. this is a potentially dangerous commit during
code freeze. you can use the jetty6 setup described in tools/proxytest
to create a non-root proxy setup without too much hassle.


Modified:
    lenya/trunk/src/modules-core/usecase/usecases.js
    lenya/trunk/src/pubs/default/config/publication.xml
    lenya/trunk/src/pubs/default/sitemap.xmap
    lenya/trunk/src/webapp/global-sitemap.xmap
    lenya/trunk/src/webapp/lenya/config/sitemap/pipelines.xmap

Modified: lenya/trunk/src/modules-core/usecase/usecases.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/usecase/usecases.js?rev=592863&r1=592862&r2=592863&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/usecase/usecases.js (original)
+++ lenya/trunk/src/modules-core/usecase/usecases.js Wed Nov  7 11:35:05 2007
@@ -18,6 +18,7 @@
 /* $Id$ */
  
 cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
+importPackage(Packages.org.apache.lenya.cms.linking)
 
 //placeholders for custom flow code:
 var customLoopFlow = undefined;
@@ -287,15 +288,40 @@
 }
 
 /**
- * Redirect to target URL after finishing the usecase.
+ * Redirect to target URL after finishing the usecase, 
+ * taking proxy settings into account.
  *
- * @param the target URL
+ * @param the webapp-internal target URL
  */
 function redirect(targetUrl) {
-    var flowHelper = cocoon.getComponent("org.apache.lenya.cms.cocoon.flow.FlowHelper");
-    var contextPath = flowHelper.getRequest(cocoon).getContextPath();
-    cocoon.releaseComponent(flowHelper);
-    cocoon.redirectTo(contextPath + targetUrl, true);
+    var flowHelper;  // needed to obtain the current objectModel 
+    var objectModel; // needed to provide context to the proxyModule 
+    var inputModuleSelector; // needed to obtain a proxyModule
+    var proxyModule; // used to rewrite the targetUrl according to the publication's proxy settings
+    var proxyUrl;    // the rewritten target Url
+
+    flowHelper = cocoon.getComponent("org.apache.lenya.cms.cocoon.flow.FlowHelper");
+    try {
+        objectModel = flowHelper.getObjectModel(cocoon);
+    } finally {
+        cocoon.releaseComponent(flowHelper);
+    }
+
+    inputModuleSelector = cocoon.getComponent(org.apache.cocoon.components.modules.input.InputModule.ROLE + "Selector");
+    try {
+        proxyModule = inputModuleSelector.select("proxy");
+        try {
+            proxyUrl = proxyModule.getAttribute(targetUrl, null, objectModel);
+        } finally {
+            cocoon.releaseComponent(proxyModule);
+        }
+    } finally {
+        cocoon.releaseComponent(inputModuleSelector);
+    }
+
+    log("debug", "Redirecting to {proxy:" + targetUrl + "} = " + proxyUrl + ".");
+
+    cocoon.redirectTo(proxyUrl, true);
 }
 
 
@@ -407,7 +433,7 @@
     }
     //getTargetURL takes a boolean that is true on success:
     targetUrl = usecase.getTargetURL(state == "success");
-    log("debug", "Completed, redirecting to url = [context:/" + targetUrl + "]", usecaseName);
+    log("debug", "Completed, redirecting to url = [" + targetUrl + "]", usecaseName);
     // jump to the appropriate URL:
     redirect(targetUrl);
 }

Modified: lenya/trunk/src/pubs/default/config/publication.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/config/publication.xml?rev=592863&r1=592862&r2=592863&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/config/publication.xml (original)
+++ lenya/trunk/src/pubs/default/config/publication.xml Wed Nov  7 11:35:05 2007
@@ -101,14 +101,16 @@
           <content-dir src="D:/tmp/default"/>
   -->
   
-  <!-- Lenya can rewrite the links to cater to special proxy setups.
+  <proxies>
+    <!-- 
+       Lenya can rewrite the links to cater to special proxy setups.
        Make sure to update the GlobalProxies configuration in cocoon.xconf as well.
        For information about these settings, read
        http://lenya.apache.org/docu/docs/2_0_x/tutorials/proxy.html
       
        This example setting simulates the following situation:
        * A customer wants a company hostname and URLs without Lenya-specific
-         path components.
+         path components for his live site.
        * The server uses name-based virtual hosting with just one IP, i.e.
          there can only be one SSL vhost, which is shared among several
          customers. This implies the need for sub-directories in the proxy
@@ -116,26 +118,25 @@
        * "authoring" should be ssl-protected. There is no need for a
          customer hostname here, since it's not publicly visible.
        * Any SSL-protected documents in "live" can be handled by the SSL
-         vhost (not using the company hostname is ok in this case).
+         vhost (not using the company hostname is ok in this case, because
+         the customer does not want to pay for an additional IP address).
          
        The desired customer hostname is customer.example.com.
-       The SSL vhost is called www.example.com.
+       The SSL vhost is called https://www.example.com.
        The Lenya CMS for our customer is reachable as
-       https://www.example.com/lenya/customer/authoring
+       http[s]://www.example.com/lenya/customer/authoring.
        The global proxy for non-publication-specific resources shall be
        http://www.example.com/lenya.
-       
-       -->
-  <proxies>
+     -->
 <!--
-    <proxy area="live" ssl="true" 
-      url="https://www.example.com/lenya/customer/live"/>
-    <proxy area="live" ssl="false" 
-      url="http://customer.example.com"/>
-    <proxy area="authoring" ssl="true" 
-      url="https://www.example.com/lenya/customer/authoring"/>
-    <proxy area="authoring" ssl="false"
-      url="http://www.example.com/lenya/customer/authoring"/>
+    <proxy area="live" ssl="true" url="https://www.example.com/lenya/customer/live"/>
+    <proxy area="live" ssl="false" url="http://customer.example.com"/>
+    <proxy area="authoring" ssl="true" url="https://www.example.com/lenya/customer/authoring"/>
+    <proxy area="authoring" ssl="false" url="http://www.example.com/lenya/customer/authoring"/>
+    <proxy area="archive" ssl="true" url="https://www.example.com/lenya/customer/archive"/>
+    <proxy area="archive" ssl="false" url="http://www.example.com/lenya/customer/archive"/>
+    <proxy area="trash" ssl="true" url="https://www.example.com/lenya/customer/trash"/>
+    <proxy area="trash" ssl="false" url="http://www.example.com/lenya/customer/trash"/>
 -->
   </proxies>
   

Modified: lenya/trunk/src/pubs/default/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/sitemap.xmap?rev=592863&r1=592862&r2=592863&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/sitemap.xmap (original)
+++ lenya/trunk/src/pubs/default/sitemap.xmap Wed Nov  7 11:35:05 2007
@@ -96,7 +96,7 @@
            a cocoon:/ URI? An apache httpd server will not send a HTTP redirect when a directory is requested, but
            serve the index.html file implicitly IIRC. -->
       <map:match pattern="**/">
-        <map:redirect-to uri="index.html"/>
+        <map:redirect-to uri="{proxy:/{page-envelope:publication-id}/{1}/index.html}"/>
       </map:match>
 
     </map:pipeline>
@@ -271,13 +271,14 @@
           This check provides the user with a dialog to import example content. 
           It should be removed in production systems.
         --> 
+
         <map:select type="resource-exists">
           <map:when test="lenya://lenya/pubs/{page-envelope:publication-id}/content/authoring/sitetree.xml"/>
           <map:otherwise>
-            <map:redirect-to uri="{request:requestUri}?lenya.usecase=export.importExampleContent"/>
+            <map:redirect-to uri="{proxy:/{page-envelope:publication-id}/{1}/{2}.html}?lenya.usecase=export.importExampleContent"/>
           </map:otherwise>
         </map:select>
-      
+
         <!-- If the requested language version of the document exists, we set a last-modified header. -->
         <map:act type="language-exists">
           <map:act type="set-header">

Modified: lenya/trunk/src/webapp/global-sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/global-sitemap.xmap?rev=592863&r1=592862&r2=592863&view=diff
==============================================================================
--- lenya/trunk/src/webapp/global-sitemap.xmap (original)
+++ lenya/trunk/src/webapp/global-sitemap.xmap Wed Nov  7 11:35:05 2007
@@ -305,7 +305,7 @@
 
       <!-- any root-level request is directed to the welcome page -->
       <map:match pattern="*">
-        <map:redirect-to uri="index.html"/>
+        <map:redirect-to uri="{proxy:/index.html}"/>
       </map:match>
 
       <!-- FIXME: this is apparently WebDAV-related. Does it have to be here, and what does it do? -->
@@ -342,10 +342,10 @@
 
       <!-- redirect publication root requests to the publication's welcome page -->
       <map:match pattern="*/">
-        <map:redirect-to uri="introduction.html"/>
+        <map:redirect-to uri="{proxy:/introduction.html}"/>
       </map:match>
       <map:match pattern="*/index.html">
-        <map:redirect-to uri="introduction.html"/>
+        <map:redirect-to uri="{proxy:/introduction.html}"/>
       </map:match>
 
       <!-- generate welcome pages for each publication with an aggregation of relevant READMEs -->

Modified: lenya/trunk/src/webapp/lenya/config/sitemap/pipelines.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/config/sitemap/pipelines.xmap?rev=592863&r1=592862&r2=592863&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/config/sitemap/pipelines.xmap (original)
+++ lenya/trunk/src/webapp/lenya/config/sitemap/pipelines.xmap Wed Nov  7 11:35:05 2007
@@ -102,7 +102,7 @@
       <map:act type="authorizer">
         <map:mount uri-prefix="" src="global-sitemap.xmap" check-reload="true" reload-method="synchron"/>
       </map:act>
-      <map:redirect-to session="true" uri="{request:requestURI}?lenya.usecase=ac.login&amp;referrerQueryString={url-encode:{request:queryString}}"/>        
+      <map:redirect-to session="true" uri="{proxy:/{1}}?lenya.usecase=ac.login&amp;referrerQueryString={url-encode:{request:queryString}}"/>        
     </map:match>
 
     </map:pipeline>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org