From 8e97335de4af41d2face06f35b18633a197b1780 Mon Sep 17 00:00:00 2001
From: Brendan Le Ny <bleny@codelutin.com>
Date: Mon, 24 Jun 2024 09:56:16 +0200
Subject: [PATCH] Improve error messages and logs

---
 src/main/java/sh/libre/scim/core/AbstractScimService.java       | 2 +-
 src/main/java/sh/libre/scim/core/ScimDispatcher.java            | 2 +-
 .../java/sh/libre/scim/event/ScimEventListenerProvider.java     | 2 +-
 .../ScimEndpointConfigurationStorageProviderFactory.java        | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/sh/libre/scim/core/AbstractScimService.java b/src/main/java/sh/libre/scim/core/AbstractScimService.java
index 8f92a22..a0939ad 100644
--- a/src/main/java/sh/libre/scim/core/AbstractScimService.java
+++ b/src/main/java/sh/libre/scim/core/AbstractScimService.java
@@ -97,7 +97,7 @@ public abstract class AbstractScimService<RMM extends RoleMapperModel, S extends
             scimClient.delete(externalId);
             getScimResourceDao().delete(resource);
         } catch (NoSuchElementException e) {
-            throw new ScimPropagationException("Failed to delete resource %s, scim mapping not found : " + id, e);
+            throw new ScimPropagationException("Failed to delete resource %s, scim mapping not found: ".formatted(id), e);
         }
     }
 
diff --git a/src/main/java/sh/libre/scim/core/ScimDispatcher.java b/src/main/java/sh/libre/scim/core/ScimDispatcher.java
index 8154bb3..62a8bfb 100644
--- a/src/main/java/sh/libre/scim/core/ScimDispatcher.java
+++ b/src/main/java/sh/libre/scim/core/ScimDispatcher.java
@@ -60,7 +60,7 @@ public class ScimDispatcher {
                                 userScimServices.add(userScimService);
                             }
                         } catch (Exception e) {
-                            logger.warnf("[SCIM] Invalid Endpoint configuration %s : %s", scimEndpointConfigurationRaw.getId(), e.getMessage());
+                            logger.warnf("[SCIM] Invalid Endpoint configuration %s: %s", scimEndpointConfigurationRaw.getId(), e.getMessage());
                             // TODO is it ok to log and try to create the other clients ?
                         }
                     });
diff --git a/src/main/java/sh/libre/scim/event/ScimEventListenerProvider.java b/src/main/java/sh/libre/scim/event/ScimEventListenerProvider.java
index e9635d4..06a01db 100644
--- a/src/main/java/sh/libre/scim/event/ScimEventListenerProvider.java
+++ b/src/main/java/sh/libre/scim/event/ScimEventListenerProvider.java
@@ -107,7 +107,7 @@ public class ScimEventListenerProvider implements EventListenerProvider {
                 ScimResourceType type = switch (rawResourceType) {
                     case "users" -> ScimResourceType.USER;
                     case "groups" -> ScimResourceType.GROUP;
-                    default -> throw new IllegalArgumentException("Unsuported resource type : " + rawResourceType);
+                    default -> throw new IllegalArgumentException("Unsuported resource type: " + rawResourceType);
                 };
                 KeycloakId id = new KeycloakId(matcher.group(2));
                 handleRoleMappingEvent(event, type, id);
diff --git a/src/main/java/sh/libre/scim/storage/ScimEndpointConfigurationStorageProviderFactory.java b/src/main/java/sh/libre/scim/storage/ScimEndpointConfigurationStorageProviderFactory.java
index 748e18b..00a527f 100644
--- a/src/main/java/sh/libre/scim/storage/ScimEndpointConfigurationStorageProviderFactory.java
+++ b/src/main/java/sh/libre/scim/storage/ScimEndpointConfigurationStorageProviderFactory.java
@@ -78,7 +78,7 @@ public class ScimEndpointConfigurationStorageProviderFactory
                         ScimDispatcher dispatcher = new ScimDispatcher(session);
                         for (GroupModel group : session.groups().getGroupsStream(realm)
                                 .filter(x -> BooleanUtils.TRUE.equals(x.getFirstAttribute("scim-dirty"))).toList()) {
-                            logger.infof("[SCIM] Dirty group : %s", group.getName());
+                            logger.infof("[SCIM] Dirty group: %s", group.getName());
                             dispatcher.dispatchGroupModificationToAll(client -> client.replace(group));
                             group.removeAttribute("scim-dirty");
                         }
-- 
GitLab