1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package eu.ehri.extension;
21
22 import eu.ehri.extension.base.AbstractAccessibleResource;
23 import eu.ehri.extension.base.AbstractResource;
24 import eu.ehri.extension.base.GetResource;
25 import eu.ehri.extension.base.ListResource;
26 import eu.ehri.project.definitions.Entities;
27 import eu.ehri.project.exceptions.ItemNotFound;
28 import eu.ehri.project.models.ContentType;
29 import org.neo4j.graphdb.GraphDatabaseService;
30
31 import javax.ws.rs.GET;
32 import javax.ws.rs.Path;
33 import javax.ws.rs.PathParam;
34 import javax.ws.rs.Produces;
35 import javax.ws.rs.core.Context;
36 import javax.ws.rs.core.MediaType;
37 import javax.ws.rs.core.Response;
38
39
40
41
42
43
44 @Path(AbstractResource.RESOURCE_ENDPOINT_PREFIX + "/" + Entities.CONTENT_TYPE)
45 public class ContentTypeResource extends AbstractAccessibleResource<ContentType>
46 implements GetResource, ListResource {
47
48 public ContentTypeResource(@Context GraphDatabaseService database) {
49 super(database, ContentType.class);
50 }
51
52 @GET
53 @Produces(MediaType.APPLICATION_JSON)
54 @Path("{id:[^/]+}")
55 @Override
56 public Response get(@PathParam("id") String id) throws ItemNotFound {
57 return getItem(id);
58 }
59
60 @GET
61 @Produces(MediaType.APPLICATION_JSON)
62 @Override
63 public Response list() {
64 return listItems();
65 }
66 }