// Generate the corresponding Atom representation of the feed
StringWriter stringWriter = new StringWriter();
com.google.gdata.util.common.xml.XmlWriter w =
new com.google.gdata.util.common.xml.XmlWriter(stringWriter);
feed.generateAtom(w, new ExtensionProfile());
w.flush();
// Write the Atom representation(XML) into Http response content
OutputStreamWriter osw = new OutputStreamWriter(response.getOutputStream());
PrintWriter out = new PrintWriter(response.getOutputStream());
out.println(stringWriter.toString());
out.close();
//System.out.println("Feed content in plain text:" + stringWriter.toString());
} else {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
} else if (path.startsWith("/")) {
// get HTTP request asking for an entry
// Return a specific entry in the collection
com.google.gdata.data.Entry feedEntry = null;
// Invoke the get operation on the service implementation
Message requestMessage = messageFactory.createMessage();
String id = path.substring(1);
requestMessage.setBody(new Object[] {id});
Message responseMessage = getInvoker.invoke(requestMessage);
if (responseMessage.isFault()) {
throw new ServletException((Throwable)responseMessage.getBody());
}
if (supportsFeedEntries) {
// The service implementation returns a feed entry
feedEntry = (com.google.gdata.data.Entry)responseMessage.getBody();
//System.out.println("entry title: " + feedEntry.getTitle().getPlainText());
} else {
// The service implementation only returns a data item, create
// an entry
// from it
Entry<Object, Object> entry = new Entry<Object, Object>(id, responseMessage.getBody());
// FIXME The line below needs to be fixed
// feedEntry = feedEntry(entry, itemClassType, itemXMLType,
// mediator, abderaFactory);
}
// Write the Gdata entry
if (feedEntry != null) {
// Write a GData entry using Atom representation
response.setContentType("application/atom+xml; charset=utf-8");
// Generate the corresponding Atom representation of the feed
StringWriter stringWriter = new StringWriter();
com.google.gdata.util.common.xml.XmlWriter w =
new com.google.gdata.util.common.xml.XmlWriter(stringWriter);
feedEntry.generateAtom(w, new ExtensionProfile());
w.flush();
// Write the Atom representation(XML) into Http response content
OutputStreamWriter osw = new OutputStreamWriter(response.getOutputStream());
PrintWriter out = new PrintWriter(response.getOutputStream());