Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The thing missing here is checking the <code>additionalRole</code> field of the ACL entry. The user is a reader <em>and</em> a commenter. Check out this raw XML response from the Documents List API:</p> <pre><code>&lt;entry gd:etag='W/&amp;quot;D0UFQH4_eCt7ImAe9WhJREEk.&amp;quot;'&gt; &lt;id&gt;https://docs.google.com/feeds/id/user%3Aa%40b.com&lt;/id&gt; &lt;updated&gt;2012-07-11T22:20:11.040Z&lt;/updated&gt; &lt;app:edited xmlns:app='http://www.w3.org/2007/app'&gt;2012-07-11T22:20:11.040Z&lt;/app:edited&gt; &lt;category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/acl/2007#accessRule'/&gt; &lt;title&gt;Document Permission - a@b.com&lt;/title&gt; &lt;link rel='self' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/expandAcl/document%3A1lD_aQPqe33JI4mObm2zc7FADUH-ypXcGekwAovPY2OpMw/acl/user%3Aa%40b.com'/&gt; &lt;link rel='edit' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/expandAcl/document%3A1lD_aQPqe33JI4mObm2zc7FADUH-ypXcGekwAovPY2OpMw/acl/user%3Aa%40b.com'/&gt; &lt;gAcl:role xmlns:gAcl='http://schemas.google.com/acl/2007' value='reader'/&gt; &lt;gAcl:scope xmlns:gAcl='http://schemas.google.com/acl/2007' type='user' value='a@b.com' name='Anderson Jones'/&gt; &lt;gAcl:additionalRole xmlns:gAcl='http://schemas.google.com/acl/2007' value='commenter'/&gt; &lt;/entry&gt; </code></pre> <p>Note the value of <code>gAcl:additionalRole</code> is <code>commenter</code>.</p> <p>Try this code to create a commenter entry:</p> <pre><code>AclEntry aclEntry = new AclEntry(); aclEntry.setScope(new AclScope("user", "user1@domain.com")); aclEntry.setRole(AclRole.READER); aclEntry.addAdditionalRole(AdditionalRole.COMMENTER); </code></pre> <p>And to determine if an entry has the <code>commenter</code> <code>additionalRole</code>, do this:</p> <pre><code>if (aclEntry.getAdditionalRoles().contains(AdditionalRole.COMMENTER)) { // Do something knowing this user is a commenter } </code></pre> <p>However, you really should upgrade to the <a href="https://developers.google.com/drive/v2/reference/" rel="nofollow noreferrer">Drive API v2</a>, which makes this easier. The following code sample is for the Drive API:</p> <pre><code>Permission permission = new Permission(); permission.setType("user"); permission.setValue("user1@domain.com"); permission.setRole("reader"); permission.setAdditionalRoles(Arrays.asList("commenter")); </code></pre> <p>Thanks to <a href="https://stackoverflow.com/users/1106381/alain">Alain Vongsouvanh</a> for providing parts of this answer!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload