Project

General

Profile

1
package eu.dnetlib.uoaadmintoolslibrary.controllers;
2

    
3
import eu.dnetlib.uoaadmintoolslibrary.entities.DivId;
4
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.DivIdResponse;
5
import eu.dnetlib.uoaadmintoolslibrary.services.DivIdService;
6

    
7
import java.util.*;
8

    
9
import org.apache.log4j.Logger;
10
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.web.bind.annotation.*;
12

    
13
@RestController
14
@CrossOrigin(origins = "*")
15
public class DivIdController {
16
    private final Logger log = Logger.getLogger(this.getClass());
17

    
18
    @Autowired
19
    private DivIdService divIdService;
20

    
21
//    // not used by portals
22
//    @RequestMapping(value = "/div", method = RequestMethod.GET)
23
//    public List<DivId> getDivIds(@RequestParam(required = false) String page,
24
//                                 @RequestParam(required = false) String name,
25
//                                 @RequestParam(value = "portal", required = false) String pid) {
26
//        return divIdService.getDivIds(page, name, pid);
27
//    }
28
//
29
//    // not used by portals
30
//    @RequestMapping(value = "/div/{id}", method = RequestMethod.GET)
31
//    public DivId getDivId(@PathVariable(value = "id") String id) {
32
//        return divIdService.getDivId(id);
33
//    }
34
//
35
//    // not used by portals
36
//    @RequestMapping(value = "/div/{id}/full", method = RequestMethod.GET)
37
//    public DivIdResponse getDivIdFull(@PathVariable(value = "id") String id) {
38
//        return divIdService.getDivIdFull(id);
39
//    }
40
//
41
//    // not used by portals
42
//    @RequestMapping(value = "/div", method = RequestMethod.DELETE)
43
//    public void deleteAllDivIds() {
44
//        divIdService.deleteAllDivIds();
45
//    }
46

    
47
    // used WITHOUT ANY PARAMS
48
    @RequestMapping(value = "/div/full", method = RequestMethod.GET)
49
    public List<DivIdResponse> getDivIdsFull(@RequestParam(required = false) String page,
50
                                             @RequestParam(required = false) String name,
51
                                             @RequestParam(value="portal", required = false) String pid) {
52
        return divIdService.getDivIdsFull(page, name, pid);
53
    }
54

    
55
    // used
56
//    @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
57
    @RequestMapping(value = "/div/save", method = RequestMethod.POST)
58
    public DivIdResponse insertDivId(@RequestBody DivIdResponse divIdResponse) {
59
        return divIdService.insertDivId(divIdResponse);
60
    }
61

    
62
    // used
63
//    @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
64
    @RequestMapping(value = "/div/update", method = RequestMethod.POST)
65
    public DivIdResponse updateDivId(@RequestBody DivIdResponse divIdResponse) {
66
        return divIdService.updateDivId(divIdResponse);
67
    }
68

    
69
    // used
70
//    @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
71
    @RequestMapping(value = "/div/delete", method = RequestMethod.POST)
72
    public Boolean deleteDivIds(@RequestBody List<String> divIds) throws Exception {
73
        return divIdService.deleteDivIds(divIds);
74
    }
75

    
76
//    // not used by portals
77
//    @RequestMapping(value = "/div/{id}", method = RequestMethod.DELETE)
78
//    public void deleteDivId(@PathVariable(value = "id") String id) {
79
//        divIdService.deleteDivId(id);
80
//    }
81
//
82
//    // not used by portals
83
//    @RequestMapping(value = "/div/pages", method = RequestMethod.GET)
84
//    public Set<String> getDivIdsPages(@RequestParam(value="portal", required = false) String pid) {
85
//        return divIdService.getDivIdsPages(pid);
86
//    }
87

    
88
}
(3-3/7)