Hi John,
I just tried this an it seemed to work.  I wonder if it's b/c you're
creating the document, and immediately deleting it.
What if you sleep for a few seconds and then try the delete?

Eric

On Sun, Aug 2, 2009 at 1:21 PM, John Brayton <johnbray...@gmail.com> wrote:

>
> I am having some difficulty deleting documents from my Google Apps
> accounts, and wonder if someone can help me.  The code below
> demonstrates what appears to be the problem.  It does the following:
>
> 1.  Creates and uploads a new document.
> 2.  Deletes that document.
> 3.  Retrieves a list of documents, and displays the text "entry still
> there".
>
> If I set the USERNAME and PASSWORD constants to a gmail.com account,
> this works as expected, and I don't see the "entry still there" text.
> But if I set the USERNAME and PASSWORD constants to a Google Apps
> account, I do see that text and I see the entries within the Google
> Docs UI.
>
> Any help would be appreciated.  Thanks.
>
> John
>
>
> ===
>
> import com.google.gdata.client.docs.DocsService;
> import com.google.gdata.data.PlainTextConstruct;
> import com.google.gdata.data.docs.DocumentEntry;
> import com.google.gdata.data.docs.DocumentListEntry;
> import com.google.gdata.data.docs.DocumentListFeed;
> import java.io.File;
> import java.net.URL;
> import java.util.List;
>
> public class DeleteDemo {
>
>        private static final String USERNAME="...";
>        private static final String PASSWORD="...";
>
>        private static final String DOC_UPLOAD_1 = "docupload1.html";
>
>        public static final void main( String[] args ) {
>                try {
>
>                        // Build a unique document title.
>                        String title = "deleteme " +
> String.valueOf(System.currentTimeMillis
> ());
>
>                        // Upload the document.
>                        DocsService service = getService();
>                        URL url = doInitialUpload(title);
>
>                        // Delete the document.
>                        DocumentEntry doc = service.getEntry(url,
> DocumentEntry.class);
>                        doc.delete();
>
>                        // See if the document is still there.
>                        checkForDocument(title);
>                } catch (Exception e) {
>                        e.printStackTrace();
>                }
>        }
>
>        /**
>         * Display the text "entry still there" if the entry with the
> specified title is present in
>         * the account.
>         */
>        private static final void checkForDocument(String title) throws
> Exception {
>                DocsService service = getService();
>                URL url = new URL("
> https://docs.google.com/feeds/documents/private/
> full");
>                DocumentListFeed feed = service.getFeed(url,
> DocumentListFeed.class);
>                List<DocumentListEntry> entries = feed.getEntries();
>                for( DocumentListEntry entry : entries ) {
>                        if (entry.getTitle().getPlainText().equals(title)) {
>                                System.out.println("entry still there!");
>                        }
>                }
>        }
>
>        /**
>         * Login and return a DocsService object.
>         */
>        private static final DocsService getService() throws Exception {
>                DocsService service = new DocsService("jbtest");
>                service.setUserCredentials(USERNAME, PASSWORD);
>                return service;
>        }
>
>        /**
>         * Create a new GoogleDocs document based on a local HTML file.
> Return the URL of the new
>         * document.
>         */
>        private static final URL doInitialUpload(String title) throws
> Exception {
>                DocsService service = getService();
>                System.out.println("title: " + title);
>                URL url = new URL("
> https://docs.google.com/feeds/documents/private/
> full");
>                DocumentEntry newDocument = new DocumentEntry();
>                File documentFile = new File(DOC_UPLOAD_1);
>                newDocument.setFile(documentFile);
>                newDocument.setTitle(new PlainTextConstruct(title));
>                DocumentEntry doc = service.insert(url, newDocument);
>                return new URL(doc.getId());
>        }
>
> }
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Docs Data APIs" group.
To post to this group, send email to Google-Docs-Data-APIs@googlegroups.com
To unsubscribe from this group, send email to 
google-docs-data-apis+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Docs-Data-APIs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to