Friday, March 28, 2008

Google's GData Java API

This has been out for a while, but I recently realized that Google's GData API provides a way to interact with all Google services (Doc, Calendar, YouTube, Blogger, Picasso, etc) through your own server side code. One nice application for Science Gateways is to write a Web Service that submits grid jobs, writes service state changes to Google Calendar, spits out result synopsis to a blog, and posts visualizations to Picasso or YouTube.

Below is some code liberally borrowed from Blogger, YouTube, and Calendar API gdata examples to show how simple this is. Some notes:

Code example below

import java.util.*;

//Google Calendar stuff

public class TestBlogger {
String clientID="XXXXX";
String developer_key="XXXXXXX";

String feedUrl="";
String scarFace5sec="";

GoogleService googleService;
YouTubeService youTubeService;
CalendarService calendarService;

public GoogleService getGoogleService() {
return googleService;
public void setGoogleService(GoogleService googleService) {

public YouTubeService getYouTubeService() {
return youTubeService;

public void setYouTubeService(YouTubeService youTubeService) {

public void setCalendarService(CalendarService calendarService) {

public CalendarService getCalendarService() {
return this.calendarService;

public TestBlogger() throws Exception {
//Replace these with real values.
String userName="";
String password= "qwerty";

//Log into blogger.
GoogleService myService=new GoogleService("blogger","");

//Log into YouTube
YouTubeService service = new YouTubeService(clientID, developer_key);

//Log into Calendar
CalendarService calService=new CalendarService(clientID);

public void writeToCalendar(String titleOfEvent,
String contentToPost) throws Exception {
URL postUrl =
new URL(""+userName+"/private/full");
CalendarEventEntry myEntry = new CalendarEventEntry();

myEntry.setTitle(new PlainTextConstruct(titleOfEvent));
myEntry.setContent(new PlainTextConstruct(contentToPost));

// DateTime startTime = DateTime.parseDateTime("2008-03-18T15:00:00-08:00");
System.out.println((new Date()).toString());
DateTime startTime = new DateTime(new Date());
// DateTime endTime = DateTime.parseDateTime("2008-03-18T17:00:00-08:00");
When eventTimes = new When();
// eventTimes.setEndTime(endTime);

// Send the request and receive the response:
CalendarEventEntry insertedEntry = calendarService.insert(postUrl, myEntry);

CalendarEventEntry myEntry2 = new CalendarEventEntry();
String now=(new Date()).toString();
myEntry2.setContent(new PlainTextConstruct("Test post at "+now));

// Send the request and receive the response:
CalendarEventEntry insertedEntry2 =calendarService.insert(postUrl, myEntry2);

public String getBloggerEntryString() throws Exception {
String returnString="";
URL feedUrl=new URL("");
Feed resultFeed = googleService.getFeed(feedUrl, Feed.class);

// Print the results
for (int i = 0; i < resultFeed.getEntries().size(); i++) { Entry entry = resultFeed.getEntries().get(i); returnString+=entry.getTitle().getPlainText()+"
return returnString;

public String getVideoFeedString() throws Exception {

String returnString;

VideoFeed videoFeed=youTubeService.getFeed(new URL(feedUrl),

VideoEntry videoEntry = youTubeService.getEntry(new URL(scarFace5sec),

returnString="Title: " + videoEntry.getTitle().getPlainText()+"
return returnString;

public Entry createPost(GoogleService myService, String blogID, String title,
String content, String authorName, String userName)
throws ServiceException, IOException {
// Create the entry to insert
Entry myEntry = new Entry();
myEntry.setTitle(new PlainTextConstruct(title));
myEntry.setContent(new PlainTextConstruct(content));
Person author = new Person(authorName, null, userName);

// Ask the service to insert the new entry
URL postUrl = new URL("" + blogID + "/posts/default");
return myService.insert(postUrl, myEntry);

public static void main(String[] args) throws Exception {
String blogId=1292929011;
String someName="test";

TestBlogger blog=new TestBlogger();
// System.out.println(blog.getBloggerEntryString());
// System.out.println(blog.getVideoFeedString());
String content="Some post test with the blogger Java api"+"
"Testing Blogger API",
"Marlon Pierce",
blog.writeToCalendar("Test Calendar Post",content);

Thursday, March 27, 2008

Broken TeraGrid RSS News Feeds

[Nagger's Update: the titles were fixed after I posted this. Hopefully reordering will be soon to follow.]

If you have a TeraGrid account, you probably have noticed the 6.02(10)^23 emails you get every day (Ranger is up! Ranger is down...). You can disable all of these by going to ' Even better, you can subscribe instead to RSS feeds and get these updates in a sensible fashion.

There are only two problems: the title fields in the feeds are broken and most of the feeds are in newest-entry-last order. The iGoogle RSS reader (for one) assumes that the first entry is the newest (not the oldest) entry.

Here is an example (to pick on the home team): I did notice that TACC had at least fixed their ordering, but most of the other centers have the same problem.

I reported these errors to the help desk like a good soldier, got my trouble ticket, and then...nothing. After a couple of weeks through some back channel emails, I found out that my ticket had been received and that they would fix it within the the year. I am not making this up. No one is willing to take five minutes to fix this simple problem. Probably they don't have any time left after all the meetings.

Friday, March 14, 2008

Testing Blogger API

Two Nice Papers by Jim Grey
SSH Empty Passphrases
Password Protected RSS/Atom Feeds
Get Off My Cloud
Counting Unique IPs in Apache Log Files
XFN Test
BBQ Flickr Mashup
Emacs for C#/.NET/Mono
Running GOAP on PolarGrid Testbed
Polar Grid Matlab Note
More with Shindig and Open Social
Quick Start with Open Social, Shindig
A Little More JavaScript and FaceBook Hacking
Quick Facebook JavaScript and PHP API Notes
Portals and Web Applications
Polar Grid URL
Some Project Zero Thoughts
More Mac OS X Emacs
Birdbath and Globus RSL
Installing and Configuring Globus Services on Mac OS X
Condor-G, Birdbath and TransferOutputRemaps
File Retrieval with BirdBath and Condor-G
Condor-G Plus TeraGrid Example
Returning Standard Output in Condor-G
Globus Client+MyProxy+Pacman on FC7 Notes
Title: Scarface in 5 seconds

Wednesday, March 12, 2008

Two Nice Papers by Jim Grey

Thanks to Shrideep for sending these:

G. Bell, J. Gray,  and A. Szalay, "Petascale Computational Systems:Balanced
CyberInfrastructure in a Data-Centric World," IEEE Computer, vol. 39, no 1,
pp. 110-112, Jan. 2006.

J. Gray, "Distributed Computing Economics", Computer Systems Theory,
Technology, and Applications, A Tribute to Roger Needham, A. Herbert and K.
Sparck Jones eds., Springer, 2004,pp 93-101