Author: rgardler
Date: Wed Mar 21 18:02:26 2007
New Revision: 521063
URL: http://svn.apache.org/viewvc?view=rev&rev=521063
Log:
- Add sitemap error handling
- (slightly) more meaningful error for locationmap resolution problems (FOR-701)
Added:
forrest/trunk/main/webapp/resources/stylesheets/exception-to-html.xsl
(with props)
Modified:
forrest/trunk/main/webapp/sitemap.xmap
Added: forrest/trunk/main/webapp/resources/stylesheets/exception-to-html.xsl
URL:
http://svn.apache.org/viewvc/forrest/trunk/main/webapp/resources/stylesheets/exception-to-html.xsl?view=auto&rev=521063
==============================================================================
--- forrest/trunk/main/webapp/resources/stylesheets/exception-to-html.xsl
(added)
+++ forrest/trunk/main/webapp/resources/stylesheets/exception-to-html.xsl Wed
Mar 21 18:02:26 2007
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+
+<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>
+
+ <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
+ found at <xsl:value-of select="substring(ex:message, 0,
string-length(ex:message) - string-length('(Access is
denied)'))"/>/locationmap.xml.</p>
+
+ <p>More information can be found in the logs.</p>
+ </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:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+</xsl:stylesheet>
Propchange:
forrest/trunk/main/webapp/resources/stylesheets/exception-to-html.xsl
------------------------------------------------------------------------------
svn:eol-style = native
Modified: forrest/trunk/main/webapp/sitemap.xmap
URL:
http://svn.apache.org/viewvc/forrest/trunk/main/webapp/sitemap.xmap?view=diff&rev=521063&r1=521062&r2=521063
==============================================================================
--- forrest/trunk/main/webapp/sitemap.xmap (original)
+++ forrest/trunk/main/webapp/sitemap.xmap Wed Mar 21 18:02:26 2007
@@ -32,7 +32,7 @@
</map:generator>
<map:generator name="exception"
- src="org.apache.cocoon.generation.ParseExceptionGenerator"/>
+ src="org.apache.cocoon.generation.ExceptionGenerator"/>
<map:generator name="notifier"
src="org.apache.cocoon.sitemap.NotifyingGenerator" />
@@ -252,12 +252,13 @@
<map:selectors>
<map:selector name="exists" logger="sitemap.selector.exists"
src="org.apache.forrest.sourceexists.SourceExistsSelector"
/>
- <map:selector name="exception" logger="sitemap.selector.exception"
- src="org.apache.cocoon.selection.ExceptionSelector">
- <exception name="syntax"
class="net.sourceforge.chaperon.process.ParseException"/>
- <exception class="java.lang.Throwable" unroll="true"/>
- </map:selector>
- <map:selector name="config" logger="sitemap.selector.config"
+
+ <map:selector name="exception"
src="org.apache.cocoon.selection.ExceptionSelector">
+ <exception name="resourceNotFound"
class="org.apache.cocoon.ResourceNotFoundException"/>
+ <exception class="java.lang.Throwable" unroll="true"/>
+ </map:selector>
+
+ <map:selector name="config" logger="sitemap.selector.config"
src="org.apache.cocoon.selection.SimpleSelector" />
</map:selectors>
@@ -728,7 +729,16 @@
<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>
- </map:pipelines>
+ </map:pipelines>
</map:sitemap>