I want to create an Android client app for Google Documents List API, taking into account that it might be replaced by the Google Drive API in the near future. Therefore, I implemented authentication using google-api-java-client, which would presumably ease a transition to the new API if needed.
Now I'm trying to extend the DocsClient.java class, found in the shared-sample-docs project provided by Google, in order to be able to share documents with user contacts.
I found no better information on this matter than the following introduction written by @yanivinbar: http://javadoc.google-api-java-client.googlecode.com/hg/1.4.1-beta/com/google/api/client/googleapis/xml/atom/package-summary.html
From the Google Documents List API docs, I figured out ACL is used to give other users access to a specific document. However, it's not clear to me which methods I should implement to achive this or other common API related transactions.
You are right, you need to add ACL entry for your document entry. You can have method as below :
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);
}
Here service is an object of com.google.gdata.client.docs.DocsService . Also you can specify different sharing types and roles on your documents.
Possible calls for above method can be
shareFile(entryObj,AclScope.Type.USER,"your email id",AclRole.OWNER);
shareFile(entryObj,AclScope.Type.DOMAIN,"domain name",AclRole.READER);