Project

General

Profile

1
package eu.dnetlib.uoaadmintools.controllers;
2

    
3
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
4
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
5
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
6
import org.apache.log4j.Logger;
7
import org.springframework.web.bind.annotation.*;
8
import org.springframework.beans.factory.annotation.Autowired;
9

    
10
import java.util.*;
11

    
12
@RestController
13
@RequestMapping("/explore")
14
@CrossOrigin(origins = "*")
15
//@PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
16
public class ExploreController {
17
    private final Logger log = Logger.getLogger(this.getClass());
18

    
19
    @Autowired
20
    private PortalService portalService;
21

    
22
//    @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
23
    @RequestMapping(value = "/update", method = RequestMethod.POST)
24
    public PortalResponse updateExplore(@RequestBody Portal portal) {
25
        PortalResponse portalResponse = portalService.updatePortal(portal);
26
        return portalResponse;
27
    }
28

    
29
//    @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
30
    @RequestMapping(value = "/save", method = RequestMethod.POST)
31
    public PortalResponse insertExplore(@RequestBody Portal portal) {
32
        PortalResponse portalResponse = portalService.insertPortal(portal);
33
        return portalResponse;
34
    }
35

    
36
    // cannot handle MismatchingContent
37
//    @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
38
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
39
    public Boolean deleteExplore(@RequestBody List<String> portals) throws Exception {
40
        for (String id : portals) {
41
            portalService.deletePortal(id);
42
        }
43

    
44
        return true;
45
    }
46
}
47

    
(5-5/9)