2012-06-07 37 views
0

我新的Google文件API,並使用谷歌文檔API第3版用java,如何設置谷歌文檔使用其API的權限?

I m trying to share doc with permission and want to change permission on different call, 

Here there is some code which i had designed to share persmission and update and delete permission , but some how i wil got some problem on each operation, 

On first time i can share docs with permission , but once i had share and again try to share with other permission then it cant allow me to upda so what should be i missing at here , 

AclEntry acl = new AclEntry(); 
    AclScope aclScope = new AclScope(AclScope.Type.USER,"[email protected]"); 
    acl.setScope(aclScope); 
    //AclRole aclRole = new AclRole(); 
    acl.setRole(AclRole.READER); 

    URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + folderResId + URL_FOLDERS + "/" + entry.getResourceId()); 
    System.out.println(url.toString()); 

    System.out.println("url : "+entry.getAclFeedLink().getHref()); 

    // For Insert 
    //service.insert(new URL(entry.getAclFeedLink().getHref()), acl); 


    // For Update 
    //service.getRequestFactory().setHeader("If-Match", "*"); 
    //service.update(new URL(entry.getEditLink().getHref()), acl); 


    // For Delete 
    service.getRequestFactory().setHeader("If-Match", "*"); 
    service.delete(new URL(entry.getEditLink().getHref()), aclScope); 


after insert first tim eif itry to insert again i wil get this error.. 
    com.google.gdata.util.VersionConflictException: This user already has access to the document. 


After insert if i try to delete that then i wil get this error 
    com.google.gdata.util.InvalidEntryException: Unexpected resource version ID 

thnaks in advance, 

回答

0

只是一個關於你的第一個錯誤消息註釋:根據我的這個API的經驗,這是一種行爲事實上預計,只要你試圖插入一個相當於已經存在的acl記錄。換句話說,您不能插入現有acl記錄的副本,當您嘗試這樣做時,您總會得到該異常。