0

我想为Google Documents List API创建一个Android客户端应用程序,同时考虑到它可能会在不久的将来被Google Drive API取代。因此,我使用google-api-java-client实现了身份验证,如果需要,可能会轻松过渡到新的API。如何在Android上使用google-api-java-client共享文档?

现在我试图扩展Google提供的shared-sample-docs项目中的DocsClient.java类,以便能够与用户联系人共享文档。

我发现在这个问题上比@yanivinbar写了下面的介绍没有更好的信息:http://javadoc.google-api-java-client.googlecode.com/hg/1.4.1-beta/com/google/api/client/googleapis/xml/atom/package-summary.html

从谷歌文档列表API文档,我想通了ACL是用来给其他用户访问特定的文档。但是,我不清楚应该实现哪些方法来实现这个或其他常见的API相关事务。

回答

0

您是对的,您需要为您的文档条目添加ACL条目。你可以有方法如下:

public void shareFile(DocumentListEntry documentListEntry, 
     AclScope.Type type, String value, String role) 
     throws MalformedURLException, IOException, ServiceException { 

    // Instantiate a AclEntry object to update sharing permissions. 
    AclEntry acl = new AclEntry(); 

    // Set the ACL scope. 
    acl.setScope(new AclScope(type, value)); 

    // Set the ACL role. 
    acl.setRole(new AclRole(role)); 

    // Insert the new role into the ACL feed. 
    service.insert(new URL(documentListEntry.getAclFeedLink().getHref()), acl);    
} 

这里服务是com.google.gdata.client.docs.DocsService的对象。您也可以在文档上指定不同的共享typesroles

用于上述方法可能调用可以是

shareFile(entryObj,AclScope.Type.USER,"your email id",AclRole.OWNER); 
shareFile(entryObj,AclScope.Type.DOMAIN,"domain name",AclRole.READER); 
相关问题