Revision 61374
Added by Konstantinos Triantafyllou over 2 years ago
RegistryService.java | ||
---|---|---|
12 | 12 |
import eu.dnetlib.openaire.usermanagement.utils.RegistryCalls; |
13 | 13 |
import eu.dnetlib.openaire.usermanagement.utils.VerificationUtils; |
14 | 14 |
import org.apache.log4j.Logger; |
15 |
import org.mitre.openid.connect.model.OIDCAuthenticationToken; |
|
16 | 15 |
import org.springframework.beans.factory.annotation.Autowired; |
17 | 16 |
import org.springframework.http.HttpStatus; |
18 | 17 |
import org.springframework.security.access.method.P; |
19 | 18 |
import org.springframework.security.access.prepost.PreAuthorize; |
20 | 19 |
import org.springframework.security.core.authority.SimpleGrantedAuthority; |
21 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
22 | 20 |
import org.springframework.stereotype.Component; |
23 | 21 |
import org.springframework.web.bind.annotation.RequestBody; |
24 | 22 |
|
... | ... | |
118 | 116 |
@PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)") |
119 | 117 |
public Response createRole(@RequestBody Role role) { |
120 | 118 |
if (calls.getCouId(role.getName()) == null) { |
121 |
calls.createRole(role); |
|
122 |
return Response.status(HttpStatus.OK.value()).entity(jsonUtils.createResponse("Role has been created").toString()).type(MediaType.APPLICATION_JSON).build(); |
|
119 |
if(calls.createRole(role) != null) { |
|
120 |
return Response.status(HttpStatus.OK.value()).entity(jsonUtils.createResponse("Role has been created").toString()).type(MediaType.APPLICATION_JSON).build(); |
|
121 |
} else { |
|
122 |
return Response.status(HttpStatus.BAD_REQUEST.value()).entity(jsonUtils.createResponse("An error has occurred. Please try again later").toString()).type(MediaType.APPLICATION_JSON).build(); |
|
123 |
} |
|
123 | 124 |
} else { |
124 | 125 |
return Response.status(HttpStatus.CONFLICT.value()).entity(jsonUtils.createResponse("Role has already existed").toString()).type(MediaType.APPLICATION_JSON).build(); |
125 | 126 |
} |
Also available in: Unified diff
Update dnet-login-core to 1.0.2. Create role returns id of created role