Project

General

Profile

Download (2.26 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.TermTree;
28
import io.swagger.annotations.Api;
29

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

    
39
    public static final Logger logger = Logger.getLogger(TermTreePortalController.class);
40

    
41

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

    
47
    private List<String> termTreeNodeInitStrategy = null;
48

    
49
    public TermTreePortalController() {
50
        setInitializationStrategy(TERMTREE_INIT_STRATEGY);
51

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

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