You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by "Gregor J. Rothfuss" <gr...@apache.org> on 2004/09/03 02:26:01 UTC

passthrough sitemaps

might be a cleaner way than the fallback module we currently use.

wdyt?

-------- Original Message --------
Subject: svn commit: rev 37379 - in cocoon/trunk: . 
src/java/org/apache/cocoon/components/treeprocessor/sitemap
Date: 2 Sep 2004 14:07:24 -0000
From: nicolaken@apache.org
Reply-To: dev@cocoon.apache.org
Newsgroups: gmane.text.xml.cocoon.cvs

Author: nicolaken
Date: Thu Sep  2 07:07:22 2004
New Revision: 37379

Modified:
 
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
 
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNodeBuilder.java
 
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java
    cocoon/trunk/status.xml
Log:
     <action dev="NKB" type="add">
      New @pass-through attribute for the sitemap mount node.
      If true, processing will resume in the base sitemap just after the 
mount node
      if the mounted sitemap has not already generated output (usually 
if no match
      is found). Previous behaviour was always to throw a 
ResourceNotFoundException.
      The attribute defaults to "false" for backwards compatibility.
    </action>

  _SIDENOTE_ Also fixed a validation error in status.xml

Modified: 
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
==============================================================================
--- 
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java 
(original)
+++ 
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java 
Thu Sep  2 07:07:22 2004
@@ -32,7 +32,7 @@
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn 
L&uuml;tkemeier</a>
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: MountNode.java,v 1.15 2004/06/24 13:18:01 
cziegeler Exp $
+ * @version CVS $Id$
   */
  public class MountNode extends AbstractProcessingNode
  implements Disposable {
@@ -52,14 +52,22 @@
      /** The value of the 'check-reload' attribute */
      private final boolean checkReload;

+    /** The value of the 'pass-through' attribute */
+    private final boolean passThrough;
+
+    /** The  key to get the pass_through value fron the Environment*/
+    protected final static String COCOON_PASS_THROUGH = new 
String("COCOON_PASS_THROUGH");
+
      public MountNode(VariableResolver prefix,
                       VariableResolver source,
                       TreeProcessor parentProcessor,
-                     boolean checkReload) {
+                     boolean checkReload,
+                     boolean passThrough) {
          this.prefix = prefix;
          this.source = source;
          this.parentProcessor = parentProcessor;
          this.checkReload = checkReload;
+        this.passThrough = passThrough;
      }

      /* (non-Javadoc)
@@ -68,6 +76,9 @@
      public final boolean invoke(Environment env, InvokeContext context)
      throws Exception {

+        Object previousPassThrough = env.getAttribute(COCOON_PASS_THROUGH);
+        env.setAttribute(COCOON_PASS_THROUGH,Boolean.valueOf(passThrough));
+
          final Map objectModel = env.getObjectModel();

          String resolvedSource = this.source.resolve(context, objectModel);
@@ -102,7 +113,11 @@
          } finally {
              // Restore context
              env.setURI(oldPrefix, oldURI);
-
+            if(previousPassThrough != null){
+               env.setAttribute(COCOON_PASS_THROUGH,previousPassThrough);
+            }else{
+               env.removeAttribute(COCOON_PASS_THROUGH);
+            }
              // Turning recomposing as a test, according to:
              // http://marc.theaimsgroup.com/?t=106802211400005&r=1&w=2
              // Recompose pipelines which may have been recomposed by 
subsitemap

Modified: 
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNodeBuilder.java
==============================================================================
--- 
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNodeBuilder.java 
(original)
+++ 
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNodeBuilder.java 
Thu Sep  2 07:07:22 2004
@@ -24,7 +24,7 @@
  /**
   *
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: MountNodeBuilder.java,v 1.4 2004/06/05 08:18:50 
sylvain Exp $
+ * @version CVS $Id$
   */

  public class MountNodeBuilder extends AbstractProcessingNodeBuilder 
implements ThreadSafe {
@@ -40,8 +40,10 @@
 
VariableResolverFactory.getResolver(config.getAttribute("uri-prefix"), 
manager),
 
VariableResolverFactory.getResolver(config.getAttribute("src"), manager),
              this.treeBuilder.getProcessor().getWrappingProcessor(),
-            config.getAttributeAsBoolean("check-reload", true)
+            config.getAttributeAsBoolean("check-reload", true),
+            config.getAttributeAsBoolean("pass-through", false)
          );
+
          return (this.treeBuilder.setupNode(node, config));
      }
  }

