Project

General

Profile

« Previous | Next » 

Revision 60513

[Admin Tools | Trunk]: Add again role Utils. Fix curator methods

View differences:

modules/uoa-admin-tools/trunk/src/main/java/eu/dnetlib/uoaadmintools/controllers/CuratorController.java
3 3
import eu.dnetlib.uoaadmintools.entities.curator.Curator;
4 4
import eu.dnetlib.uoaadmintools.entities.curator.CuratorResponse;
5 5
import eu.dnetlib.uoaadmintools.services.CuratorService;
6
import eu.dnetlib.uoaauthorizationlibrary.security.AuthorizationService;
6
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
7
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
7 8
import org.apache.log4j.Logger;
8 9
import org.springframework.beans.factory.annotation.Autowired;
9 10
import org.springframework.security.access.prepost.PreAuthorize;
......
20 21
    private CuratorService curatorService;
21 22

  
22 23
    @Autowired
23
    private AuthorizationService authorizationService;
24
    private RolesUtils rolesUtils;
24 25

  
25 26
    /**
26 27
     * Return a list with curator for a specific community
......
34 35
    }
35 36

  
36 37
    /**
37
     * Return a Curator with the given id.
38
     * Return Curator info of logged in user.
38 39
     *
39
     * @param id
40 40
     * @return
41 41
     */
42 42
    @PreAuthorize("isAuthenticated()")
43
    @RequestMapping(value = "/curator/{id}", method = RequestMethod.GET)
44
    public Curator getCuratorById(@PathVariable String id) {
45
        return curatorService.findById(id);
43
    @RequestMapping(value = "/curator", method = RequestMethod.GET)
44
    public Curator getCuratorById() {
45
        Curator curator = curatorService.findById(getId());
46
        if(curator != null) {
47
            return curator;
48
        }
49
        throw new ContentNotFoundException("No curator found");
46 50
    }
47 51

  
48 52
    /**
......
54 58
    @PreAuthorize("isAuthenticated()")
55 59
    @RequestMapping(value = "/curator", method = RequestMethod.POST)
56 60
    public Curator insertCurator(@RequestBody Curator curator) {
57
        String aaiId = authorizationService.getAaiId();
58
        curator.setId(aaiId.substring(0, aaiId.indexOf("@")));
61
        curator.setId(getId());
59 62
        return curatorService.save(curator);
60 63
    }
61 64

  
......
71 74
        curatorService.deleteCurators(pid);
72 75
    }
73 76

  
77
    private String getId() {
78
        String aaiId = rolesUtils.getAaiId();
79
        return  aaiId.substring(0, aaiId.indexOf("@"));
80
    }
74 81
}
modules/uoa-admin-tools/trunk/src/main/java/eu/dnetlib/uoaadmintools/controllers/CommunityController.java
9 9
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PortalResponse;
10 10
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
11 11
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
12
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
12 13
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
13 14
import eu.dnetlib.uoaauthorizationlibrary.security.AuthorizationService;
14 15
import org.apache.log4j.Logger;
......
25 26
    private final Logger log = Logger.getLogger(this.getClass());
26 27

  
27 28
    @Autowired
28
    private AuthorizationService authorizationService;
29
    private RolesUtils rolesUtils;
29 30

  
30 31
    @Autowired
31 32
    private LayoutService layoutService;
......
95 96
    @PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
96 97
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
97 98
    public Boolean deleteCommunities(@RequestBody List<String> portals) {
98
        List<String> roles = authorizationService.getRoles();
99
        List<String> roles = rolesUtils.getRoles();
99 100

  
100 101
        for (String id: portals) {
101 102
            Portal portal = portalService.getPortalById(id);
modules/uoa-admin-tools/trunk/pom.xml
80 80
            <artifactId>uoa-admin-tools-library</artifactId>
81 81
            <version>1.0.0-SNAPSHOT</version>
82 82
        </dependency>
83
        <dependency>
83
        <!--<dependency>
84 84
            <groupId>eu.dnetlib</groupId>
85 85
            <artifactId>uoa-authorization-library</artifactId>
86 86
            <version>1.0.0-SNAPSHOT</version>
87
        </dependency>
87
        </dependency>-->
88 88
    </dependencies>
89 89

  
90 90
	<build>

Also available in: Unified diff