Improve logging

This commit is contained in:
Alex Morel 2024-06-21 14:22:04 +02:00
parent 080cc8c273
commit 5aa9410bac
2 changed files with 6 additions and 6 deletions

View file

@ -78,7 +78,7 @@ public abstract class AbstractScimService<RMM extends RoleMapperModel, S extends
KeycloakId id = getId(roleMapperModel); KeycloakId id = getId(roleMapperModel);
ScimResource scimResource = findById(id).get(); ScimResource scimResource = findById(id).get();
EntityOnRemoteScimId externalId = scimResource.getExternalIdAsEntityOnRemoteScimId(); EntityOnRemoteScimId externalId = scimResource.getExternalIdAsEntityOnRemoteScimId();
ResourceNode scimForReplace = toScimForReplace(roleMapperModel, externalId); S scimForReplace = toScimForReplace(roleMapperModel, externalId);
scimClient.replace(externalId, scimForReplace); scimClient.replace(externalId, scimForReplace);
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
LOGGER.warnf("failed to replace resource %s, scim mapping not found", getId(roleMapperModel)); LOGGER.warnf("failed to replace resource %s, scim mapping not found", getId(roleMapperModel));
@ -87,7 +87,7 @@ public abstract class AbstractScimService<RMM extends RoleMapperModel, S extends
} }
} }
protected abstract ResourceNode toScimForReplace(RMM roleMapperModel, EntityOnRemoteScimId externalId); protected abstract S toScimForReplace(RMM roleMapperModel, EntityOnRemoteScimId externalId);
public void delete(KeycloakId id) { public void delete(KeycloakId id) {
try { try {

View file

@ -72,13 +72,13 @@ public class ScimDispatcher {
public void dispatchUserModificationToAll(Consumer<UserScimService> operationToDispatch) { public void dispatchUserModificationToAll(Consumer<UserScimService> operationToDispatch) {
initializeClientsIfNeeded(); initializeClientsIfNeeded();
userScimServices.forEach(operationToDispatch); userScimServices.forEach(operationToDispatch);
logger.infof("[SCIM] User operation dispatched to %d SCIM clients", userScimServices.size()); logger.infof("[SCIM] User operation dispatched to %d SCIM server", userScimServices.size());
} }
public void dispatchGroupModificationToAll(Consumer<GroupScimService> operationToDispatch) { public void dispatchGroupModificationToAll(Consumer<GroupScimService> operationToDispatch) {
initializeClientsIfNeeded(); initializeClientsIfNeeded();
groupScimServices.forEach(operationToDispatch); groupScimServices.forEach(operationToDispatch);
logger.infof("[SCIM] Group operation dispatched to %d SCIM clients", groupScimServices.size()); logger.infof("[SCIM] Group operation dispatched to %d SCIM server", groupScimServices.size());
} }
public void dispatchUserModificationToOne(ComponentModel scimServerConfiguration, Consumer<UserScimService> operationToDispatch) { public void dispatchUserModificationToOne(ComponentModel scimServerConfiguration, Consumer<UserScimService> operationToDispatch) {
@ -87,7 +87,7 @@ public class ScimDispatcher {
Optional<UserScimService> matchingClient = userScimServices.stream().filter(u -> u.getConfiguration().getId().equals(scimServerConfiguration.getId())).findFirst(); Optional<UserScimService> matchingClient = userScimServices.stream().filter(u -> u.getConfiguration().getId().equals(scimServerConfiguration.getId())).findFirst();
if (matchingClient.isPresent()) { if (matchingClient.isPresent()) {
operationToDispatch.accept(matchingClient.get()); operationToDispatch.accept(matchingClient.get());
logger.infof("[SCIM] User operation dispatched to SCIM client %s", matchingClient.get().getConfiguration().getId()); logger.infof("[SCIM] User operation dispatched to SCIM server %s", matchingClient.get().getConfiguration().getId());
} else { } else {
logger.error("[SCIM] Could not find a Scim Client matching endpoint configuration" + scimServerConfiguration.getId()); logger.error("[SCIM] Could not find a Scim Client matching endpoint configuration" + scimServerConfiguration.getId());
} }
@ -100,7 +100,7 @@ public class ScimDispatcher {
Optional<GroupScimService> matchingClient = groupScimServices.stream().filter(u -> u.getConfiguration().getId().equals(scimServerConfiguration.getId())).findFirst(); Optional<GroupScimService> matchingClient = groupScimServices.stream().filter(u -> u.getConfiguration().getId().equals(scimServerConfiguration.getId())).findFirst();
if (matchingClient.isPresent()) { if (matchingClient.isPresent()) {
operationToDispatch.accept(matchingClient.get()); operationToDispatch.accept(matchingClient.get());
logger.infof("[SCIM] Group operation dispatched to SCIM client %s", matchingClient.get().getConfiguration().getId()); logger.infof("[SCIM] Group operation dispatched to SCIM server %s", matchingClient.get().getConfiguration().getId());
} else { } else {
logger.error("[SCIM] Could not find a Scim Client matching endpoint configuration" + scimServerConfiguration.getId()); logger.error("[SCIM] Could not find a Scim Client matching endpoint configuration" + scimServerConfiguration.getId());
} }