You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2013/07/01 11:10:23 UTC

svn commit: r1498331 - in /manifoldcf/trunk/framework: authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/ pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/

Author: kwright
Date: Mon Jul  1 09:10:23 2013
New Revision: 1498331

URL: http://svn.apache.org/r1498331
Log:
Handle case where mapping fails more elegantly.  Part of CONNECTORS-703.

Modified:
    manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java
    manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java
    manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java

Modified: manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java?rev=1498331&r1=1498330&r2=1498331&view=diff
==============================================================================
--- manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java (original)
+++ manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java Mon Jul  1 09:10:23 2013
@@ -320,7 +320,14 @@ public class UserACLServlet extends Http
             return;
           }
 
-          if (reply.getResponseStatus() == AuthorizationResponse.RESPONSE_UNREACHABLE)
+          // A null reply means the same as USERNOTFOUND; it occurs because a user mapping failed somewhere.
+          if (reply == null)
+          {
+            if (Logging.authorityService.isDebugEnabled())
+              Logging.authorityService.debug("User '"+userID+"' mapping failed for authority '"+ar.getIdentifyingString()+"'");
+            sb.append(USERNOTFOUND_VALUE).append(java.net.URLEncoder.encode(ar.getIdentifyingString(),"UTF-8")).append("\n");
+          }
+          else if (reply.getResponseStatus() == AuthorizationResponse.RESPONSE_UNREACHABLE)
           {
             Logging.authorityService.warn("Authority '"+ar.getIdentifyingString()+"' is unreachable for user '"+userID+"'");
             sb.append(UNREACHABLE_VALUE).append(java.net.URLEncoder.encode(ar.getIdentifyingString(),"UTF-8")).append("\n");

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java?rev=1498331&r1=1498330&r2=1498331&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java Mon Jul  1 09:10:23 2013
@@ -72,55 +72,59 @@ public class AuthCheckThread extends Thr
         AuthorizationResponse response = null;
         Throwable exception = null;
 
-        try
+        // Grab an authorization response only if there's a user
+        if (theRequest.getUserID() != null)
         {
-          IAuthorityConnector connector = AuthorityConnectorFactory.grab(threadContext,
-            theRequest.getClassName(),
-            theRequest.getConfigurationParams(),
-            theRequest.getMaxConnections());
-          // If this is null, we MUST treat this as an "unauthorized" condition!!
-          // We signal that by setting the exception value.
           try
           {
-            if (connector == null)
-              exception = new ManifoldCFException("Authority connector "+theRequest.getClassName()+" is not registered.");
-            else
+            IAuthorityConnector connector = AuthorityConnectorFactory.grab(threadContext,
+              theRequest.getClassName(),
+              theRequest.getConfigurationParams(),
+              theRequest.getMaxConnections());
+            // If this is null, we MUST treat this as an "unauthorized" condition!!
+            // We signal that by setting the exception value.
+            try
             {
-              // Get the acl for the user
-              try
+              if (connector == null)
+                exception = new ManifoldCFException("Authority connector "+theRequest.getClassName()+" is not registered.");
+              else
               {
-                response = connector.getAuthorizationResponse(theRequest.getUserID());
-              }
-              catch (ManifoldCFException e)
-              {
-                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-                  throw e;
-                Logging.authorityService.warn("Authority error: "+e.getMessage(),e);
-                response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getClassName(),theRequest.getUserID());
-              }
+                // Get the acl for the user
+                try
+                {
+                  response = connector.getAuthorizationResponse(theRequest.getUserID());
+                }
+                catch (ManifoldCFException e)
+                {
+                  if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+                    throw e;
+                  Logging.authorityService.warn("Authority error: "+e.getMessage(),e);
+                  response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getClassName(),theRequest.getUserID());
+                }
 
+              }
+            }
+            finally
+            {
+              AuthorityConnectorFactory.release(connector);
             }
           }
-          finally
+          catch (ManifoldCFException e)
           {
-            AuthorityConnectorFactory.release(connector);
+            if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+              throw e;
+            Logging.authorityService.warn("Authority connection exception: "+e.getMessage(),e);
+            response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getClassName(),theRequest.getUserID());
+            if (response == null)
+              exception = e;
+          }
+          catch (Throwable e)
+          {
+            Logging.authorityService.warn("Authority connection error: "+e.getMessage(),e);
+            response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getClassName(),theRequest.getUserID());
+            if (response == null)
+              exception = e;
           }
-        }
-        catch (ManifoldCFException e)
-        {
-          if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-            throw e;
-          Logging.authorityService.warn("Authority connection exception: "+e.getMessage(),e);
-          response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getClassName(),theRequest.getUserID());
-          if (response == null)
-            exception = e;
-        }
-        catch (Throwable e)
-        {
-          Logging.authorityService.warn("Authority connection error: "+e.getMessage(),e);
-          response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getClassName(),theRequest.getUserID());
-          if (response == null)
-            exception = e;
         }
 
         // The request is complete

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java?rev=1498331&r1=1498330&r2=1498331&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java Mon Jul  1 09:10:23 2013
@@ -71,48 +71,52 @@ public class MappingThread extends Threa
 	String outputUserID = null;
         Throwable exception = null;
 
-        try
+        // Only try a mapping if we have a user to map...
+        if (theRequest.getUserID() != null)
         {
-          IMappingConnector connector = MappingConnectorFactory.grab(threadContext,
-            theRequest.getClassName(),
-            theRequest.getConfigurationParams(),
-            theRequest.getMaxConnections());
           try
           {
-            if (connector == null)
-              exception = new ManifoldCFException("Mapping connector "+theRequest.getClassName()+" is not registered.");
-            else
+            IMappingConnector connector = MappingConnectorFactory.grab(threadContext,
+              theRequest.getClassName(),
+              theRequest.getConfigurationParams(),
+              theRequest.getMaxConnections());
+            try
             {
-              // Do the mapping
-              try
+              if (connector == null)
+                exception = new ManifoldCFException("Mapping connector "+theRequest.getClassName()+" is not registered.");
+              else
               {
-                outputUserID = connector.mapUser(theRequest.getUserID());
-              }
-              catch (ManifoldCFException e)
-              {
-                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-                  throw e;
-                Logging.authorityService.warn("Mapping error: "+e.getMessage(),e);
-              }
+                // Do the mapping
+                try
+                {
+                  outputUserID = connector.mapUser(theRequest.getUserID());
+                }
+                catch (ManifoldCFException e)
+                {
+                  if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+                    throw e;
+                  Logging.authorityService.warn("Mapping error: "+e.getMessage(),e);
+                }
 
+              }
+            }
+            finally
+            {
+              MappingConnectorFactory.release(connector);
             }
           }
-          finally
+          catch (ManifoldCFException e)
           {
-            MappingConnectorFactory.release(connector);
+            if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+              throw e;
+            Logging.authorityService.warn("Mapping connection exception: "+e.getMessage(),e);
+            exception = e;
+          }
+          catch (Throwable e)
+          {
+            Logging.authorityService.warn("Mapping connection error: "+e.getMessage(),e);
+            exception = e;
           }
-        }
-        catch (ManifoldCFException e)
-        {
-          if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-            throw e;
-          Logging.authorityService.warn("Mapping connection exception: "+e.getMessage(),e);
-          exception = e;
-        }
-        catch (Throwable e)
-        {
-          Logging.authorityService.warn("Mapping connection error: "+e.getMessage(),e);
-          exception = e;
         }
 
         // The request is complete