You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2003/08/12 17:48:03 UTC
cvs commit: cocoon-2.1/src/webapp/samples/i18n sitemap.xmap
sylvain 2003/08/12 08:48:02
Modified: . status.xml
src/java/org/apache/cocoon/components
ExtendedComponentSelector.java
src/java/org/apache/cocoon/components/treeprocessor/sitemap
ComponentsSelector.java SerializeNode.java
SitemapNodeBuilder.java
src/java/org/apache/cocoon/sitemap
DefaultSitemapComponentSelector.java
src/webapp/samples/i18n sitemap.xmap
Log:
Fix bug #22239 (views on resources don't work)
Revision Changes Path
1.116 +6 -2 cocoon-2.1/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/status.xml,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -r1.115 -r1.116
--- status.xml 12 Aug 2003 11:37:44 -0000 1.115
+++ status.xml 12 Aug 2003 15:48:02 -0000 1.116
@@ -202,7 +202,11 @@
<changes>
<release version="@version@" date="@date@">
- <action dev="CZ" type="add">DUMMY</action>
+ <action dev="SW" type="fix" fixes-bug="22239">
+ Views are now always loaded before resources, ensuring proper call of views from resources.
+ Redeclaring a component (e.g. file generator) with no "label" attribute was wrongly inheriting
+ view labels from the same component in the parent sitemap.
+ </action>
</release>
<release version="2.1" date="August 12 2003">
<action dev="JH" type="update" fixes-bug="22288" due-to="Mark Leicester" due-to-email="mark.leicester@energyintellect.com">
1.4 +21 -1 cocoon-2.1/src/java/org/apache/cocoon/components/ExtendedComponentSelector.java
Index: ExtendedComponentSelector.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/ExtendedComponentSelector.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ExtendedComponentSelector.java 4 Aug 2003 03:19:22 -0000 1.3
+++ ExtendedComponentSelector.java 12 Aug 2003 15:48:02 -0000 1.4
@@ -95,6 +95,9 @@
/** The default hint */
protected String defaultHint;
+ /** This selector's location (used for debugging purposes) */
+ private String location;
+
public ExtendedComponentSelector()
{
super();
@@ -210,6 +213,9 @@
*/
public void configure(Configuration config) throws ConfigurationException {
+ // Store location
+ this.location = config.getLocation();
+
this.roleName = getRoleName(config);
// Pass a copy of the top-level object to superclass so that
@@ -321,12 +327,26 @@
}
}
+ /**
+ * Does this selector or its parent have the given hint ?
+ */
public boolean hasComponent(Object hint) {
boolean exists = super.hasComponent( hint );
if ( !exists && this.parentSelector != null ) {
exists = this.parentSelector.hasComponent( hint );
}
return exists;
+ }
+
+ /**
+ * Does this selector declare a given hint? Check is performed on the components declared for this
+ * selector only, and <strong>not</strong> those potentially inherited from the parent selector.
+ *
+ * @param hint the hint to check for
+ * @return <code>true</code> if this selector has the specified hint
+ */
+ protected boolean hasDeclaredComponent(Object hint) {
+ return super.hasComponent(hint);
}
/* (non-Javadoc)
1.5 +27 -22 cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsSelector.java
Index: ComponentsSelector.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsSelector.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ComponentsSelector.java 29 Jul 2003 07:41:26 -0000 1.4
+++ ComponentsSelector.java 12 Aug 2003 15:48:02 -0000 1.5
@@ -134,7 +134,7 @@
/** The parent selector, if it's of the current class */
private SitemapComponentSelector parentSitemapSelector;
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.components.ParentAware#setParentInformation(org.apache.avalon.framework.component.ComponentManager, java.lang.String)
*/
@@ -165,8 +165,8 @@
public void configure(Configuration config) throws ConfigurationException {
-
- // How are we ?
+
+ // Who are we ?
String role = getRoleName(config);
this.roleId = UNKNOWN; // unknown
for (int i = 0; i < SELECTOR_ROLES.length; i++) {
@@ -295,17 +295,16 @@
public String getMimeTypeForHint(Object hint) {
if (this.hintMimeTypes == null) {
+ // Not a component that has mime types
return null;
} else {
- String mimeType = (String)this.hintMimeTypes.get(hint);
-
- if (mimeType != null) {
- return mimeType;
-
+ if (this.hasDeclaredComponent(hint)) {
+ return (String)this.hintMimeTypes.get(hint);
+
} else if (this.parentSitemapSelector != null) {
return this.parentSitemapSelector.getMimeTypeForHint(hint);
-
+
} else {
return null;
}
@@ -313,34 +312,40 @@
}
public boolean hasLabel(Object hint, String label) {
- String[] labels = (String[])this.hintLabels.get(hint);
+ String[] labels = this.getLabels(hint);
if (labels != null) {
for (int i = 0; i < labels.length; i++) {
if (labels[i].equals(label))
return true;
}
- } else if (parentSitemapSelector != null) {
- return parentSitemapSelector.hasLabel(hint, label);
}
return false;
}
public String[] getLabels(Object hint) {
- String[] labels = (String[])this.hintLabels.get(hint);
- // Labels can be inherited or completely overrided
- if (labels == null && parentSitemapSelector != null) {
+ // If this hint is declared locally, use its labels (if any), otherwise inherit
+ // those of the parent.
+ if (this.hasDeclaredComponent(hint)) {
+ return (String[])this.hintLabels.get(hint);
+
+ } else if (this.parentSitemapSelector != null) {
return parentSitemapSelector.getLabels(hint);
+
+ } else {
+ return null;
}
- return labels;
}
public String getPipelineHint(Object hint) {
- String pipelineHint = (String)this.pipelineHints.get(hint);
- // Pipeline-hints can be inherited or completely overrided
- if (pipelineHint == null && parentSitemapSelector != null) {
- return parentSitemapSelector.getPipelineHint(hint);
+ // If this hint is declared locally, use its hints (if any), otherwise inherit
+ // those of the parent.
+ if (this.hasDeclaredComponent(hint)) {
+ return (String)this.pipelineHints.get(hint);
+ } else if (this.parentSitemapSelector != null) {
+ return this.parentSitemapSelector.getPipelineHint(hint);
+ } else {
+ return null;
}
- return pipelineHint;
}
public void dispose() {
1.5 +10 -13 cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java
Index: SerializeNode.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SerializeNode.java 7 Jul 2003 09:26:53 -0000 1.4
+++ SerializeNode.java 12 Aug 2003 15:48:02 -0000 1.5
@@ -114,21 +114,18 @@
}
}
}
+
+ Map objectModel = env.getObjectModel();
+ ProcessingPipeline pipeline = context.getProcessingPipeline();
+
// Perform link translation if requested
- if (env.getObjectModel().containsKey(Constants.LINK_OBJECT)) {
- context.getProcessingPipeline().addTransformer(
- "<translator>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS
- );
+ if (objectModel.containsKey(Constants.LINK_OBJECT)) {
+ pipeline.addTransformer("<translator>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
}
- if (env.getObjectModel().containsKey(Constants.LINK_COLLECTION_OBJECT) && env.isExternal()) {
- context.getProcessingPipeline().addTransformer(
- "<gatherer>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS
- );
+
+ if (objectModel.containsKey(Constants.LINK_COLLECTION_OBJECT) && env.isExternal()) {
+ pipeline.addTransformer("<gatherer>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
}
-
- ProcessingPipeline pipeline = context.getProcessingPipeline();
-
- Map objectModel = env.getObjectModel();
pipeline.setSerializer(
this.serializerName,
1.2 +40 -10 cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapNodeBuilder.java
Index: SitemapNodeBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapNodeBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SitemapNodeBuilder.java 9 Mar 2003 00:09:22 -0000 1.1
+++ SitemapNodeBuilder.java 12 Aug 2003 15:48:02 -0000 1.2
@@ -55,6 +55,7 @@
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNodeBuilder;
import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.components.treeprocessor.ProcessingNodeBuilder;
/**
* Builds all nodes below the top-level <sitemap> element, and returns the
@@ -66,20 +67,49 @@
*/
public class SitemapNodeBuilder extends AbstractParentProcessingNodeBuilder implements ThreadSafe {
+
+ // Name of children that have to be built in a particular order.
+ // For example, views have to be built before resources and both before pipelines.
+ private static final String[] orderedNames = { "components", "views", "resources" };
public ProcessingNode buildNode(Configuration config) throws Exception {
-
- ProcessingNode[] children = this.buildChildNodes(config);
-
+
+ // Start by explicitely ordered children
+ for (int i = 0; i < orderedNames.length; i++) {
+ Configuration childConfig = config.getChild(orderedNames[i], false);
+ if (childConfig != null) {
+ ProcessingNodeBuilder builder = this.treeBuilder.createNodeBuilder(childConfig);
+ // Don't build them since "pipelines" is not present in this list
+ builder.buildNode(childConfig);
+ }
+ }
+
ProcessingNode pipelines = null;
- for (int i = 0; i < children.length; i++) {
- if (children[i] instanceof PipelinesNode) {
- if (pipelines != null) {
- String msg = "Only one 'pipelines' is allowed, at " + config.getLocation();
- throw new ConfigurationException(msg);
+ // Now build all those that have no particular order
+ Configuration[] childConfigs = config.getChildren();
+
+ loop: for (int i = 0; i < childConfigs.length; i++) {
+
+ Configuration childConfig = childConfigs[i];
+ if (isChild(childConfig)) {
+ // Is it in the ordered list ?
+ for (int j = 0; j < orderedNames.length; j++) {
+ if (orderedNames[j].equals(childConfig.getName())) {
+ // yep : already built above
+ continue loop;
+ }
+ }
+
+ ProcessingNodeBuilder builder = this.treeBuilder.createNodeBuilder(childConfig);
+ ProcessingNode node = builder.buildNode(childConfig);
+ if (node instanceof PipelinesNode) {
+ if (pipelines != null) {
+ String msg = "Only one 'pipelines' is allowed, at " + childConfig.getLocation();
+ throw new ConfigurationException(msg);
+ }
+ pipelines = node;
}
- pipelines = children[i];
}
}
1.2 +14 -14 cocoon-2.1/src/java/org/apache/cocoon/sitemap/DefaultSitemapComponentSelector.java
Index: DefaultSitemapComponentSelector.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/sitemap/DefaultSitemapComponentSelector.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultSitemapComponentSelector.java 9 Mar 2003 00:09:38 -0000 1.1
+++ DefaultSitemapComponentSelector.java 12 Aug 2003 15:48:02 -0000 1.2
@@ -155,34 +155,34 @@
}
public boolean hasLabel(Object hint, String label) {
- String[] labels = (String[])this.hintLabels.get(hint);
+ String[] labels = this.getLabels(hint);
if (labels != null) {
for (int i = 0; i < labels.length; i++) {
if (labels[i].equals(label))
return true;
}
- } else if (parentSelector != null) {
- return parentSelector.hasLabel(hint, label);
}
return false;
}
public String[] getLabels(Object hint) {
- String[] labels = (String[])this.hintLabels.get(hint);
- // Labels can be inherited or completely overrided
- if (labels == null && parentSelector != null) {
+ // If this hint is declared locally, use its labels (if any), otherwise inherit
+ // those of the parent.
+ if (super.hasComponent(hint)) {
+ return (String[])this.hintLabels.get(hint);
+ } else {
return parentSelector.getLabels(hint);
- }
- return labels;
+ }
}
public String getPipelineHint(Object hint) {
- String pipelineHint = (String)this.pipelineHints.get(hint);
- // Pipeline-hints can be inherited or completely overrided
- if (pipelineHint == null && parentSelector != null) {
+ // If this hint is declared locally, use its hints (if any), otherwise inherit
+ // those of the parent.
+ if (super.hasComponent(hint)) {
+ return (String)this.pipelineHints.get(hint);
+ } else {
return parentSelector.getPipelineHint(hint);
- }
- return pipelineHint;
+ }
}
public void addComponent(Object hint, Class component, Configuration conf)
1.6 +6 -1 cocoon-2.1/src/webapp/samples/i18n/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/webapp/samples/i18n/sitemap.xmap,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- sitemap.xmap 29 Jul 2003 03:15:47 -0000 1.5
+++ sitemap.xmap 12 Aug 2003 15:48:02 -0000 1.6
@@ -6,6 +6,11 @@
<!-- =========================== Components ================================ -->
<map:components>
+ <map:generators default="file">
+ <!-- redefine the generators to remove their labels (otherwise aggregated parts also go through views) -->
+ <map:generator name="file" src="org.apache.cocoon.generation.FileGenerator" logger="sitemap.generator.file"/>
+ <map:generator name="serverpages" src="org.apache.cocoon.generation.ServerPagesGenerator" logger="sitemap.generator.serverpages"/>
+ </map:generators>
<map:transformers default="xslt">
<!-- Configure i18n transformer -->
<map:transformer name="i18n" logger="sitemap.transformer.i18n" src="org.apache.cocoon.transformation.I18nTransformer">