You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Nicola Ken Barozzi <ni...@apache.org> on 2004/09/03 08:35:30 UTC

cocoon:/ protocol bug in 2.2?

I've updated Cocoon to use 2.2-dev to test the new pass-through stuff, 
and one thing is not working as before. In a subsitemap, I do a cocoon:/ 
call and it does not work. It works when I put the things to call in the 
base sitemap, but wasn't that cocoon:// (which BTW seems to work correctly)?

-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


Re: cocoon:/ protocol bug in 2.2?

Posted by Andreas Hartmann <an...@apache.org>.
Andreas Hartmann wrote:
> Nicola Ken Barozzi wrote:
> 
>>
>> I've updated Cocoon to use 2.2-dev to test the new pass-through stuff, 
>> and one thing is not working as before. In a subsitemap, I do a 
>> cocoon:/ call and it does not work. It works when I put the things to 
>> call in the base sitemap, but wasn't that cocoon:// (which BTW seems 
>> to work correctly)?
>>

[...]

> Maybe a slash finds its way into the URI so that
> it results in a cocoon:// call?

Apparently not:

DEBUG   (2004-09-22) 15:57.59:476   [sitemap] 
(/default/authoring/info-sitetree/sitetree.js) 
PoolThread-1/SitemapSourceFactory: Creating source object for 
cocoon:/default/authoring/sitetree.xml

OK, I'll do some further investigation.

-- Andreas


Re: cocoon:/ protocol bug in 2.2?

Posted by Andreas Hartmann <an...@apache.org>.
Andreas Hartmann wrote:
> Andreas Hartmann wrote:
> 
>> Nicola Ken Barozzi wrote:
>>
>>>
>>> I've updated Cocoon to use 2.2-dev to test the new pass-through 
>>> stuff, and one thing is not working as before. In a subsitemap, I do 
>>> a cocoon:/ call and it does not work. It works when I put the things 
>>> to call in the base sitemap, but wasn't that cocoon:// (which BTW 
>>> seems to work correctly)?

I filed a bug:

http://issues.apache.org/bugzilla/show_bug.cgi?id=31363

-- Andreas


Re: cocoon:/ protocol bug in 2.2?

Posted by Andreas Hartmann <an...@apache.org>.
Carsten Ziegeler wrote:
> Looks good to me; and you beat me by one minute in submitting the patch :(

commit wars :)

Sorry for that,
-- Andreas


RE: cocoon:/ protocol bug in 2.2?

Posted by Carsten Ziegeler <cz...@apache.org>.
Looks good to me; and you beat me by one minute in submitting the patch :(

Thanks
Carsten 

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Andreas Hartmann
> Sent: Wednesday, September 22, 2004 7:20 PM
> To: dev@cocoon.apache.org
> Subject: Re: cocoon:/ protocol bug in 2.2?
> 
> Vadim Gritsenko wrote:
> > Andreas Hartmann wrote:
> > 
> >> - Is it allowed to mount sitemaps with an empty URI prefix?
> >>   If not, the problem will not appear.
> >>   If yes, what can I do about it?
> > 
> > 
> > Yes, it should be. Can you make a patch fixing it? :)
> 
> It seems that the SitemapSource cannot rely on the 
> SitemapSourceInfo.prefix to determine the target processor.
> 
> That's why I would add a boolean field
> 
>    SitemapSourceInfo.processFromRoot
> 
> 
> // does the uri point to this sitemap or to the root sitemap?
> if (sitemapURI.startsWith("//", position)) {
>      position += 2;
>      info.processFromRoot = true;
>      info.prefix = "";
> } else if (sitemapURI.startsWith("/", position)) {
>      position ++;
>      info.processFromRoot = false;
>      info.prefix = env.getURIPrefix();
> } else {
>      throw new MalformedURLException("Malformed cocoon URI: " 
> + sitemapURI); }
> 
> 
> SitemapSource:
> 
> // does the uri point to this sitemap or to the root sitemap?
> if (info.processFromRoot) {
>      this.processor =
> EnvironmentHelper.getCurrentProcessor().getRootProcessor();
> } else {
>      this.processor = EnvironmentHelper.getCurrentProcessor();
> }
> 
> 
> That seems to do the trick, at least in my application.
> If you think it is appropriate and sufficient, I'll
> commit it to the trunk.
> 
> -- Andreas
> 
> 


Re: cocoon:/ protocol bug in 2.2?

Posted by Andreas Hartmann <an...@apache.org>.
Vadim Gritsenko wrote:
> Andreas Hartmann wrote:
> 
>> - Is it allowed to mount sitemaps with an empty URI prefix?
>>   If not, the problem will not appear.
>>   If yes, what can I do about it?
> 
> 
> Yes, it should be. Can you make a patch fixing it? :)

