Flipping isSP2010 check to isSP2007 check to support SP2013
code review https://codereview.appspot.com/13243043/
diff --git a/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java b/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
index a60f6a4..822cf76 100644
--- a/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
+++ b/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
@@ -243,10 +243,10 @@
   private String defaultNamespace;
   /** Authenticator instance that authenticates with SP. */
   /**
-   * Cached value of whether we are talking to a SP 2010 server or not. This
+   * Cached value of whether we are talking to a SP 2007 server or not. This
    * value is used in case of error in certain situations.
    */
-  private boolean isSp2010;
+  private boolean isSp2007;
   private NtlmAuthenticator ntlmAuthenticator;
   /**
    * Lock for refreshing MemberIdMapping. We use a unique lock because it is
@@ -336,7 +336,13 @@
           = new RareModificationCache(virtualServerSiteDataClient, executor);
 
       // Test out configuration.
-      virtualServerSiteDataClient.getContentVirtualServer();
+      VirtualServer vs = virtualServerSiteDataClient.getContentVirtualServer();
+      String version = vs.getMetadata().getVersion();
+      log.log(Level.INFO, "SharePoint Version : {0}", version);
+      // Version is missing for SP 2007 (but its version is 12).
+      // Version for SP2010 is 14. Version for SP2013 is 15.
+      isSp2007 = (version == null);
+      log.log(Level.FINE, "isSP2007 : {0}", isSp2007);
     } catch (Exception e) {
       // Don't leak the executor.
       destroy();
@@ -420,17 +426,9 @@
     Set<String> discoveredContentDatabases;
     if (vs == null) {
       // Retrieving list of databases failed, but we can continue without it.
-      // We don't set isSp2010 here, because we don't know what version of
-      // server we are talking to. However, if isSp2010 is still its default,
-      // then contentDatabaseChangeId is also its default and is empty. When
-      // contentDatabaseChangeId is empty, we won't end up using isSp2010.
       discoveredContentDatabases
         = new HashSet<String>(contentDatabaseChangeId.keySet());
     } else {
-      String version = vs.getMetadata().getVersion();
-      // Version is missing for SP 2007 (but its version is 12). SP 2010 is 14.
-      isSp2010 = version != null && version.startsWith("14.");
-
       discoveredContentDatabases = new HashSet<String>();
       if (vs.getContentDatabases() != null) {
         for (ContentDatabases.ContentDatabase cd
@@ -482,7 +480,7 @@
       }
       CursorPaginator<SPContentDatabase, String> changesPaginator
           = client.getChangesContentDatabase(contentDatabase, changeId,
-              isSp2010);
+              isSp2007);
       Set<DocId> docIds = new HashSet<DocId>();
       try {
         while (true) {
diff --git a/src/com/google/enterprise/adaptor/sharepoint/SiteDataClient.java b/src/com/google/enterprise/adaptor/sharepoint/SiteDataClient.java
index a33c7e8..6ec751c 100644
--- a/src/com/google/enterprise/adaptor/sharepoint/SiteDataClient.java
+++ b/src/com/google/enterprise/adaptor/sharepoint/SiteDataClient.java
@@ -251,7 +251,7 @@
    */
   public CursorPaginator<SPContentDatabase, String>
       getChangesContentDatabase(final String contentDatabaseGuid,
-          String startChangeId, final boolean isSp2010) {
+          String startChangeId, final boolean isSp2007) {
     log.entering("SiteDataClient", "getChangesContentDatabase",
         new Object[] {contentDatabaseGuid, startChangeId});
     final Holder<String> lastChangeId = new Holder<String>(startChangeId);
@@ -267,12 +267,12 @@
         }
         lastLastChangeId.value = lastChangeId.value;
         Holder<String> result = new Holder<String>();
-        // In non-SP2010, the timeout is a number of seconds. In SP2010, the
-        // timeout is n * 60, where n is the number of items you want
-        // returned. However, in SP2010, asking for more than 10 items seems
-        // to lose results. If timeout is less than 60 in SP 2010, then it
-        // causes an infinite loop.
-        int timeout = isSp2010 ? 10 * 60 : 15;
+        // In SP 2007, the timeout is a number of seconds. In SP2010 and above,
+        // the timeout is n * 60, where n is the number of items you want
+        // returned. However, asking for more than 10 items seems
+        // to lose results. If timeout is less than 60 in SP 2010 / 2013,
+        // then it causes an infinite loop.
+        int timeout = isSp2007 ? 15 : 10 * 60;
         siteData.getChanges(ObjectType.CONTENT_DATABASE, contentDatabaseGuid,
             lastChangeId, currentChangeId, timeout, result, moreChanges);
         // XmlProcessingExceptions fine after this point.