manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1490553 - in /manifoldcf/trunk: ./ connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/ connectors/googledrive/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/googled...
Date Fri, 07 Jun 2013 09:28:17 GMT
Author: kwright
Date: Fri Jun  7 09:28:15 2013
New Revision: 1490553

URL: http://svn.apache.org/r1490553
Log:
Fix for CONNECTORS-702.

Added:
    manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveSecurity.html
  (with props)
Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java
    manifoldcf/trunk/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveSession.java
    manifoldcf/trunk/connectors/googledrive/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/googledrive/common_en_US.properties
    manifoldcf/trunk/connectors/googledrive/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/googledrive/common_ja_JP.properties
    manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editConfiguration_google_server.html
    manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledrive.js
    manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveQuery.html
    manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/viewConfiguration_googledrive.html
    manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/viewSpecification_googledrive.html

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1490553&r1=1490552&r2=1490553&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Fri Jun  7 09:28:15 2013
@@ -3,6 +3,10 @@ $Id$
 
 ======================= 1.3-dev =====================
 
+CONNECTORS-702: Add forced ACLs to GoogleDrive connector.  Also
+fixed a number of UI-related issues.
+(Karl Wright)
+
 CONNECTORS-684: Add Dropbox connector end-user documentation for
 Japanese.
 (Shinichiro Abe)

Modified: manifoldcf/trunk/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java?rev=1490553&r1=1490552&r2=1490553&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java
(original)
+++ manifoldcf/trunk/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java
Fri Jun  7 09:28:15 2013
@@ -26,10 +26,13 @@ import java.io.InputStream;
 import java.io.InterruptedIOException;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 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;
@@ -62,10 +65,24 @@ public class GoogleDriveRepositoryConnec
   protected final static String ACTIVITY_READ = "read document";
   public final static String ACTIVITY_FETCH = "fetch";
   protected static final String RELATIONSHIP_CHILD = "child";
+  
+  /** Deny access token for default authority */
+  private final static String defaultAuthorityDenyToken = "DEAD_AUTHORITY";
+
+  // Nodes
   private static final String JOB_STARTPOINT_NODE_TYPE = "startpoint";
+  private static final String JOB_QUERY_ATTRIBUTE = "query";
+  private static final String JOB_ACCESS_NODE_TYPE = "access";
+  private static final String JOB_TOKEN_ATTRIBUTE = "token";
+
+  // Configuration tabs
   private static final String GOOGLEDRIVE_SERVER_TAB_PROPERTY = "GoogleDriveRepositoryConnector.Server";
+  
+  // Specification tabs
   private static final String GOOGLEDRIVE_QUERY_TAB_PROPERTY = "GoogleDriveRepositoryConnector.GoogleDriveQuery";
-  // Template names
+  private static final String GOOGLEDRIVE_SECURITY_TAB_PROPERTY = "GoogleDriveRepositoryConnector.Security";
+  
+  // Template names for configuration
   /**
    * Forward to the javascript to check the configuration parameters
    */
@@ -74,23 +91,31 @@ public class GoogleDriveRepositoryConnec
    * Server tab template
    */
   private static final String EDIT_CONFIG_FORWARD_SERVER = "editConfiguration_google_server.html";
+  
+  /**
+   * Forward to the HTML template to view the configuration parameters
+   */
+  private static final String VIEW_CONFIG_FORWARD = "viewConfiguration_googledrive.html";
+   
+  // Template names for specification
   /**
-   * Forward to the javascript to check the specification parameters for the
-   * job
+   * Forward to the javascript to check the specification parameters for the job
    */
   private static final String EDIT_SPEC_HEADER_FORWARD = "editSpecification_googledrive.js";
   /**
-   * Forward to the template to edit the configuration parameters for the job
+   * Forward to the template to edit the query for the job
    */
   private static final String EDIT_SPEC_FORWARD_GOOGLEDRIVEQUERY = "editSpecification_googledriveQuery.html";
   /**
-   * Forward to the HTML template to view the configuration parameters
+   * Forward to the template to edit the security parameters for the job
    */
-  private static final String VIEW_CONFIG_FORWARD = "viewConfiguration_googledrive.html";
+  private static final String EDIT_SPEC_FORWARD_SECURITY = "editSpecification_googledriveSecurity.html";
+  
   /**
    * Forward to the template to view the specification parameters for the job
    */
   private static final String VIEW_SPEC_FORWARD = "viewSpecification_googledrive.html";
+  
   /**
    * Endpoint server name
    */
@@ -393,7 +418,7 @@ public class GoogleDriveRepositoryConnec
    * @param newMap is the map to fill in
    * @param parameters is the current set of configuration parameters
    */
