Attatched is a first release of a possible patch to Cocoon HEAD for the
correction of the error notification stuff.

I've not yet submitted it as a patch because there are some minor problems
that I still need to solve before releasing it as such.

This patch contains code and suggestions from Peter Royal whom I thank for
the valuable and kind cooperation.

What has been done:
1- Changed the names of the classes to be more clear; for example
    Notificable becomes Notifying (that notifies), Notification becomes
   SimpleNotifyingBean and ErrorNotifier becomes NotifyingGenerator.
2- Refactored the error notification classes to fit under
   components.notification and separated the code that builds a Notifying
   object from the SimpleNotifyingBean for max flexibility:
   (Default)NotifyingBuilder, that is also an Avalon component. In this way
   you can filter your errors without touching the Notification DTD or
   creating  custom Generators.
3- Added to the objectModel (in sitemap.xsl) from the beginning of
   processing a NotifyingObjects object that can contain any Notifying
   object  that any component in the sitemap wants to add to it. In this way
   warnings (from Xalan or Xerces 4 example) can be appended to this and
   reported at the end with a notifications-view.
4- Deprecated special method in AbstractEventPipeline for ErrorNotifier; now
   the Notification is gotten from the objectmodel.
5- As a direct consequence of point 3 now Actions put in the handle-errors
   sitemap can get the NotifyingObjects and act on those; many times
   requested for error reporting to admins.
6- Last, but not least, any Exception that is alse Notifying gets notified
   using Notifying methods by the DefaultNotifyingBuilder.

The DTD of the notification is the same and Notifying is almost identical to
Notificable (a HashMap became a Map). Old classes and methods have been
deprecated.

The points that I need to resolve before submitting the patch are:
I - should Constants.NOTIFYING_OBJECTS be put in the objectmodel and created
   there instead of in the sitemap?
II - How come the handle-error pipeline works only after some
   time/invocations? The logs say that:

DEBUG   (2001-12-27) 14:57.21:537   [core    ] (/cocoon/generror)
HttpProcessor[8080][3]/ExcaliburComponentManager: Could not find component
for role: org.apache.cocoon.generation.GeneratorSelector
ERROR   (2001-12-27) 14:57.21:537   [core    ] (/cocoon/generror)
HttpProcessor[8080][3]/sitemap_xmap: NotifyingGenerator was not able to
notify the exception.
org.apache.avalon.framework.component.ComponentException: Could not find
component
 at
org.apache.avalon.excalibur.component.ExcaliburComponentManager.lookup(Excal
iburComponentManager.java:318)
 at
org.apache.cocoon.components.pipeline.AbstractEventPipeline.setGenerator(Abs
tractEventPipeline.java:97)
 at
org.apache.cocoon.components.pipeline.CachingEventPipeline.setGenerator(Cach
ingEventPipeline.java:75)
 at
org.apache.cocoon.www.sitemap_xmap.error_process_9_500(sitemap_xmap.java:932
9)
 at org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:3285)

   After some invocations/time it cutely says:

DEBUG   (2001-12-27) 14:58.14:973   [core    ] (/cocoon/generror)
HttpProcessor[8080][4]/ExcaliburComponentManager: Could not find component
for role: org.apache.cocoon.generation.GeneratorSelector
DEBUG   (2001-12-27) 14:58.14:973   [core    ] (/cocoon/generror)
HttpProcessor[8080][4]/ExcaliburComponentManager: The Role Manager has not
been set!
DEBUG   (2001-12-27) 14:58.14:973   [core    ] (/cocoon/generror)
HttpProcessor[8080][4]/AbstractEventPipeline: New GS
org.apache.cocoon.sitemap.SitemapComponentSelector@24c22b
DEBUG   (2001-12-27) 14:58.14:973   [core    ] (/cocoon/generror)
HttpProcessor[8080][4]/ExcaliburComponentManager: The Role Manager has not
been set!
DEBUG   (2001-12-27) 14:58.14:973   [core    ] (/cocoon/generror)
HttpProcessor[8080][4]/LogKitLogger: Retrieving a
org.apache.cocoon.sitemap.NotifyingGenerator from the pool
DEBUG   (2001-12-27) 14:58.14:973   [core    ] (/cocoon/generror)
HttpProcessor[8080][4]/AbstractEventPipeline:
!NG!org.apache.cocoon.sitemap.NotifyingGenerator@392fe8

   Then all works perfectly.
   Does this have something to do with the Recomposable stuff?
   Suggestions?
III- I would prefer to add the special NotifyingGenerator
   (ex-ErrorNotifier) to the sitemap in sitemap.roles instead
   of doing it in code in the sitemap.
   I've put tentative code in it (now commented) that doesn't work.
   Does this have something to do with the Recomposable stuff?
   Suggestions?

Things that I will do when this is approved:
a- create a <notify:xxx> XSP taglib, for reporting errors or setting
   notifictions in the objectmodel.
b- create a NotifyingBuilder that filters error messages and enhances them
   using a Resource Bundle (taken also from faqs?).
c- make a notifications-view to see if non-error notifications were issued
d- documentation

Finally, I've read the Constitution and [VOTE]s must be called by active
developers. Being a developer, I humbly suggest that an active developer
asks for a [VOTE] on this issue, being it a refactoring effort that
touches the objectmodel and maybe Environment.

Thank you.
Nicola Ken Barozzi

--
Nicola Ken Barozzi                 [EMAIL PROTECTED]

These are the days of miracle and wonder...
          ...so don't cry baby, don't cry...
                                                  Paul Simon
