diff --git a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/ConfigurableBrowse.java b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/ConfigurableBrowse.java index 0f95435903..94db26cfb0 100644 --- a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/ConfigurableBrowse.java +++ b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/ConfigurableBrowse.java @@ -12,21 +12,20 @@ import java.io.Serializable; import java.sql.SQLException; import java.util.*; +import org.apache.avalon.framework.parameters.Parameters; +import org.apache.cocoon.ProcessingException; 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.SourceResolver; import org.apache.cocoon.environment.http.HttpEnvironment; import org.apache.cocoon.util.HashUtil; import org.apache.commons.lang.StringUtils; import org.apache.excalibur.source.SourceValidity; import org.apache.log4j.Logger; import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer; -import org.dspace.app.xmlui.utils.ContextUtil; -import org.dspace.app.xmlui.utils.DSpaceValidity; -import org.dspace.app.xmlui.utils.HandleUtil; -import org.dspace.app.xmlui.utils.RequestUtils; -import org.dspace.app.xmlui.utils.UIException; +import org.dspace.app.xmlui.utils.*; import org.dspace.app.xmlui.wing.Message; import org.dspace.app.xmlui.wing.WingException; import org.dspace.app.xmlui.wing.element.Body; @@ -134,6 +133,22 @@ public class ConfigurableBrowse extends AbstractDSpaceTransformer implements private Message titleMessage = null; private Message trailMessage = null; + @Override + public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters) throws ProcessingException, SAXException, IOException { + super.setup(resolver, objectModel, src, parameters); + + //Verify if we have received valid parameters + try { + getUserParams(); + } catch (ResourceNotFoundException e) { + throw new BadRequestException("Invalid parameters"); + } catch (SQLException e) { + throw new RuntimeException(e); + } catch (UIException e) { + throw new RuntimeException(e); + } + } + public Serializable getKey() { try diff --git a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/SearchFacetFilter.java b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/SearchFacetFilter.java index 32476455c6..55a7009f5e 100644 --- a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/SearchFacetFilter.java +++ b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/SearchFacetFilter.java @@ -7,18 +7,19 @@ */ package org.dspace.app.xmlui.aspect.discovery; +import org.apache.avalon.framework.parameters.Parameters; +import org.apache.cocoon.ProcessingException; import org.apache.cocoon.caching.CacheableProcessingComponent; import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.environment.Request; +import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.util.HashUtil; +import org.apache.commons.lang.StringUtils; import org.apache.excalibur.source.SourceValidity; import org.apache.log4j.Logger; import org.dspace.app.util.Util; import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer; -import org.dspace.app.xmlui.utils.DSpaceValidity; -import org.dspace.app.xmlui.utils.HandleUtil; -import org.dspace.app.xmlui.utils.RequestUtils; -import org.dspace.app.xmlui.utils.UIException; +import org.dspace.app.xmlui.utils.*; import org.dspace.app.xmlui.wing.Message; import org.dspace.app.xmlui.wing.WingException; import org.dspace.app.xmlui.wing.element.*; @@ -84,6 +85,19 @@ public class SearchFacetFilter extends AbstractDSpaceTransformer implements Cach } + @Override + public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters) throws ProcessingException, SAXException, IOException { + super.setup(resolver, objectModel, src, parameters); + + Request request = ObjectModelHelper.getRequest(objectModel); + String facetField = request.getParameter(SearchFilterParam.FACET_FIELD); + + if(StringUtils.isBlank(facetField)) + { + throw new BadRequestException("Invalid " + SearchFilterParam.FACET_FIELD + " parameter"); + } + } + /** * Generate the unique caching key. * This key must be unique inside the space of this component. diff --git a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/utils/BadRequestException.java b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/utils/BadRequestException.java new file mode 100644 index 0000000000..e033bf2e19 --- /dev/null +++ b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/utils/BadRequestException.java @@ -0,0 +1,32 @@ +/** + * 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.utils; + +import java.io.IOException; + +/** + * Exception thrown in case of bad request syntax + * + * Example: invalid/missing parameters, ... + * + * @author Kevin Van de Velde (kevin at atmire dot com) + */ +public class BadRequestException extends IOException { + + public BadRequestException(String message) { + super(message); + } + + public BadRequestException(Throwable t) { + super(t); + } + + public BadRequestException(String message, Throwable t) { + super(message, t); + } +} diff --git a/dspace-xmlui/src/main/webapp/sitemap.xmap b/dspace-xmlui/src/main/webapp/sitemap.xmap index 093f772257..963e292eda 100644 --- a/dspace-xmlui/src/main/webapp/sitemap.xmap +++ b/dspace-xmlui/src/main/webapp/sitemap.xmap @@ -176,6 +176,7 @@ + @@ -655,6 +656,20 @@ + + + + + + + + + + + + + +