Project

General

Profile

Download (2.9 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 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

    
10
package eu.etaxonomy.cdm.remote.controller;
11

    
12
import java.io.IOException;
13
import java.util.Arrays;
14
import java.util.UUID;
15

    
16
import javax.servlet.http.HttpServletRequest;
17
import javax.servlet.http.HttpServletResponse;
18

    
19
import org.springframework.beans.factory.annotation.Autowired;
20
import org.springframework.stereotype.Controller;
21
import org.springframework.web.bind.annotation.PathVariable;
22
import org.springframework.web.bind.annotation.RequestMapping;
23

    
24
import eu.etaxonomy.cdm.api.service.IRegistrationService;
25
import eu.etaxonomy.cdm.model.name.Registration;
26
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
27
import io.swagger.annotations.Api;
28

    
29
/**
30
 * TODO write controller documentation
31
 *
32
 * @author a.kohlbecker
33
 * @since 24.03.2009
34
 */
35

    
36
@Controller
37
@Api("registration")
38
@RequestMapping(value = {"/registration/{uuid}", "/registration/{localID}"})
39
public class RegistrationController extends BaseController<Registration, IRegistrationService>
40
{
41

    
42
    public RegistrationController(){
43
        setInitializationStrategy(Arrays.asList(new String[]{
44
                "$",
45
                "name.$",
46
                "typeDesignations.$"
47
             }));
48
    }
49

    
50
    /* (non-Javadoc)
51
     * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
52
     */
53
    @Autowired
54
    @Override
55
    public void setService(IRegistrationService service) {
56
        this.service = service;
57
    }
58

    
59
    @Override
60
    public Registration doGet(@PathVariable("uuid") UUID uuid,
61
            HttpServletRequest request,
62
            HttpServletResponse response) throws IOException {
63

    
64
        Registration reg = super.doGet(uuid, request, response);
65
        if(reg != null){
66
            if(userIsAutheticated() && userIsAnnonymous() && !reg.getStatus().equals(RegistrationStatus.PUBLISHED)) {
67
                // completely hide the fact that there is a registration
68
                HttpStatusMessage.create("No such Registration", HttpServletResponse.SC_NO_CONTENT).send(response);
69
            }
70
        }
71
        return reg;
72
    }
73

    
74
 /*
75
    @Override
76
    public Registration doGetbyLocalId(@PathVariable("localID") Integer localID,
77
            HttpServletRequest request,
78
            HttpServletResponse response) throws IOException {
79

    
80
        Registration reg = super.doGet(localID, request, response);
81
        if(reg != null){
82
            if(userIsAutheticated() && userIsAnnonymous() && !reg.getStatus().equals(RegistrationStatus.PUBLISHED)) {
83
                // completely hide the fact that there is a registration
84
                HttpStatusMessage.create("No such Registration", HttpServletResponse.SC_NO_CONTENT);
85
            }
86
        }
87
        return reg;
88
    }
89
*/
90

    
91
}
(54-54/67)