Adds content negotiation to XMLUI.

This commit is contained in:
Pascal-Nicolas Becker
2014-10-02 17:34:39 +02:00
parent dfa5ade578
commit b87aa949a4
2 changed files with 25 additions and 1 deletions

View File

@@ -76,10 +76,19 @@ public class NegotiationFilter implements Filter
String handle = null;
String extraPathInfo = null;
String path = hrequest.getPathInfo();
// in JSPUI the pathInfo starts after /handle, in XMLUI it starts with /handle
Pattern handleCheckPattern = Pattern.compile("^/*handle/(.*)$");
Matcher handleCheckMatcher = handleCheckPattern.matcher(path);
if (handleCheckMatcher.matches())
{
// remove trailing /handle
path = handleCheckMatcher.group(1);
}
// we expect the path to be in the form <prefix>/<suffix>/[<stuff>],
// where <prefix> is a handle prefix, <suffix> is the handle suffix
// and <stuff> may be further information.
String path = hrequest.getPathInfo();
log.debug("PathInfo: " + path);
if (path == null) path = "";
Pattern pathPattern =
Pattern.compile("^/*([^/]+)/+([^/]+)(?:/*||/+(.*))?$");
@@ -89,6 +98,7 @@ public class NegotiationFilter implements Filter
handle = pathMatcher.group(1) + "/" + pathMatcher.group(2);
extraPathInfo = pathMatcher.group(3);
}
log.debug("handle: " + handle + "\n" + "extraPathInfo: " + extraPathInfo);
int requestedContent = Negotiator.negotiate(acceptHeader);

View File

@@ -110,6 +110,15 @@
</init-param>
</filter>
<!--
Declare a filter to do content negotiation in combination for our
Linked Data support.
-->
<filter>
<filter-name>rdf-content-negotiation</filter-name>
<filter-class>org.dspace.rdf.negotiation.NegotiationFilter</filter-class>
</filter>
<!-- Filter mappings ================================================ -->
@@ -136,6 +145,11 @@
<filter-name>SetCharacterEncoding</filter-name>
<servlet-name>spring</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>rdf-content-negotiation</filter-name>
<url-pattern>/handle/*</url-pattern>
</filter-mapping>
<!--
- Use the Cocoon debug filter together with the Cocoon demo webapp