1 16 package org.apache.cocoon.components.treeprocessor.sitemap; 17 18 import org.apache.avalon.framework.configuration.Configuration; 19 import org.apache.avalon.framework.configuration.ConfigurationException; 20 import org.apache.avalon.framework.thread.ThreadSafe; 21 import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNodeBuilder; 22 import org.apache.cocoon.components.treeprocessor.ProcessingNode; 23 import org.apache.cocoon.components.treeprocessor.ProcessingNodeBuilder; 24 25 33 34 public class SitemapNodeBuilder extends AbstractParentProcessingNodeBuilder implements ThreadSafe { 35 36 private static final String [] orderedNames = { "components", "views", "resources" }; 39 40 public ProcessingNode buildNode(Configuration config) throws Exception { 41 42 for (int i = 0; i < orderedNames.length; i++) { 44 Configuration childConfig = config.getChild(orderedNames[i], false); 45 if (childConfig != null) { 46 ProcessingNodeBuilder builder = this.treeBuilder.createNodeBuilder(childConfig); 47 builder.buildNode(childConfig); 49 } 50 } 51 52 ProcessingNode pipelines = null; 53 54 Configuration[] childConfigs = config.getChildren(); 56 57 loop: for (int i = 0; i < childConfigs.length; i++) { 58 59 Configuration childConfig = childConfigs[i]; 60 if (isChild(childConfig)) { 61 for (int j = 0; j < orderedNames.length; j++) { 63 if (orderedNames[j].equals(childConfig.getName())) { 64 continue loop; 66 } 67 } 68 69 ProcessingNodeBuilder builder = this.treeBuilder.createNodeBuilder(childConfig); 70 ProcessingNode node = builder.buildNode(childConfig); 71 if (node instanceof PipelinesNode) { 72 if (pipelines != null) { 73 String msg = "Only one 'pipelines' is allowed, at " + childConfig.getLocation(); 74 throw new ConfigurationException(msg); 75 } 76 pipelines = node; 77 } 78 } 79 } 80 81 if (pipelines == null) { 82 String msg = "Invalid sitemap : there must be a 'pipelines' at " + config.getLocation(); 83 throw new ConfigurationException(msg); 84 } 85 86 return pipelines; 87 } 88 } 89 | Popular Tags |