Project

General

Profile

Download (2.32 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
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
import java.io.IOException;
12
import java.util.ArrayList;
13
import java.util.Arrays;
14
import java.util.List;
15
import java.util.UUID;
16

    
17
import javax.persistence.EntityNotFoundException;
18
import javax.servlet.http.HttpServletRequest;
19
import javax.servlet.http.HttpServletResponse;
20

    
21
import org.apache.log4j.Logger;
22
import org.springframework.stereotype.Controller;
23
import org.springframework.web.bind.annotation.PathVariable;
24
import org.springframework.web.bind.annotation.RequestMapping;
25
import org.springframework.web.bind.annotation.RequestMethod;
26

    
27
import eu.etaxonomy.cdm.model.term.FeatureTree;
28
import io.swagger.annotations.Api;
29

    
30
/**
31
 * @author a.kohlbecker
32
 * @since Jun 24, 2013
33
 *
34
 */
35
@Controller
36
@Api("portal_featureTree")
37
@RequestMapping(value = {"/portal/featureTree/{uuid}"})
38
public class FeatureTreePortalController extends FeatureTreeController {
39

    
40
    public static final Logger logger = Logger.getLogger(FeatureTreePortalController.class);
41

    
42

    
43
    private static final List<String> FEATURETREE_INIT_STRATEGY = Arrays.asList(
44
            new String[]{
45
                    "representations",
46
            });
47

    
48
    private List<String> featuretreeNodeInitStrategy = null;
49

    
50
    public FeatureTreePortalController() {
51
        setInitializationStrategy(FEATURETREE_INIT_STRATEGY);
52

    
53
        featuretreeNodeInitStrategy = new ArrayList<>(2);
54
        featuretreeNodeInitStrategy.add("term.representations");
55
    }
56

    
57
    @Override
58
    @RequestMapping(method = RequestMethod.GET)
59
    public FeatureTree doGet(@PathVariable("uuid") UUID uuid,
60
                HttpServletRequest request,
61
                HttpServletResponse response) throws IOException {
62
        if(request != null) {
63
            logger.info("doGet() " + request.getRequestURI());
64
        }
65
        FeatureTree featureTree = null;
66
        try {
67
            featureTree = service.loadWithNodes(uuid, getInitializationStrategy(), featuretreeNodeInitStrategy);
68
        } catch(EntityNotFoundException e){
69
            HttpStatusMessage.UUID_NOT_FOUND.send(response);
70
        }
71
        return featureTree;
72
    }
73
}
(31-31/70)