Project

General

Profile

1
package eu.dnetlib.uoaadmintoolslibrary.controllers;
2

    
3
import eu.dnetlib.uoaadmintoolslibrary.entities.Entity;
4
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PortalEntity;
5
import eu.dnetlib.uoaadmintoolslibrary.services.EntityService;
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.List;
12

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

    
18
    @Autowired
19
    private EntityService entityService;
20

    
21
    // used
22
    @RequestMapping(value = "/entity", method = RequestMethod.GET)
23
    public List<Entity> getAllEntities() {
24
        return entityService.getAllEntities();
25
    }
26

    
27
    // used
28
//    @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
29
    @RequestMapping(value = "/entity/save", method = RequestMethod.POST)
30
    public PortalEntity insertEntity(@RequestBody Entity entity) {
31
        return entityService.insertEntity(entity);
32
    }
33

    
34
    // used
35
//    @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
36
    @RequestMapping(value = "/entity/update", method = RequestMethod.POST)
37
    public PortalEntity updateEntity(@RequestBody PortalEntity portalEntity) {
38
        return entityService.updateEntity(portalEntity);
39
    }
40

    
41
    // used
42
//    @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
43
    @RequestMapping(value = "/entity/delete", method = RequestMethod.POST)
44
    public Boolean deleteEntities(@RequestBody List<String> entities) throws Exception {
45
        return entityService.deleteEntities(entities);
46
    }
47

    
48
//    // not used by portals
49
//    @RequestMapping(value = "/entity", method = RequestMethod.DELETE)
50
//    public void deleteAllEntities() {
51
//        entityService.deleteAllEntities();
52
//    }
53
//
54
//    // not used by portals    @RequestMapping(value = "/entity", method = RequestMethod.POST)
55
//    public Entity insertOrUpdateEntity(@RequestBody Entity entity) {
56
//        return entityService.insertOrUpdateEntity(entity);
57
//    }
58
//
59
//    // not used by portals
60
//    @RequestMapping(value = "/entity/{id}", method = RequestMethod.GET)
61
//    public Entity getEntity(@PathVariable(value = "id") String id) {
62
//        return entityService.getEntity(id);
63
//    }
64
//
65
//    // not used by portals
66
//    @RequestMapping(value = "/entity/{id}", method = RequestMethod.DELETE)
67
//    public void deleteEntity(@PathVariable(value = "id") String id) {
68
//        entityService.deleteEntity(id);
69
//    }
70
}
(4-4/9)