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/12/12 14:10:37 UTC

svn commit: r486124 - /lenya/trunk/src/pubs/default/java/src/org/apache/lenya/defaultpub/cms/publication/templating/Instantiator.java

Author: andreas
Date: Tue Dec 12 05:10:37 2006
New Revision: 486124

URL: http://svn.apache.org/viewvc?view=rev&rev=486124
Log:
Don't copy module and resource type declarations to child publications

Modified:
    lenya/trunk/src/pubs/default/java/src/org/apache/lenya/defaultpub/cms/publication/templating/Instantiator.java

Modified: lenya/trunk/src/pubs/default/java/src/org/apache/lenya/defaultpub/cms/publication/templating/Instantiator.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/java/src/org/apache/lenya/defaultpub/cms/publication/templating/Instantiator.java?view=diff&rev=486124&r1=486123&r2=486124
==============================================================================
--- lenya/trunk/src/pubs/default/java/src/org/apache/lenya/defaultpub/cms/publication/templating/Instantiator.java (original)
+++ lenya/trunk/src/pubs/default/java/src/org/apache/lenya/defaultpub/cms/publication/templating/Instantiator.java Tue Dec 12 05:10:37 2006
@@ -144,20 +144,11 @@
             configSource = (ModifiableSource) resolver.resolveURI(publicationsUri + "/"
                     + newPublicationId + "/config/publication.xconf");
             DefaultConfiguration config = (DefaultConfiguration) new DefaultConfigurationBuilder().build(configSource.getInputStream());
-            DefaultConfiguration templatesConfig = (DefaultConfiguration) config.getChild("templates",
-                    false);
-            if (templatesConfig == null) {
-                templatesConfig = new DefaultConfiguration("templates");
-                config.addChild(templatesConfig);
-            } else {
-                Configuration[] templateConfigs = templatesConfig.getChildren("template");
-                for (int i = 0; i < templateConfigs.length; i++) {
-                    templatesConfig.removeChild(templateConfigs[i]);
-                }
-            }
-            DefaultConfiguration templateConfig = new DefaultConfiguration("template");
-            templateConfig.setAttribute("id", template.getId());
-            templatesConfig.addChild(templateConfig);
+            addTemplateConfiguration(template, config);
+            
+            removeChildren(config, "module");
+            removeChildren(config, "resource-type");
+            
             OutputStream oStream = configSource.getOutputStream();
             new DefaultConfigurationSerializer().serialize(oStream, config);
             if (oStream != null) {
@@ -177,6 +168,30 @@
                     resolver.release(configSource);
                 }
             }
+        }
+    }
+
+    protected void addTemplateConfiguration(Publication template, DefaultConfiguration config) {
+        DefaultConfiguration templatesConfig = (DefaultConfiguration) config.getChild("templates",
+                false);
+        if (templatesConfig == null) {
+            templatesConfig = new DefaultConfiguration("templates");
+            config.addChild(templatesConfig);
+        } else {
+            Configuration[] templateConfigs = templatesConfig.getChildren("template");
+            for (int i = 0; i < templateConfigs.length; i++) {
+                templatesConfig.removeChild(templateConfigs[i]);
+            }
+        }
+        DefaultConfiguration templateConfig = new DefaultConfiguration("template");
+        templateConfig.setAttribute("id", template.getId());
+        templatesConfig.addChild(templateConfig);
+    }
+
+    protected void removeChildren(DefaultConfiguration config, String name) {
+        Configuration[] moduleConfigs = config.getChildren(name);
+        for (int i = 0; i < moduleConfigs.length; i++) {
+            config.removeChild(moduleConfigs[i]);
         }
     }
 



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