It seems that the SitemapSource cannot rely on the
SitemapSourceInfo.prefix to determine the target processor.

That's why I would add a boolean field

   SitemapSourceInfo.processFromRoot


// does the uri point to this sitemap or to the root sitemap?
if (sitemapURI.startsWith("//", position)) {
     position += 2;
     info.processFromRoot = true;
     info.prefix = "";
} else if (sitemapURI.startsWith("/", position)) {
     position ++;
     info.processFromRoot = false;
     info.prefix = env.getURIPrefix();
} else {
     throw new MalformedURLException("Malformed cocoon URI: " + sitemapURI);
}


SitemapSource:

// does the uri point to this sitemap or to the root sitemap?
if (info.processFromRoot) {
     this.processor = 
EnvironmentHelper.getCurrentProcessor().getRootProcessor();
} else {
     this.processor = EnvironmentHelper.getCurrentProcessor();
}


That seems to do the trick, at least in my application.
If you think it is appropriate and sufficient, I'll
commit it to the trunk.

-- Andreas


Re: cocoon:/ protocol bug in 2.2?

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Andreas Hartmann wrote:

> - Is it allowed to mount sitemaps with an empty URI prefix?
>   If not, the problem will not appear.
>   If yes, what can I do about it?

Yes, it should be. Can you make a patch fixing it? :)

Vadim


Re: cocoon:/ protocol bug in 2.2?

Posted by Andreas Hartmann <an...@apache.org>.
Andreas Hartmann wrote:
> Nicola Ken Barozzi wrote:
> 
>>
>> I've updated Cocoon to use 2.2-dev to test the new pass-through stuff, 
>> and one thing is not working as before. In a subsitemap, I do a 
>> cocoon:/ call and it does not work. It works when I put the things to 
>> call in the base sitemap, but wasn't that cocoon:// (which BTW seems 
>> to work correctly)?
>>
> 
> I can confirm the problem.
> 
> Test case: Lenya 1.4-dev (trunk) with Cocoon 2.2 (trunk)
> 
> The sub-sitemap is mounted using
> 
> <map:match pattern="*/*/info-sitetree/**">
>   <map:mount uri-prefix="" src="lenya/info.xmap"
>              check-reload="true" reload-method="synchron"/>
> </map:match>
> 
> (BTW, is it allowed to have an empty URI prefix here?
> Carsten just told me it has to end with a slash)
> 
> 
> The cocoon:/ call in info.xmap
> 
>   <map:match pattern="*/*/info-sitetree/sitetree.js">
>     <map:aggregate element="lenya" label="aggregate">
>       <map:part src="cocoon:/{1}/authoring/sitetree.xml"/>
>         ...
> 
> goes directly to the root sitemap instead of staying in
> info.xmap.

I think I tracked it down.

--------------------------------------------------------

SitemapSourceInfo.parseURI() (I added some logging):


// does the uri point to this sitemap or to the root sitemap?
if (sitemapURI.startsWith("//", position)) {
     position += 2;
     info.prefix = ""; // start at the root
} else if (sitemapURI.startsWith("/", position)) {
     position ++;
     info.prefix = env.getURIPrefix();
} else {
     throw new MalformedURLException("Malformed cocoon URI: " + sitemapURI);
}

logger.debug("Sitemap URI: [" + sitemapURI + "]");
logger.debug("URI prefix: [" + env.getURIPrefix() + "]");
logger.debug("Prefix: [" + info.prefix + "]");

--------------------------------------------------------

results in:

SitemapSourceInfo: Sitemap URI: [cocoon:/default/trash/sitetree.xml]
SitemapSourceInfo: URI prefix: []
SitemapSourceInfo: Prefix: []

I guess the URI prefix is empty because the sitemap was mounted
using an empty URI prefix.

--------------------------------------------------------

SitemapSource:

// does the uri point to this sitemap or to the root sitemap?
if (info.prefix.length() == 0) {
     this.processor = 
EnvironmentHelper.getCurrentProcessor().getRootProcessor();
} else {
     this.processor = EnvironmentHelper.getCurrentProcessor();
}

--------------------------------------------------------

This means the root sitemap processor is used.

Some questions:

- Is this behaviour intended?

- Is it allowed to mount sitemaps with an empty URI prefix?
   If not, the problem will not appear.
   If yes, what can I do about it?


Thanks in advance,
-- Andreas


Re: cocoon:/ protocol bug in 2.2?

Posted by Andreas Hartmann <an...@apache.org>.
Nicola Ken Barozzi wrote:
> 
> I've updated Cocoon to use 2.2-dev to test the new pass-through stuff, 
> and one thing is not working as before. In a subsitemap, I do a cocoon:/ 
> call and it does not work. It works when I put the things to call in the 
> base sitemap, but wasn't that cocoon:// (which BTW seems to work 
> correctly)?
>

