ref #9222 ref #6581 adapting web services to single sourced classes
[cdmlib.git] / cdmlib-remote / src / main / java / eu / etaxonomy / cdm / remote / controller / NomenclaturalStatusController.java
1 /**
2 * Copyright (C) 2016 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.cdm.remote.controller;
10
11 import java.io.IOException;
12 import java.util.Arrays;
13 import java.util.UUID;
14
15 import javax.servlet.http.HttpServletRequest;
16 import javax.servlet.http.HttpServletResponse;
17
18 import org.apache.commons.io.FilenameUtils;
19 import org.apache.log4j.Logger;
20 import org.springframework.beans.factory.annotation.Autowired;
21 import org.springframework.stereotype.Controller;
22 import org.springframework.web.bind.annotation.PathVariable;
23 import org.springframework.web.bind.annotation.RequestMapping;
24 import org.springframework.web.bind.annotation.RequestMethod;
25
26 import eu.etaxonomy.cdm.api.service.INameService;
27 import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
28 import eu.etaxonomy.cdm.model.name.TaxonName;
29 import io.swagger.annotations.Api;
30
31 /**
32 * @author a.kohlbecker
33 * @since Oct 11, 2016
34 *
35 */
36 @Controller
37 @Api("nomenclaturalStatus")
38 @RequestMapping(value = {"/nomenclaturalStatus/{uuid}"})
39 public class NomenclaturalStatusController extends AbstractController<TaxonName, INameService> {
40
41
42 private static final Logger logger = Logger.getLogger(NomenclaturalStatusController.class);
43
44 /**
45 * {@inheritDoc}
46 */
47 @Override
48 @Autowired
49 public void setService(INameService service) {
50 this.service = service;
51 }
52
53 @RequestMapping(method = RequestMethod.GET)
54 public NomenclaturalStatus doGetMethod(
55 @PathVariable("uuid") UUID uuid,
56 HttpServletRequest request,
57 HttpServletResponse response) throws IOException {
58
59 String servletPath = request.getServletPath();
60 String propertyName = FilenameUtils.getBaseName(servletPath);
61
62 logger.info("doGet() - " + requestPathAndQuery(request));
63
64 NomenclaturalStatus nomstatus = service.loadNomenclaturalStatus(uuid, Arrays.asList("$", "source.citation.inReference"));
65 if(nomstatus == null){
66 HttpStatusMessage.UUID_NOT_FOUND.send(response);
67 }
68 return nomstatus;
69 }
70
71
72
73 }