[Authorization-Library | Trunk]: Authorization Service add boolean communityMap on mapType

This commit is contained in:
Konstantinos Triantafyllou 2021-01-27 13:47:55 +00:00
parent cc70806ad2
commit 89e87dea27
1 changed files with 15 additions and 17 deletions

View File

@ -19,11 +19,10 @@ public class AuthorizationService {
public final String REGISTERED_USER = "REGISTERED_USER"; public final String REGISTERED_USER = "REGISTERED_USER";
private String mapType(String type) { private String mapType(String type, boolean communityMap) {
if (type.equals("organization")) { if (type.equals("organization")) {
type = "institution"; type = "institution";
} } else if (type.equals("ri") && communityMap) {
if(type.equals("ri")) {
type = "community"; type = "community";
} }
return type; return type;
@ -31,28 +30,27 @@ public class AuthorizationService {
/** /**
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT * Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
* */
* */
public String curator(String type) { public String curator(String type) {
return "CURATOR_"+mapType(type).toUpperCase(); return "CURATOR_" + mapType(type, true).toUpperCase();
} }
/** /**
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT * Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
* * <p>
* Id = EE, EGI, etc * Id = EE, EGI, etc
* */ */
public String manager(String type, String id) { public String manager(String type, String id) {
return mapType(type).toUpperCase() + "_" + id.toUpperCase() + "_MANAGER"; return mapType(type, true).toUpperCase() + "_" + id.toUpperCase() + "_MANAGER";
} }
/** /**
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT * Type = FUNDER | COMMUNITY | RI | INSTITUTION | PROJECT
* * <p>
* Id = EE, EGI, etc * Id = EE, EGI, etc
* */ */
public String member(String type, String id) { public String member(String type, String id) {
return mapType(type).toUpperCase() + "_" + id.toUpperCase(); return mapType(type, false).toUpperCase() + "_" + id.toUpperCase();
} }
public List<String> getRoles() { public List<String> getRoles() {