diff --git a/src/main/java/sh/libre/scim/core/AbstractScimService.java b/src/main/java/sh/libre/scim/core/AbstractScimService.java index e32f178977..53a6738b35 100644 --- a/src/main/java/sh/libre/scim/core/AbstractScimService.java +++ b/src/main/java/sh/libre/scim/core/AbstractScimService.java @@ -45,7 +45,7 @@ public abstract class AbstractScimService implements AutoCloseable { return new ScimClient(scimRequestBuilder, scimResourceType); } - public EntityOnRemoteScimId create(ResourceNode scimForCreation) { - Retry retry = retryRegistry.retry("create-" + scimForCreation.getId().get()); + public EntityOnRemoteScimId create(KeycloakId id, ResourceNode scimForCreation) { + if (scimForCreation.getId().isPresent()) { + throw new IllegalArgumentException( + "%s is already created on remote with id %s".formatted(id, scimForCreation.getId().get()) + ); + } + Retry retry = retryRegistry.retry("create-%s".formatted(id.asString())); ServerResponse response = retry.executeSupplier(() -> { try { return scimRequestBuilder @@ -98,7 +103,7 @@ public class ScimClient implements AutoCloseable { } public void replace(EntityOnRemoteScimId externalId, ResourceNode scimForReplace) { - Retry retry = retryRegistry.retry("replace-" + scimForReplace.getId().get()); + Retry retry = retryRegistry.retry("replace-%s".formatted(externalId.asString())); ServerResponse response = retry.executeSupplier(() -> { try { return scimRequestBuilder @@ -113,7 +118,7 @@ public class ScimClient implements AutoCloseable { } public void delete(EntityOnRemoteScimId externalId) { - Retry retry = retryRegistry.retry("delete-" + externalId.asString()); + Retry retry = retryRegistry.retry("delete-%s".formatted(externalId.asString())); ServerResponse response = retry.executeSupplier(() -> { try { return scimRequestBuilder.delete(getResourceClass(), getScimEndpoint(), externalId.asString())