diff --git a/extensions/api/participant-context-mgmt-api/src/main/java/org/eclipse/edc/identityhub/api/participantcontext/v1/ParticipantContextApiController.java b/extensions/api/participant-context-mgmt-api/src/main/java/org/eclipse/edc/identityhub/api/participantcontext/v1/ParticipantContextApiController.java index bb42d2179..778278141 100644 --- a/extensions/api/participant-context-mgmt-api/src/main/java/org/eclipse/edc/identityhub/api/participantcontext/v1/ParticipantContextApiController.java +++ b/extensions/api/participant-context-mgmt-api/src/main/java/org/eclipse/edc/identityhub/api/participantcontext/v1/ParticipantContextApiController.java @@ -108,10 +108,7 @@ public void deleteParticipant(@PathParam("participantId") String participantId, @Path("/{participantId}/roles") @RolesAllowed(ServicePrincipal.ROLE_ADMIN) public void updateRoles(@PathParam("participantId") String participantId, List roles) { - participantContextService.updateParticipant(participantId, participantContext -> { - participantContext.getRoles().clear(); - participantContext.getRoles().addAll(roles); - }).orElseThrow(exceptionMapper(ParticipantContext.class, participantId)); + participantContextService.updateParticipant(participantId, participantContext -> participantContext.setRoles(roles)).orElseThrow(exceptionMapper(ParticipantContext.class, participantId)); } } diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/participant/ParticipantContext.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/participant/ParticipantContext.java index fb17e040a..ac3c2e5e3 100644 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/participant/ParticipantContext.java +++ b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/participant/ParticipantContext.java @@ -22,6 +22,7 @@ import java.time.Instant; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -100,7 +101,11 @@ public String getDid() { } public List getRoles() { - return roles; + return Collections.unmodifiableList(roles); + } + + public void setRoles(List roles) { + this.roles = roles; } @JsonPOJOBuilder(withPrefix = "")