Mailing List Archive

svn commit: r1550140 - in /forrest/trunk: main/webapp/ main/webapp/WEB-INF/ main/webapp/resources/stylesheets/ site-author/ site-author/content/xdocs/ site-author/content/xdocs/docs_0_100/
Author: crossley
Date: Wed Dec 11 13:57:21 2013
New Revision: 1550140

URL: http://svn.apache.org/r1550140
Log:
Enable per-project configuration of Cocoon error handling.
Issue: FOR-1245

Added:
forrest/trunk/main/webapp/resources/stylesheets/exception-to-text.xsl
- copied, changed from r1546505, forrest/trunk/main/webapp/resources/stylesheets/exception-to-html.xsl
Modified:
forrest/trunk/main/webapp/WEB-INF/logkit.xconf
forrest/trunk/main/webapp/sitemap.xmap
forrest/trunk/site-author/content/xdocs/docs_0_100/faq.xml
forrest/trunk/site-author/content/xdocs/site.xml
forrest/trunk/site-author/status.xml

Modified: forrest/trunk/main/webapp/WEB-INF/logkit.xconf
URL: http://svn.apache.org/viewvc/forrest/trunk/main/webapp/WEB-INF/logkit.xconf?rev=1550140&r1=1550139&r2=1550140&view=diff
==============================================================================
--- forrest/trunk/main/webapp/WEB-INF/logkit.xconf (original)
+++ forrest/trunk/main/webapp/WEB-INF/logkit.xconf Wed Dec 11 13:57:21 2013
@@ -102,6 +102,14 @@
<append>false</append>
</cocoon>

+ <cocoon id="exception">
+ <filename>${context-root}/WEB-INF/logs/exception.log</filename>
+ <format type="cocoon">
+ %7.7{priority} %{time} [%{category}] (%{uri}): %{message}\n%{throwable}
+ </format>
+ <append>false</append>
+ </cocoon>
+
<cocoon id="idgen">
<filename>${context-root}/WEB-INF/logs/idgen.log</filename>
<format type="cocoon">
@@ -246,6 +254,10 @@
<log-target id-ref="linkrewriter"/>
<log-target id-ref="error"/>
</category>
+ <category name="handled-errors" log-level="INFO">
+ <log-target id-ref="exception"/>
+ <log-target id-ref="error"/>
+ </category>

<log-target id-ref="sitemap"/>
<log-target id-ref="error"/>

Copied: forrest/trunk/main/webapp/resources/stylesheets/exception-to-text.xsl (from r1546505, forrest/trunk/main/webapp/resources/stylesheets/exception-to-html.xsl)
URL: http://svn.apache.org/viewvc/forrest/trunk/main/webapp/resources/stylesheets/exception-to-text.xsl?p2=forrest/trunk/main/webapp/resources/stylesheets/exception-to-text.xsl&p1=forrest/trunk/main/webapp/resources/stylesheets/exception-to-html.xsl&r1=1546505&r2=1550140&rev=1550140&view=diff
==============================================================================
--- forrest/trunk/main/webapp/resources/stylesheets/exception-to-html.xsl (original)
+++ forrest/trunk/main/webapp/resources/stylesheets/exception-to-text.xsl Wed Dec 11 13:57:21 2013
@@ -17,37 +17,19 @@
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:ex="http://apache.org/cocoon/exception/1.0">
- <xsl:template match="/">
- <html>
- <head>
- <title>Exception</title>
- </head>
- <body>
- <xsl:apply-templates/>
- </body>
- </html>
- </xsl:template>
+ xmlns:ex="http://apache.org/cocoon/exception/1.0"
+ exclude-result-prefixes="ex">
+ <xsl:param name="type"/>
<xsl:template match="ex:exception-report">
<xsl:choose>
<xsl:when test="contains(ex:message, '(Access is denied)')">
- <h1>An Error Occurred</h1>
- <p>
- It looks like there is a problem with an unresolved hint in the your
- locationmap.
- </p>
- <p>
- More information can be found in the logs.
- </p>
+ <xsl:text>It looks like there is a problem with an unresolved hint in your locationmap.</xsl:text>
+ </xsl:when>
+ <xsl:when test="contains(ex:message, '(No such file')">
+ <xsl:text>No such source content.</xsl:text>
</xsl:when>
<xsl:otherwise>
- <h1>An Error Occurred</h1>
- <p>
- <xsl:value-of select="ex:message"/>
- </p>
- <p>
- More information can be found in the logs.
- </p>
+ <xsl:value-of select="ex:message"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Modified: forrest/trunk/main/webapp/sitemap.xmap
URL: http://svn.apache.org/viewvc/forrest/trunk/main/webapp/sitemap.xmap?rev=1550140&r1=1550139&r2=1550140&view=diff
==============================================================================
--- forrest/trunk/main/webapp/sitemap.xmap (original)
+++ forrest/trunk/main/webapp/sitemap.xmap Wed Dec 11 13:57:21 2013
@@ -223,8 +223,9 @@ $Revision: 1.12 $
<map:selectors>
<map:selector name="exists" logger="sitemap.selector.exists"
src="org.apache.forrest.sourceexists.SourceExistsSelector" />
- <map:selector name="exception" src="org.apache.cocoon.selection.ExceptionSelector">
+ <map:selector name="exception" logger="sitemap.selector.exception" src="org.apache.cocoon.selection.ExceptionSelector">
<exception name="resourceNotFound" class="org.apache.cocoon.ResourceNotFoundException"/>
+ <exception name="transformer" class="javax.xml.transform.TransformerException"/>
<exception class="java.lang.Throwable" unroll="true"/>
</map:selector>
<map:selector name="config" logger="sitemap.selector.config"
@@ -638,16 +639,7 @@ $Revision: 1.12 $
<map:redirect-to uri="index.html"/>
</map:match>
</map:pipeline>
-<!--
- <map:handle-errors>
- <map:select type="exception">
- <map:when test="resourceNotFound">
- <map:generate type="exception"/>
- <map:transform src="{lm:transform.exception.html}"/>
- <map:serialize type="html"/>
- </map:when>
- </map:select>
- </map:handle-errors>
- -->
+<!-- Enable Cocoon error handling. See FOR-1245. -->
+ &handle-errors;
</map:pipelines>
</map:sitemap>

