cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r190154 - in /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor: CategoryNodeBuilder.java DefaultTreeBuilder.java TreeBuilder.java sitemap/FlowNodeBuilder.java
Date Sat, 11 Jun 2005 17:15:05 GMT
Author: cziegeler
Date: Sat Jun 11 10:15:03 2005
New Revision: 190154

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

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

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/CategoryNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/CategoryNodeBuilder.java?rev=190154&r1=190153&r2=190154&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/CategoryNodeBuilder.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/CategoryNodeBuilder.java
Sat Jun 11 10:15:03 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.3 2004/03/05 13:02:51 bdelacretaz 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/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java?rev=190154&r1=190153&r2=190154&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
Sat Jun 11 10:15:03 2005
@@ -1,12 +1,12 @@
 /*
- * 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.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -260,12 +260,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/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java?rev=190154&r1=190153&r2=190154&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
Sat Jun 11 10:15:03 2005
@@ -1,12 +1,12 @@
 /*
- * 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.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -49,8 +49,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/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java?rev=190154&r1=190153&r2=190154&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java
Sat Jun 11 10:15:03 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.
@@ -31,10 +31,12 @@
 
     public ProcessingNode buildNode(Configuration config)
     throws Exception {
-        String language = config.getAttribute("language", "JavaScript");
+        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