Modified: 
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java
==============================================================================
--- 
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java 
(original)
+++ 
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java 
Thu Sep  2 07:07:22 2004
@@ -26,6 +26,7 @@
  import org.apache.cocoon.components.treeprocessor.InvokeContext;
  import 
org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode;
  import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.components.treeprocessor.sitemap.MountNode;
  import org.apache.cocoon.environment.Environment;

  /**
@@ -36,7 +37,7 @@
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   * @author <a href="mailto:gianugo@apache.org">Gianugo Rabellino</a>
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: PipelineNode.java,v 1.17 2004/07/15 12:49:50 
sylvain Exp $
+ * @version CVS $Id$
   */
  public class PipelineNode
          extends AbstractParentProcessingNode
@@ -114,6 +115,17 @@
      public final boolean invoke(Environment env, InvokeContext context)
      throws Exception {

+        boolean passThrough;
+
+        Object passThroughRaw = 
env.getAttribute(MountNode.COCOON_PASS_THROUGH);
+
+        if(passThroughRaw == null){
+            //use legacy default value
+            passThrough = false;
+        }else{
+            passThrough = ((Boolean)passThroughRaw).booleanValue() ;
+        }
+
          boolean externalRequest = env.isExternal();

          // Always fail on external request if pipeline is internal only.
@@ -125,7 +137,7 @@
          try {
              if (invokeNodes(children, env, context)) {
                  return true;
-            } else if (!this.isLast) {
+            } else if (!this.isLast || passThrough) {
                  return false;
              } else {
                  throw new ResourceNotFoundException("No pipeline 
matched request: " +

Modified: cocoon/trunk/status.xml
==============================================================================
--- cocoon/trunk/status.xml	(original)
+++ cocoon/trunk/status.xml	Thu Sep  2 07:07:22 2004
@@ -204,6 +204,13 @@

    <changes>
   <release version="@version@" date="@date@">
+    <action dev="NKB" type="add">
+     New @pass-through attribute for the sitemap mount node.
+     If true, processing will resume in the base sitemap just after the 
mount node
+     if the mounted sitemap has not already generated output (usually 
if no match
+     is found). Previous behaviour was always to throw a 
ResourceNotFoundException.
+     The attribute defaults to "false" for backwards compatibility.
+   </action>
     <action dev="CZ" type="add">
       New getSitemapPath() method on the Request object to get the path 
to the
       current sitemap even if you are in a sub sitemap. Added an 
abstract request
@@ -326,7 +333,7 @@
     <action dev="VG" type="update">
       Reworked LocaleAction and LocaleMatcher to have similar logic and
       configuration.
-     <br/><strong>NOTE:</strong> Sitemap variable "lang" renamed to
+     <br/>NOTE: Sitemap variable "lang" renamed to
       "language", removed configuration parameters: "language-attribute",
       "country-attribute", "variant-attribute".
     </action>



-- 
Gregor J. Rothfuss
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://wyona.com                   http://cocoon.apache.org/lenya
gregor.rothfuss@wyona.com                       gregor@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-dev-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-dev-help@cocoon.apache.org


Re: passthrough sitemaps

Posted by Andreas Hartmann <an...@apache.org>.
Rolf Kulemann wrote:

[...]

>>
>>Yes, but ATM you need usecase-*.xmap files instead of a single
>>usecase.xmap in your publication. This won't be necessary with the
>>new technology.
> 
> 
> Why wasn't it possible before ? (sorry for the silly question)

Because you couldn't find out if a particular usecase is
overridden in the <pub>/usecase.xmap.

> What is the advantage of having only one usecase.xmap?

You can share pipelines between different usecases.
With multiple usecase-*.xmap files, you have to mount
a shared sitemap from different sitemaps to achieve this.

> Advantages of having different usecase-*.xmaps are imho
> 
> * better modularisation
> * -> more maintainable
> * easier to keep js,jx etc files included in the sub sitemaps close to
> the usecase they belong to, if we also keep the usecases with its
> resources in a different directory.

You can still dispatch the request to multiple <pub>/usecase-*.xmap
files from <pub>/usecase.xmap.

-- Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-dev-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-dev-help@cocoon.apache.org


Re: passthrough sitemaps

Posted by Rolf Kulemann <ro...@apache.org>.
On Fri, 2004-09-03 at 10:55, Andreas Hartmann wrote:
> Rolf Kulemann wrote:
> > On Fri, 2004-09-03 at 09:40, Andreas Hartmann wrote:
> > 
> >>Gregor J. Rothfuss wrote:
> >>
> >>>might be a cleaner way than the fallback module we currently use.
> >>>
> >>>wdyt?
> >>
> >>
> >>>    <action dev="NKB" type="add">
> >>>     New @pass-through attribute for the sitemap mount node.
> >>>     If true, processing will resume in the base sitemap just after the 
> >>>mount node
> >>>     if the mounted sitemap has not already generated output (usually if 
> >>>no match
> >>>     is found). Previous behaviour was always to throw a 
> >>>ResourceNotFoundException.
> >>>     The attribute defaults to "false" for backwards compatibility.
> >>>   </action>
> >>
> >>
> >>I guess this works fine for the usecase.xmap problem, we wouldn't need
> >>single usecase sitemaps in publications anymore.
> > 
> > 
> > Mmhh, why? I thought publications can have their own, additional, or
> > overriden usecases? 
> 
> Yes, but ATM you need usecase-*.xmap files instead of a single
> usecase.xmap in your publication. This won't be necessary with the
> new technology.

Why wasn't it possible before ? (sorry for the silly question)
What is the advantage of having only one usecase.xmap?

Advantages of having different usecase-*.xmaps are imho

* better modularisation
* -> more maintainable
* easier to keep js,jx etc files included in the sub sitemaps close to
the usecase they belong to, if we also keep the usecases with its
resources in a different directory.

-- 
Rolf Kulemann


---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-dev-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-dev-help@cocoon.apache.org


Re: passthrough sitemaps

Posted by Andreas Hartmann <an...@apache.org>.
Rolf Kulemann wrote:
> On Fri, 2004-09-03 at 09:40, Andreas Hartmann wrote:
> 
>>Gregor J. Rothfuss wrote:
>>
>>>might be a cleaner way than the fallback module we currently use.
>>>
>>>wdyt?
>>
>>
>>>    <action dev="NKB" type="add">
>>>     New @pass-through attribute for the sitemap mount node.
>>>     If true, processing will resume in the base sitemap just after the 
>>>mount node
>>>     if the mounted sitemap has not already generated output (usually if 
>>>no match
>>>     is found). Previous behaviour was always to throw a 
>>>ResourceNotFoundException.
>>>     The attribute defaults to "false" for backwards compatibility.
>>>   </action>
>>
>>
>>I guess this works fine for the usecase.xmap problem, we wouldn't need
>>single usecase sitemaps in publications anymore.
> 
> 
> Mmhh, why? I thought publications can have their own, additional, or
> overriden usecases? 

Yes, but ATM you need usecase-*.xmap files instead of a single
usecase.xmap in your publication. This won't be necessary with the
new technology.

-- Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-dev-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-dev-help@cocoon.apache.org


Re: passthrough sitemaps

Posted by Rolf Kulemann <ro...@apache.org>.
On Fri, 2004-09-03 at 09:40, Andreas Hartmann wrote:
> Gregor J. Rothfuss wrote:
> > might be a cleaner way than the fallback module we currently use.
> > 
> > wdyt?
> 
> 
> >     <action dev="NKB" type="add">
> >      New @pass-through attribute for the sitemap mount node.
> >      If true, processing will resume in the base sitemap just after the 
> > mount node
> >      if the mounted sitemap has not already generated output (usually if 
> > no match
> >      is found). Previous behaviour was always to throw a 
> > ResourceNotFoundException.
> >      The attribute defaults to "false" for backwards compatibility.
> >    </action>
> 
> 
> I guess this works fine for the usecase.xmap problem, we wouldn't need
> single usecase sitemaps in publications anymore.

Mmhh, why? I thought publications can have their own, additional, or
overriden usecases? 

-- 
Rolf Kulemann


---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-dev-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-dev-help@cocoon.apache.org


Re: passthrough sitemaps

Posted by Andreas Hartmann <an...@apache.org>.
Gregor J. Rothfuss wrote:
> might be a cleaner way than the fallback module we currently use.
> 
> wdyt?


>     <action dev="NKB" type="add">
>      New @pass-through attribute for the sitemap mount node.
>      If true, processing will resume in the base sitemap just after the 
> mount node
>      if the mounted sitemap has not already generated output (usually if 
> no match
>      is found). Previous behaviour was always to throw a 
> ResourceNotFoundException.
>      The attribute defaults to "false" for backwards compatibility.
>    </action>


I guess this works fine for the usecase.xmap problem, we wouldn't need
single usecase sitemaps in publications anymore.

But it wouldn't be a replacement for fallback, because it is required
that the mounted sitemap exists.

-- Andreas



---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-dev-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-dev-help@cocoon.apache.org