Skip to content

Commit

Permalink
[DS-768] Add ProcessingException to XMLUI transformers, throw Resourc…
Browse files Browse the repository at this point in the history
…eNotFoundException from PageNotFoundTransformer

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@6780 9c30dcfa-912a-0410-8fc2-9e0234be79fd
  • Loading branch information
kshepherd committed Oct 4, 2011
1 parent 466d99c commit 6a72f72
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
Expand Up @@ -11,12 +11,10 @@
import java.io.Serializable;
import java.sql.SQLException;

import javax.servlet.http.HttpServletResponse;

import org.apache.cocoon.ResourceNotFoundException;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.http.HttpEnvironment;
import org.apache.cocoon.util.HashUtil;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.NOPValidity;
Expand All @@ -29,6 +27,7 @@
import org.dspace.app.xmlui.wing.element.Division;
import org.dspace.app.xmlui.wing.element.PageMeta;
import org.dspace.authorize.AuthorizeException;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

Expand All @@ -37,6 +36,7 @@
* it is then displays some page not found text.
*
* @author Scott Phillips
* @author Kim Shepherd
*/
public class PageNotFoundTransformer extends AbstractDSpaceTransformer implements CacheableProcessingComponent
{
Expand Down Expand Up @@ -87,6 +87,7 @@ public SourceValidity getValidity() {
/**
* Receive notification of the beginning of a document.
*/
@Override
public void startDocument() throws SAXException
{
// Reset our parameters before starting a new document.
Expand All @@ -99,6 +100,7 @@ public void startDocument() throws SAXException
* Process the SAX event.
* @see org.xml.sax.ContentHandler#startElement
*/
@Override
public void startElement(String namespaceURI, String localName,
String qName, Attributes attributes) throws SAXException
{
Expand Down Expand Up @@ -126,6 +128,7 @@ public void startElement(String namespaceURI, String localName,
* Process the SAX event.
* @see org.xml.sax.ContentHandler#endElement
*/
@Override
public void endElement(String namespaceURI, String localName, String qName)
throws SAXException
{
Expand All @@ -148,8 +151,9 @@ public void endElement(String namespaceURI, String localName, String qName)


/** What to add at the end of the body */
@Override
public void addBody(Body body) throws SAXException, WingException,
UIException, SQLException, IOException, AuthorizeException
UIException, SQLException, IOException, AuthorizeException, ResourceNotFoundException
{
if (this.bodyEmpty)
{
Expand All @@ -158,16 +162,17 @@ public void addBody(Body body) throws SAXException, WingException,
notFound.setHead(T_head);

notFound.addPara(T_para1);

notFound.addPara().addXref(contextPath + "/",T_go_home);

HttpServletResponse response = (HttpServletResponse)objectModel
.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
throw new ResourceNotFoundException("Page cannot be found");


}
}

/** What page metadata to add to the document */
@Override
public void addPageMeta(PageMeta pageMeta) throws SAXException,
WingException, UIException, SQLException, IOException,
AuthorizeException
Expand Down
Expand Up @@ -13,6 +13,7 @@

import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.ResourceNotFoundException;
import org.apache.cocoon.environment.SourceResolver;

import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
Expand Down Expand Up @@ -138,7 +139,7 @@ public void setup(SourceResolver resolver, Map objectModel, String src, Paramete

/** What to add at the end of the body */
public void addBody(Body body) throws SAXException, WingException,
UIException, SQLException, IOException, AuthorizeException
UIException, SQLException, IOException, AuthorizeException, ProcessingException
{
//call addBody for this step
step.addBody(body);
Expand Down
Expand Up @@ -113,7 +113,7 @@ protected void handleException(Exception e) throws SAXException

/** What to add at the end of the body */
public void addBody(Body body) throws SAXException, WingException,
UIException, SQLException, IOException, AuthorizeException
UIException, SQLException, IOException, AuthorizeException, ProcessingException
{
// Do nothing
}
Expand Down
Expand Up @@ -10,6 +10,7 @@
import java.io.IOException;
import java.sql.SQLException;

import org.apache.cocoon.ProcessingException;
import org.dspace.app.xmlui.utils.UIException;
import org.dspace.app.xmlui.wing.WingException;
import org.dspace.app.xmlui.wing.WingTransformer;
Expand All @@ -35,7 +36,7 @@ public interface DSpaceTransformer extends WingTransformer

/** What to add at the end of the body */
public void addBody(Body body) throws SAXException, WingException,
UIException, SQLException, IOException, AuthorizeException;
UIException, SQLException, IOException, AuthorizeException, ProcessingException;

/** What to add to the options list */
public void addOptions(Options options) throws SAXException, WingException,
Expand Down

0 comments on commit 6a72f72

Please sign in to comment.