1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2013 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
|
package eu.etaxonomy.cdm.remote.controller;
|
11
|
|
12
|
import java.io.IOException;
|
13
|
import java.util.ArrayList;
|
14
|
import java.util.Arrays;
|
15
|
import java.util.List;
|
16
|
import java.util.UUID;
|
17
|
|
18
|
import javax.persistence.EntityNotFoundException;
|
19
|
import javax.servlet.http.HttpServletRequest;
|
20
|
import javax.servlet.http.HttpServletResponse;
|
21
|
|
22
|
import org.apache.log4j.Logger;
|
23
|
import org.springframework.stereotype.Controller;
|
24
|
import org.springframework.web.bind.annotation.PathVariable;
|
25
|
import org.springframework.web.bind.annotation.RequestMapping;
|
26
|
import org.springframework.web.bind.annotation.RequestMethod;
|
27
|
|
28
|
import com.wordnik.swagger.annotations.Api;
|
29
|
|
30
|
import eu.etaxonomy.cdm.model.description.FeatureTree;
|
31
|
|
32
|
/**
|
33
|
* @author a.kohlbecker
|
34
|
* @date Jun 24, 2013
|
35
|
*
|
36
|
*/
|
37
|
@Controller
|
38
|
@Api("portal_featureTree")
|
39
|
@RequestMapping(value = {"/portal/featureTree/{uuid}"})
|
40
|
public class FeatureTreePortalController extends FeatureTreeController {
|
41
|
|
42
|
public static final Logger logger = Logger.getLogger(FeatureTreePortalController.class);
|
43
|
|
44
|
|
45
|
private static final List<String> FEATURETREE_INIT_STRATEGY = Arrays.asList(
|
46
|
new String[]{
|
47
|
"representations",
|
48
|
});
|
49
|
|
50
|
private List<String> featuretreeNodeInitStrategy = null;
|
51
|
|
52
|
public FeatureTreePortalController() {
|
53
|
setInitializationStrategy(FEATURETREE_INIT_STRATEGY);
|
54
|
|
55
|
featuretreeNodeInitStrategy = new ArrayList<String>(2);
|
56
|
// featuretreeNodeInitStrategy.add("representations");
|
57
|
featuretreeNodeInitStrategy.add("feature.representations");
|
58
|
}
|
59
|
|
60
|
@Override
|
61
|
@RequestMapping(method = RequestMethod.GET)
|
62
|
public FeatureTree doGet(@PathVariable("uuid") UUID uuid,
|
63
|
HttpServletRequest request,
|
64
|
HttpServletResponse response) throws IOException {
|
65
|
if(request != null) {
|
66
|
logger.info("doGet() " + request.getRequestURI());
|
67
|
}
|
68
|
FeatureTree featureTree = null;
|
69
|
try {
|
70
|
featureTree = service.loadWithNodes(uuid, getInitializationStrategy(), featuretreeNodeInitStrategy);
|
71
|
} catch(EntityNotFoundException e){
|
72
|
HttpStatusMessage.UUID_NOT_FOUND.send(response);
|
73
|
}
|
74
|
return featureTree;
|
75
|
}
|
76
|
}
|