Author: bdelacretaz
Date: Thu Feb  4 10:43:11 2016
New Revision: 1728437

URL: http://svn.apache.org/viewvc?rev=1728437&view=rev
Log:
SLING-5484 - more logging for ServiceUserMapperImpl.getServiceUserID and 
related methods

Modified:
    
sling/trunk/bundles/extensions/serviceusermapper/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java

Modified: 
sling/trunk/bundles/extensions/serviceusermapper/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/serviceusermapper/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java?rev=1728437&r1=1728436&r2=1728437&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/serviceusermapper/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java
 (original)
+++ 
sling/trunk/bundles/extensions/serviceusermapper/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java
 Thu Feb  4 10:43:11 2016
@@ -193,7 +193,12 @@ public class ServiceUserMapperImpl imple
     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 imple
             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 imple
                     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 imple
         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 imple
         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 imple
 
     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) {


Reply via email to