Last change
on this file since 5508 was
5508,
checked in by Twan Goosen, 10 years ago
|
All representations of a VC are retrieved at the same URL that provides internal XML, JSON, CMDI, or a web UI redirect determined through content negotiation. Added a filter that allows for 'content negotation' through URL extension
Refs #604
TODO: Default to CMDI
TODO: PID reference
|
File size:
1.0 KB
|
Line | |
---|
1 | package eu.clarin.cmdi.virtualcollectionregistry.rest; |
---|
2 | |
---|
3 | import com.sun.jersey.api.container.filter.UriConnegFilter; |
---|
4 | import java.util.HashMap; |
---|
5 | import java.util.Map; |
---|
6 | import javax.ws.rs.core.MediaType; |
---|
7 | |
---|
8 | /** |
---|
9 | * Extension of the Jersey filter that allows "content negotation" by means of |
---|
10 | * URL extensions, { |
---|
11 | * |
---|
12 | * @lit e.g.} /service/virtualcollections/7.cmdi will call |
---|
13 | * /service/virtualcollections/7 with content type application/x-cmdi+xml |
---|
14 | * |
---|
15 | * Based on description at {@link http://stackoverflow.com/a/8765749} |
---|
16 | * @author twagoo |
---|
17 | */ |
---|
18 | public class VirtualCollectionMediaTypeFilter extends UriConnegFilter { |
---|
19 | |
---|
20 | private static final Map<String, MediaType> mediaTypes = new HashMap<>(); |
---|
21 | |
---|
22 | static { |
---|
23 | mediaTypes.put("xml", MediaType.APPLICATION_XML_TYPE); |
---|
24 | mediaTypes.put("json", MediaType.APPLICATION_JSON_TYPE); |
---|
25 | mediaTypes.put("html", MediaType.TEXT_HTML_TYPE); |
---|
26 | mediaTypes.put("cmdi", VirtualCollectionResource.MediaTypes.CMDI_TYPE); |
---|
27 | } |
---|
28 | |
---|
29 | public VirtualCollectionMediaTypeFilter() { |
---|
30 | super(mediaTypes); |
---|
31 | } |
---|
32 | |
---|
33 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.