Archive for the ‘GData’ category

Groovy and Google Notebook

September 8, 2007

I started learning Groovy in the past few days. So far I am wondering why I waited so long to start learning it. I like the shorthand style and the ability to get tasks that are a pain in Java done quickly. These are obvious things to like certainly since they are objectives of the language.

Anyhow, I needed something to do with the language so I chose to write a simple script to download a list of public notebooks from Google Notebook and then process the first one in the list. Here are some observations on the process.

  • It was not immediately obvious to me how to obtain my Google userid that the documentation mentions. I discovered after a bit of frustration that it is a large numeric value that is passed no the query string and is not the userid that one logs in with. This didn’t jump out at me from the documentation.
  • I used Eclipse to write my script and boy did I miss several things that the plugin lacks: code auto formatting and a debugger. Even though the script I wrote is trivial a debugger would be a nice tool in learning Groovy. Maybe one of the other IDE’s has one for Groovy?
  • Groovy still awkward to me after living the structurd life of a Java programmer for so many years. The corner-cutting takes some getting used to. The missing ;’s can feel like nails on a chalkbaord.

  • import com.google.gdata.client.*;
    import com.google.gdata.data.*;
    def myId = 'big number from google url'
    def urlUser = "http://www.google.com/notebook/feeds/$myId"
    URL feedUrl = new URL(urlUser);


    GoogleService googleService = new GoogleService("notebook", "alex sample");

    /**
    * request the feed
    */
    Feed myFeed = googleService.getFeed(feedUrl, Feed.class);

    print 'notebook name: '
    println myFeed.title.plainText;

    List l = myFeed.entries;

    println "public notebook's: "
    for (Entry e in l) {

    print e.title.plainText;

    URL notebookUrl = new URL(e.id)

    Feed notebookFeed = googleService.getFeed(notebookUrl, Feed.class);
    /* process the feed */

    }