I can confirm the problem.

Test case: Lenya 1.4-dev (trunk) with Cocoon 2.2 (trunk)

The sub-sitemap is mounted using

<map:match pattern="*/*/info-sitetree/**">
   <map:mount uri-prefix="" src="lenya/info.xmap"
              check-reload="true" reload-method="synchron"/>
</map:match>

(BTW, is it allowed to have an empty URI prefix here?
Carsten just told me it has to end with a slash)


The cocoon:/ call in info.xmap

   <map:match pattern="*/*/info-sitetree/sitetree.js">
     <map:aggregate element="lenya" label="aggregate">
       <map:part src="cocoon:/{1}/authoring/sitetree.xml"/>
         ...

goes directly to the root sitemap instead of staying in
info.xmap. Maybe a slash finds its way into the URI so that
it results in a cocoon:// call?


-- Andreas


Re: cocoon:/ protocol bug in 2.2?

Posted by Andreas Hartmann <an...@apache.org>.
Nicola Ken Barozzi wrote:
> Carsten Ziegeler wrote:
> 
>> Hmm, I just tested latest trunk from SVN and it works for me.
>> For example our samples:
>>
>> http://localhost:8888/samples/sources/xsl-cocoon
>> or the portal work very well and they all use the cocoon:/
>> protocol.
>>
>> Can you provide a test-case?
> 
> 
> In the base sitemap I put:
> 
>       <map:pipeline internal-only="false">
>         <map:match pattern="*.xml">
>            <map:select type="exists">
>              <map:when test="subsitemap.xmap">
>                <map:mount uri-prefix=""
>                           src="subsitemap.xmap"
>                           check-reload="yes"/>


OK, this seems to affirm my results, you mount the sitemap
using an empty URI prefix as well.

-- Andreas



Re: cocoon:/ protocol bug in 2.2?

Posted by Nicola Ken Barozzi <ni...@apache.org>.
Carsten Ziegeler wrote:
> Hmm, I just tested latest trunk from SVN and it works for me.
> For example our samples:
> 
> http://localhost:8888/samples/sources/xsl-cocoon 
> 
> or the portal work very well and they all use the cocoon:/
> protocol.
> 
> Can you provide a test-case?

In the base sitemap I put:

       <map:pipeline internal-only="false">
         <map:match pattern="*.xml">
            <map:select type="exists">
              <map:when test="subsitemap.xmap">
                <map:mount uri-prefix=""
                           src="subsitemap.xmap"
                           check-reload="yes"/>
              </map:when>
            </map:select>
          </map:match>
       </map:pipeline>

Then in the subsitemap I put:

   <map:pipelines>

       <map:pipeline internal-only="false">
          <map:match pattern="test2.xml">
            <map:generate src="index2.xml" />
            <map:serialize type="xml" />
          </map:match>
        </map:pipeline>

       <map:pipeline internal-only="false">
          <map:match pattern="test.xml">
            <map:generate src="cocoon:/index2.internal" />
            <map:serialize type="xml" />
          </map:match>
        </map:pipeline>

       <map:pipeline internal-only="true">
          <map:match pattern="*.internal">
            <map:generate src="{1}.xml" />
            <map:serialize type="xml" />
          </map:match>
        </map:pipeline>

    </map:pipelines>

Then test2.xml gives output, test.xml does not.

Note that if I remove the match in the base sitemap, both tests work 
even if the internal pipeline in the subsitemap is still hidden from 
direct calls.

-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


RE: cocoon:/ protocol bug in 2.2?

Posted by Carsten Ziegeler <cz...@apache.org>.
Hmm, I just tested latest trunk from SVN and it works for me.
For example our samples:

http://localhost:8888/samples/sources/xsl-cocoon 

or the portal work very well and they all use the cocoon:/
protocol.

Can you provide a test-case?

Carsten

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Nicola Ken Barozzi
> Sent: Friday, September 03, 2004 8:36 AM
> To: dev@cocoon.apache.org
> Subject: cocoon:/ protocol bug in 2.2?
> 
> 
> I've updated Cocoon to use 2.2-dev to test the new 
> pass-through stuff, and one thing is not working as before. 
> In a subsitemap, I do a cocoon:/ call and it does not work. 
> It works when I put the things to call in the base sitemap, 
> but wasn't that cocoon:// (which BTW seems to work correctly)?
> 
> -- 
> Nicola Ken Barozzi                   nicolaken@apache.org
>              - verba volant, scripta manent -
>     (discussions get forgotten, just code remains)
> ---------------------------------------------------------------------
> 
>