You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:14:34 UTC

[sling-org-apache-sling-serviceusermapper] 04/18: SLING-5484 - more logging for ServiceUserMapperImpl.getServiceUserID and related methods

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.serviceusermapper-1.2.6
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-serviceusermapper.git

commit 80132424248f70d32e05cfd3458a2a1ea57d397c
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Feb 4 10:43:11 2016 +0000

    SLING-5484 - more logging for ServiceUserMapperImpl.getServiceUserID and related methods
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/serviceusermapper@1728437 13f79535-47bb-0310-9956-ffa450edef68
---
 .../serviceusermapping/impl/ServiceUserMapperImpl.java | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java b/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java
index 6b545f1..fbb3465 100644
--- a/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java
+++ b/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java
@@ -193,7 +193,12 @@ public class ServiceUserMapperImpl implements ServiceUserMapper {
     public String getServiceUserID(final Bundle bundle, final String subServiceName) {
         final String serviceName = getServiceName(bundle);
         final String userId = internalGetUserId(serviceName, subServiceName);
-        return isValidUser(userId, serviceName, subServiceName) ? userId : null;
+        final boolean valid = isValidUser(userId, serviceName, subServiceName);
+        final String result = valid ? userId : null;
+        log.debug(
+                "getServiceUserID(bundle {}, subServiceName {}) returns [{}] (raw userId={}, valid={})",
+                new Object[] { bundle, subServiceName, result, userId, valid });
+        return result;
     }
 
     protected synchronized void bindAmendment(final MappingConfigAmendment amendment, final Map<String, Object> props) {
@@ -313,6 +318,7 @@ public class ServiceUserMapperImpl implements ServiceUserMapper {
             if (serviceRegistration != null) {
                 try {
                     serviceRegistration.unregister();
+                    log.debug("Unregistered ServiceUserMapped {}", registration.mapping);
                 } catch (IllegalStateException e) {
                     log.error("cannot unregister ServiceUserMapped {}", registration.mapping,  e);
                 }
@@ -337,6 +343,7 @@ public class ServiceUserMapperImpl implements ServiceUserMapper {
                     new ServiceUserMappedImpl(), properties);
 
             ServiceRegistration oldServiceRegistration = registration.setService(serviceRegistration);
+            log.debug("Activated ServiceUserMapped {}", registration.mapping);
 
             if (oldServiceRegistration != null) {
                 try {
@@ -354,6 +361,7 @@ public class ServiceUserMapperImpl implements ServiceUserMapper {
         for (final Mapping mapping : this.activeMappings) {
             final String userId = mapping.map(serviceName, subServiceName);
             if (userId != null) {
+                log.debug("Got userId [{}] from {}/{}", new Object[] { userId, serviceName, subServiceName });
                 return userId;
             }
         }
@@ -362,6 +370,7 @@ public class ServiceUserMapperImpl implements ServiceUserMapper {
         for (Mapping mapping : this.activeMappings) {
             final String userId = mapping.map(serviceName, null);
             if (userId != null) {
+                log.debug("Got userId [{}] from {}/<no subServiceName>", userId, serviceName);
                 return userId;
             }
         }
@@ -372,17 +381,22 @@ public class ServiceUserMapperImpl implements ServiceUserMapper {
 
     private boolean isValidUser(final String userId, final String serviceName, final String subServiceName) {
         if (userId == null) {
+            log.debug("isValidUser: userId is null -> invalid");
             return false;
         }
         if ( !validators.isEmpty() ) {
             for (final ServiceUserValidator validator : validators) {
                 if ( validator.isValid(userId, serviceName, subServiceName) ) {
+                    log.debug("isValidUser: Validator {} accepts userId [{}] -> valid", validator, userId);
                     return true;
                 }
             }
+            log.debug("isValidUser: No validator accepte userId [{}] -> invalid", userId);
             return false;
+        } else {
+            log.debug("isValidUser: No active validators for userId [{}] -> valid", userId);
+            return true;
         }
-        return true;
     }
 
     static String getServiceName(final Bundle bundle) {

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.