Detect error page from SharePoint
While downloading document contents, In case of error, SharePoint returns Error.aspx which contains ROBOTS NOINDEX tag and response code 200. Due to this, document gets excluded on GSA incorrectly. SharePoint also includes "SharePointError"  header as a part of response to indicate error. with this CL, SharePointAdaptor will check if error header is present and throw IOException which will result into error code 500 on GSA but wont be excluded from index.

https://codereview.appspot.com/65800043/
diff --git a/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java b/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
index 8fee0f5..ed3ce34 100644
--- a/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
+++ b/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
@@ -2489,6 +2489,24 @@
       if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
         throw new IOException("Got status code: " + conn.getResponseCode());
       }
+      String errorHeader = conn.getHeaderField("SharePointError");
+      // SharePoint adds header SharePointError to response to indicate error
+      // on SharePoint for requested URL.
+      // errorHeader = 2 if SharePoint rejects current request because 
+      // of current processing load
+      // errorHeader = 0 for other errors on SharePoint server
+      
+      if (errorHeader != null) {            
+        if ("2".equals(errorHeader)) {
+          throw new IOException("Got error 2 from SharePoint for URL [" + url 
+              + "]. Error Code 2 indicates SharePoint has rejected current "
+              + "request because of current processing load on SharePoint.");            
+        } else {
+          throw new IOException("Got error " + errorHeader 
+              + " from SharePoint for URL [" + url + "].");
+        }
+      }
+      
       List<String> headers = new LinkedList<String>();
       // Start at 1 since index 0 is special.
       for (int i = 1;; i++) {