ACL DELETE for docs - what is the correct feed url in java

61 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Paul Ford

ungelesen,
23.03.2012, 10:58:2823.03.12
an google-docum...@googlegroups.com
Can someone please help? If this proves to difficult to read please provide a link to a JAVA example for deleting a ACL feed url with an example feed. Thank you!

-------current code - i.e. I hardcoded the feedurl so you can see it i obtained this through interactive debugging.

  public Boolean removeDocsShare(){
  if (this.getLogEnabled().equals("true")) { this.get_commonUtils().get_httpLogger().log(this.get_commonUtils().get_httpLogger().getLevel(), "[CALL - " + logCount++ + "]-->removeDocsShare in method"); }
  
     Boolean complete = false;
  Properties prop = this.get_commonUtils().getProps();
  
  DocsService sourceService = this.authenticateCredentials("SOURCE");
  
  DocumentListFeed allNodes = getAllNodes(sourceService, "SOURCE"); 
  
  int entryCount = 1;
  int totalEntries = allNodes.getEntries().size();
  
  for (DocumentListEntry entry : allNodes.getEntries()) {
  
  String logValues = "Removing Shared Source DocumentListEntry # -" + entryCount + " of " + totalEntries + "]";
  if (this.getLogEnabled().equals("true") && this.getLogValues().equals("true")) { this.get_commonUtils().get_httpLogger().log(this.get_commonUtils().get_httpLogger().getLevel(), logValues); }
  
  try {
  String aclfeed = entry.getAclFeedLink().getHref();
  
  AclFeed feed = sourceService.getFeed(new URL(aclfeed), AclFeed.class);

  
  for (AclEntry aentry : feed.getEntries()){
  logValues = " Doc Name - [" + entry.getTitle().getPlainText() + "] ACL Name - [" + aentry.getTitle().getPlainText()  + "] Scope id - [" + aentry.getId() + "] Scope Value - [" + aentry.getScope().getValue() + "] Scope Type (" + aentry.getScope().getType() + ") : Role Value - [" + aentry.getRole().getValue() + "]";
  if (this.getLogEnabled().equals("true") && this.getLogValues().equals("true")) { this.get_commonUtils().get_httpLogger().log(this.get_commonUtils().get_httpLogger().getLevel(), logValues); }
  if (aentry.getScope().getValue().contains(prop.getProperty("SOURCEDOMAIN"))){

  //AclScope scope = new AclScope(AclScope.Type.USER, prop.getProperty("DESTEMAIL")); //this line needs to change to object.currentUser - TODO pwf 03192012
  String username = this.get_currentUser() + "@" + prop.getProperty("DESTDOMAIN"); //changed :)
  AclScope scope = new AclScope(AclScope.Type.USER, username);
  
  
  
  sourceService.delete(new URL(aclfeed), scope);
  }
  }
  complete = true;
  } catch (Exception e) {
  e.printStackTrace();
  }
  entryCount++;  
  }
  if (this.getLogEnabled().equals("true")) { this.get_commonUtils().get_httpLogger().log(this.get_commonUtils().get_httpLogger().getLevel(), "[CALL - " + logCount++ + "]-->removeDocsShare out method"); }
  return complete;
  }

----exception

INFO:  Doc Name - [carl test 2] ACL Name - [Document Permission - carl.franklin@paulwilliamford.net] Scope id - [https://docs.google.com/feeds/id/folder%3A0BxGfvfeVWfueY2x0S09LMVBRWWFVVnBWTUg0cHBmZw/acl/user%3Acarl.franklin%40paulwilliamford.net] Scope Value - [carl.franklin@paulwilliamford.net] Scope Type (USER) : Role Value - [owner]
com.google.gdata.util.AuthenticationException: Unknown authorization header
<HTML>
<HEAD>
<TITLE>Unknown authorization header</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unknown authorization header</H1>
<H2>Error 401</H2>
</BODY>
</HTML>

at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:600)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)
at com.google.gdata.client.Service.delete(Service.java:1738)
at com.google.gdata.client.GoogleService.delete(GoogleService.java:691)
at com.google.gdata.client.Service.delete(Service.java:1700)
at com.google.gdata.client.GoogleService.delete(GoogleService.java:676)
at com.google.gdata.client.docs.DocsService.delete(DocsService.java:269)
at com.mwp.google.tools.documents.Documents.removeDocsShare(Documents.java:1152)
at com.mwp.google.tools.documents.Documents.delegateMigrate(Documents.java:420)
at com.mwp.google.tools.delegate.DelegateCommands.executeCommandArgs(DelegateCommands.java:193)
at com.mwp.google.tools.delegate.DelegateCommands.executeCommand(DelegateCommands.java:168)
at com.mwp.google.tools.delegate.DelegateCommands.run(DelegateCommands.java:229)
at com.mwp.google.tools.delegate.DelegateCommands.main(DelegateCommands.java:284)