*** src/org/apache/cocoon/components/notification/DefaultNotifyingBuilder.java  Wed 
Dec 31 14:00:00 1969
--- src/org/apache/cocoon/components/notification/DefaultNotifyingBuilder.java  Sun 
Dec 23 17:40:00 2001
***************
*** 0 ****
--- 1,161 ----
+ /*****************************************************************************
+  * Copyright (C) The Apache Software Foundation. All rights reserved.        *
+  * ------------------------------------------------------------------------- *
+  * This software is published under the terms of the Apache Software License *
+  * version 1.1, a copy of which has been included  with this distribution in *
+  * the LICENSE file.                                                         *
+  **************************************************************************** *
+  */
+ 
+ package org.apache.cocoon.components.notification;
+ 
+ import org.apache.avalon.framework.CascadingThrowable;
+ import org.apache.avalon.framework.component.Component;
+ 
+ import org.xml.sax.SAXException;
+ 
+ import java.io.PrintWriter;
+ import java.io.StringWriter;
+ import java.util.Map;
+ 
+ /**
+  *  Generates an Notifying representation of widely used objects.
+  *
+  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a>
+  * @created 24 August 2000
+  */
+ public class DefaultNotifyingBuilder implements NotifyingBuilder, Component {
+ 
+   /** Builds a Notifying object (SimpleNotifyingBean in this case)
+    *  that tries to explain what the Object o can reveal.
+    * @param sender who sent this Object.
+    * @param o the object to use when building the SimpleNotifyingBean
+    * @return the  Notifying Object that was build
+    * @see org.apache.cocoon.components.notification.Notifying   
+    */
+   public Notifying build (Object sender, Object o) {
+     if (o instanceof Notifying) {
+       return (Notifying) o;
+     } else if (o instanceof Throwable) {
+       Throwable t = (Throwable) o;
+       SimpleNotifyingBean n = new SimpleNotifyingBean(sender);
+       n.setType("error");
+       n.setTitle("An error occurred");
+       if (t != null) {
+         n.setSource(t.getClass().getName());
+         n.setMessage(t.getMessage());
+         n.setDescription(t.toString());
+ 
+         Throwable rootT = getRootCause(t);
+         n.addExtraDescription("original message", rootT.toString());
+ 
+         // get the stacktrace: if the exception is a SAXException,
+         // the stacktrace of the embedded exception is used as the
+         // SAXException does not append it automatically
+         Throwable stackTraceException;
+         if (t instanceof SAXException && ((SAXException) t).getException() != null) {
+           stackTraceException = ((SAXException) t).getException();
+         } else {
+           stackTraceException = t;
+         }
+         //org.apache.avalon.framework.ExceptionUtil.captureStackTrace();
+         StringWriter sw = new StringWriter();
+         stackTraceException.printStackTrace(new PrintWriter(sw));
+         n.addExtraDescription("stacktrace", sw.toString());
+         // Add nested throwables description
+         sw = new StringWriter();
+         appendCauses(new PrintWriter(sw), stackTraceException);
+         String causes = sw.toString();
+         if (causes != null && causes.length() != 0) {
+           n.addExtraDescription("full exception chain stacktrace", causes);
+         }
+       }
+       return n;
+     } else {
+       SimpleNotifyingBean n = new SimpleNotifyingBean(sender);
+       n.setType("unknown");
+       n.setTitle("Object notification");
+       n.setSource(o.getClass().getName());
+       n.setMessage(o.toString());
+       n.setDescription("No details available.");
+       return n;
+     }
+   }
+ 
+   /** Builds a Notifying object (SimpleNotifyingBean in this case)
+    *  that explains a notification.
+    * @param sender who sent this Object.
+    * @param o the object to use when building the SimpleNotifyingBean
+    * @param type see the Notifying apidocs
+    * @param title see the Notifying apidocs
+    * @param source see the Notifying apidocs
+    * @param message see the Notifying apidocs
+    * @param description see the Notifying apidocs
+    * @param extra see the Notifying apidocs   
+    * @return the  Notifying Object that was build
+    * @see org.apache.cocoon.components.notification.Notifying
+    */
+   public Notifying build(Object sender, Object o, String type, String title,
+           String source, String message, String description, Map extra) {
+     //NKB Cast here is secure, the method is of this class
+     SimpleNotifyingBean n = (SimpleNotifyingBean) build (sender, o);
+ 
+     if (type != null)
+       n.setType(type);
+     if (title != null)
+       n.setTitle(title);
+     if (source != null)
+       n.setSource(source);
+     if (message != null)
+       n.setMessage(message);
+     if (description != null)
+       n.setDescription(description);
+     if (extra != null)
+       n.replaceExtraDescriptions(extra);
+ 
+     return n;
+   }
+ 
+ 
+   /**
+    * Print recursively all nested causes of a Throwable in a PrintWriter.
+    */
+   private static void appendCauses (PrintWriter out, Throwable t) {
+     Throwable cause = null;
+     if (t instanceof CascadingThrowable) {
+       cause = ((CascadingThrowable) t).getCause();
+     } else if (t instanceof SAXException) {
+       cause = ((SAXException) t).getException();
+     } else if (t instanceof java.sql.SQLException) {
+       cause = ((java.sql.SQLException) t).getNextException();
+     }
+     if (cause != null) {
+       out.print("Original exception : ");
+       cause.printStackTrace(out);
+       out.println();
+       // Recurse
+       appendCauses(out, cause);
+     }
+   }
+ 
+   /**
+    * Get root Exception.
+    */
+   private static Throwable getRootCause (Throwable t) {
+     Throwable cause = null;
+     if (t instanceof CascadingThrowable) {
+       cause = ((CascadingThrowable) t).getCause();
+     } else if (t instanceof SAXException) {
+       cause = ((SAXException) t).getException();
+     } else if (t instanceof java.sql.SQLException) {
+       cause = ((java.sql.SQLException) t).getNextException();
+     }
+     if (cause == null) {
+       return t;
+     } else {
+       // Recurse
+       return getRootCause(cause);
+     }
+   }
+ }
+ 

