Rollback on exception
This commit is contained in:
parent
5aa9410bac
commit
81d9f5424c
3 changed files with 9 additions and 5 deletions
|
@ -44,12 +44,12 @@ public abstract class AbstractScimService<RMM extends RoleMapperModel, S extends
|
|||
if (findById(id).isPresent()) {
|
||||
return;
|
||||
}
|
||||
ResourceNode scimForCreation = toScimForCreation(roleMapperModel);
|
||||
S scimForCreation = toScimForCreation(roleMapperModel);
|
||||
EntityOnRemoteScimId externalId = scimClient.create(id, scimForCreation);
|
||||
createMapping(id, externalId);
|
||||
}
|
||||
|
||||
protected abstract ResourceNode toScimForCreation(RMM roleMapperModel);
|
||||
protected abstract S toScimForCreation(RMM roleMapperModel);
|
||||
|
||||
protected abstract KeycloakId getId(RMM roleMapperModel);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.google.common.net.HttpHeaders;
|
|||
import de.captaingoldfish.scim.sdk.client.ScimClientConfig;
|
||||
import de.captaingoldfish.scim.sdk.client.ScimRequestBuilder;
|
||||
import de.captaingoldfish.scim.sdk.client.response.ServerResponse;
|
||||
import de.captaingoldfish.scim.sdk.common.exceptions.ResponseException;
|
||||
import de.captaingoldfish.scim.sdk.common.resources.ResourceNode;
|
||||
import de.captaingoldfish.scim.sdk.common.response.ListResponse;
|
||||
import io.github.resilience4j.core.IntervalFunction;
|
||||
|
@ -63,7 +62,7 @@ public class ScimClient<S extends ResourceNode> implements AutoCloseable {
|
|||
return new ScimClient(scimRequestBuilder, scimResourceType);
|
||||
}
|
||||
|
||||
public EntityOnRemoteScimId create(KeycloakId id, ResourceNode scimForCreation) {
|
||||
public EntityOnRemoteScimId create(KeycloakId id, S scimForCreation) {
|
||||
if (scimForCreation.getId().isPresent()) {
|
||||
throw new IllegalArgumentException(
|
||||
"%s is already created on remote with id %s".formatted(id, scimForCreation.getId().get())
|
||||
|
@ -97,8 +96,9 @@ public class ScimClient<S extends ResourceNode> implements AutoCloseable {
|
|||
return scimResourceType.getResourceClass();
|
||||
}
|
||||
|
||||
public void replace(EntityOnRemoteScimId externalId, ResourceNode scimForReplace) {
|
||||
public void replace(EntityOnRemoteScimId externalId, S scimForReplace) {
|
||||
Retry retry = retryRegistry.retry("replace-%s".formatted(externalId.asString()));
|
||||
logger.warn(scimForReplace);
|
||||
ServerResponse<S> response = retry.executeSupplier(() -> scimRequestBuilder
|
||||
.update(getResourceClass(), getScimEndpoint(), externalId.asString())
|
||||
.setResource(scimForReplace)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
package sh.libre.scim.core;
|
||||
|
||||
public class ScimPropagationException {
|
||||
}
|
Loading…
Reference in a new issue