我想为Google Documents List API创建一个Android客户端应用程序,考虑到它可能在不久的将来被Google Drive API取代。因此,我使用google- API -java-client实现了身份验证,如果需要的话,这可能会简化到新API的过渡。
现在,我正在尝试扩展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
从Google文档列表API文档中,我发现ACL是用来让其他用户访问特定文档的。但是,我不清楚我应该实现哪些方法来实现此事务或其他常见的API相关事务。
发布于 2012-06-02 19:17:49
您是对的,您需要为您的文档条目添加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的一个对象。您还可以在您的文档上指定不同的共享types和roles。
上述方法的可能调用可以是
shareFile(entryObj,AclScope.Type.USER,"your email id",AclRole.OWNER);
shareFile(entryObj,AclScope.Type.DOMAIN,"domain name",AclRole.READER);https://stackoverflow.com/questions/10787379
复制相似问题