You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/11/15 16:48:46 UTC

svn commit: r475267 - in /lenya/trunk/src: java/org/apache/lenya/cms/cocoon/source/AggregatingFallbackSourceFactory.java java/org/apache/lenya/cms/cocoon/source/AggregatingSource.java webapp/lenya/i18n.xmap

Author: andreas
Date: Wed Nov 15 07:48:45 2006
New Revision: 475267

URL: http://svn.apache.org/viewvc?view=rev&rev=475267
Log:
Fix AggregatingFallbackSourceFactory to support modules correctly

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingFallbackSourceFactory.java
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingSource.java
    lenya/trunk/src/webapp/lenya/i18n.xmap

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingFallbackSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingFallbackSourceFactory.java?view=diff&rev=475267&r1=475266&r2=475267
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingFallbackSourceFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingFallbackSourceFactory.java Wed Nov 15 07:48:45 2006
@@ -19,6 +19,9 @@
 
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.avalon.framework.context.Context;
@@ -34,6 +37,7 @@
 import org.apache.excalibur.source.SourceFactory;
 import org.apache.excalibur.source.SourceUtil;
 import org.apache.excalibur.source.URIAbsolutizer;
+import org.apache.lenya.cms.module.ModuleManager;
 import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.publication.DocumentUtil;
 import org.apache.lenya.cms.publication.Publication;
@@ -43,7 +47,8 @@
 import org.apache.lenya.cms.publication.templating.PublicationTemplateManager;
 
 /**
- * @see org.apache.lenya.cms.publication.templating.AggregatingVisitor
+ * Aggregate all existing fallback URIs by merging their XML content under
+ * the document element of the first encountered source.
  */
 public class AggregatingFallbackSourceFactory extends AbstractLogEnabled implements SourceFactory,
         Serviceable, Contextualizable, URIAbsolutizer {
@@ -108,8 +113,33 @@
             } else {
                 uris = new String[0];
             }
+            
+            List allUris = new ArrayList();
+            allUris.addAll(Arrays.asList(uris));
+            
+            String contextSourceUri = null;
+            if (path.startsWith("lenya/modules/")) {
+                ModuleManager moduleMgr = null;
+                try {
+                    moduleMgr = (ModuleManager) this.manager.lookup(ModuleManager.ROLE);
+                    final String moduleShortcut = path.split("/")[2];
+                    String baseUri = moduleMgr.getBaseURI(moduleShortcut);
+                    final String modulePath = path.substring(("lenya/modules/" + moduleShortcut).length());
+                    contextSourceUri = baseUri + modulePath;
+                } finally {
+                    if (moduleMgr != null) {
+                        this.manager.release(moduleMgr);
+                    }
+                }
+            } else {
+                contextSourceUri = "context://" + path;
+            }
+            if (org.apache.lenya.cms.cocoon.source.SourceUtil.exists(contextSourceUri, this.manager)) {
+                allUris.add(contextSourceUri);
+            }
 
-            return new AggregatingSource(location, uris, this.manager);
+            String[] aggregateUris = (String[]) allUris.toArray(new String[allUris.size()]); 
+            return new AggregatingSource(location, aggregateUris, this.manager);
 
         } catch (Exception e) {
             throw new RuntimeException("Resolving path [" + location + "] failed: ", e);

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingSource.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingSource.java?view=diff&rev=475267&r1=475266&r2=475267
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingSource.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingSource.java Wed Nov 15 07:48:45 2006
@@ -35,6 +35,10 @@
         this.sourceUris = uris;
         this.uri = uri;
     }
+    
+    public String toString() {
+        return getURI();
+    }
 
     protected void loadDom() {
         try {

Modified: lenya/trunk/src/webapp/lenya/i18n.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/i18n.xmap?view=diff&rev=475267&r1=475266&r2=475267
==============================================================================
--- lenya/trunk/src/webapp/lenya/i18n.xmap (original)
+++ lenya/trunk/src/webapp/lenya/i18n.xmap Wed Nov 15 07:48:45 2006
@@ -61,21 +61,15 @@
       <map:match pattern="i18n-catalogue/**">
         <map:select type="resource-exists">
           <map:when test="aggregate-fallback://lenya/resources/i18n/{1}">
-            <map:generate type="serverpages" src="fallback://lenya/resources/i18n/catalogue.xsp">
-              <map:parameter name="pub-catalogue-location" value="aggregate-fallback://lenya/resources/i18n/"/>
-              <map:parameter name="catalogue-file" value="{1}"/>
-            </map:generate>
-            <map:call resource="serializeCatalogue">
-              <map:parameter name="catalogue" value="{1}"/>
-            </map:call>
-          </map:when>
-          <map:when test="resources/i18n/{1}">
-            <map:generate src="resources/i18n/{1}"/>
-            <map:call resource="serializeCatalogue">
-              <map:parameter name="catalogue" value="{1}"/>
-            </map:call>
+            <map:generate src="aggregate-fallback://lenya/resources/i18n/{1}"/>
           </map:when>
+          <map:otherwise>
+            <map:generate src="aggregate-fallback://lenya/resources/i18n/cmsui.xml"/>
+          </map:otherwise>
         </map:select>
+        <map:call resource="serializeCatalogue">
+          <map:parameter name="catalogue" value="{1}"/>
+        </map:call>
       </map:match>
     </map:pipeline>  
   </map:pipelines>



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