You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/06/16 10:54:26 UTC

svn commit: r414780 - in /cocoon/trunk: commons/ core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ core/cocoon-core/src/main/resources/org/apache/cocoon/components/treeprocessor/

Author: cziegeler
Date: Fri Jun 16 01:54:26 2006
New Revision: 414780

URL: http://svn.apache.org/viewvc?rev=414780&view=rev
Log:
Readd support for global sitemap variables for compatibility

Modified:
    cocoon/trunk/commons/status.xml
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
    cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/components/treeprocessor/sitemap-language.xml

Modified: cocoon/trunk/commons/status.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/commons/status.xml?rev=414780&r1=414779&r2=414780&view=diff
==============================================================================
--- cocoon/trunk/commons/status.xml (original)
+++ cocoon/trunk/commons/status.xml Fri Jun 16 01:54:26 2006
@@ -59,7 +59,7 @@
 <!ENTITY ccedil           "&#x000E7;">
 ]>
 
-<!-- SVN $Id$ -->
+<!-- @version $Id$ -->
 
 <status>
  <developers>
@@ -185,7 +185,8 @@
     </action>
     <action dev="CZ" type="remove">
       Remove the SitemapConfigurable interface completly. The new include and property mechanism provides
-      a cleaner way of per sitemap configurations.
+      a cleaner way of per sitemap configurations. (Compatibility for global sitemap variables is provided but
+      will be removed in later versions.)
     </action>
     <action dev="CZ" type="add">
       Properties can now be defined on a per sitemap base. This includes different set of

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java?rev=414780&r1=414779&r2=414780&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java Fri Jun 16 01:54:26 2006
@@ -77,6 +77,7 @@
 import org.apache.cocoon.sitemap.PatternException;
 import org.apache.cocoon.sitemap.SitemapParameters;
 import org.apache.cocoon.util.ClassUtils;
+import org.apache.cocoon.util.Deprecation;
 import org.apache.cocoon.util.location.Location;
 import org.apache.cocoon.util.location.LocationImpl;
 import org.apache.cocoon.util.location.LocationUtils;
@@ -389,6 +390,31 @@
         if ( componentConfig != null && componentConfig.getAttribute("property-dir", null) != null ) {
             final String propertyDir = componentConfig.getAttribute("property-dir");
             settings = this.createSettings(settings, propertyDir);
+        }
+        // compatibility with 2.1.x - check for global variables in sitemap
+        // TODO - This will be removed in later versions!
+        if ( tree.getChild("pipelines").getChild("component-configurations", false) != null ) {
+            Deprecation.logger.warn("The 'component-configurations' section in the sitemap is deprecated. Please check for alternatives.");
+            // now check for global variables - if any other element occurs: throw exception
+            Configuration[] children = tree.getChild("pipelines").getChild("component-configurations").getChildren();
+            for(int i=0; i<children.length; i++) {
+                if ( "global-variables".equals(children[i].getName()) ) {
+                    final Properties p = new Properties();
+                    final MutableSettings mutableSettings;
+                    if ( settings instanceof MutableSettings ) {
+                        mutableSettings = (MutableSettings)settings;
+                    } else {
+                        mutableSettings = new MutableSettings(settings);
+                    }
+                    Configuration[] variables = children[i].getChildren();
+                    for(int v=0; v<variables.length; v++) {
+                        p.setProperty(variables[v].getName(), variables[v].getValue());
+                    }
+                    mutableSettings.fill(p);
+                } else {
+                    throw new ConfigurationException("Component configurations in the sitemap are not allowed for component: " + children[i].getName());
+                }
+            }
         }
         // replace properties?
         if ( componentConfig == null || componentConfig.getAttributeAsBoolean("replace-properties", true) ) {

Modified: cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/components/treeprocessor/sitemap-language.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/components/treeprocessor/sitemap-language.xml?rev=414780&r1=414779&r2=414780&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/components/treeprocessor/sitemap-language.xml (original)
+++ cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/components/treeprocessor/sitemap-language.xml Fri Jun 16 01:54:26 2006
@@ -101,6 +101,7 @@
 
       <node name="pipelines" builder="org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNodeBuilder">
         <allowed-children>pipeline, handle-errors</allowed-children>
+        <ignored-children>component-configurations</ignored-children>
       </node>
 
       <node name="pipeline" builder="org.apache.cocoon.components.treeprocessor.sitemap.PipelineNodeBuilder">