All 1 entries tagged Atom

View all 4 entries tagged Atom on Warwick Blogs | View entries tagged Atom at Technorati | There are no images tagged Atom on this blog

September 13, 2006

Implementing the Atom Publishing Protocol

Writing about web page http://www.ietf.org/html.charters/atompub-charter.html

Yesterday I did a deploy of BlogBuilder that includes support for the Atom Publishing Protocol (APP). What this essentially means is that you can use a desktop client, a web service or your own programming to create, edit and delete entries from a Warwick Blog.

We chose the APP because the other blogging APIs out there are all a bit horrible really and the APP is new and shiny and relatively easy to understand and program for.

The implementation was not without its difficulties. For a start reference clients and servers are very thin on the ground at the moment as the spec is not actually 100% complete (although almost there). This meant a fair bit of time just getting my head around how it worked and sniffing traffic to spot what a working client and server actually did when they talked to each other.

In the end, with the help of the Atomic Client, Tim Bray’s Atom Protocol Exerciser and Elias Torres’s public server implementation I was able to get it all working…and here’s how I did it :)

We already used Rome in places for our Atom/RSS feed creation and parsing. It’s slightly tricky to get it to do everything you need to create an Atom Protocol server as you don’t always need to send and receive whole feeds. Sometimes you’ll just want to parse/create a single entry. This leads to code which manually creates or strips the feed around the single entry so that Rome can then parse it properly… blah.

As we’re a Spring shop here, I used a single MultiActionController to do all of the GET/POST/PUT/DELETE functionality that the Atom Protocol needs. You can easily map incoming requests to the right method with something like this MethodNameResolver:

public class HttpMethodTypeMethodResolver implements MethodNameResolver {

    private Map<String, String> methodMappings;

    public final String getHandlerMethodName(final HttpServletRequest request) throws NoSuchRequestHandlingMethodException {

        String method = request.getMethod().toUpperCase();

        if (methodMappings.containsKey(method)) {
            return methodMappings.get(method);
        }

        throw new NoSuchRequestHandlingMethodException(request);

    }

    public final String[] getSupportedMethods() {
        return methodMappings.keySet().toArray(new String[] {});
    }

    public final Map<String, String> getMethodMappings() {
        return methodMappings;
    }

    public final void setMethodMappings(final Map<String, String> methods) {
        this.methodMappings = methods;
    }

}

Then you just set this up to map your DELETE -> deleteEntry() method and PUT -> updateEntry() method and so on…

Another little thing with Rome is that you have to use the Atom specific parts of the API, you can’t just use the generic SyndFeed/SyndEntry classes as they do not convert to/from the exact Atom markup you need. So instead you need to use the Feed and Entry classes in the com.sun.syndication.feed.atom package.

So far I’ve only tested our implementation against Tim Bray’s APE and the Atomic client (which doesn’t send authentication headers when doing POST/PUT/DELETE operations so we could only really try it out with the GET stuff.

We’ll be trying it out against the new Office 2007 Atom client code later on today so it’ll be interesting to see if we need to tweak it a bit more (as I think everyone interprets the as to be completed standard a little differently).


November 2018

Mo Tu We Th Fr Sa Su
Oct |  Today  |
         1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30      

Tags

Search this blog

Most recent comments

  • One thing that was glossed over is that if you use Spring, there is a filter you can put in your XML… by Mathew Mannion on this entry
  • You are my hero. by Mathew Mannion on this entry
  • And may all your chickens come home to roost – in a nice fluffy organic, non–supermarket farmed kind… by Julie Moreton on this entry
  • Good luck I hope that you enjoy the new job! by on this entry
  • Good luck Kieran. :) by on this entry

Galleries

Not signed in
Sign in

Powered by BlogBuilder
© MMXVIII