-  private static void fillInServerConfigurationMap(Map<String, String> newMap, ConfigParams
parameters) {
+  private static void fillInServerConfigurationMap(Map<String, Object> newMap, ConfigParams
parameters) {
     String clientid = parameters.getParameter(GoogleDriveConfig.CLIENT_ID_PARAM);
     String clientsecret = parameters.getParameter(GoogleDriveConfig.CLIENT_SECRET_PARAM);
     String refreshtoken = parameters.getParameter(GoogleDriveConfig.REFRESH_TOKEN_PARAM);
@@ -401,18 +426,18 @@ public class GoogleDriveRepositoryConnec
     if (clientid == null) {
       clientid = StringUtils.EMPTY;
     }
+    
     if (clientsecret == null) {
       clientsecret = StringUtils.EMPTY;
     }
 
-
     if (refreshtoken == null) {
       refreshtoken = StringUtils.EMPTY;
     }
 
-    newMap.put(GoogleDriveConfig.CLIENT_ID_PARAM, clientid);
-    newMap.put(GoogleDriveConfig.CLIENT_SECRET_PARAM, clientsecret);
-    newMap.put(GoogleDriveConfig.REFRESH_TOKEN_PARAM, refreshtoken);
+    newMap.put("CLIENTID", clientid);
+    newMap.put("CLIENTSECRET", clientsecret);
+    newMap.put("REFRESHTOKEN", refreshtoken);
   }
 
   /**
@@ -430,25 +455,12 @@ public class GoogleDriveRepositoryConnec
   @Override
   public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out,
       Locale locale, ConfigParams parameters) throws ManifoldCFException, IOException {
-    Map<String, String> paramMap = new HashMap<String, String>();
+    Map<String, Object> paramMap = new HashMap<String, Object>();
 
     // Fill in map from each tab
     fillInServerConfigurationMap(paramMap, parameters);
 
-    outputResource(VIEW_CONFIG_FORWARD, out, locale, paramMap);
-  }
-
-  /**
-   * Read the content of a resource, replace the variable ${PARAMNAME} with
-   * the value and copy it to the out.
-   *
-   * @param resName
-   * @param out
-   * @throws ManifoldCFException
-   */
-  private static void outputResource(String resName, IHTTPOutput out,
-      Locale locale, Map<String, String> paramMap) throws ManifoldCFException {
-    Messages.outputResourceWithVelocity(out, locale, resName, paramMap, true);
+    Messages.outputResourceWithVelocity(out,locale,VIEW_CONFIG_FORWARD,paramMap);
   }
 
   /**
@@ -472,13 +484,13 @@ public class GoogleDriveRepositoryConnec
     // Add the Server tab
     tabsArray.add(Messages.getString(locale, GOOGLEDRIVE_SERVER_TAB_PROPERTY));
     // Map the parameters
-    Map<String, String> paramMap = new HashMap<String, String>();
+    Map<String, Object> paramMap = new HashMap<String, Object>();
 
     // Fill in the parameters from each tab
     fillInServerConfigurationMap(paramMap, parameters);
 
     // Output the Javascript - only one Velocity template for all tabs
-    outputResource(EDIT_CONFIG_HEADER_FORWARD, out, locale, paramMap);
+    Messages.outputResourceWithVelocity(out,locale,EDIT_CONFIG_HEADER_FORWARD,paramMap);
   }
 
   @Override
@@ -486,16 +498,16 @@ public class GoogleDriveRepositoryConnec
       IHTTPOutput out, Locale locale, ConfigParams parameters, String tabName)
       throws ManifoldCFException, IOException {
 
-    // Call the Velocity templates for each tab
 
-    // Server tab
-    Map<String, String> paramMap = new HashMap<String, String>();
+    // Call the Velocity templates for each tab
+    Map<String, Object> paramMap = new HashMap<String, Object>();
     // Set the tab name
     paramMap.put("TabName", tabName);
+
+    // Server tab
     // Fill in the parameters
     fillInServerConfigurationMap(paramMap, parameters);
-    outputResource(EDIT_CONFIG_FORWARD_SERVER, out, locale, paramMap);
-
+    Messages.outputResourceWithVelocity(out,locale,EDIT_CONFIG_FORWARD_SERVER,paramMap);
   }
 
   /**
@@ -541,17 +553,32 @@ public class GoogleDriveRepositoryConnec
   /**
    * Fill in specification Velocity parameter map for GOOGLEDRIVEQuery tab.
    */
-  private static void fillInGOOGLEDRIVEQuerySpecificationMap(Map<String, String> newMap,
DocumentSpecification ds) {
-    int i = 0;
+  private static void fillInGOOGLEDRIVEQuerySpecificationMap(Map<String, Object> newMap,
DocumentSpecification ds) {
     String GoogleDriveQuery = GoogleDriveConfig.GOOGLEDRIVE_QUERY_DEFAULT;
-    while (i < ds.getChildCount()) {
+    for (int i = 0; i < ds.getChildCount(); i++) {
       SpecificationNode sn = ds.getChild(i);
       if (sn.getType().equals(JOB_STARTPOINT_NODE_TYPE)) {
-        GoogleDriveQuery = sn.getAttributeValue(GoogleDriveConfig.GOOGLEDRIVE_QUERY_PARAM);
+        GoogleDriveQuery = sn.getAttributeValue(JOB_QUERY_ATTRIBUTE);
       }
-      i++;
     }
-    newMap.put(GoogleDriveConfig.GOOGLEDRIVE_QUERY_PARAM, GoogleDriveQuery);
+    newMap.put("GOOGLEDRIVEQUERY", GoogleDriveQuery);
+  }
+
+  /**
+   * Fill in specification Velocity parameter map for GOOGLEDRIVESecurity tab.
+   */
+  private static void fillInGOOGLEDRIVESecuritySpecificationMap(Map<String, Object>
newMap, DocumentSpecification ds) {
+    List<Map<String,String>> accessTokenList = new ArrayList<Map<String,String>>();
+    for (int i = 0; i < ds.getChildCount(); i++) {
+      SpecificationNode sn = ds.getChild(i);
+      if (sn.getType().equals(JOB_ACCESS_NODE_TYPE)) {
+        String token = sn.getAttributeValue(JOB_TOKEN_ATTRIBUTE);
+        Map<String,String> accessMap = new HashMap<String,String>();
+        accessMap.put("TOKEN",token);
+        accessTokenList.add(accessMap);
+      }
+    }
+    newMap.put("ACCESSTOKENS", accessTokenList);
   }
 
   /**
@@ -568,12 +595,13 @@ public class GoogleDriveRepositoryConnec
   public void viewSpecification(IHTTPOutput out, Locale locale, DocumentSpecification ds)
       throws ManifoldCFException, IOException {
 
-    Map<String, String> paramMap = new HashMap<String, String>();
+    Map<String, Object> paramMap = new HashMap<String, Object>();
 
     // Fill in the map with data from all tabs
     fillInGOOGLEDRIVEQuerySpecificationMap(paramMap, ds);
+    fillInGOOGLEDRIVESecuritySpecificationMap(paramMap, ds);
 
-    outputResource(VIEW_SPEC_FORWARD, out, locale, paramMap);
+    Messages.outputResourceWithVelocity(out,locale,VIEW_SPEC_FORWARD,paramMap);
   }
 
   /**
@@ -593,8 +621,9 @@ public class GoogleDriveRepositoryConnec
   @Override
   public String processSpecificationPost(IPostParameters variableContext,
       DocumentSpecification ds) throws ManifoldCFException {
-    String cmisQuery = variableContext.getParameter(GoogleDriveConfig.GOOGLEDRIVE_QUERY_PARAM);
-    if (cmisQuery != null) {
+
+    String googleDriveQuery = variableContext.getParameter("googledrivequery");
+    if (googleDriveQuery != null) {
       int i = 0;
       while (i < ds.getChildCount()) {
         SpecificationNode oldNode = ds.getChild(i);
@@ -605,10 +634,51 @@ public class GoogleDriveRepositoryConnec
         i++;
       }
       SpecificationNode node = new SpecificationNode(JOB_STARTPOINT_NODE_TYPE);
-      node.setAttribute(GoogleDriveConfig.GOOGLEDRIVE_QUERY_PARAM, cmisQuery);
-      variableContext.setParameter(GoogleDriveConfig.GOOGLEDRIVE_QUERY_PARAM, cmisQuery);
+      node.setAttribute(JOB_QUERY_ATTRIBUTE, googleDriveQuery);
       ds.addChild(ds.getChildCount(), node);
     }
+    
+    String xc = variableContext.getParameter("tokencount");
+    if (xc != null) {
+      // Delete all tokens first
+      int i = 0;
+      while (i < ds.getChildCount()) {
+        SpecificationNode sn = ds.getChild(i);
+        if (sn.getType().equals(JOB_ACCESS_NODE_TYPE))
+          ds.removeChild(i);
+        else
+          i++;
+      }
+
+      int accessCount = Integer.parseInt(xc);
+      i = 0;
+      while (i < accessCount) {
+        String accessDescription = "_"+Integer.toString(i);
+        String accessOpName = "accessop"+accessDescription;
+        xc = variableContext.getParameter(accessOpName);
+        if (xc != null && xc.equals("Delete")) {
+          // Next row
+          i++;
+          continue;
+        }
+        // Get the stuff we need
+        String accessSpec = variableContext.getParameter("spectoken"+accessDescription);
+        SpecificationNode node = new SpecificationNode(JOB_ACCESS_NODE_TYPE);
+        node.setAttribute(JOB_TOKEN_ATTRIBUTE,accessSpec);
+        ds.addChild(ds.getChildCount(),node);
+        i++;
+      }
+
+      String op = variableContext.getParameter("accessop");
+      if (op != null && op.equals("Add"))
+      {
+        String accessspec = variableContext.getParameter("spectoken");
+        SpecificationNode node = new SpecificationNode(JOB_ACCESS_NODE_TYPE);
+        node.setAttribute(JOB_TOKEN_ATTRIBUTE,accessspec);
+        ds.addChild(ds.getChildCount(),node);
+      }
+    }
+
     return null;
   }
 
@@ -630,10 +700,12 @@ public class GoogleDriveRepositoryConnec
       IOException {
 
     // Output GOOGLEDRIVEQuery tab
-    Map<String, String> paramMap = new HashMap<String, String>();
+    Map<String, Object> paramMap = new HashMap<String, Object>();
     paramMap.put("TabName", tabName);
     fillInGOOGLEDRIVEQuerySpecificationMap(paramMap, ds);
-    outputResource(EDIT_SPEC_FORWARD_GOOGLEDRIVEQUERY, out, locale, paramMap);
+    fillInGOOGLEDRIVESecuritySpecificationMap(paramMap, ds);
+    Messages.outputResourceWithVelocity(out,locale,EDIT_SPEC_FORWARD_GOOGLEDRIVEQUERY,paramMap);
+    Messages.outputResourceWithVelocity(out,locale,EDIT_SPEC_FORWARD_SECURITY,paramMap);
   }
 
   /**
@@ -652,14 +724,17 @@ public class GoogleDriveRepositoryConnec
   public void outputSpecificationHeader(IHTTPOutput out,
       Locale locale, DocumentSpecification ds, List<String> tabsArray)
       throws ManifoldCFException, IOException {
+
     tabsArray.add(Messages.getString(locale, GOOGLEDRIVE_QUERY_TAB_PROPERTY));
+    tabsArray.add(Messages.getString(locale, GOOGLEDRIVE_SECURITY_TAB_PROPERTY));
 
-    Map<String, String> paramMap = new HashMap<String, String>();
+    Map<String, Object> paramMap = new HashMap<String, Object>();
 
     // Fill in the specification header map, using data from all tabs.
     fillInGOOGLEDRIVEQuerySpecificationMap(paramMap, ds);
+    fillInGOOGLEDRIVESecuritySpecificationMap(paramMap, ds);
 
-    outputResource(EDIT_SPEC_HEADER_FORWARD, out, locale, paramMap);
+    Messages.outputResourceWithVelocity(out,locale,EDIT_SPEC_HEADER_FORWARD,paramMap);
   }
 
   /**
@@ -710,7 +785,7 @@ public class GoogleDriveRepositoryConnec
     while (i < spec.getChildCount()) {
       SpecificationNode sn = spec.getChild(i);
       if (sn.getType().equals(JOB_STARTPOINT_NODE_TYPE)) {
-        googleDriveQuery = sn.getAttributeValue(GoogleDriveConfig.GOOGLEDRIVE_QUERY_PARAM);
+        googleDriveQuery = sn.getAttributeValue(JOB_QUERY_ATTRIBUTE);
         break;
       }
       i++;
@@ -895,8 +970,9 @@ public class GoogleDriveRepositoryConnec
       boolean[] scanOnly) throws ManifoldCFException, ServiceInterruption {
 
     Logging.connectors.debug("GOOGLEDRIVE: Inside processDocuments");
-        
+
     for (int i = 0; i < documentIdentifiers.length; i++) {
+      // MHL for access tokens
       long startTime = System.currentTimeMillis();
       String errorCode = "FAILED";
       String errorDesc = StringUtils.EMPTY;
@@ -912,8 +988,7 @@ public class GoogleDriveRepositoryConnec
         }
 
         File googleFile = getObject(nodeId);
-
-        if (googleFile.containsKey("explicitlyTrashed") && googleFile.getExplicitlyTrashed())
{
+        if (googleFile == null || (googleFile.containsKey("explicitlyTrashed") &&
googleFile.getExplicitlyTrashed())) {
           //its deleted, move on
           continue;
         }
@@ -990,9 +1065,29 @@ public class GoogleDriveRepositoryConnec
             // Get the file length
             long fileLength = googleFile.getFileSize();
 
+            // Unpack the version string
+            ArrayList acls = new ArrayList();
+            StringBuilder denyAclBuffer = new StringBuilder();
+            int index = unpackList(acls,version,0,'+');
+            if (index < version.length() && version.charAt(index++) == '+') {
+              index = unpack(denyAclBuffer,version,index,'+');
+            }
+
             //otherwise process
             RepositoryDocument rd = new RepositoryDocument();
 
+            // Turn into acls and add into description
+            String[] aclArray = new String[acls.size()];
+            for (int j = 0; j < aclArray.length; j++) {
+              aclArray[j] = (String)acls.get(j);
+            }
+            rd.setACL(aclArray);
+            if (denyAclBuffer.length() > 0) {
+              String[] denyAclArray = new String[]{denyAclBuffer.toString()};
+              rd.setDenyACL(denyAclArray);
+            }
+
+            // Now do standard stuff
             String mimeType = googleFile.getMimeType();
             DateTime createdDate = googleFile.getCreatedDate();
             DateTime modifiedDate = googleFile.getModifiedDate();
@@ -1012,6 +1107,7 @@ public class GoogleDriveRepositoryConnec
               rd.setFileName(title + "." + extension);
             }
 
+            // Get general document metadata
             for (Entry<String, Object> entry : googleFile.entrySet()) {
               rd.addField(entry.getKey(), entry.getValue().toString());
             }
@@ -1199,17 +1295,35 @@ public class GoogleDriveRepositoryConnec
   public String[] getDocumentVersions(String[] documentIdentifiers,
       DocumentSpecification spec) throws ManifoldCFException,
       ServiceInterruption {
-    getSession();
+
+    // Forced acls
+    String[] acls = getAcls(spec);
+    // Sort it,
+    java.util.Arrays.sort(acls);
+
     String[] rval = new String[documentIdentifiers.length];
     for (int i = 0; i < rval.length; i++) {
       File googleFile = getObject(documentIdentifiers[i]);
       if (!isDir(googleFile)) {
         String rev = googleFile.getModifiedDate().toStringRfc3339();
         if (StringUtils.isNotEmpty(rev)) {
-          rval[i] = rev;
+          StringBuilder sb = new StringBuilder();
+
+          // Acls
+          packList(sb,acls,'+');
+          if (acls.length > 0) {
+            sb.append('+');
+            pack(sb,defaultAuthorityDenyToken,'+');
+          }
+          else
+            sb.append('-');
+
+          sb.append(rev);
+          rval[i] = sb.toString();
         } else {
-          //a google document that doesn't contain versioning information will always be
processed
-          rval[i] = StringUtils.EMPTY;
+          //a google document that doesn't contain versioning information will NEVER be processed.
+          // I don't know what this means, and whether it can ever occur.
+          rval[i] = null;
         }
       } else {
         //a google folder will always be processed
@@ -1219,6 +1333,29 @@ public class GoogleDriveRepositoryConnec
     return rval;
   }
 
+  /** Grab forced acl out of document specification.
+  *@param spec is the document specification.
+  *@return the acls.
+  */
+  protected static String[] getAcls(DocumentSpecification spec) {
+    Set<String> map = new HashSet<String>();
+    for (int i = 0; i < spec.getChildCount(); i++) {
+      SpecificationNode sn = spec.getChild(i);
+      if (sn.getType().equals(JOB_ACCESS_NODE_TYPE)) {
+        String token = sn.getAttributeValue(JOB_TOKEN_ATTRIBUTE);
+        map.add(token);
+      }
+    }
+
+    String[] rval = new String[map.size()];
+    Iterator<String> iter = map.iterator();
+    int i = 0;
+    while (iter.hasNext()) {
+      rval[i++] = (String)iter.next();
+    }
+    return rval;
+  }
+
   private boolean isDir(File f) {
     return f.getMimeType().compareToIgnoreCase("application/vnd.google-apps.folder") == 0;
   }

Modified: manifoldcf/trunk/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveSession.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveSession.java?rev=1490553&r1=1490552&r2=1490553&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveSession.java
(original)
+++ manifoldcf/trunk/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveSession.java
Fri Jun  7 09:28:15 2013
@@ -84,6 +84,8 @@ public class GoogleDriveSession {
     Map<String, String> info = new HashMap<String, String>();
     info.put("Application Name", drive.getApplicationName());
     info.put("Base URL", drive.getBaseUrl());
+    // We need something that will actually cause a back-and-forth to the server!
+    drive.files().get("").execute();
     return info;
   }
 

Modified: manifoldcf/trunk/connectors/googledrive/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/googledrive/common_en_US.properties
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/googledrive/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/googledrive/common_en_US.properties?rev=1490553&r1=1490552&r2=1490553&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/googledrive/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/googledrive/common_en_US.properties
(original)
+++ manifoldcf/trunk/connectors/googledrive/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/googledrive/common_en_US.properties
Fri Jun  7 09:28:15 2013
@@ -14,22 +14,25 @@
 # limitations under the License.
 
 GoogleDriveRepositoryConnector.Server=Server
-GoogleDriveRepositoryConnector.GoogleDriveQuery=Google Drive Seed Query
+GoogleDriveRepositoryConnector.GoogleDriveQuery=Seed Query
 GoogleDriveRepositoryConnector.Security=Security
 
-GoogleDriveRepositoryConnector.RefreshToken=RefreshToken:
-GoogleDriveRepositoryConnector.ClientID=Client ID:
-GoogleDriveRepositoryConnector.ClientSecret=Client Secret ID:
+GoogleDriveRepositoryConnector.RefreshTokenColon=RefreshToken:
+GoogleDriveRepositoryConnector.ClientIDColon=Client ID:
+GoogleDriveRepositoryConnector.ClientSecretColon=Client Secret ID:
 
 
 GoogleDriveRepositoryConnector.RefreshTokenMustNotBeNull=Refresh Token must not be null
 GoogleDriveRepositoryConnector.ClientSecretMustNotBeNull=Client Secret must not be null
 GoogleDriveRepositoryConnector.ClientMustNotBeNull=Client must not be null
 
+GoogleDriveRepositoryConnector.SeedQueryCannotBeNull=Seed query cannot be null
+GoogleDriveRepositoryConnector.GoogleDriveQueryColon=Google Drive seed query:
 
-GoogleDriveRepositoryConnector.GoogleDriveQueryColon=Google Drive Seed Query:
-
-GoogleDriveRepositoryConnector.ParametersColon=Parameters:
-GoogleDriveRepositoryConnector.UsernameEquals=username=
-GoogleDriveRepositoryConnector.PasswordEquals=password=
-
+GoogleDriveRepositoryConnector.NoAccessTokensPresent=No access tokens present
+GoogleDriveRepositoryConnector.Add=Add
+GoogleDriveRepositoryConnector.AddAccessToken=Add access token
+GoogleDriveRepositoryConnector.Delete=Delete
+GoogleDriveRepositoryConnector.DeleteToken=Delete token #
+GoogleDriveRepositoryConnector.AccessTokensColon=Access tokens:
+GoogleDriveRepositoryConnector.TypeInAnAccessToken=Type in an access token

Modified: manifoldcf/trunk/connectors/googledrive/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/googledrive/common_ja_JP.properties
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/googledrive/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/googledrive/common_ja_JP.properties?rev=1490553&r1=1490552&r2=1490553&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/googledrive/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/googledrive/common_ja_JP.properties
(original)
+++ manifoldcf/trunk/connectors/googledrive/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/googledrive/common_ja_JP.properties
Fri Jun  7 09:28:15 2013
@@ -14,22 +14,25 @@
 # limitations under the License.
 
 GoogleDriveRepositoryConnector.Server=Server
+GoogleDriveRepositoryConnector.GoogleDriveQuery=Seed Query
+GoogleDriveRepositoryConnector.Security=Security
 
-
-GoogleDriveRepositoryConnector.RefreshToken=RefreshToken:
-GoogleDriveRepositoryConnector.ClientID=Client ID:
-GoogleDriveRepositoryConnector.ClientSecret=Client Secret ID:
+GoogleDriveRepositoryConnector.RefreshTokenColon=RefreshToken:
+GoogleDriveRepositoryConnector.ClientIDColon=Client ID:
+GoogleDriveRepositoryConnector.ClientSecretColon=Client Secret ID:
 
 
 GoogleDriveRepositoryConnector.RefreshTokenMustNotBeNull=Refresh Token must not be null
 GoogleDriveRepositoryConnector.ClientSecretMustNotBeNull=Client Secret must not be null
 GoogleDriveRepositoryConnector.ClientMustNotBeNull=Client must not be null
 
+GoogleDriveRepositoryConnector.SeedQueryCannotBeNull=Seed query cannot be null
+GoogleDriveRepositoryConnector.GoogleDriveQueryColon=Google Drive seed query:
 
-GoogleDriveRepositoryConnector.GoogleDriveQuery=Google Drive Seed Query
-GoogleDriveRepositoryConnector.GoogleDriveQueryColon=Google Drive Seed Query:
-
-GoogleDriveRepositoryConnector.ParametersColon=Parameters:
-GoogleDriveRepositoryConnector.UsernameEquals=username=
-GoogleDriveRepositoryConnector.PasswordEquals=password=
-
+GoogleDriveRepositoryConnector.NoAccessTokensPresent=No access tokens present
+GoogleDriveRepositoryConnector.Add=Add
+GoogleDriveRepositoryConnector.AddAccessToken=Add access token
+GoogleDriveRepositoryConnector.Delete=Delete
+GoogleDriveRepositoryConnector.DeleteToken=Delete token #
+GoogleDriveRepositoryConnector.AccessTokensColon=Access tokens:
+GoogleDriveRepositoryConnector.TypeInAnAccessToken=Type in an access token

Modified: manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editConfiguration_google_server.html
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editConfiguration_google_server.html?rev=1490553&r1=1490552&r2=1490553&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editConfiguration_google_server.html
(original)
+++ manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editConfiguration_google_server.html
Fri Jun  7 09:28:15 2013
@@ -15,7 +15,7 @@
  limitations under the License.
 -->
 
-#if($TABNAME == $ResourceBundle.getString('GoogleDriveRepositoryConnector.Server'))
+#if($TabName == $ResourceBundle.getString('GoogleDriveRepositoryConnector.Server'))
 
 <table class="displaytable">
   <tr>

Modified: manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledrive.js
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledrive.js?rev=1490553&r1=1490552&r2=1490553&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledrive.js
(original)
+++ manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledrive.js
Fri Jun  7 09:28:15 2013
@@ -17,9 +17,14 @@
 
 <script type="text/javascript">
 <!--
-function checkSpecification()
+function checkSpecificationForSave()
 {
-  // Does nothing right now.
+  if (editjob.googledrivequery.value == "") {
+    alert("$Encoder.bodyJavascriptEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.SeedQueryCannotBeNull'))");
+    SelectTab("$Encoder.bodyJavascriptEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.GoogleDriveQuery'))");
+    editjob.googledrivequery.focus();
+    return false;
+  }
   return true;
 }
  
@@ -28,5 +33,22 @@ function SpecOp(n, opValue, anchorvalue)
   eval("editjob."+n+".value = \""+opValue+"\"");
   postFormSetAnchor(anchorvalue);
 }
+
+function SpecDeleteToken(i)
+{
+  SpecOp("accessop_"+i,"Delete","token_"+i);
+}
+
+function SpecAddToken(i)
+{
+  if (editjob.spectoken.value == "")
+  {
+    alert("$Encoder.bodyJavascriptEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.TypeInAnAccessToken'))");
+    editjob.spectoken.focus();
+    return;
+  }
+  SpecOp("accessop","Add","token_"+i);
+}
+
 //-->
 </script>
\ No newline at end of file

Modified: manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveQuery.html
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveQuery.html?rev=1490553&r1=1490552&r2=1490553&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveQuery.html
(original)
+++ manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveQuery.html
Fri Jun  7 09:28:15 2013
@@ -15,7 +15,7 @@
  limitations under the License.
 -->
 
-#if($TABNAME == $ResourceBundle.getString('GoogleDriveRepositoryConnector.GoogleDriveQuery'))
+#if($TabName == $ResourceBundle.getString('GoogleDriveRepositoryConnector.GoogleDriveQuery'))
 
 <table class="displaytable">
   <tr><td class="separator" colspan="2"><hr/></td></tr>
@@ -27,7 +27,7 @@
     </td>
     <td class="value">
       <nobr>
-        <input type="text" size="120" name="googledriveQuery" value="$Encoder.attributeEscape($GOOGLEDRIVEQUERY)"
/>
+        <input type="text" size="120" name="googledrivequery" value="$Encoder.attributeEscape($GOOGLEDRIVEQUERY)"
/>
       </nobr>
     </td>
   </tr>
@@ -35,6 +35,6 @@
 
 #else
 
-<input type="hidden" name="googledriveQuery" value="$Encoder.attributeEscape($GOOGLEDRIVEQUERY)"
/>
+<input type="hidden" name="googledrivequery" value="$Encoder.attributeEscape($GOOGLEDRIVEQUERY)"
/>
 
 #end

Added: manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveSecurity.html
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveSecurity.html?rev=1490553&view=auto
==============================================================================
--- manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveSecurity.html
(added)
+++ manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveSecurity.html
Fri Jun  7 09:28:15 2013
@@ -0,0 +1,73 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+#if($TabName == $ResourceBundle.getString('GoogleDriveRepositoryConnector.Security'))
+
+<table class="displaytable">
+  <tr><td class="separator" colspan="2"><hr/></td></tr>
+  
+  #set($atcounter = 0)
+  #foreach($atoken in $ACCESSTOKENS)
+
+  <tr>
+    <td class="description">
+      <input type="hidden" name="accessop_$atcounter" value=""/>
+      <input type="hidden" name="spectoken_$atcounter" value="$Encoder.attributeEscape($atoken.get('TOKEN'))"/>
+      <a name="token_$atcounter">
+        <input type="button" value="$Encoder.attributeEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.Delete'))"
onClick='Javascript:SpecDeleteToken($atcounter)' alt="$Encoder.attributeEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.DeleteToken'))$atcounter"/>
+      </a>
+    </td>
+    <td class="value">$Encoder.bodyEscape($atoken.get('TOKEN'))</td>
+  </tr>
+
+    #set($atcounter = $atcounter + 1)
+  #end
+
+  #set($nexttoken = $atcounter + 1)
+
+  #if($atcounter == 0)
+  <tr>
+    <td class="message" colspan="2">$Encoder.bodyEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.NoAccessTokensPresent'))</td>
+  </tr>
+  #end
+
+  <tr><td class="lightseparator" colspan="2"><hr/></td></tr>
+  
+  <tr>
+    <td class="description">
+      <input type="hidden" name="tokencount" value="$atcounter"/>
+      <input type="hidden" name="accessop" value=""/>
+      <a name="token_$atcounter">
+        <input type="button" value="$Encoder.attributeEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.Add'))"
onClick='Javascript:SpecAddToken($nexttoken)' alt="$Encoder.attributeEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.AddAccessToken'))"/>
+      </a>
+    </td>
+    <td class="value">
+      <input type="text" size="30" name="spectoken" value=""/>
+    </td>
+  </tr>
+</table>
+
+#else
+
+  #set($atcounter = 0)
+  #foreach($atoken in $ACCESSTOKENS)
+<input type="hidden" name="spectoken_$atcounter" value="$Encoder.attributeEscape($atoken.get('TOKEN'))"/>
+    #set($atcounter = $atcounter + 1)
+  #end
+<input type="hidden" name="tokencount" value="$atcounter"/>
+
+#end

Propchange: manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveSecurity.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveSecurity.html
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/viewConfiguration_googledrive.html
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/viewConfiguration_googledrive.html?rev=1490553&r1=1490552&r2=1490553&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/viewConfiguration_googledrive.html
(original)
+++ manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/viewConfiguration_googledrive.html
Fri Jun  7 09:28:15 2013
@@ -17,23 +17,27 @@
 
 <table class="displaytable">
   <tr>
-    <td class="description" colspan="1">
-      <nobr>
-        $Encoder.bodyEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.ParametersColon'))
-      </nobr>
-    </td>
-    <td class="value" colspan="3">
-      <nobr>
-        $Encoder.bodyEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.CliendID'))$Encoder.bodyEscape($CLIENTID)
-      </nobr>
-      <br />
-      <nobr>
-        $Encoder.bodyEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.ClientSecret'))$Encoder.bodyEscape($CLIENTSECRET)
-      </nobr>
-      <br />
-       <nobr>
-        $Encoder.bodyEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.RefreshToken'))$Encoder.bodyEscape($REFRESHTOKEN)
-      </nobr>
+    <td class="description">
+      <nobr>$Encoder.bodyEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.ClientIDColon'))</nobr>
+    </td>
+    <td class="value">
+      <nobr>$Encoder.bodyEscape($CLIENTID)</nobr>
+    </td>
+  </tr>
+  <tr>
+    <td class="description">
+      <nobr>$Encoder.bodyEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.ClientSecretColon'))</nobr>
+    </td>
+    <td class="value">
+      <nobr>$Encoder.bodyEscape($CLIENTSECRET)</nobr>
+    </td>
+  </tr>
+  <tr>
+    <td class="description">
+      <nobr>$Encoder.bodyEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.RefreshTokenColon'))</nobr>
+    </td>
+    <td class="value">
+      <nobr>$Encoder.bodyEscape($REFRESHTOKEN)</nobr>
     </td>
   </tr>
 </table>

Modified: manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/viewSpecification_googledrive.html
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/viewSpecification_googledrive.html?rev=1490553&r1=1490552&r2=1490553&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/viewSpecification_googledrive.html
(original)
+++ manifoldcf/trunk/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/viewSpecification_googledrive.html
Fri Jun  7 09:28:15 2013
@@ -18,10 +18,30 @@
 <table class="displaytable">
   <tr>
     <td class="description">
-      $Encoder.bodyEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.GoogleDriveQueryColon'))
+      <nobr>$Encoder.bodyEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.GoogleDriveQueryColon'))</nobr>
     </td>
     <td class="value">
-      $Encoder.bodyEscape($GOOGLEDRIVEQUERY)
+      <nobr>$Encoder.bodyEscape($GOOGLEDRIVEQUERY)</nobr>
     </td>
   </tr>
+  <tr><td class="separator" colspan="2"><hr/></td></tr>
+  <tr>
+#if($ACCESSTOKENS.size() == 0)
+    <td class="message" colspan="2">
+      $Encoder.bodyEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.NoAccessTokensPresent'))
+    </td>
+#else
+    <td class="description">
+      <nobr>$Encoder.bodyEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.AccessTokensColon'))</nobr>
+    </td>
+    <td class="value">
+  #set($atcounter = 0)
+  #foreach($atoken in $ACCESSTOKENS)
+    <nobr>$Encoder.bodyEscape($atoken.get('TOKEN'))</nobr><br/>
+    #set($atcounter = $atcounter + 1)
+  #end
+    </td>
+#end
+  </tr>
+
 </table>



Mime
View raw message