svn commit: r594615 - in /lenya/trunk/src: java/org/apache/lenya/cms/cocoon/components/modules/input/ modules-core/linking/config/sitemap/ modules/bxe/ webapp/lenya/xslt/resources/

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: nettings
Date: Tue Nov 13 11:36:51 2007
New Revision: 594615

URL: http://svn.apache.org/viewvc?rev=594615&view=rev
Log:
make bxe work in proxied environments.
the primary problem was that bxe needs an rng file on the client, and we
did not correctly resolve <rng:include href=".."> urls.

there are two ugly hacks in the existing code that should
eventually be removed altogether. the current patch just adds
workarounds, since we're in code freeze.
the hacks are:
* webapp/lenya/xslt/resources/translate-rng-includes.xsl implements a
fallback uri resolver for client requests and gets it wrong. the error
has been fixed and a proxy transformation added, but we should not duplicate knowledge about fallback
resolving in an xslt! 
* java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java
adds a context prefix to the schema uri and also tries to resolve
fallback itself, again not really watertight. the context prefix has
been removed, and we now apply a proxy transformer afterwards.

to make this work, the proxy transformer configuration was extended to catch
rng:include elements.

TODO: bxe.close still redirects to a wrong URL (context prefix instead
of proxy)

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java
    lenya/trunk/src/modules-core/linking/config/sitemap/transformers.xmap
    lenya/trunk/src/modules/bxe/sitemap.xmap
    lenya/trunk/src/webapp/lenya/xslt/resources/translate-rng-includes.xsl

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java?rev=594615&r1=594614&r2=594615&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java Tue Nov 13 11:36:51 2007
@@ -59,7 +59,7 @@
  * {@link org.apache.lenya.cms.publication.ResourceType#getExpires()}</li>
  * <li><strong><code>schemaUri</code></strong> - see
  * {@link org.apache.lenya.xml.Schema#getURI()}</li>
- * <li><strong><code>httpSchemaUri</code></strong> - the URI to request the schema over HTTP</li>
+ * <li><strong><code>httpSchemaUri</code></strong> - the URI to request the schema over HTTP, without Proxy and context (use {proxy:} around it).</li>
  * <li><strong><code>supportsFormat:{format}</code></strong> - true if the resource type
  * supports this format, false otherwise</li>
  * </ul>
@@ -115,8 +115,7 @@
                 value = resourceType.getSchema().getURI();
             } else if (attribute.equals(HTTP_SCHEMA_URI)) {
                 String uri = resourceType.getSchema().getURI();
-                String prefix = request.getContextPath();
-                value = transformFallbackUriToHttp(pub.getId(), prefix, uri);
+                value = transformFallbackUriToHttp(pub.getId(), uri);
             } else if (attribute.equals(EXPIRES)) {
                 Date expires = resourceType.getExpires();
                 SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy kk:mm:ss zzz");
@@ -152,13 +151,13 @@
      * @return A string.
      * @throws ConfigurationException
      */
-    protected String transformFallbackUriToHttp(String pubid, String prefix, String uri)
+    protected String transformFallbackUriToHttp(String pubid, String uri)
             throws ConfigurationException {
         if (uri.startsWith("fallback://lenya/modules/")) {
             String path = StringUtils.substringAfter(uri, "fallback://lenya/modules/");
             String module = StringUtils.substringBefore(path, "/");
             path = StringUtils.substringAfter(path, module + "/resources");
-            return prefix + "/" + pubid + "/modules/" + module + path;
+            return "/" + pubid + "/modules/" + module + path;
         } else {
             throw new ConfigurationException("Don't know how to create HTTP URL from : " + uri);
         }

Modified: lenya/trunk/src/modules-core/linking/config/sitemap/transformers.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/config/sitemap/transformers.xmap?rev=594615&r1=594614&r2=594615&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/linking/config/sitemap/transformers.xmap (original)
+++ lenya/trunk/src/modules-core/linking/config/sitemap/transformers.xmap Tue Nov 13 11:36:51 2007
@@ -47,7 +47,9 @@
     <transform namespace="http://www.w3.org/1999/xhtml" element="img" attribute="src"/>
     <transform namespace="http://www.w3.org/1999/xhtml" element="link" attribute="href"/>
     <transform namespace="http://www.w3.org/1999/xhtml" element="form" attribute="action"/>
-    <transform namespace="http://www.w3.org/1999/xhtml" element="script" attribute="src"/>
+    <transform namespace="http://www.w3.org/1999/xhtml" element="script" attribute="src"/>
+<!-- temporary fix for bxe. should be reconsidered -->
+    <transform namespace="http://relaxng.org/ns/structure/1.0" element="include" attribute="href"/>
   </map:transformer>
 
   <map:transformer name="incoming-proxy" logger="lenya.sitemap.transformer.incoming-proxy"

Modified: lenya/trunk/src/modules/bxe/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/bxe/sitemap.xmap?rev=594615&r1=594614&r2=594615&view=diff
==============================================================================
--- lenya/trunk/src/modules/bxe/sitemap.xmap (original)
+++ lenya/trunk/src/modules/bxe/sitemap.xmap Tue Nov 13 11:36:51 2007
@@ -74,7 +74,12 @@
             <map:call resource="style-cms-page"/>
             <map:serialize />
         </map:act>  
-        <map:redirect-to uri="{request:requestURI}"/>
+        <!-- proxy must be applied here! normally the request should already contain
+             a correct proxy url, but this particular request is generated by the bxe usecase
+             and it is apparently unaware of proxy settings. should eventually be fixed at the root cause.
+             FIXME: review this!
+        -->
+        <map:redirect-to uri="{proxy:{request:requestURI}}"/>
       </map:match>
       
       <map:match pattern="*/*/**.html">
@@ -105,7 +110,7 @@
               <map:parameter name="BX_xslfile" value="{2}.xsl"/>
             -->
             <map:parameter name="BX_xhtmlfile" value="{proxy:/{../1}/{../2}/{../3}.bxe.html}?rendertype=edit"/>
-            <map:parameter name="BX_validationfile" value="{resource-type:httpSchemaUri}"/>
+            <map:parameter name="BX_validationfile" value="{proxy:{resource-type:httpSchemaUri}}"/>
             <map:parameter name="css" value="{proxy:/lenya/css/default.css}"/>
             <!-- The document is checked in when we exit from bx (in case of save&exit and in case of exit), so we use the usecase
               for the checkin while we redirect to the document

Modified: lenya/trunk/src/webapp/lenya/xslt/resources/translate-rng-includes.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/xslt/resources/translate-rng-includes.xsl?rev=594615&r1=594614&r2=594615&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/xslt/resources/translate-rng-includes.xsl (original)
+++ lenya/trunk/src/webapp/lenya/xslt/resources/translate-rng-includes.xsl Tue Nov 13 11:36:51 2007
@@ -16,17 +16,22 @@
   limitations under the License.
 -->
 
+
+<!-- FIXME: this file should be killed the sooner the better.
+     There is really no excuse to re-invent a fallback source resolver with substring guessing.
+-->
+
+
 <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     >
 
   <xsl:param name="publicationid" />
-  <xsl:param name="contextprefix"/>
   
   <xsl:template match="@href[starts-with(.,'fallback://lenya/resources/')]" priority="10">
     <xsl:attribute name="href">
       <xsl:variable name="resource" select="substring-after(., 'fallback://lenya/resources/')"/>
-      <xsl:value-of select="concat($contextprefix, '/lenya/', $resource )"/>
+      <xsl:value-of select="concat('/lenya/', $resource )"/>
     </xsl:attribute>
   </xsl:template>
 
@@ -35,7 +40,7 @@
     <xsl:variable name="restype" select="substring-before($nofallback,'/resources')"/>
     <xsl:variable name="resource" select="substring-after($nofallback,'resources/')"/>
     <xsl:attribute name="href">
-      <xsl:value-of select="concat($contextprefix, '/' , $publicationid, '/modules/' , $restype, '/', $resource)"/>
+      <xsl:value-of select="concat('/' , $publicationid, '/modules/' , $restype, '/', $resource)"/>
     </xsl:attribute>
   </xsl:template>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.