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 2014/08/27 10:40:53 UTC

svn commit: r1620813 - in /manifoldcf/branches/dev_1x: ./ CHANGES.txt connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java

Author: kwright
Date: Wed Aug 27 08:40:53 2014
New Revision: 1620813

URL: http://svn.apache.org/r1620813
Log:
Pull up fix for CONNECTORS-1006 from trunk.

Modified:
    manifoldcf/branches/dev_1x/   (props changed)
    manifoldcf/branches/dev_1x/CHANGES.txt
    manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java

Propchange: manifoldcf/branches/dev_1x/
------------------------------------------------------------------------------
  Merged /manifoldcf/trunk:r1620812

Modified: manifoldcf/branches/dev_1x/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/CHANGES.txt?rev=1620813&r1=1620812&r2=1620813&view=diff
==============================================================================
--- manifoldcf/branches/dev_1x/CHANGES.txt (original)
+++ manifoldcf/branches/dev_1x/CHANGES.txt Wed Aug 27 08:40:53 2014
@@ -3,6 +3,10 @@ $Id$
 
 ======================= 1.8-dev =====================
 
+CONNECTORS-1006: Extend GoogleDrive connector to capture
+Google native spreadsheets.
+(Shigeki Kabayashi)
+
 CONNECTORS-1015: Add minimum file size to Allowed Documents
 transformation filter.
 (David Morana, Karl Wright)

Modified: manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java?rev=1620813&r1=1620812&r2=1620813&view=diff
==============================================================================
--- manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java (original)
+++ manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java Wed Aug 27 08:40:53 2014
@@ -33,6 +33,7 @@ import java.util.Map;
 import java.util.Date;
 import java.util.Set;
 import java.util.Iterator;
+
 import org.apache.manifoldcf.crawler.system.Logging;
 import org.apache.manifoldcf.crawler.connectors.BaseRepositoryConnector;
 import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
@@ -49,8 +50,11 @@ import org.apache.manifoldcf.crawler.int
 import org.apache.manifoldcf.crawler.interfaces.IProcessActivity;
 import org.apache.manifoldcf.crawler.interfaces.ISeedingActivity;
 import org.apache.log4j.Logger;
+
 import com.google.api.services.drive.model.File;
+import com.google.api.client.repackaged.com.google.common.base.Objects;
 import com.google.api.client.util.DateTime;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.FileOutputStream;
@@ -1067,11 +1071,16 @@ public class GoogleDriveRepositoryConnec
               Logging.connectors.debug("GOOGLEDRIVE: its a file");
             }
 
-            // We always direct to the PDF
-            String documentURI = getUrl(googleFile, "application/pdf");
+            // We always direct to the PDF except for Spreadsheets
+            String documentURI = null;
+            if (!googleFile.getMimeType().equals("application/vnd.google-apps.spreadsheet")) {
+              documentURI = getUrl(googleFile, "application/pdf");
+            } else {
+              documentURI = getUrl(googleFile, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+            }
 
             // Get the file length
-            Long fileLength = googleFile.getFileSize();
+            Long fileLength = Objects.firstNonNull(googleFile.getFileSize(), 0L);
             if (fileLength != null) {
 
               // Unpack the version string