Author: vgritsenko
Date: Fri Mar 11 08:18:02 2005
New Revision: 157096

URL: http://svn.apache.org/viewcvs?view=rev&rev=157096
Log:
error handling samples refactoring

Added:
    
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionAction.java
   (with props)
    cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/notFound.html
      - copied, changed from r157080, 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/resourceNotFound.htm
Removed:
    
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/generalerror.htm
    
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/resourceNotFound.htm
Modified:
    
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ApplicationException.java
    
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionGenerator.java
    
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ValidationException.java
    
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application.htm
    
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application1.htm
    
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application2.htm
    
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/error-giving-page.xml
    
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/sitemap.xmap
    
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/validation.htm
    cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/samples.xml
    cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/sitemap.xmap
    cocoon/branches/BRANCH_2_1_X/src/webapp/samples/samples.xml

Modified: 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ApplicationException.java
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ApplicationException.java?view=diff&r1=157095&r2=157096
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ApplicationException.java
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ApplicationException.java
 Fri Mar 11 08:18:02 2005
@@ -1,12 +1,12 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,22 +16,25 @@
 package org.apache.cocoon.samples.errorhandling;
 
 /**
-* @author <a href="mailto:[EMAIL PROTECTED]">Bj&ouml;rn L&uuml;tkemeier</a>
-* 
-* @version CVS $Id: ApplicationException.java,v 1.3 2004/03/05 13:03:02 
bdelacretaz Exp $
-*/
-public class ApplicationException 
-extends Exception {
+ * @author <a href="mailto:[EMAIL PROTECTED]">Bj&ouml;rn L&uuml;tkemeier</a>
+ * @version $Id$
+ */
+public class ApplicationException extends Exception {
        private int errorCode;
-       
+
+       public ApplicationException(int errorCode, String message) {
+        super(message);
+               this.errorCode = errorCode;
+       }
+
        public ApplicationException(int errorCode) {
                this.errorCode = errorCode;
        }
-       
+
        public void setErrorCode(int errorCode) {
                this.errorCode = errorCode;
        }
-       
+
        public int getErrorCode() {
                return this.errorCode;
        }

Added: 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionAction.java
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionAction.java?view=auto&rev=157096
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionAction.java
 (added)
+++ 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionAction.java
 Fri Mar 11 08:18:02 2005
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.samples.errorhandling;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.ResourceNotFoundException;
+import org.apache.cocoon.acting.AbstractAction;
+import org.apache.cocoon.environment.Redirector;
+import org.apache.cocoon.environment.SourceResolver;
+
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Exception action. Throws different kinds of exception depending on
+ * value of src attribute.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a>
+ * @version $Id$
+ */
+public class ExceptionAction extends AbstractAction {
+
+    public Map act(Redirector redirector, SourceResolver resolver, Map 
objectModel, String source, Parameters parameters)
+    throws Exception {
+        String exception = parameters.getParameter("exception", source);
+        int code = parameters.getParameterAsInteger("code", 1);
+        exception(exception, code);
+        return null;
+    }
+
+    public static String exception(String exception, int code)
+    throws ProcessingException , SAXException, IOException {
+        if (exception == null) {
+            return "No exception occured.";
+        } else if (exception.equals("validation")) {
+            throw new ProcessingException(new ValidationException("Validation 
Exception Message"));
+        } else if (exception.equals("application")) {
+            throw new ProcessingException(new ApplicationException(code, 
"Application Exception " + code + " Message"));
+        } else if (exception.equals("processing")) {
+            throw new ProcessingException("Processing Exception Message");
+        } else if (exception.equals("notFound")) {
+            throw new ResourceNotFoundException("Resource Not Found Exception 
Message");
+        } else if (exception.equals("sax")) {
+            throw new SAXException("SAX Exception Message");
+        } else if (exception.equals("saxWrapped")) {
+            throw new SAXException(new ProcessingException("Processing 
Exception Wrapped In SAX Exception Message"));
+        } else if (exception.equals("nullPointer")) {
+            throw new NullPointerException("Null Pointer Exception Message");
+        } else if (exception.equals("io")) {
+            throw new IOException("IO Exception Message");
+        } else if (exception.equals("error")) {
+            throw new Error("Error Message");
+        } else {
+            return "Unknown exception requested.";
+        }
+    }
+}

Propchange: 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionAction.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionGenerator.java
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionGenerator.java?view=diff&r1=157095&r2=157096
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionGenerator.java
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionGenerator.java
 Fri Mar 11 08:18:02 2005
@@ -1,72 +1,66 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.cocoon.samples.errorhandling;
 
-import java.io.IOException;
+import org.apache.avalon.framework.parameters.Parameters;
 
 import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.ResourceNotFoundException;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.generation.AbstractGenerator;
+
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
 
+import java.io.IOException;
+import java.util.Map;
+
 /**
- * Exception generator.
+ * Exception generator. Throws different kinds of exception depending on
+ * value of src attribute.
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Bj&ouml;rn L&uuml;tkemeier</a>
- * @version CVS $Id: ExceptionGenerator.java,v 1.5 2004/03/05 13:03:02 
bdelacretaz Exp $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a>
+ * @version $Id$
  */
 public class ExceptionGenerator extends AbstractGenerator {
 
-    /** Name of request parameters. */
-    public static final String PAR_EXCEPTION = "exception";
+    private String exception;
+    private int code;
 
-    public static final String PAR_CODE = "code";
+    public void setup(SourceResolver resolver, Map objectModel, String src, 
Parameters parameters)
+    throws ProcessingException, SAXException, IOException {
+        super.setup(resolver, objectModel, src, parameters);
+
+        this.exception = parameters.getParameter("exception", super.source);
+        this.code = Integer.parseInt(parameters.getParameter("code", "0"));
+
+        // Throw exception in the setup phase?
+        if (parameters.getParameterAsBoolean("setup", false)) {
+            ExceptionAction.exception(this.exception, this.code);
+        }
+    }
 
     /**
      * Overridden from superclass.
      */
     public void generate()
-      throws IOException, SAXException, ProcessingException {
-        Request request = ObjectModelHelper.getRequest(this.objectModel);
-        String exception = request.getParameter(PAR_EXCEPTION);
-        String text = null;
-
-        if (exception==null) {
-            text = "No exception occured.";
-        } else if (exception.equals("validation")) {
-            throw new ProcessingException(new ValidationException());
-        } else if (exception.equals("application")) {
-            throw new ProcessingException(new 
ApplicationException(Integer.parseInt(request.getParameter(PAR_CODE))));
-        } else if (exception.equals("resourceNotFound")) {
-            throw new ProcessingException(new ResourceNotFoundException(""));
-        } else if (exception.equals("nullPointer")) {
-            throw new NullPointerException();
-        } else if (exception.equals("error")) {
-            throw new Error("Error");
-        } else {
-            text = "Unknown exception requested.";
-        }
-
+    throws ProcessingException , SAXException, IOException {
+        String text = ExceptionAction.exception(this.exception, this.code);
         Attributes noAttrs = new AttributesImpl();
-
         this.contentHandler.startDocument();
         this.contentHandler.startElement("", "html", "html", noAttrs);
         this.contentHandler.startElement("", "body", "body", noAttrs);

Modified: 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ValidationException.java
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ValidationException.java?view=diff&r1=157095&r2=157096
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ValidationException.java
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ValidationException.java
 Fri Mar 11 08:18:02 2005
@@ -1,27 +1,31 @@
 /*
-* Copyright 1999-2004 The Apache Software Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-/*
-       ValidationException.java
-
-       Author: Bj&ouml;rn L&uuml;tkemeier <[EMAIL PROTECTED]>
-       Date: April 23, 2003
-
+ * Copyright 1999-2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.cocoon.samples.errorhandling;
 
-public class ValidationException 
-extends Exception {
+/**
+ * @author Bj&ouml;rn L&uuml;tkemeier <[EMAIL PROTECTED]>
+ * @since April 23, 2003
+ * @version $Id$
+ */
+public class ValidationException extends Exception {
+    public ValidationException() {
+        super();
+    }
+
+    public ValidationException(String message) {
+        super(message);
+    }
 }

Modified: 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application.htm
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application.htm?view=diff&r1=157095&r2=157096
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application.htm
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application.htm
 Fri Mar 11 08:18:02 2005
@@ -13,8 +13,13 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
+
 <html>
-       <body>
-               <p>An ApplicationException has occured. Handled by pipelines' 
error handler.</p>
-       </body>
-</html>
\ No newline at end of file
+  <body>
+    <p>
+      An <b>ApplicationException</b> has occured.
+      Handled by <code>map:pipelines</code> error handler in
+      <code>errorhandling/exception/sitemap.xmap</code>.
+    </p>
+  </body>
+</html>

Modified: 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application1.htm
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application1.htm?view=diff&r1=157095&r2=157096
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application1.htm
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application1.htm
 Fri Mar 11 08:18:02 2005
@@ -13,8 +13,13 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
+
 <html>
-       <body>
-               <p>An ApplicationException with errorCode=1 has occured. 
Handled by pipelines' error handler.</p>
-       </body>
-</html>
\ No newline at end of file
+  <body>
+    <p>
+      An <b>ApplicationException</b> with errorCode <b>1</b> has occured.
+      Handled by <code>map:pipelines</code> error handler in
+      <code>errorhandling/exception/sitemap.xmap</code>.
+    </p>
+  </body>
+</html>

Modified: 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application2.htm
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application2.htm?view=diff&r1=157095&r2=157096
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application2.htm
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/application2.htm
 Fri Mar 11 08:18:02 2005
@@ -13,8 +13,13 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
+
 <html>
-       <body>
-               <p>An ApplicationException with errorCode=2 has occured. 
Handled by pipelines' error handler.</p>
-       </body>
+  <body>
+    <p>
+      An <b>ApplicationException</b> with errorCode <b>2</b> has occured.
+      Handled by <code>map:pipelines</code> error handler in
+      <code>errorhandling/exception/sitemap.xmap</code>.
+    </p>
+  </body>
 </html>

Modified: 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/error-giving-page.xml
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/error-giving-page.xml?view=diff&r1=157095&r2=157096
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/error-giving-page.xml
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/error-giving-page.xml
 Fri Mar 11 08:18:02 2005
@@ -15,8 +15,6 @@
   limitations under the License.
 -->
 
-<!-- CVS $Id: error-giving-page.xml,v 1.3 2004/03/06 02:26:04 antonio Exp $ -->
-
 <!DOCTYPE page [
  <!ELEMENT page (title?, content)>
  <!ELEMENT title (#PCDATA)>
@@ -24,11 +22,19 @@
  <!ELEMENT para (#PCDATA)>
 ]>
 
+<!--+
+    | Broken Page.
+    |
+    | NOTE: This page is intentionally not well-formed in order
+    |       to trigger an exception and show how the sitemap
+    |       error handling works!
+    |
+    | $Id$
+    +-->
+
 <page>
- <!-- NOTE: this page is not well-formed intentionally in order to trigger an 
exception
-      and show how the sitemap error handling works -->
- <title>Hello<title>
- <content>
-  <para>This is my first Cocoon page!</para>
- </content>
+  <title>Hello<title>
+  <content>
+    <para>This is my first Cocoon page!</para>
+  </content>
 </page>

Modified: 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/sitemap.xmap
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/sitemap.xmap?view=diff&r1=157095&r2=157096
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/sitemap.xmap
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/sitemap.xmap
 Fri Mar 11 08:18:02 2005
@@ -15,26 +15,21 @@
   limitations under the License.
 -->
 
-<!-- CVS $Id: sitemap.xmap,v 1.7 2004/03/06 02:26:04 antonio Exp $ -->
-
+<!--+
+    |
+    | $Id$
+    +-->
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0";>
 
-  <map:components>
-    <map:generators default="file">
-      <map:generator name="exception" 
src="org.apache.cocoon.samples.errorhandling.ExceptionGenerator"/>
-    </map:generators>
-  </map:components>
-
   <map:pipelines>
     <map:pipeline>
-
-      <map:match pattern="exception">
-        <map:generate type="exception"/>
+      <map:match pattern="generror">
+        <map:generate src="error-giving-page.xml"/>
         <map:serialize/>
       </map:match>
 
-      <map:match pattern="generror">
-        <map:generate src="error-giving-page.xml"/>
+      <map:match pattern="*">
+        <map:generate type="exception" src="{1}"/>
         <map:serialize/>
       </map:match>
 

Modified: 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/validation.htm
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/validation.htm?view=diff&r1=157095&r2=157096
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/validation.htm
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/exception/validation.htm
 Fri Mar 11 08:18:02 2005
@@ -13,8 +13,13 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
+
 <html>
-       <body>
-               <p>A ValidationException has occured. Handled by pipeline's 
error handler.</p>
-       </body>
-</html>
\ No newline at end of file
+  <body>
+    <p>
+      A <b>ValidationException</b> has occured.
+      Handled by <code>map:pipeline</code> error handler in
+      <code>errorhandling/exception/sitemap.xmap</code>.
+    </p>
+  </body>
+</html>

Copied: 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/notFound.html 
(from r157080, 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/resourceNotFound.htm)
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/notFound.html?view=diff&rev=157096&p1=cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/resourceNotFound.htm&r1=157080&p2=cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/notFound.html&r2=157096
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/resourceNotFound.htm
 (original)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/notFound.html 
Fri Mar 11 08:18:02 2005
@@ -14,7 +14,11 @@
   limitations under the License.
 -->
 <html>
-       <body>
-               <p>A ResourceNotFoundException has occured. Handled by 
pipeline's error handler in parent sitemap.</p>
-       </body>
+  <body>
+    <p>
+      A <b>ResourceNotFoundException</b> has occured.
+      Handled by <code>map:pipeline</code> error handler in
+      <code>errorhandling/sitemap.xmap</code>.
+    </p>
+  </body>
 </html>

Modified: 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/samples.xml
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/samples.xml?view=diff&r1=157095&r2=157096
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/samples.xml 
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/samples.xml 
Fri Mar 11 08:18:02 2005
@@ -15,56 +15,71 @@
   limitations under the License.
 -->
 
-<!-- CVS $Id$ -->
-
+<!--+
+    | $Id$
+    +-->
 <samples name="Error Handling Samples" 
xmlns:xlink="http://www.w3.org/1999/xlink";>
 
   <group name="Back">
-   <sample name="Back" href="../">
-    Back to the samples home page.
-   </sample>
+    <sample name="Back" href="../">
+      Back to the samples home page.
+    </sample>
   </group>
 
   <group name="Cocoon Exceptions">
-   <note>Choose what exception you want to generate...</note>
-   <sample name="SAXParseException" href="exception/generror">
-    Attempt to read invalid XML file.
-   </sample>
-   <sample name="ValidationException" 
href="exception/exception?exception=validation">
-    Generate ValidationException.
-   </sample>
-   <sample name="ResourceNotFoundException" 
href="exception/exception?exception=resourceNotFound">
-    Generate ResourceNotFoundException.
-   </sample>
+    <note>Demonstrates common Cocoon exceptions and default error 
handling.</note>
+    <sample name="SAXParseException" href="exception/generror">
+      Attempt to read invalid XML file.
+    </sample>
+    <sample name="ResourceNotFoundException" href="not-exists">
+      Attempt to read non existent file.
+    </sample>
+    <sample name="ProcessingException" href="processing">
+      General processing error.
+    </sample>
+    <sample name="SAXException" href="sax">
+      SAX processing error.
+    </sample>
+    <sample name="Wrapped ProcessingException" href="saxWrapped">
+      General processing error wrapped in SAX exception.
+    </sample>
   </group>
 
-  <group name="Application Exceptions">
-   <sample name="ApplicationException (1)" 
href="exception/exception?exception=application&amp;code=1">
-    Generate ApplicationException with error code 1.
-   </sample>
-   <sample name="ApplicationException (2)" 
href="exception/exception?exception=application&amp;code=2">
-    Generate ApplicationException with error code 2.
-   </sample>
-   <sample name="ApplicationException (3)" 
href="exception/exception?exception=application&amp;code=3">
-    Generate ApplicationException with error code 3.
-   </sample>
+  <group name="Java Exceptions">
+    <note>Demonstrates common Java exceptions and default error 
handling.</note>
+    <sample name="NullPointerException" href="nullPointer">
+      Generate NullPointerException.
+    </sample>
+    <sample name="IOException" href="io">
+      Generate IOException.
+    </sample>
+    <note>
+      Since Cocoon does not process java.lang.Error (and derived objects),
+      behavior of this sample will depend on behavior of servlet engine.
+      In case of Jetty and Tomcat, they will show empty page and print
+      Error's stacktrace to the console.
+    </note>
+    <sample name="Error" href="exception/error">
+      Generate Error.
+    </sample>
   </group>
 
-  <group name="Java Exceptions">
-   <sample name="NullPointerException" 
href="exception/exception?exception=nullPointer">
-    Generate RuntimeException.
-   </sample>
-   <note>
-     Since Cocoon does not process java.lang.Error (and derived objects),
-     behavior of this sample will depend on behavior of servlet engine.
-     In case of Jetty and Tomcat, they will show empty page and print
-     Error's stacktrace to the console.
-   </note>
-   <sample name="Error" href="exception/exception?exception=error">
-    Generate Error.
-   </sample>
-   <sample name="No Exception" href="exception/exception">
-    Normal behaviour.
-   </sample>
+  <group name="Custom Exception Handling">
+    <note>Demonstrates custom error handling of Cocoon and Application 
exceptions.</note>
+    <sample name="ResourceNotFoundException" href="exception/notFound">
+      Generate ResourceNotFoundException.
+    </sample>
+    <sample name="ValidationException" href="exception/validation">
+      Generate ValidationException.
+    </sample>
+    <sample name="ApplicationException (1)" 
href="exception/application?code=1">
+      Generate ApplicationException with error code 1.
+    </sample>
+    <sample name="ApplicationException (2)" 
href="exception/application?code=2">
+      Generate ApplicationException with error code 2.
+    </sample>
+    <sample name="ApplicationException (3)" 
href="exception/application?code=3">
+      Generate ApplicationException with error code 3.
+    </sample>
   </group>
 </samples>

Modified: 
cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/sitemap.xmap
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/sitemap.xmap?view=diff&r1=157095&r2=157096
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/sitemap.xmap 
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/samples/errorhandling/sitemap.xmap 
Fri Mar 11 08:18:02 2005
@@ -15,11 +15,15 @@
   limitations under the License.
 -->
 
-<!-- CVS $Id: sitemap.xmap,v 1.7 2004/03/06 02:26:18 antonio Exp $ -->
-
+<!--+
+    | $Id$
+    +-->
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0";>
 
   <map:components>
+    <map:generators default="file">
+      <map:generator name="exception" 
src="org.apache.cocoon.samples.errorhandling.ExceptionGenerator"/>
+    </map:generators>
     <map:selectors default="browser">
       <map:selector name="exception" 
src="org.apache.cocoon.selection.XPathExceptionSelector">
         <exception name="application" 
class="org.apache.cocoon.samples.errorhandling.ApplicationException">
@@ -31,6 +35,9 @@
         <exception class="java.lang.Throwable" unroll="true"/>
       </map:selector>
     </map:selectors>
+    <map:actions>
+      <map:action name="exception" 
src="org.apache.cocoon.samples.errorhandling.ExceptionAction"/>
+    </map:actions>
   </map:components>
 
   <map:pipelines>
@@ -47,13 +54,19 @@
         <map:serialize/>
       </map:match>
 
-      <map:match pattern="main">
-        <map:generate src="main.xml"/>
-        <map:transform 
src="context://samples/common/style/xsl/html/complex-page2html.xsl">
-          <map:parameter name="contextPath" value="{request:contextPath}"/>
-        </map:transform>
+      <map:match pattern="not-exists">
+        <map:generate src="{0}.xml"/>
+        <map:serialize/>
+      </map:match>
+
+      <map:match pattern="*">
+        <map:generate type="exception" src="{1}"/>
         <map:serialize/>
       </map:match>
+
+      <map:match pattern="internal/**">
+        <map:mount uri-prefix="internal" src="internal/"/>
+      </map:match>
     </map:pipeline>
 
     <map:pipeline>
@@ -62,7 +75,7 @@
       <map:handle-errors>
         <map:select type="exception">
           <map:when test="not-found">
-            <map:generate src="resourceNotFound.htm"/>
+            <map:generate src="notFound.html"/>
             <map:serialize/>
           </map:when>
         </map:select>

Modified: cocoon/branches/BRANCH_2_1_X/src/webapp/samples/samples.xml
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/samples.xml?view=diff&r1=157095&r2=157096
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/webapp/samples/samples.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/samples/samples.xml Fri Mar 11 
08:18:02 2005
@@ -18,7 +18,7 @@
 <!--+
     | Main samples page
     |
-    | CVS $Id: samples.xml,v 1.40 2004/05/24 01:48:24 crossley Exp $
+    | CVS $Id$
     +-->
 
 <samples name="Cocoon Samples" xmlns:xlink="http://www.w3.org/1999/xlink";>
@@ -42,7 +42,7 @@
       languages. Here is an example of the power of such an approach with
       the help of those i18n and l10n Cocoon facilities.
     </sample>
-    <sample name="Syndication and Content Aggregation" href="aggregation/">
+    <sample name="Content Syndication &amp; Aggregation" href="aggregation/">
       Separation of content and style allows not only to serve your content
       in different ways, but also to syndicate, aggregate or otherwise include
       and transform content provided by other web sites.
@@ -67,7 +67,7 @@
       An example page producing exceptions and handling them. Demonstrates the 
       handler hierarchy and the exception selectors.
     </sample>
-    <sample href="components" name="Components">
+    <sample href="components" name="Core Components">
       Some samples of various components that are included with the core,
       e.g. Stream Generators, Paginator Transformers, Image Readers.
     </sample>


Reply via email to