Alain Vongsouvanh

ungelesen,
23.03.2012, 14:16:2223.03.12
an google-docum...@googlegroups.com
Hello Paul,

Are you trying to remove permission for a specific user? If this is the case, you need to send a DELETE request to the ACL resource URL and not the ACL feed URL as described here:

From your Java code, you should be able to do something like:
  aentry.delete();

Best,
Alain
--
Alain Vongsouvanh | Developer Programs Engineer

Paul Ford

ungelesen,
23.03.2012, 15:28:1823.03.12
an google-docum...@googlegroups.com
Alain,

Thanks for the hint it did work. However, what is interesting is the following:

1.) When using 3LO I used to just pass the aclfeed of the source domain (since I'm doing domain-to-domain migration) and it removed the acl no problem. THe ACL is on a shared doc to a destination domain.
2.) Since I moved to 2LO the methdo call is different i.e. aentry.delete( and now I remove the shares from the source/sharing domain and only when the shared items contain the destination domain in it's scope.

Now this after all makes complete sense and thank you for that. But I got to say the new google docs are not at all helpful. The reference you pointed me to (which is the new site and no python or java examples) is merely ATOM/protocol reference and not examples per se. In building enterprise level apps for customer's a reliance on example rich docs are preferred.

Thanks for taking the time to answer this and help me out. 

Best 

paul

BTW here is the complete code for other users to reference:

 public Boolean removeDocsShare(){
 if (this.getLogEnabled().equals("true")) { this.get_commonUtils().get_httpLogger().log(this.get_commonUtils().get_httpLogger().getLevel(), "[CALL - " + logCount++ + "]-->removeDocsShare in method"); }
 
   Boolean complete = false;
 Properties prop = this.get_commonUtils().getProps();
 
 DocsService sourceService = this.authenticateCredentials("SOURCE");
 
 DocumentListFeed allNodes = getAllNodes(sourceService, "SOURCE"); 
 
 int entryCount = 1;
 int totalEntries = allNodes.getEntries().size();
 
 for (DocumentListEntry entry : allNodes.getEntries()) {
 
 String logValues = "Removing Shared Source DocumentListEntry # -" + entryCount + " of " + totalEntries + "]";
 if (this.getLogEnabled().equals("true") && this.getLogValues().equals("true")) { this.get_commonUtils().get_httpLogger().log(this.get_commonUtils().get_httpLogger().getLevel(), logValues); }
 
 try {
 String aclfeed = entry.getAclFeedLink().getHref();
 
 AclFeed feed = sourceService.getFeed(new URL(aclfeed), AclFeed.class);

 
 for (AclEntry aentry : feed.getEntries()){
 logValues = " Doc Name - [" + entry.getTitle().getPlainText() + "] ACL Name - [" + aentry.getTitle().getPlainText()  + "] Scope id - [" + aentry.getId() + "] Scope Value - [" + aentry.getScope().getValue() + "] Scope Type (" + aentry.getScope().getType() + ") : Role Value - [" + aentry.getRole().getValue() + "]";
 if (this.getLogEnabled().equals("true") && this.getLogValues().equals("true")) { this.get_commonUtils().get_httpLogger().log(this.get_commonUtils().get_httpLogger().getLevel(), logValues); }
 if (aentry.getScope().getValue().contains(prop.getProperty("DESTDOMAIN"))){

 aentry.delete();
--
Paul 

Paul W. Ford │ Principal
Maven Wave Partners LLC

Please check out our Fusion Blog for more insights

Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten