You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by footh <fo...@yahoo.com> on 2006/08/11 22:41:01 UTC

Forcing error in sitemap

I have a sitemap that first goes through a javaflow,
then is forwarded to an aggregation of several
different pieces.

One of those pieces is the main content.  If a URL is
requested that doesn't exist, grabbing the main
content will cause a null error in the pipeline (but
since it "matches" a pipeline, a 404 error will not be
thrown).

I need these instances to produce 404 error because
I'm getting killed by search engines that are
requesting URLs that don't exist anymore. They are not
getting 404 so they keep trying the URLs which causes
my log file to balloon in size.

So, anyway, I've figured out I should use the
"resource-exists" selector on the main content
aggregation part.  But, if the resource doesn't exist,
I want to force a 404 error so the "handle-errors"
block properly handles the error.  However, I can't
figure out how to generate an error that moves the
sitemap processing to the handle-errors block.  Here
is the pipeline snippet in question:

<map:match pattern="**-content">
  <map:select type="resource-exists">
    <map:when test="documents/{1}.xml">
      <map:generate type="jx"
src="documents/{1}.xml"/>
      <map:serialize type="xml"/>
    </map:when>
    <map:otherwise>
    <!-- force 404 error here!!! -->
    </map:otherwise>      
  </map:select>
</map:match>

So, in the "otherwise" block, I'd like to force a 404
error.  I'm hoping there is a really simple way to do
this.  Anyone have a suggestion?

Thanks,

JF


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Forcing error in sitemap

Posted by footh <fo...@yahoo.com>.
Actually, I think I found a solution...by not even
trying.

Before, I was trying different things in the
"otherwise" block.  But then I just left it blank and
forgot about it.  Then, I mistakenly went to a bad URL
and the 404 error showed up!

So, basically, if a pipeline doesn't return anything,
I've concluded that a resource-not-found error occurs.

--- "Steven D. Majewski" <sd...@virginia.edu> wrote:

> Well: how about just throwing an error from
> flowscript ?
> 
> ( or from java. The problem with flowscript is that
> the sitemap uses  
> java exceptions,
>    and I think all of the rhino exceptions are going
> to get mapped  
> into JavaScriptException's
>    in java. )
> 
> -- Steve Majewski
> 
> 
> On Aug 11, 2006, at 6:24 PM, footh wrote:
> 
> >
> > The problem, this sitemap snippet is three deep in
> the
> > chain.  The first pipeline calls the javaflow
> which
> > forwards to the second pipeline which contains an
> > "aggregation" tag that aggregrates the header,
> > sidebars, and main content into one big xml page.
> > Each of these is a separate internal pipeline. 
> It's
> > the "main content" internal pipeline that bombs on
> a
> > bad URL (the header and sidebar content is always
> in
> > the same spot regardless of the URL).
> >
> > So, if I serialize with 404 error, nothing happens
> > (had already tried this) because this pipeline is
> only
> > one piece of the eventual response.  That's why I
> need
> > to "force" the error so the handle-errors block
> deals
> > with it.
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail:
> users-help@cocoon.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Forcing error in sitemap

Posted by "Steven D. Majewski" <sd...@virginia.edu>.
Well: how about just throwing an error from flowscript ?

( or from java. The problem with flowscript is that the sitemap uses  
java exceptions,
   and I think all of the rhino exceptions are going to get mapped  
into JavaScriptException's
   in java. )

-- Steve Majewski


On Aug 11, 2006, at 6:24 PM, footh wrote:

>
> The problem, this sitemap snippet is three deep in the
> chain.  The first pipeline calls the javaflow which
> forwards to the second pipeline which contains an
> "aggregation" tag that aggregrates the header,
> sidebars, and main content into one big xml page.
> Each of these is a separate internal pipeline.  It's
> the "main content" internal pipeline that bombs on a
> bad URL (the header and sidebar content is always in
> the same spot regardless of the URL).
>
> So, if I serialize with 404 error, nothing happens
> (had already tried this) because this pipeline is only
> one piece of the eventual response.  That's why I need
> to "force" the error so the handle-errors block deals
> with it.


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


Re: Forcing error in sitemap

Posted by footh <fo...@yahoo.com>.
Thanks for the reply.

The problem, this sitemap snippet is three deep in the
chain.  The first pipeline calls the javaflow which
forwards to the second pipeline which contains an
"aggregation" tag that aggregrates the header,
sidebars, and main content into one big xml page. 
Each of these is a separate internal pipeline.  It's
the "main content" internal pipeline that bombs on a
bad URL (the header and sidebar content is always in
the same spot regardless of the URL).

So, if I serialize with 404 error, nothing happens
(had already tried this) because this pipeline is only
one piece of the eventual response.  That's why I need
to "force" the error so the handle-errors block deals
with it.

--- "Steven D. Majewski" <sd...@virginia.edu> wrote:

> 
> 
> You can generate the 404 error by specifying  a
> status-code for  
> serialize:
> 
>     <map:serialize type="xml" status-code="404"/>
> 
> But you'll also need some sort of dummy/error
> document to be serialized.
> 
> Or (I think) you can do a cocoon.sendStatus( 404 )
> from flowscript.
> 
> But I thought that the error handler would only
> catch exceptions.
> This would be a successful completion of a pipeline
> that resulted in  
> a 404 error to the browser,
> so I would think it would not trigger the
> handle-errors block.
> 
> ( I'm new to this myself, so correct me if I'm
> wrong.
>    I only chimed in because I'm working on something
> like the above
>    in my sitemap right now. )
> 
> 
> -- Steve Majewski
> 
> 
> On Aug 11, 2006, at 4:41 PM, footh wrote:
> 
> > I have a sitemap that first goes through a
> javaflow,
> > then is forwarded to an aggregation of several
> > different pieces.
> >
> > One of those pieces is the main content.  If a URL
> is
> > requested that doesn't exist, grabbing the main
> > content will cause a null error in the pipeline
> (but
> > since it "matches" a pipeline, a 404 error will
> not be
> > thrown).
> >
> > I need these instances to produce 404 error
> because
> > I'm getting killed by search engines that are
> > requesting URLs that don't exist anymore. They are
> not
> > getting 404 so they keep trying the URLs which
> causes
> > my log file to balloon in size.
> >
> > So, anyway, I've figured out I should use the
> > "resource-exists" selector on the main content
> > aggregation part.  But, if the resource doesn't
> exist,
> > I want to force a 404 error so the "handle-errors"
> > block properly handles the error.  However, I
> can't
> > figure out how to generate an error that moves the
> > sitemap processing to the handle-errors block. 
> Here
> > is the pipeline snippet in question:
> >
> > <map:match pattern="**-content">
> >   <map:select type="resource-exists">
> >     <map:when test="documents/{1}.xml">
> >       <map:generate type="jx"
> > src="documents/{1}.xml"/>
> >       <map:serialize type="xml"/>
> >     </map:when>
> >     <map:otherwise>
> >     <!-- force 404 error here!!! -->
> >     </map:otherwise>
> >   </map:select>
> > </map:match>
> >
> > So, in the "otherwise" block, I'd like to force a
> 404
> > error.  I'm hoping there is a really simple way to
> do
> > this.  Anyone have a suggestion?
> >
> > Thanks,
> >
> > JF
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail:
> users-help@cocoon.apache.org
> >
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail:
> users-help@cocoon.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Forcing error in sitemap

Posted by "Steven D. Majewski" <sd...@virginia.edu>.

You can generate the 404 error by specifying  a status-code for  
serialize:

    <map:serialize type="xml" status-code="404"/>

But you'll also need some sort of dummy/error document to be serialized.

Or (I think) you can do a cocoon.sendStatus( 404 ) from flowscript.

But I thought that the error handler would only catch exceptions.
This would be a successful completion of a pipeline that resulted in  
a 404 error to the browser,
so I would think it would not trigger the handle-errors block.

( I'm new to this myself, so correct me if I'm wrong.
   I only chimed in because I'm working on something like the above
   in my sitemap right now. )


-- Steve Majewski


On Aug 11, 2006, at 4:41 PM, footh wrote:

> I have a sitemap that first goes through a javaflow,
> then is forwarded to an aggregation of several
> different pieces.
>
> One of those pieces is the main content.  If a URL is
> requested that doesn't exist, grabbing the main
> content will cause a null error in the pipeline (but
> since it "matches" a pipeline, a 404 error will not be
> thrown).
>
> I need these instances to produce 404 error because
> I'm getting killed by search engines that are
> requesting URLs that don't exist anymore. They are not
> getting 404 so they keep trying the URLs which causes
> my log file to balloon in size.
>
> So, anyway, I've figured out I should use the
> "resource-exists" selector on the main content
> aggregation part.  But, if the resource doesn't exist,
> I want to force a 404 error so the "handle-errors"
> block properly handles the error.  However, I can't
> figure out how to generate an error that moves the
> sitemap processing to the handle-errors block.  Here
> is the pipeline snippet in question:
>
> <map:match pattern="**-content">
>   <map:select type="resource-exists">
>     <map:when test="documents/{1}.xml">
>       <map:generate type="jx"
> src="documents/{1}.xml"/>
>       <map:serialize type="xml"/>
>     </map:when>
>     <map:otherwise>
>     <!-- force 404 error here!!! -->
>     </map:otherwise>
>   </map:select>
> </map:match>
>
> So, in the "otherwise" block, I'd like to force a 404
> error.  I'm hoping there is a really simple way to do
> this.  Anyone have a suggestion?
>
> Thanks,
>
> JF
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


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