Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.2
-
None
-
None
Description
Suppose I have a subsitemap that generates XML documents, and then i want to mount it with different prefixes. For example :
<map:match pattern="*/doc/**">
<map:action ......>
<map:mount src="mysubfolder" location="{1}"/>
</map:match>
<map:match pattern="something/*/**">
<map:generate src="cocoon://{1}/doc/{2}"/>
<map:transform src="cocoon://otherprefix/doc/somethingelse"/>
....
The second call with cocoon:// fails with the cause that "/otherprefix/docs/blabla does not start with /originalprefix/".
This is because in MountNode getProcessor() the TreeProcessors are cached based on their source (mysubfolder/sitemap.xmap), but not regarding their prefix.
I "solved" this using also the prefix in the cache key :
Index: src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
===================================================================
--- src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java (revision 449416)
+++ src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java (working copy)
@@ -135,13 +135,13 @@
private synchronized TreeProcessor getProcessor(String source, String prefix)
throws Exception {
- TreeProcessor processor = (TreeProcessor) processors.get(source);
+ TreeProcessor processor = (TreeProcessor) processors.get(source + "||" + prefix);
if (processor == null) {
processor = this.parentProcessor.createChildProcessor(source, this.checkReload, prefix);
// Associate to the original source
- processors.put(source, processor);
+ processors.put(source + "||" + prefix, processor);
}
return processor;
But this means that two tree processors gets generated to represent the same sitemap, with only the prefix changing. I'm sure that there is a best way to do it.
<map:match pattern="*/doc/**">
<map:action ......>
<map:mount src="mysubfolder" location="{1}"/>
</map:match>
<map:match pattern="something/*/**">
<map:generate src="cocoon://{1}/doc/{2}"/>
<map:transform src="cocoon://otherprefix/doc/somethingelse"/>
....
The second call with cocoon:// fails with the cause that "/otherprefix/docs/blabla does not start with /originalprefix/".
This is because in MountNode getProcessor() the TreeProcessors are cached based on their source (mysubfolder/sitemap.xmap), but not regarding their prefix.
I "solved" this using also the prefix in the cache key :
Index: src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
===================================================================
--- src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java (revision 449416)
+++ src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java (working copy)
@@ -135,13 +135,13 @@
private synchronized TreeProcessor getProcessor(String source, String prefix)
throws Exception {
- TreeProcessor processor = (TreeProcessor) processors.get(source);
+ TreeProcessor processor = (TreeProcessor) processors.get(source + "||" + prefix);
if (processor == null) {
processor = this.parentProcessor.createChildProcessor(source, this.checkReload, prefix);
// Associate to the original source
- processors.put(source, processor);
+ processors.put(source + "||" + prefix, processor);
}
return processor;
But this means that two tree processors gets generated to represent the same sitemap, with only the prefix changing. I'm sure that there is a best way to do it.