Return-Path: X-Original-To: apmail-manifoldcf-commits-archive@www.apache.org Delivered-To: apmail-manifoldcf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C7C9BD65D for ; Tue, 11 Sep 2012 01:48:06 +0000 (UTC) Received: (qmail 69445 invoked by uid 500); 11 Sep 2012 01:48:06 -0000 Delivered-To: apmail-manifoldcf-commits-archive@manifoldcf.apache.org Received: (qmail 69396 invoked by uid 500); 11 Sep 2012 01:48:06 -0000 Mailing-List: contact commits-help@manifoldcf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@manifoldcf.apache.org Delivered-To: mailing list commits@manifoldcf.apache.org Received: (qmail 69386 invoked by uid 99); 11 Sep 2012 01:48:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2012 01:48:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2012 01:48:03 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 91594238890D; Tue, 11 Sep 2012 01:47:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1383215 - /manifoldcf/branches/CONNECTORS-518/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java Date: Tue, 11 Sep 2012 01:47:19 -0000 To: commits@manifoldcf.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120911014719.91594238890D@eris.apache.org> Author: kwright Date: Tue Sep 11 01:47:19 2012 New Revision: 1383215 URL: http://svn.apache.org/viewvc?rev=1383215&view=rev Log: Prevent us from winding up in infinite logon loops, by only permitting one logon attempt per fetch. Modified: manifoldcf/branches/CONNECTORS-518/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java Modified: manifoldcf/branches/CONNECTORS-518/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-518/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java?rev=1383215&r1=1383214&r2=1383215&view=diff ============================================================================== --- manifoldcf/branches/CONNECTORS-518/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java (original) +++ manifoldcf/branches/CONNECTORS-518/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java Tue Sep 11 01:47:19 2012 @@ -141,20 +141,22 @@ public class WikiConnector extends org.a httpClient = new HttpClient(connectionManager); - if (serverLogin != null && !"".equals(serverLogin)) { - loginToAPI(); - } - + loginToAPI(); + hasBeenSetup = true; } } /** Log in via the Wiki API. * Call this method whenever login is apparently needed. + *@return true if the login was successful, false otherwise. */ - protected void loginToAPI() + protected boolean loginToAPI() throws ManifoldCFException, ServiceInterruption { + if (serverLogin == null || serverLogin.length() == 0) + return false; + // Grab the httpclient, and use the same one throughout. HttpClient client = getInitializedClient(); @@ -326,7 +328,11 @@ public class WikiConnector extends org.a // Check result if (!result.result) + { + Logging.connectors.debug("WIKI API login error: '" + result.reason + "'"); throw new ManifoldCFException("WIKI API login error: " + result.reason, null, ManifoldCFException.REPOSITORY_CONNECTION_ERROR); + } + return true; } /** @@ -1633,6 +1639,7 @@ public class WikiConnector extends org.a throws ManifoldCFException, ServiceInterruption { getSession(); + boolean loginAttempted = false; while (true) { HttpClient client = getInitializedClient(); @@ -1662,7 +1669,7 @@ public class WikiConnector extends org.a else throw (Error)thr; } - if (!t.isLoginRequired()) + if (loginAttempted || !t.isLoginRequired()) return; } catch (ManifoldCFException e) @@ -1730,7 +1737,9 @@ public class WikiConnector extends org.a executeMethod.releaseConnection(); } - loginToAPI(); + if (!loginToAPI()) + break; + loginAttempted = true; // Back around... } } @@ -1970,6 +1979,7 @@ public class WikiConnector extends org.a protected String executeListPagesViaThread(String startPageTitle, String namespace, String prefix, ISeedingActivity activities) throws ManifoldCFException, ServiceInterruption { + boolean loginAttempted = false; while (true) { HttpClient client = getInitializedClient(); @@ -2012,7 +2022,7 @@ public class WikiConnector extends org.a else throw (Error)thr; } - if (!t.isLoginRequired()) + if (loginAttempted || !t.isLoginRequired()) return t.getLastPageTitle(); } catch (ManifoldCFException e) @@ -2085,10 +2095,13 @@ public class WikiConnector extends org.a executeMethod.releaseConnection(); } - loginToAPI(); + if (!loginToAPI()) + break; + loginAttempted = true; // Back around... } + return null; } /** Create a URL to obtain the next 500 pages. @@ -2389,6 +2402,7 @@ public class WikiConnector extends org.a throws ManifoldCFException, ServiceInterruption { getSession(); + boolean loginAttempted = false; while (true) { HttpClient client = getInitializedClient(); @@ -2418,7 +2432,7 @@ public class WikiConnector extends org.a else throw (Error)thr; } - if (!t.isLoginRequired()) + if (loginAttempted || !t.isLoginRequired()) return; } catch (ManifoldCFException e) @@ -2486,7 +2500,9 @@ public class WikiConnector extends org.a executeMethod.releaseConnection(); } - loginToAPI(); + if (!loginToAPI()) + break; + loginAttempted = true; } } @@ -2720,6 +2736,7 @@ public class WikiConnector extends org.a throws ManifoldCFException, ServiceInterruption { getSession(); + boolean loginAttempted = false; while (true) { HttpClient client = getInitializedClient(); @@ -2749,7 +2766,7 @@ public class WikiConnector extends org.a else throw (Error)thr; } - if (!t.isLoginRequired()) + if (loginAttempted || !t.isLoginRequired()) return; } catch (ManifoldCFException e) @@ -2817,7 +2834,9 @@ public class WikiConnector extends org.a executeMethod.releaseConnection(); } - loginToAPI(); + if (!loginToAPI()) + break; + loginAttempted = true; } } @@ -3122,6 +3141,7 @@ public class WikiConnector extends org.a throws ManifoldCFException, ServiceInterruption { getSession(); + boolean loginAttempted = false; while (true) { HttpClient client = getInitializedClient(); @@ -3153,7 +3173,7 @@ public class WikiConnector extends org.a else throw (Error)thr; } - if (!t.isLoginRequired()) + if (loginAttempted || !t.isLoginRequired()) return; } catch (ManifoldCFException e) @@ -3221,7 +3241,9 @@ public class WikiConnector extends org.a executeMethod.releaseConnection(); } - loginToAPI(); + if (!loginToAPI()) + break; + loginAttempted = true; } } @@ -3469,6 +3491,7 @@ public class WikiConnector extends org.a throws ManifoldCFException, ServiceInterruption { getSession(); + boolean loginAttempted = false; while (true) { HttpClient client = getInitializedClient(); @@ -3558,7 +3581,7 @@ public class WikiConnector extends org.a } } - if (!t.isLoginRequired()) + if (loginAttempted || !t.isLoginRequired()) return; } catch (ManifoldCFException e) @@ -3637,7 +3660,9 @@ public class WikiConnector extends org.a activities.recordActivity(new Long(startTime),ACTIVITY_FETCH,new Long(dataSize),documentIdentifier,statusCode,errorMessage,null); } - loginToAPI(); + if (!loginToAPI()) + break; + loginAttempted = true; } }