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