cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Gritsenko <vadim.gritse...@verizon.net>
Subject Re: New error handling
Date Wed, 16 Apr 2003 13:51:23 GMT
Upayavira wrote:

>>>Is there a way that I can find out that a page has failed (either
>>>through an exception or an error code) so that I can prevent the CLI
>>>      
>>>
>>>from just accept the default page served back?
>>    
>>
>
>  
>
>>I would recommend:
>>
>>1. Implement setStatus() in AbstractCommandLineEnvironment 
>>(implementation is empty right now)
>>2. Add getStatus() to the AbstractCommandLineEnvironment
>>3. Test getStatus() in the CLI crawling code.
>>4. Test how it works and fix the broken link :)
>>    
>>
>
>So you're saying that the treeprocessor (or whatever) will 
>

Not will, but does! This was done long time ago (for http), otherwise 
how you will get 404 in the browser? :)


>call the setStatus() method 
>on the environment to tell it whether page generation succeeded. Then all I need to 
>do is store that within the environment and use it. Is this correct?
>

Yes, this is correct.


>Similarly, based upon comments from Nicola Ken ages ago:
>
>  
>
>>>In the Environment there is
>>>
>>>    boolean isResponseModified(long lastModified);
>>>    void setResponseIsNotModified();
>>>
>>>But it's never implemented. In AbstractEnvironment:
>>>
>>>    public boolean isResponseModified(long lastModified) {
>>>        return true; // always modified
>>>    }
>>>
>>>    public void setResponseIsNotModified() {
>>>        // does nothing
>>>    }
>>>      
>>>
>
>Similarly, the setResponseIsNotModified() will be called on the current environment if

>a response was read from the cache. At present, this method does nothing.
>

Before you go further with this... Look at method isResponseModified() 
in [1].


>However, 
>if I get the environment to store something based upon this, then the CLI can know 
>whether or not to bother saving the page?
>

What you need to do is to:
1. Implement method isResponseModified() for command line environment.
2. In the CLI, get the file corresponding to the request URI, and get 
its last modification time.
3. Populate environment with this modification time (this will be 
similar to If-Modified-Since date header in http).
4. Call cocoon. It will skip generation if response is not modified, and 
won't even read it from cache.


>Thanks for this.
>  
>

You are welcome.

Vadim

[1] 
http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java?rev=1.3&content-type=text/vnd.viewcvs-markup



Mime
View raw message