*** src/org/apache/cocoon/components/notification/Notifier.java Wed Dec 31 14:00:00 
1969
--- src/org/apache/cocoon/components/notification/Notifier.java Fri Dec 21 15:02:04 
2001
***************
*** 0 ****
--- 1,140 ----
+ /*****************************************************************************
+  * Copyright (C) The Apache Software Foundation. All rights reserved.        *
+  * ------------------------------------------------------------------------- *
+  * This software is published under the terms of the Apache Software License *
+  * version 1.1, a copy of which has been included  with this distribution in *
+  * the LICENSE file.                                                         *
+  *****************************************************************************/
+ 
+ package org.apache.cocoon.components.notification;
+ 
+ import org.apache.cocoon.Constants;
+ 
+ import org.xml.sax.ContentHandler;
+ import org.xml.sax.SAXException;
+ import org.xml.sax.helpers.AttributesImpl;
+ 
+ import java.io.IOException;
+ import java.io.OutputStream;
+ import java.util.Map;
+ import java.util.Iterator;
+ 
+ /**
+  * Generates a representations of the specified Notifying Object.
+  *
+  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a> Aisa
+  * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
+  * @version CVS $Revision: 1.2.2.4 $ $Date: 2001/10/11 08:56:04 $
+  */
+ 
+ public class Notifier {
+ 
+   /**
+    * Generate notification information as a response.
+    * The notification is directly written to the OutputStream.
+    * @param  n The <code>Notifying</code> object
+    * @param outputStream The output stream the notification is written to
+    *        This could be <code>null</code>.
+    * @return The content type for this notification
+    *         (currently always text/html)
+    */
+   public static String notify(Notifying n,
+           OutputStream outputStream) throws IOException {
+ 
+     StringBuffer sb = new StringBuffer();
+ 
+     sb.append("<html><head><title>").append(n.getTitle()).append("</title>");
+     sb.append("<STYLE><!--H1{font-family : sans-serif,Arial,Tahoma;color : 
+white;background-color : #0086b2;} ");
+     sb.append("BODY{font-family : sans-serif,Arial,Tahoma;color : 
+black;background-color : white;} ");
+     sb.append("B{color : white;background-color : #0086b2;} ");
+     sb.append("HR{color : #0086b2;} ");
+     sb.append("--></STYLE> ");
+     sb.append("</head><body>");
+     sb.append("<h1>Cocoon 2 - ").append(n.getTitle()).append("</h1>");
+     sb.append("<HR size=\"1\" noshade=\"noshade\">");
+     sb.append("<p><b>type</b> ").append(n.getType()).append("</p>");
+     sb.append("<p><b>message</b> <u>").append(n.getMessage()).append("</u></p>");
+     sb.append("<p><b>description</b> 
+<u>").append(n.getDescription()).append("</u></p>");
+     sb.append("<p><b>sender</b> ").append(n.getSender()).append("</p>");
+     sb.append("<p><b>source</b> ").append(n.getSource()).append("</p>");
+ 
+     Map extraDescriptions = n.getExtraDescriptions();
+     Iterator keyIter = extraDescriptions.keySet().iterator();
+ 
+     while (keyIter.hasNext()) {
+       String key = (String) keyIter.next();
+ 
+       sb.append("<p><b>").append(key).append("</b><pre>").append(
+               extraDescriptions.get(key)).append("</pre></p>");
+     }
+ 
+     sb.append("<HR size=\"1\" noshade>");
+     sb.append("</body></html>");
+ 
+     if (outputStream != null)
+       outputStream.write(sb.toString().getBytes());
+     // FIXME (SM) how can we send the error with the proper content type?
+ 
+     return "text/html";
+   }
+ 
+   /**
+    * Generate notification information in XML format.
+    */
+   public static void notify(Notifying n, ContentHandler ch) throws SAXException {
+ 
+     final String PREFIX = Constants.ERROR_NAMESPACE_PREFIX;
+     final String URI = Constants.ERROR_NAMESPACE_URI;
+ 
+     // Start the document
+     ch.startDocument();
+     ch.startPrefixMapping(PREFIX, URI);
+ 
+     // Root element.
+     AttributesImpl atts = new AttributesImpl();
+ 
+     atts.addAttribute(URI, "type", PREFIX + ":type", "CDATA", n.getType());
+     atts.addAttribute(URI, "sender", PREFIX + ":sender", "CDATA", n.getSender());
+     ch.startElement(URI, "notify", PREFIX + ":notify", atts);
+     ch.startElement(URI, "title", PREFIX + ":title", new AttributesImpl());
+     ch.characters(n.getTitle().toCharArray(), 0, n.getTitle().length());
+     ch.endElement(URI, "title", PREFIX + ":title");
+     ch.startElement(URI, "source", PREFIX + ":source", new AttributesImpl());
+     ch.characters(n.getSource().toCharArray(), 0, n.getSource().length());
+     ch.endElement(URI, "source", PREFIX + ":source");
+     ch.startElement(URI, "message", PREFIX + ":message", new AttributesImpl());
+ 
+     if (n.getMessage() != null) {
+       ch.characters(n.getMessage().toCharArray(), 0, n.getMessage().length());
+     }
+ 
+     ch.endElement(URI, "message", PREFIX + ":message");
+     ch.startElement(URI, "description", PREFIX + ":description",
+             new AttributesImpl());
+     ch.characters(n.getDescription().toCharArray(), 0, n.getDescription().length());
+     ch.endElement(URI, "description", PREFIX + ":description");
+ 
+     Map extraDescriptions = n.getExtraDescriptions();
+     Iterator keyIter = extraDescriptions.keySet().iterator();
+ 
+     while (keyIter.hasNext()) {
+       String key = (String) keyIter.next();
+ 
+       atts = new AttributesImpl();
+ 
+       atts.addAttribute(URI, "description", PREFIX + ":description", "CDATA", key);
+       ch.startElement(URI, "extra", PREFIX + ":extra", atts);
+       ch.characters(extraDescriptions.get(key).toString().toCharArray(), 0,
+               (extraDescriptions.get(key).toString()).length());
+       ch.endElement(URI, "extra", PREFIX + ":extra");
+     }
+ 
+     // End root element.
+     ch.endElement(URI, "notify", PREFIX + ":notify");
+ 
+     // End the document.
+     ch.endPrefixMapping(PREFIX);
+     ch.endDocument();
+   }
+ }
+ 

*** src/org/apache/cocoon/components/notification/Notifying.java        Wed Dec 31 
14:00:00 1969
--- src/org/apache/cocoon/components/notification/Notifying.java        Thu Dec 20 
13:11:24 2001
***************
*** 0 ****
--- 1,67 ----
+ /*****************************************************************************
+  * Copyright (C) The Apache Software Foundation. All rights reserved.        *
+  * ------------------------------------------------------------------------- *
+  * This software is published under the terms of the Apache Software License *
+  * version 1.1, a copy of which has been included  with this distribution in *
+  * the LICENSE file.                                                         *
+  *****************************************************************************/
+ 
+ package org.apache.cocoon.components.notification;
+ 
+ import java.util.Map;
+ 
+ /**
+  *  Interface for Objects that can notify something.
+  *
+  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a>
+  * @created 24 August 2000
+  */
+ 
+ public interface Notifying {
+ 
+   /**
+    *  Proposed types of notifications
+    */
+   public static final String UNKNOWN_NOTIFICATION = "unknown";
+   public static final String DEBUG_NOTIFICATION = "debug";
+   public static final String INFO_NOTIFICATION = "info" ;
+   public static final String WARN_NOTIFICATION = "warn" ;
+   public static final String ERROR_NOTIFICATION = "error";
+   public static final String FATAL_NOTIFICATION = "fatal";
+ 
+   /**
+    *  Gets the Type of the Notifying object
+    */
+   String getType();
+ 
+   /**
+    *  Gets the Title of the Notifying object
+    */
+   String getTitle();
+ 
+   /**
+    *  Gets the Source of the Notifying object
+    */
+   String getSource();
+ 
+   /**
+    *  Gets the Sender of the Notifying object
+    */
+   String getSender();
+ 
+   /**
+    *  Gets the Message of the Notifying object
+    */
+   String getMessage();
+ 
+   /**
+    *  Gets the Description of the Notifying object
+    */
+   String getDescription();
+ 
+   /**
+    *  Gets the ExtraDescriptions of the Notifying object
+    */
+   Map getExtraDescriptions();
+ }
+ 

*** src/org/apache/cocoon/components/notification/NotifyingBuilder.java Wed Dec 31 
14:00:00 1969
--- src/org/apache/cocoon/components/notification/NotifyingBuilder.java Sun Dec 23 
17:40:00 2001
***************
*** 0 ****
--- 1,56 ----
+ /*****************************************************************************
+  * Copyright (C) The Apache Software Foundation. All rights reserved.        *
+  * ------------------------------------------------------------------------- *
+  * This software is published under the terms of the Apache Software License *
+  * version 1.1, a copy of which has been included  with this distribution in *
+  * the LICENSE file.                                                         *
+  *****************************************************************************/
+ 
+ package org.apache.cocoon.components.notification;
+ 
+ import java.util.Map;
+ 
+ import org.apache.avalon.framework.component.Component;
+ 
+ /**
+  *  Generates an Notifying representation of widely used objects.
+  *
+  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a>
+  * @created 24 August 2000
+  */
+ 
+ public interface NotifyingBuilder extends Component{
+ 
+   /**
+   * The role implemented by a <code>NotifyingBuilder</code>.
+   */
+   String ROLE = "org.apache.cocoon.components.notification.NotifyingBuilder";
+ 
+   /** Builds a Notifying object (SimpleNotifyingObject in this case)
+    *  that tries to explain what the Object o can reveal.
+    * @param sender who sent this Object.
+    * @param o the object to use when building the SimpleNotifyingObject
+    * @return the  Notifying Object that was build
+    * @see org.apache.cocoon.components.notification.Notifying
+    */
+   public Notifying build(Object sender, Object o);
+ 
+ 
+   /** Builds a Notifying object (SimpleNotifyingObject in this case)
+    *  that explains a notification.
+    * @param sender who sent this Object.
+    * @param o the object to use when building the SimpleNotifyingObject
+    * @param type see the Notifying apidocs
+    * @param title see the Notifying apidocs
+    * @param source see the Notifying apidocs
+    * @param message see the Notifying apidocs
+    * @param description see the Notifying apidocs
+    * @param extra see the Notifying apidocs
+    * @return the  Notifying Object that was build
+    * @see org.apache.cocoon.components.notification.Notifying
+    */
+   public Notifying build(Object sender, Object o, String type, String title,
+           String source, String message, String description, Map extra);
+ }
+ 
+ 

*** 
src/org/apache/cocoon/components/notification/NotifyingCascadingRuntimeException.java  
     Wed Dec 31 14:00:00 1969
--- 
src/org/apache/cocoon/components/notification/NotifyingCascadingRuntimeException.java  
     Fri Dec 21 15:05:46 2001
***************
*** 0 ****
--- 1,108 ----
+ /*****************************************************************************
+  * Copyright (C) The Apache Software Foundation. All rights reserved.        *
+  * ------------------------------------------------------------------------- *
+  * This software is published under the terms of the Apache Software License *
+  * version 1.1, a copy of which has been included  with this distribution in *
+  * the LICENSE file.                                                         *
+  *****************************************************************************/
+  
+ package org.apache.cocoon.components.notification;
+ 
+ import org.apache.avalon.framework.CascadingRuntimeException;
+ 
+ import java.util.Map;
+ 
+ import java.io.PrintStream;
+ import java.io.PrintWriter;
+ 
+ /**
+  * A CascadingRuntimeException that is also Notifying.
+  *
+  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a>
+  * @created 7 December 2001
+  */
+ public class NotifyingCascadingRuntimeException extends CascadingRuntimeException {
+ 
+   /**
+    * The Notifying Object used internally to keep Notifying fields
+    */
+   Notifying n;
+ 
+   /**
+    * Construct a new <code>NotifyingCascadingRuntimeException</code> instance.
+    */
+   public NotifyingCascadingRuntimeException(String message) {
+     super(message, null);
+     n = new DefaultNotifyingBuilder().build(this, message);
+   }
+ 
+   /**
+    * Creates a new <code>ProcessingException</code> instance.
+    *
+    * @param ex an <code>Exception</code> value
+    */
+   public NotifyingCascadingRuntimeException(Exception ex) {
+     super(ex.getMessage(), ex);
+     n = new DefaultNotifyingBuilder().build(this, ex);
+   }
+ 
+   /**
+    * Construct a new <code>ProcessingException</code> that references
+    * a parent Exception.
+    */
+   public NotifyingCascadingRuntimeException(String message, Throwable t) {
+     super(message, t);
+     n = new DefaultNotifyingBuilder().build(this, t);
+   }
+ 
+   /**
+    *  Gets the Type attribute of the Notifying object
+    */
+   public String getType() {
+     return n.getType();
+   }
+ 
+   /**
+    *  Gets the Title attribute of the Notifying object
+    */
+   public String getTitle() {
+     return n.getTitle();
+   }
+ 
+   /**
+    *  Gets the Source attribute of the Notifying object
+    */
+   public String getSource() {
+     return n.getSource();
+   }
+ 
+   /**
+    *  Gets the Sender attribute of the Notifying object
+    */
+   public String getSender() {
+     return n.getSender();
+   }
+ 
+   /**
+    *  Gets the Message attribute of the Notifying object
+    */
+   public String getMessage() {
+     return n.getMessage();
+   }
+ 
+   /**
+    *  Gets the Description attribute of the Notifying object
+    */
+   public String getDescription() {
+     return n.getDescription();
+   }
+ 
+   /**
+    *  Gets the ExtraDescriptions attribute of the Notifying object
+    */
+   public Map getExtraDescriptions() {
+     return n.getExtraDescriptions();
+   }
+ 
+ }
+ 

*** src/org/apache/cocoon/components/notification/NotifyingObjects.java Wed Dec 31 
14:00:00 1969
--- src/org/apache/cocoon/components/notification/NotifyingObjects.java Sun Dec 23 
17:06:04 2001
***************
*** 0 ****
--- 1,57 ----
+ /*****************************************************************************
+  * Copyright (C) The Apache Software Foundation. All rights reserved.        *
+  * ------------------------------------------------------------------------- *
+  * This software is published under the terms of the Apache Software License *
+  * version 1.1, a copy of which has been included  with this distribution in *
+  * the LICENSE file.                                                         *
+  *****************************************************************************/
+ 
+ package org.apache.cocoon.components.notification;
+ 
+ import java.util.List;
+ import java.util.ArrayList;
+ import java.util.Iterator;
+ 
+ /**
+  *  Interface for a List of Objects that can notify something.
+  *  NKB: FIXME The type checks are not complete.
+  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a>
+  * @created 18 December 2001
+  */
+ public class NotifyingObjects{
+ 
+   private ArrayList notifyingObjects;
+   
+   public NotifyingObjects()
+   {
+     notifyingObjects = new ArrayList();
+   }
+   
+   public synchronized void addNotifying(Notifying n)
+   { 
+       notifyingObjects.add(n);
+   }
+   
+   public synchronized Notifying getNotifying(int i)
+   { //NKB cast is safe here
+     return (Notifying)notifyingObjects.get(i);
+   }
+   
+   public synchronized Notifying getLastNotifying()
+   { //NKB cast is safe here
+     return (Notifying)notifyingObjects.get(notifyingObjects.size()-1);
+   }
+   
+   public Iterator iterator()
+   {
+     return notifyingObjects.iterator();
+   }
+   
+   public int size()
+   {
+      return notifyingObjects.size();
+   }
+   
+ 
+ }
+ 

*** src/org/apache/cocoon/components/notification/SimpleNotifyingBean.java      Wed 
Dec 31 14:00:00 1969
--- src/org/apache/cocoon/components/notification/SimpleNotifyingBean.java      Fri 
Dec 21 15:07:48 2001
***************
*** 0 ****
--- 1,204 ----
+ /*****************************************************************************
+  * Copyright (C) The Apache Software Foundation. All rights reserved.        *
+  * ------------------------------------------------------------------------- *
+  * This software is published under the terms of the Apache Software License *
+  * version 1.1, a copy of which has been included  with this distribution in *
+  * the LICENSE file.                                                         *
+  *****************************************************************************/
+ 
+ package org.apache.cocoon.components.notification;
+ 
+ import java.io.PrintWriter;
+ import java.io.StringWriter;
+ import java.util.Map;
+ import java.util.HashMap;
+ 
+ /**
+  *  A simple bean implementation of Notifying.
+  *
+  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a>
+  * @created 24 August 2000
+  */
+ 
+ public class SimpleNotifyingBean implements Notifying {
+ 
+   /**
+    *  The type of the notification. Examples can be "warning" or "error"
+    */
+   private String type = "unknown";
+ 
+   /**
+    *  The title of the notification.
+    */
+   private String title = "";
+ 
+   /**
+    *  The source that generates the notification.
+    */
+   private String source = "";
+ 
+   /**
+    *  The sender of the notification.
+    */
+   private String sender = "";
+ 
+   /**
+    *  The notification itself.
+    */
+   private String message = "Message not known.";
+ 
+   /**
+    *  A more detailed description of the notification.
+    */
+   private String description = "No details available.";
+ 
+   /**
+    *  A HashMap containing extra notifications
+    */
+   private HashMap extraDescriptions = new HashMap();
+ 
+   public SimpleNotifyingBean(Object sender) {
+     this.sender = sender.getClass().getName();
+     setSource(this.getClass().getName());
+     setTitle("Generic notification");
+   }
+ 
+   /**
+    *  Sets the Type of the SimpleNotifyingBean object
+    *
+    *@param  type  The new Type value
+    */
+   public void setType(String type) {
+     this.type = type;
+   }
+ 
+   /**
+    *  Sets the Title of the SimpleNotifyingBean object
+    *
+    *@param  title  The new Title value
+    */
+   public void setTitle(String title) {
+     this.title = title;
+   }
+ 
+   /**
+    *  Sets the Source of the SimpleNotifyingBean object
+    *
+    *@param  source  The new Source value
+    */
+   public void setSource(String source) {
+     this.source = source;
+   }
+ 
+   /**
+    *  Sets the Sender of the SimpleNotifyingBean object
+    *
+    *@param  sender  The new sender value
+    */
+   private void setSender(Object sender) {
+     this.sender = sender.getClass().getName();
+   }
+ 
+   /**
+    *  Sets the Sender of the SimpleNotifyingBean object
+    *
+    *@param  sender  The new sender value
+    */
+   private void setSender(String sender) {
+     this.sender = sender;
+   }
+ 
+   /**
+    *  Sets the Message of the SimpleNotifyingBean object
+    *
+    *@param  message  The new Message value
+    */
+   public void setMessage(String message) {
+     this.message = message;
+   }
+ 
+   /**
+    *  Sets the Description of the SimpleNotifyingBean object
+    *
+    *@param  description  The new Description value
+    */
+   public void setDescription(String description) {
+     this.description = description;
+   }
+ 
+   /**
+    *  Sets the ExtraDescriptions of the SimpleNotifyingBean object
+    *
+    *@param  extraDescriptions  The new ExtraDescriptions value
+    */
+   public void addExtraDescription(String extraDescriptionDescription,
+           String extraDescription) {
+     this.extraDescriptions.put(extraDescriptionDescription, extraDescription);
+   }
+ 
+   /**
+    *  replaces the ExtraDescriptions of the SimpleNotifyingBean object
+    */
+   protected void replaceExtraDescriptions(Map extraDescriptions) {
+     this.extraDescriptions = new HashMap(extraDescriptions);
+   }
+ 
+   /**
+    *  replaces the ExtraDescriptions of the SimpleNotifyingBean object
+    */
+   protected void replaceExtraDescriptions(HashMap extraDescriptions) {
+     this.extraDescriptions = extraDescriptions;
+   }
+   
+   /**
+    *  Gets the Type of the SimpleNotifyingBean object
+    */
+   public String getType() {
+     return type;
+   }
+ 
+   /**
+    *  Gets the Title of the SimpleNotifyingBean object
+    */
+   public String getTitle() {
+     return title;
+   }
+ 
+   /**
+    *  Gets the Source of the SimpleNotifyingBean object
+    */
+   public String getSource() {
+     return source;
+   }
+ 
+   /**
+    *  Gets the Sender of the SimpleNotifyingBean object
+    */
+   public String getSender() {
+     return sender;
+   }
+ 
+   /**
+    *  Gets the Message of the SimpleNotifyingBean object
+    */
+   public String getMessage() {
+     return message;
+   }
+ 
+   /**
+    *  Gets the Description of the SimpleNotifyingBean object
+    */
+   public String getDescription() {
+     return description;
+   }
+ 
+   /**
+    *  Gets the ExtraDescriptions of the SimpleNotifyingBean object
+    */
+   public Map getExtraDescriptions() {
+     return extraDescriptions;
+   }
+ }
+ 
+ 
+ 

*** src/org/apache/cocoon/sitemap/NotifyingGenerator.java       Wed Dec 31 14:00:00 
1969
--- src/org/apache/cocoon/sitemap/NotifyingGenerator.java       Sun Dec 23 17:08:28 
2001
***************
*** 0 ****
--- 1,73 ----
+ /*****************************************************************************
+  * Copyright (C) The Apache Software Foundation. All rights reserved.        *
+  * ------------------------------------------------------------------------- *
+  * This software is published under the terms of the Apache Software License *
+  * version 1.1, a copy of which has been included  with this distribution in *
+  * the LICENSE file.                                                         *
+  *****************************************************************************/
+ 
+ package org.apache.cocoon.sitemap;
+ 
+ import java.util.Map;
+ import java.io.IOException;
+ 
+ import org.apache.avalon.excalibur.pool.Recyclable;
+ import org.apache.avalon.framework.parameters.Parameters;
+ import org.apache.cocoon.components.notification.Notifying;
+ import org.apache.cocoon.components.notification.Notifier;
+ import org.apache.cocoon.components.notification.NotifyingObjects;
+ import org.apache.cocoon.generation.ComposerGenerator;
+ import org.apache.cocoon.environment.SourceResolver;
+ import org.apache.cocoon.ProcessingException;
+ import org.apache.cocoon.Constants;
+ 
+ import org.xml.sax.SAXException;
+ 
+ /**
+  * Generates an XML representation of the current notification.
+  *
+  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a>
+  * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
+  * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Royal</a>
+  * @created 31 July 2000
+  * @version CVS $Revision: 1.5 $ $Date: 2001/10/11 07:28:23 $
+  */
+ public class NotifyingGenerator extends ComposerGenerator implements Recyclable {
+   /**
+    * The <code>Notification</code> to report.
+    */
+   private Notifying notification = null;
+ 
+   public void setup(SourceResolver resolver, Map objectModel, String src,
+           Parameters par) throws ProcessingException, SAXException, IOException {
+     super.setup(resolver, objectModel, src, par);
+ 
+     NotifyingObjects notifyingObjects = 
+(NotifyingObjects)objectModel.get(Constants.NOTIFYING_OBJECTS);
+     
+     if ( notifyingObjects == null) {
+       throw new ProcessingException("Expected NotifyingObjects not found in object 
+model");
+     }
+     
+     notification = notifyingObjects.getLastNotifying();
+   }
+ 
+   /**
+    * Generate the notification information in XML format.
+    *
+    * @exception  SAXException  Description of problem there is creating the output 
+SAX events.
+    * @throws SAXException when there is a problem creating the
+    *      output SAX events.
+    */
+   public void generate() throws SAXException {
+     Notifier.notify(notification, this.contentHandler);
+   }
+ 
+   /**
+    * Recycle
+    */
+   public void recycle() {
+     super.recycle();
+     this.notification = null;
+   }
+ }
+ 

*** src/org/apache/cocoon/Constants.java
--- src/org/apache/cocoon/Constants.java
*** src/org/apache/cocoon/Notificable.java
--- src/org/apache/cocoon/Notificable.java
*** src/org/apache/cocoon/Notification.java
--- src/org/apache/cocoon/Notification.java
*** src/org/apache/cocoon/Notifier.java
--- src/org/apache/cocoon/Notifier.java
*** src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl   
2001/12/19 14:17:12     1.56
--- src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl   
2001/12/27 15:26:05
***************
*** 114,131 ****
      import org.apache.cocoon.components.pipeline.StreamPipeline;
      import org.apache.cocoon.components.pipeline.EventPipeline;
      import org.apache.cocoon.sitemap.Sitemap;
!     import org.apache.cocoon.sitemap.ErrorNotifier;
      import org.apache.cocoon.sitemap.ContentAggregator;
      import org.apache.cocoon.sitemap.Manager;
      import org.apache.cocoon.sitemap.SitemapRedirector;
      import org.apache.cocoon.components.language.markup.xsp.XSPRequestHelper;
      import org.apache.cocoon.components.language.markup.xsp.XSPResponseHelper;
  
      /**
       * This is the automatically generated class from the sitemap definitions
       *
       * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Giacomo Pati&lt;/a&gt;
       * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Berin Loritsch&lt;/a&gt;
       * @version CVS $Id: sitemap.xsl,v 1.56 2001/12/19 14:17:12 haul Exp $
       */
      public class <xsl:value-of select="@file-name"/> extends AbstractSitemap {
--- 114,136 ----
      import org.apache.cocoon.components.pipeline.StreamPipeline;
      import org.apache.cocoon.components.pipeline.EventPipeline;
      import org.apache.cocoon.sitemap.Sitemap;
!     import org.apache.cocoon.sitemap.NotifyingGenerator;
      import org.apache.cocoon.sitemap.ContentAggregator;
      import org.apache.cocoon.sitemap.Manager;
      import org.apache.cocoon.sitemap.SitemapRedirector;
      import org.apache.cocoon.components.language.markup.xsp.XSPRequestHelper;
      import org.apache.cocoon.components.language.markup.xsp.XSPResponseHelper;
+     import org.apache.cocoon.components.notification.NotifyingBuilder;
+     import org.apache.cocoon.components.notification.Notifying;
+     import org.apache.cocoon.components.notification.NotifyingObjects;
  
      /**
       * This is the automatically generated class from the sitemap definitions
       *
       * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Giacomo Pati&lt;/a&gt;
       * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Berin Loritsch&lt;/a&gt;
+      * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Nicola Ken 
+Barozzi&lt;/a&gt;
+      * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Peter 
+Royal&lt;/a&gt;
       * @version CVS $Id: sitemap.xsl,v 1.56 2001/12/19 14:17:12 haul Exp $
       */
      public class <xsl:value-of select="@file-name"/> extends AbstractSitemap {
***************
*** 289,295 ****
  
          try {
            <!-- configure well known components first -->
!           load_component (Sitemap.GENERATOR, "!error-notifier!", 
"org.apache.cocoon.sitemap.ErrorNotifier", new DefaultConfiguration("", LOCATION), 
null);
            load_component (Sitemap.GENERATOR, "!content-aggregator!", 
"org.apache.cocoon.sitemap.ContentAggregator", new DefaultConfiguration("", LOCATION), 
null);
            load_component (Sitemap.TRANSFORMER, "!link-translator!", 
"org.apache.cocoon.sitemap.LinkTranslator", new DefaultConfiguration("", LOCATION), 
null);
  
--- 294,300 ----
  
          try {
            <!-- configure well known components first -->
!           load_component (Sitemap.GENERATOR, "!notifying-generator!", 
"org.apache.cocoon.sitemap.NotifyingGenerator", new DefaultConfiguration("", 
LOCATION), null);
            load_component (Sitemap.GENERATOR, "!content-aggregator!", 
"org.apache.cocoon.sitemap.ContentAggregator", new DefaultConfiguration("", LOCATION), 
null);
            load_component (Sitemap.TRANSFORMER, "!link-translator!", 
"org.apache.cocoon.sitemap.LinkTranslator", new DefaultConfiguration("", LOCATION), 
null);
  
***************
*** 633,638 ****
--- 638,646 ----
             XPath kind expressions in values of src attribute used with
             generate and transform elements */
          List listOfMaps = (List) new ArrayList();
+         //Adds Constants.NOTIFYING_OBJECTS to ObjectModel
+         //NKB FIXME add to ObjectModel?
+         environment.getObjectModel().put(Constants.NOTIFYING_OBJECTS, new 
+NotifyingObjects());
          SitemapRedirector redirector = new SitemapRedirector(environment);
          <!-- process the pipelines -->
          <!-- for each pipeline element generate a try/catch block -->
***************
*** 740,749 ****
                List listOfMaps = (List)(new ArrayList());
                Map map;
                Parameters param;
!               eventPipeline.setGenerator ("!error-notifier!", e.getMessage(), 
emptyParam, e);
                <xsl:apply-templates select="./*"/>
              } catch (Exception ex) {
!               if (getLogger().isErrorEnabled()) getLogger().error("error notifier 
barfs", ex);
                throw e;
              } finally {
                if(eventPipeline != null)
--- 748,771 ----
                List listOfMaps = (List)(new ArrayList());
                Map map;
                Parameters param;
! 
!               // Create a Notifying out of this exception and stick it in the object 
model Constants.NOTIFYING_OBJECTS
!               boolean de = getLogger().isDebugEnabled() ? true : false;
!               de=true;
!               if(de)getLogger().debug("Starting to build Notifying");
!               NotifyingBuilder notifyingBuilder= 
(NotifyingBuilder)this.manager.lookup(NotifyingBuilder.ROLE);
!               if(de)getLogger().debug("Got "+notifyingBuilder);
!               Notifying currentNotifying = notifyingBuilder.build(this, e);
!               if(de)getLogger().debug("Built "+currentNotifying);      
!               NotifyingObjects notifyingObjects = 
(NotifyingObjects)objectModel.get(Constants.NOTIFYING_OBJECTS);
!               if(de)getLogger().debug("Got "+notifyingObjects);          
!               notifyingObjects.addNotifying(currentNotifying);
!               if(de)getLogger().debug("Added to "+notifyingObjects);        
!               eventPipeline.setGenerator ("!notifying-generator!", e.getMessage(), 
emptyParam);
! 
                <xsl:apply-templates select="./*"/>
              } catch (Exception ex) {
!               if (getLogger().isErrorEnabled()) 
getLogger().error("NotifyingGenerator was not able to notify the exception.", ex);
                throw e;
              } finally {
                if(eventPipeline != null)
***************
*** 1925,1927 ****
--- 1947,1950 ----
    <xsl:template match="map:logicsheet|map:dependency|map:handle-errors"/>
  
  </xsl:stylesheet>
+ 


*** src/org/apache/cocoon/components/pipeline/AbstractEventPipeline.java        
2001/12/10 12:56:22     1.18
--- src/org/apache/cocoon/components/pipeline/AbstractEventPipeline.java        
2001/12/27 15:26:11
***************
*** 17,23 ****
  import org.apache.cocoon.components.saxconnector.SAXConnector;
  import org.apache.cocoon.environment.Environment;
  import org.apache.cocoon.generation.Generator;
- import org.apache.cocoon.sitemap.ErrorNotifier;
  import org.apache.cocoon.transformation.Transformer;
  import org.apache.cocoon.xml.AbstractXMLProducer;
  import org.apache.cocoon.xml.XMLConsumer;
--- 17,22 ----
***************
*** 31,37 ****
  /**
   * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
   * @author <a href="mailto:cziegeler@Carsten Ziegeler">Carsten Ziegeler</a>
!  * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
   * @version CVS $Revision: 1.18 $ $Date: 2001/12/10 12:56:22 $
   */
  public abstract class AbstractEventPipeline
--- 30,38 ----
  /**
   * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
   * @author <a href="mailto:cziegeler@Carsten Ziegeler">Carsten Ziegeler</a>
!  * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a
!  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a>
!  * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Royal</a>
   * @version CVS $Revision: 1.18 $ $Date: 2001/12/10 12:56:22 $
   */
  public abstract class AbstractEventPipeline
***************
*** 69,82 ****
          this.newManager = manager;
      }
  
      public void setGenerator (String role, String source, Parameters param, 
Exception e)
      throws Exception {
          this.setGenerator (role, source, param);
!         // FIXME(CZ) What can be done if this is not an ErrorNotifier?
!         // (The sitemap uses this setGenerator() method only from inside
!         // the error pipeline, when a ErrorNotifier is explicitly generated.)
!         if (this.generator instanceof ErrorNotifier) {
!             ((ErrorNotifier)this.generator).setException(e);
          }
      }
  
--- 70,83 ----
          this.newManager = manager;
      }
  
+     /**
+      * @deprecated The NotifyingGenerator gets the Notificable from the objectModel
+      */
      public void setGenerator (String role, String source, Parameters param, 
Exception e)
      throws Exception {
          this.setGenerator (role, source, param);
!         if (this.generator instanceof org.apache.cocoon.sitemap.ErrorNotifier) {
!             
((org.apache.cocoon.sitemap.ErrorNotifier)this.generator).setThrowable(e);
          }
      }
  
***************
*** 85,91 ****
          if (this.generator != null) {
              throw new ProcessingException ("Generator already set. You can only 
select one Generator (" + role + ")");
          }
!         this.generatorSelector = (ComponentSelector) 
this.newManager.lookup(Generator.ROLE + "Selector");
          this.generator = (Generator) this.generatorSelector.select(role);
          this.generatorSource = source;
          this.generatorParam = param;
--- 86,92 ----
          if (this.generator != null) {
              throw new ProcessingException ("Generator already set. You can only 
select one Generator (" + role + ")");
          }
!         this.generatorSelector = (ComponentSelector) 
this.newManager.lookup(Generator.ROLE + "Selector");     
          this.generator = (Generator) this.generatorSelector.select(role);
          this.generatorSource = source;
          this.generatorParam = param;
***************
*** 289,291 ****
--- 290,293 ----
          // Nothing here
      }
  }
+ 


*** src/org/apache/cocoon/servlet/CocoonServlet.java    2001/12/20 15:15:36     1.57
--- src/org/apache/cocoon/servlet/CocoonServlet.java    2001/12/27 15:26:19
***************
*** 16,23 ****
  import org.apache.avalon.framework.context.DefaultContext;
  import org.apache.avalon.framework.logger.Loggable;
  import org.apache.cocoon.Constants;
! import org.apache.cocoon.Notification;
! import org.apache.cocoon.Notifier;
  import org.apache.cocoon.ResourceNotFoundException;
  import org.apache.cocoon.ConnectionResetException;
  import org.apache.cocoon.Cocoon;
--- 16,26 ----
  import org.apache.avalon.framework.context.DefaultContext;
  import org.apache.avalon.framework.logger.Loggable;
  import org.apache.cocoon.Constants;
! import org.apache.cocoon.components.notification.Notifying;
! import org.apache.cocoon.components.notification.SimpleNotifyingBean;
! import org.apache.cocoon.components.notification.NotifyingBuilder;
! import org.apache.cocoon.components.notification.DefaultNotifyingBuilder;
! import org.apache.cocoon.components.notification.Notifier;
  import org.apache.cocoon.ResourceNotFoundException;
  import org.apache.cocoon.ConnectionResetException;
  import org.apache.cocoon.Cocoon;
***************
*** 50,55 ****
--- 53,59 ----
  import java.lang.reflect.Constructor;
  import java.net.URL;
  import java.util.Arrays;
+ import java.util.HashMap;
  import java.util.StringTokenizer;
  
  /**
***************
*** 58,70 ****
   * @author <a href="mailto:[EMAIL PROTECTED]";>Pierpaolo Fumagalli</a>
   *         (Apache Software Foundation, Exoffice Technologies)
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
!  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a> Aisa
   * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Leo Sutic</a>
   * @version CVS $Revision: 1.57 $ $Date: 2001/12/20 15:15:36 $
   */
- 
  public class CocoonServlet extends HttpServlet {
  
      protected Logger log;
--- 62,73 ----
   * @author <a href="mailto:[EMAIL PROTECTED]";>Pierpaolo Fumagalli</a>
   *         (Apache Software Foundation, Exoffice Technologies)
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
!  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Leo Sutic</a>
   * @version CVS $Revision: 1.57 $ $Date: 2001/12/20 15:15:36 $
   */
  public class CocoonServlet extends HttpServlet {
  
      protected Logger log;
***************
*** 731,744 ****
          if (this.cocoon == null) {
              res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
  
!             Notification n = new Notification(this, this.exception);
!             n.setType("internal-servlet-error");
              n.setTitle("Internal servlet error");
              n.setSource("Cocoon servlet");
!             n.setMessage("Internal servlet error");
!             n.setDescription("Cocoon was not initialized.");
              n.addExtraDescription("request-uri", request.getRequestURI());
!             res.setContentType(Notifier.notify(n, res.getOutputStream()));;
  
              return;
          }
--- 734,747 ----
          if (this.cocoon == null) {
              res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
  
!             SimpleNotifyingBean n= new SimpleNotifyingBean(this);
!             n.setType("fatal");
              n.setTitle("Internal servlet error");
              n.setSource("Cocoon servlet");
!             n.setMessage("Cocoon was not initialized.");
!             n.setDescription("Cocoon was not initialized. Cannot process request.");
              n.addExtraDescription("request-uri", request.getRequestURI());
!             res.setContentType(Notifier.notify(n, res.getOutputStream()));
  
              return;
          }
***************
*** 793,806 ****
              if (this.cocoon.process(env)) {
                  contentType = env.getContentType();
              } else {
                  // means SC_NOT_FOUND
                  res.sendError(res.SC_NOT_FOUND);
  
!                 Notification n = new Notification(this);
!                 n.setType("resource-not-found");
                  n.setTitle("Resource not found");
                  n.setSource("Cocoon servlet");
!                 n.setMessage("Resource not found");
                  n.setDescription("The requested URI \""
                                   + request.getRequestURI()
                                   + "\" was not found.");
--- 796,810 ----
              if (this.cocoon.process(env)) {
                  contentType = env.getContentType();
              } else {
+                 // Should not get here!
                  // means SC_NOT_FOUND
                  res.sendError(res.SC_NOT_FOUND);
  
!                 SimpleNotifyingBean n = new SimpleNotifyingBean(this);
!                 n.setType("error");
                  n.setTitle("Resource not found");
                  n.setSource("Cocoon servlet");
!                 n.setMessage("The requested resource not found.");
                  n.setDescription("The requested URI \""
                                   + request.getRequestURI()
                                   + "\" was not found.");
***************
*** 816,822 ****
              }
  
              res.sendError(res.SC_NOT_FOUND);
!             Notification n = new Notification(this);
              n.setType("resource-not-found");
              n.setTitle("Resource not found");
              n.setSource("Cocoon servlet");
--- 820,827 ----
              }
  
              res.sendError(res.SC_NOT_FOUND);
!             
!             SimpleNotifyingBean n = new SimpleNotifyingBean(this);
              n.setType("resource-not-found");
              n.setTitle("Resource not found");
              n.setSource("Cocoon servlet");
***************
*** 829,841 ****
              // send the notification but don't include it in the output stream
              // as the status SC_NOT_FOUND is enough
              res.setContentType(Notifier.notify(n, (OutputStream)null));
          } catch (ConnectionResetException cre) {
              if (log.isWarnEnabled()) {
                  log.warn("The connection was reset", cre);
              }
  
!             Notification n = new Notification(this);
!             n.setType("resource-not-found");
              n.setTitle("Resource not found");
              n.setSource("Cocoon servlet");
              n.setMessage("Resource not found");
--- 834,847 ----
              // send the notification but don't include it in the output stream
              // as the status SC_NOT_FOUND is enough
              res.setContentType(Notifier.notify(n, (OutputStream)null));
+             
          } catch (ConnectionResetException cre) {
              if (log.isWarnEnabled()) {
                  log.warn("The connection was reset", cre);
              }
  
!             SimpleNotifyingBean n = new SimpleNotifyingBean(this);
!             n.setType("error");
              n.setTitle("Resource not found");
              n.setSource("Cocoon servlet");
              n.setMessage("Resource not found");
***************
*** 852,863 ****
                  log.error("Problem with servlet", e);
              }
              //res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
!             Notification n = new Notification(this, e);
!             n.setType("internal-server-error");
!             n.setTitle("Internal server error");
!             n.setSource("Cocoon servlet");
!             n.addExtraDescription("request-uri", request.getRequestURI());
!             n.addExtraDescription("path-info", uri);
              res.setContentType(contentType = Notifier.notify(n, 
res.getOutputStream()));
          }
  
--- 858,871 ----
                  log.error("Problem with servlet", e);
              }
              //res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
! 
!             HashMap extraDescriptions = new HashMap(2);
!             extraDescriptions.put("request-uri", request.getRequestURI());
!             extraDescriptions.put("path-info", uri);
!             
!             Notifying n=new DefaultNotifyingBuilder().build(
!              this, e, "fatal","Internal server error","Cocoon 
servlet",null,null,extraDescriptions);
! 
              res.setContentType(contentType = Notifier.notify(n, 
res.getOutputStream()));
          }
  


*** src/org/apache/cocoon/sitemap/ErrorNotifier.java    2001/10/11 07:28:23     1.5
--- src/org/apache/cocoon/sitemap/ErrorNotifier.java    2001/12/27 15:26:25
***************
*** 8,69 ****
  
  package org.apache.cocoon.sitemap;
  
  import org.apache.avalon.excalibur.pool.Recyclable;
! import org.apache.cocoon.Notification;
! import org.apache.cocoon.Notifier;
  import org.apache.cocoon.generation.ComposerGenerator;
  import org.xml.sax.SAXException;
  
  /**
   * Generates an XML representation of the current notification.
!  *
!  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a> Aisa
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
   * @created 31 July 2000
   * @version CVS $Revision: 1.5 $ $Date: 2001/10/11 07:28:23 $
   */
! public class ErrorNotifier extends ComposerGenerator implements Recyclable {
!     /**
!      * The <code>Notification</code> to report.
!      */
!     private Notification notification = null;
! 
!     /**
!      * Set the Exception to report.
!      *
!      * @param exception The Exception to report
!      */
!     public void setException(Throwable throwable) {
!         notification = new Notification(this, throwable);
!         notification.setTitle("Error creating the resource");
!     }
  
!     /**
!      * Set the Notification to report.
!      *
!      * @param exception The Exception to report
!      */
!     public void setNotification(Object o) {
!         notification = new Notification(this, o);
!         notification.setTitle("Error creating the resource");
      }
! 
!     /**
!      * Generate the notification information in XML format.
!      *
!      * @exception  SAXException  Description of problem there is creating the output 
SAX events.
!      * @throws SAXException when there is a problem creating the
!      *      output SAX events.
!      */
!     public void generate() throws SAXException {
!         Notifier.notify(notification, this.contentHandler);
      }
  
!     /**
!      * Recycle
!      */
!     public void recycle() {
!         super.recycle();
!         this.notification = null;
      }
  }
--- 8,66 ----
  
  package org.apache.cocoon.sitemap;
  
+ import java.util.Map;
+ import java.io.IOException;
+ 
  import org.apache.avalon.excalibur.pool.Recyclable;
! import org.apache.avalon.framework.parameters.Parameters;
! import org.apache.cocoon.components.notification.Notifying;
! import org.apache.cocoon.components.notification.DefaultNotifyingBuilder;
  import org.apache.cocoon.generation.ComposerGenerator;
+ import org.apache.cocoon.environment.SourceResolver;
+ import org.apache.cocoon.ProcessingException;
+ import org.apache.cocoon.Constants;
+ 
  import org.xml.sax.SAXException;
  
  /**
   * Generates an XML representation of the current notification.
!  * @deprecated Now using NotifyingGenerator in sitemap
!  * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
   * @created 31 July 2000
   * @version CVS $Revision: 1.5 $ $Date: 2001/10/11 07:28:23 $
   */
! public class ErrorNotifier extends NotifyingGenerator {
!   /**
!    * The <code>Notification</code> to report.
!    */
!   private Notifying notification = null;
  
!   public void setup(SourceResolver resolver, Map objectModel, String src,
!           Parameters par) throws ProcessingException, SAXException, IOException {
!     try
!     {
!       super.setup(resolver, objectModel, src, par);
      }
!     catch(ProcessingException pe)
!     {
!       //do nothing, thrown by superclass that didn't find the object to notify
!       //it will be set in setThrowable in this class
      }
+   }
  
!   /**
!    * Set the Notification to report.
!    * @deprecated Now it gets the Exception from the ObjectModel
!    * @param exception The Exception to report
!    */
!   public void setThrowable(Throwable throwable) {
!     if (throwable instanceof Notifying) {
!       this.notification = (Notifying) throwable;
!     } else {
!       notification = new DefaultNotifyingBuilder().build("@deprecated method 
setThrowable() in ErrorNotifier", throwable);
      }
+   }
+ 
  }
+ 


*** src/org/apache/cocoon/sitemap/sitemap.roles
--- src/org/apache/cocoon/sitemap/sitemap.roles
*** webapp/sitemap.xmap 2001/12/23 09:48:40     1.72
--- webapp/sitemap.xmap 2001/12/27 15:26:34
***************
*** 1096,1102 ****
     </map:match>
  
     <map:handle-errors>
!     <map:transform src="stylesheets/system/error2html.xsl"/>
      <map:serialize status-code="500"/>
     </map:handle-errors>
  
--- 1096,1102 ----
     </map:match>
  
     <map:handle-errors>
!     <map:transform src="context://stylesheets/system/error2html.xsl"/>
      <map:serialize status-code="500"/>
     </map:handle-errors>
  


*** webapp/stylesheets/simple-samples2html.xsl
--- webapp/stylesheets/simple-samples2html.xsl

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to