cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r190155 - in /cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor: CategoryNodeBuilder.java DefaultTreeBuilder.java TreeBuilder.java sitemap/FlowNodeBuilder.java
Date Sat, 11 Jun 2005 17:25:51 GMT
Author: cziegeler
Date: Sat Jun 11 10:25:50 2005
New Revision: 190155

URL: http://svn.apache.org/viewcvs?rev=190155&view=rev
Log:
Allow only one flow node per sitemap

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/CategoryNodeBuilder.java
    cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
    cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
    cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/CategoryNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/CategoryNodeBuilder.java?rev=190155&r1=190154&r2=190155&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/CategoryNodeBuilder.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/CategoryNodeBuilder.java
Sat Jun 11 10:25:50 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@
  * Builds a generic container node.
  *
  * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: CategoryNodeBuilder.java,v 1.4 2004/06/09 11:59:23 cziegeler Exp $
+ * @version CVS $Id$
  */
 
 public class CategoryNodeBuilder extends AbstractParentProcessingNodeBuilder
@@ -72,7 +72,9 @@
         node.setCategory(this.name, category);
 
         // Register node to allow lookup by other nodes
-        this.treeBuilder.registerNode(PREFIX + this.name, node);
+        if ( !this.treeBuilder.registerNode(PREFIX + this.name, node) ) {
+            throw new ConfigurationException("There can only be one category with the name:
" + this.name);
+        }
 
         return node;
     }

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java?rev=190155&r1=190154&r2=190155&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
Sat Jun 11 10:25:50 2005
@@ -280,12 +280,14 @@
     }
 
     /**
-     * Register a <code>ProcessingNode</code> under a given name.
-     * For example, <code>ResourceNodeBuilder</code> stores here the <code>ProcessingNode</code>s
-     * it produces for use by sitemap pipelines. This allows to turn the tree into a graph.
+     * @see org.apache.cocoon.components.treeprocessor.TreeBuilder#registerNode(java.lang.String,
org.apache.cocoon.components.treeprocessor.ProcessingNode)
      */
-    public void registerNode(String name, ProcessingNode node) {
+    public boolean registerNode(String name, ProcessingNode node) {
+        if ( this.registeredNodes.containsKey(name) ) {
+            return false;
+        }
         this.registeredNodes.put(name, node);
+        return true;
     }
 
     public ProcessingNode getRegisteredNode(String name) {

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java?rev=190155&r1=190154&r2=190155&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java Sat
Jun 11 10:25:50 2005
@@ -56,8 +56,10 @@
      * Register a <code>ProcessingNode</code> under a given name.
      * For example, <code>ResourceNodeBuilder</code> stores here the <code>ProcessingNode</code>s
      * it produces for use by sitemap pipelines. This allows to turn the tree into a graph.
+     * If a node with the name is already registed, the process fails!
+     * @return If the node could be registered, <code>true</code> is returned;
otherwise false.
      */
-    void registerNode(String name, ProcessingNode node);
+    boolean registerNode(String name, ProcessingNode node);
 
     /**
      * @throws IllegalStateException

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java?rev=190155&r1=190154&r2=190155&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java
Sat Jun 11 10:25:50 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
 package org.apache.cocoon.components.treeprocessor.sitemap;
 
 import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNodeBuilder;
 import org.apache.cocoon.components.treeprocessor.ProcessingNode;
 
@@ -34,7 +35,9 @@
         String language = config.getAttribute("language", "javascript");
         FlowNode node = new FlowNode(language);
 
-        this.treeBuilder.registerNode("flow", node);
+        if ( !this.treeBuilder.registerNode("flow", node) ) {
+            throw new ConfigurationException("Only one flow node per sitemap allowed.");
+        }
         this.treeBuilder.setupNode(node, config);
 
         buildChildNodesList(config);



Mime
View raw message