1
|
// $Id: TaxonController.java 5473 2009-03-25 13:42:07Z a.kohlbecker $
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.remote.controller;
|
12
|
|
13
|
import java.io.IOException;
|
14
|
import java.util.Arrays;
|
15
|
import java.util.List;
|
16
|
import java.util.UUID;
|
17
|
|
18
|
import javax.servlet.http.HttpServletRequest;
|
19
|
import javax.servlet.http.HttpServletResponse;
|
20
|
|
21
|
import org.apache.log4j.Logger;
|
22
|
import org.springframework.beans.factory.annotation.Autowired;
|
23
|
import org.springframework.stereotype.Controller;
|
24
|
import org.springframework.util.Assert;
|
25
|
import org.springframework.web.bind.annotation.RequestMapping;
|
26
|
import org.springframework.web.bind.annotation.RequestMethod;
|
27
|
|
28
|
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
29
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
30
|
|
31
|
/**
|
32
|
* @author a.kohlbecker
|
33
|
*
|
34
|
*/
|
35
|
|
36
|
@Controller
|
37
|
@RequestMapping(value = {"/*/portal/taxon/*"})
|
38
|
public class TaxonPortalController extends BaseController<TaxonBase, ITaxonService>
|
39
|
{
|
40
|
public static final Logger logger = Logger.getLogger(TaxonPortalController.class);
|
41
|
|
42
|
private static final List<String> TAXON_INIT_STRATEGY = Arrays.asList(new String []{
|
43
|
"*",
|
44
|
"name.*",
|
45
|
"name.nomenclaturalReference.authorTeam.*",
|
46
|
"name.homotypicalGroup.typifiedNames.*",
|
47
|
"name.status.type.representations",
|
48
|
"name.rank.representations",
|
49
|
"synonymRelations.*"});
|
50
|
|
51
|
public TaxonPortalController(){
|
52
|
super();
|
53
|
setUuidParameterPattern("^/(?:[^/]+)/portal/taxon/([^/?#&\\.]+).*");
|
54
|
}
|
55
|
|
56
|
/* (non-Javadoc)
|
57
|
* @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
|
58
|
*/
|
59
|
@Autowired
|
60
|
@Override
|
61
|
public void setService(ITaxonService service) {
|
62
|
this.service = service;
|
63
|
}
|
64
|
|
65
|
@Override
|
66
|
@RequestMapping(method = RequestMethod.GET)
|
67
|
public TaxonBase doGet(HttpServletRequest request, HttpServletResponse response)throws IOException {
|
68
|
|
69
|
TaxonBase tb;
|
70
|
try {
|
71
|
UUID uuid = readValueUuid(request);
|
72
|
Assert.notNull(uuid, HttpStatusMessage.UUID_NOT_FOUND.toString());
|
73
|
|
74
|
tb = service.load(uuid, TAXON_INIT_STRATEGY);
|
75
|
Assert.notNull(tb, HttpStatusMessage.UUID_NOT_FOUND.toString());
|
76
|
} catch (IllegalArgumentException iae) {
|
77
|
HttpStatusMessage.fromString(iae.getMessage()).send(response);
|
78
|
return null;
|
79
|
}
|
80
|
|
81
|
return tb;
|
82
|
}
|
83
|
}
|