Project

General

Profile

1
package eu.dnetlib.openaire.usermanagement.utils;
2

    
3
import org.springframework.stereotype.Component;
4

    
5
@Component("AuthorizationService")
6
public class AuthorizationService {
7

    
8
    public final String SUPER_ADMIN = "SUPER_ADMINISTRATOR";
9
    public final String PORTAL_ADMIN = "PORTAL_ADMINISTRATOR";
10
    public final String USER_ADMIN = "USER_MANAGER";
11

    
12
    private String mapType(String type) {
13
        if(type.equals("organization")) {
14
            type = "institution";
15
        }
16
        if(type.equals("ri")) {
17
            type = "community";
18
        }
19
        return type;
20
    }
21

    
22
    /**
23
     * Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
24
     *
25
     * */
26
    public String curator(String type) {
27
        return "CURATOR_" + mapType(type).toUpperCase();
28
    }
29

    
30
    /**
31
     * Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
32
     *
33
     * Id = EE, EGI, etc
34
     * */
35
    public String manager(String type, String id) {
36
        return mapType(type).toUpperCase() + "_" + id.toUpperCase() + "_MANAGER";
37
    }
38

    
39
    /**
40
     * Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
41
     *
42
     * Id = EE, EGI, etc
43
     * */
44
    public String member(String type, String id) {
45
        return mapType(type).toUpperCase() + "_" + id.toUpperCase();
46
    }
47

    
48
    public boolean isCommunity(String type) {
49
        return mapType(type).equals("community");
50
    }
51
}
(2-2/9)