Project

General

Profile

1
package eu.dnetlib.uoaadmintoolslibrary.controllers;
2

    
3
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
4
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PortalPage;
5
import eu.dnetlib.uoaadmintoolslibrary.services.PageService;
6

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

    
11
import java.util.*;
12

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

    
18
    @Autowired
19
    private PageService pageService;
20

    
21
    // used by portals WITHOUT ANY PARAMS
22
    @RequestMapping(value = "/page/full", method = RequestMethod.GET)
23
    public List<PortalPage> getPagesFull(@RequestParam(value="pid", required=false) String pid,
24
                                         @RequestParam(value="page_route", required=false) String page_route) {
25
        return pageService.getPagesFull(pid, page_route);
26
    }
27

    
28
    // used by portals WITHOUT ANY PARAMS
29
    @RequestMapping(value = "/page", method = RequestMethod.GET)
30
    public List<Page> getAllPages(@RequestParam(value="pid", required=false) String pid,
31
                                  @RequestParam(value="page_route", required=false) String page_route,
32
                                  @RequestParam(value="with_positions", required=false) String with_positions) {
33
        return pageService.getAllPages(pid, page_route, with_positions);
34
    }
35

    
36
//    // not used by portals
37
//    @RequestMapping(value = "/page", method = RequestMethod.DELETE)
38
//    public void deleteAllPages() {
39
//        pageService.deleteAllPages();
40
//    }
41

    
42
    // used
43
//    @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
44
    @RequestMapping(value = "/page/update", method = RequestMethod.POST)
45
    public PortalPage updatePage(@RequestBody PortalPage portalPage) {
46
        return pageService.updatePage(portalPage);
47
    }
48

    
49
    // used
50
//    @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
51
    @RequestMapping(value = "/page/save", method = RequestMethod.POST)
52
    public PortalPage insertPage(@RequestBody PortalPage portalPage) {
53
        return pageService.insertPage(portalPage);
54
    }
55

    
56
    // used
57
//    @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
58
    @RequestMapping(value = "/page/delete", method = RequestMethod.POST)
59
    public Boolean deletePages(@RequestBody List<String> pages) throws Exception {
60
        return pageService.deletePages(pages);
61
    }
62

    
63
//    // not used by portals
64
//    @RequestMapping(value = "/page/{id}", method = RequestMethod.GET)
65
//    public Page getPage(@PathVariable(value = "id") String id) {
66
//        return pageService.getPage(id);
67
//    }
68
//
69
//    // not used by portals
70
//    @RequestMapping(value = "/page/{id}", method = RequestMethod.DELETE)
71
//    public void deletePage(@PathVariable(value = "id") String id) {
72
//        pageService.deletePage(id);
73
//    }
74
//
75
//    // not used by portals
76
//    @RequestMapping(value = "/page/{id}/entity", method = RequestMethod.GET)
77
//    public List<String> getPageEntities(@PathVariable(value = "id") String id) {
78
//        return pageService.getPageEntities(id);
79
//    }
80
//
81
//    // not used by portals
82
//    @RequestMapping(value = "page/{id}/entity/toggle", method = RequestMethod.POST)
83
//    public Page togglePageEntity(@PathVariable(value = "id") String id, @RequestParam String entityId, @RequestParam String status) throws Exception {
84
//        return pageService.togglePageEntity(id, entityId, status);
85
//    }
86
}
(6-6/9)