View Javadoc

1   /*
2    * Copyright 2015 Data Archiving and Networked Services (an institute of
3    * Koninklijke Nederlandse Akademie van Wetenschappen), King's College London,
4    * Georg-August-Universitaet Goettingen Stiftung Oeffentlichen Rechts
5    *
6    * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by
7    * the European Commission - subsequent versions of the EUPL (the "Licence");
8    * You may not use this work except in compliance with the Licence.
9    * You may obtain a copy of the Licence at:
10   *
11   * https://joinup.ec.europa.eu/software/page/eupl
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the Licence is distributed on an "AS IS" basis,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the Licence for the specific language governing
17   * permissions and limitations under the Licence.
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   * Provides a web service interface for the ContentType model. Note: ContentType instances
41   * are created by the system, so we do not have create/update/delete methods
42   * here.
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  }