Merge pull request #1356 from atmire/DS-3131

DS-3131
This commit is contained in:
Tim Donohue
2016-04-20 08:52:53 -05:00
4 changed files with 45 additions and 2 deletions

View File

@@ -54,6 +54,11 @@
<transformer name="strip-namespaces" src="org.apache.cocoon.transformation.StripNameSpacesTransformer"/>
</map:transformers>
<map:actions>
<map:action name="ContextAbortAction" src="org.dspace.app.xmlui.cocoon.ContextAbortAction" />
</map:actions>
<map:serializers>
<map:serializer name="html-no-doctype" logger="sitemap.serializer.xhtml"
src="org.apache.cocoon.serialization.HTMLSerializer"
@@ -215,6 +220,7 @@
</map:when>
<!-- All other errors (HTTP 500 Internal Server Error) -->
<map:otherwise>
<map:act type="ContextAbortAction"/>
<map:serialize type="html-no-doctype" status-code="500"/>
</map:otherwise>
</map:select>

View File

@@ -0,0 +1,29 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.xmlui.cocoon;
import java.util.*;
import org.apache.avalon.framework.parameters.*;
import org.apache.cocoon.acting.*;
import org.apache.cocoon.environment.*;
import org.dspace.app.xmlui.utils.*;
/**
* This action is used to abort the context when an exception occurs.
* The action is called by the handle-errors section in either the theme's sitemap or the
* main webapp/sitemap if the theme does not have a handle-errors section.
*
* @author philip at atmire.com
*/
public class ContextAbortAction extends ServiceableAction {
@Override
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception {
ContextUtil.abortContext(ObjectModelHelper.getRequest(objectModel));
return EMPTY_MAP;
}
}

View File

@@ -208,6 +208,7 @@
<map:action name="StartAuthentication" src="org.dspace.app.xmlui.aspect.eperson.StartAuthenticationAction"/>
<map:action name="DSpacePropertyFileReader" src="org.dspace.app.xmlui.cocoon.DSpacePropertyFileReader" />
<map:action name="PropertyFileReader" src="org.dspace.app.xmlui.cocoon.PropertyFileReader" />
<map:action name="ContextAbortAction" src="org.dspace.app.xmlui.cocoon.ContextAbortAction" />
</map:actions>
<map:pipes default="caching">
<map:pipe name="noncaching" src="org.apache.cocoon.components.pipeline.impl.NonCachingProcessingPipeline">
@@ -747,7 +748,9 @@
</map:when>
<map:otherwise>
<map:generate type="exception"/>
<map:act type="ContextAbortAction"/>
<map:generate type="exception"/>
<map:transform src="exception2html.xslt">
<map:parameter name="contextPath" value="{request:contextPath}"/>
</map:transform>

View File

@@ -49,6 +49,10 @@
<map:readers>
<map:reader name="ConcatenationReader" src="org.dspace.app.xmlui.cocoon.ConcatenationReader"/>
</map:readers>
<map:actions>
<map:action name="ContextAbortAction" src="org.dspace.app.xmlui.cocoon.ContextAbortAction" />
</map:actions>
</map:components>
<!-- Define global resources that are used in multiple areas of the pipeline. -->
@@ -197,7 +201,7 @@
<!-- Step 3: Transform that DRI formatted exception into XHTML (using our Theme) -->
<map:call resource="transform-to-xhtml"/>
<!-- Step 4: Serialize XHTML page to user's brower. Based on the type of error,
<!-- Step 4: Serialize XHTML page to user's brower. Based on the type of error,
provide a different HTTP response code. -->
<map:select type="exception">
<!-- HTTP 400 Bad Request -->
@@ -210,6 +214,7 @@
</map:when>
<!-- All other errors (HTTP 500 Internal Server Error) -->
<map:otherwise>
<map:act type="ContextAbortAction"/>
<map:serialize type="xhtml" status-code="500"/>
</map:otherwise>
</map:select>