Modified: forrest/trunk/site-author/content/xdocs/docs_0_100/faq.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/site-author/content/xdocs/docs_0_100/faq.xml?rev=1550140&r1=1550139&r2=1550140&view=diff
==============================================================================
--- forrest/trunk/site-author/content/xdocs/docs_0_100/faq.xml (original)
+++ forrest/trunk/site-author/content/xdocs/docs_0_100/faq.xml Wed Dec 11 13:57:21 2013
@@ -1313,6 +1313,50 @@ X [0] /docs_0_80/upgrading_08.ht
</p>
</answer>
</faq>
+ <faq id="handle-errors">
+ <question>How to enable Cocoon error handling?</question>
+ <answer>
+ <p>
+ When Cocoon encounters an exception then it will present a default
+ page to explain the error. Better error handling can be configured
+ by adding a "map:handle-errors" section to each sitemap from which
+ such exceptions might arise.
+ </p>
+ <p>
+ That is easily added directly to your project sitemap for any
+ special processing.
+ However for many cases it needs to be added to the main
+ webapp/sitemap.xmap file.
+ </p>
+ <p>
+ Do this by adding a "handle-errors" xml entity to your project
+ "symbols" file (<a href="#sitemap-entities">explained above</a>).
+ For example:
+ </p>
+ <source>
+<![.CDATA[.<!ENTITY handle-errors '
+ <map:handle-errors>
+ <map:select type="exception">
+ <map:when test="resourceNotFound">
+ <map:generate type="exception"/>
+ <map:transform src="{lm:transform.exception.text}">
+ <map:parameter name="type" value="404"/>
+ </map:transform>
+ <map:serialize type="text" status-code="404"/>
+ </map:when>
+ </map:select>
+ </map:handle-errors>
+'>]]></source>
+ <p>
+ Some exception selectors are configured in webapp/sitemap.xmap file
+ at the "map:selectors" section.
+ Please send patches for others if you need them to be added.
+ </p>
+ <p>
+ See further <a href="http://s.apache.org/b8V">exxplanation</a>.
+ </p>
+ </answer>
+ </faq>
<faq id="svn-eol-style">
<question>Why are there SVN diffs for some documents, even though they have not changed?</question>
<answer>

Modified: forrest/trunk/site-author/content/xdocs/site.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/site-author/content/xdocs/site.xml?rev=1550140&r1=1550139&r2=1550140&view=diff
==============================================================================
--- forrest/trunk/site-author/content/xdocs/site.xml (original)
+++ forrest/trunk/site-author/content/xdocs/site.xml Wed Dec 11 13:57:21 2013
@@ -340,6 +340,7 @@
<run_port href="#run_port"/>
<single-document href="#single-document"/>
<sitemap-entities href="#sitemap-entities"/>
+ <handle-errors href="#handle-errors"/>
<svn-eol-style href="#svn-eol-style"/>
<tab-index href="#tab-index"/>
<cli-xconf href="#cli-xconf"/>

Modified: forrest/trunk/site-author/status.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/site-author/status.xml?rev=1550140&r1=1550139&r2=1550140&view=diff
==============================================================================
--- forrest/trunk/site-author/status.xml (original)
+++ forrest/trunk/site-author/status.xml Wed Dec 11 13:57:21 2013
@@ -153,6 +153,11 @@
Added document to facilitate
<link href="site:upgrading_010">upgrading to v0.10-dev</link>
</action>
+<!-- 2013-12 -->
+ <action context="code" type="add" dev="DC" fixes-bug="FOR-1245">
+ Enable per-project configuration of Cocoon error handling.
+ Added an <link href="site:faq/handle-errors">FAQ</link>.
+ </action>
<!-- 2013-11 -->
<action context="code" type="update" dev="DC">
Updated JSch to v0.1.50