logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

svn commit: r451442 - /lenya/trunk/src/java/org/apache/lenya/cms/cocoon/sou: msg#00155

Subject: svn commit: r451442 - /lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java
Author: chestnut
Date: Fri Sep 29 14:13:20 2006
New Revision: 451442

URL: http://svn.apache.org/viewvc?view=rev&rev=451442
Log:
Added ability to reference publication from which to fallback from,

This should resolves the problem of an xslt template trying to import itself 
when

xslt/page2xhtml.xsl -> imports -> template-fallback://xslt/page2xhtml.xsl -> 
imports -> template-fallback://xslt/page2xhtml.xsl

instead use   

xslt/page2xhtml.xsl -> imports -> 
template-fallback://{template1}//xslt/page2xhtml.xsl -> imports -> 
template-fallback://{template2}//xslt/page2xhtml.xsl



Adding pubids to your fallback:// protocols should also allow one to leave the 
xslt use-store on if used properly

Modified:
    
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java

Modified: 
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java
URL: 
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java?view=diff&rev=451442&r1=451441&r2=451442
==============================================================================
--- 
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java
 (original)
+++ 
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java
 Fri Sep 29 14:13:20 2006
@@ -72,14 +72,23 @@
         long startTime = new GregorianCalendar().getTimeInMillis();
 
         // Remove the protocol and the first '//'
-        final int pos = location.indexOf("://");
+        int pos = location.indexOf("://");
 
         if (pos == -1) {
             throw new RuntimeException("The location [" + location
                     + "] does not contain the string '://'");
         }
-
-        final String path = location.substring(pos + 3);
+        
+        String path = location.substring(pos + 3);
+        String publicationId = null;
+        
+        //allow for template-fallback://{pubid}//{path} for the sake of the
+        //cocoon use-store
+        if (path.indexOf("//") > 1) {
+            pos = path.indexOf("//");
+            publicationId = path.substring(0, pos);
+            path = path.substring(pos + 2, path.length());
+        }
 
         if (path.length() == 0) {
             throw new RuntimeException("The path after the protocol must not 
be empty!");
@@ -99,11 +108,15 @@
 
             templateManager = (PublicationTemplateManager) 
this.manager.lookup(PublicationTemplateManager.ROLE);
 
+            
             Request request = ContextHelper.getRequest(this.context);
-            String webappUrl = 
request.getRequestURI().substring(request.getContextPath().length());
-
-            URLInformation info = new URLInformation(webappUrl);
-            String publicationId = info.getPublicationId();
+            
+            if (publicationId == null) {
+                String webappUrl = 
request.getRequestURI().substring(request.getContextPath().length());
+
+                URLInformation info = new URLInformation(webappUrl);
+                publicationId = info.getPublicationId();
+            }
 
             pubMgr = (PublicationManager) 
this.manager.lookup(PublicationManager.ROLE);
             DocumentFactory factory = 
DocumentUtil.getDocumentFactory(this.manager, request);


<Prev in Thread] Current Thread [Next in Thread>