Slinging some ideas around RESTful content

Via Seth Gottlieb news that Apache Sling has been officially released. Sling is interesting–I’ve played with it only a bit. You can read more about it on Seth’s post but essentially it is a REST API that sits on top of Apache Jackrabbit. Jackrabbit is the reference implementation of the JCR spec.

I’m not crazy about the JCR API because it is Java-only (yes, I know there are bridges out there). Plus, it doesn’t seem to be rich enough for many types of implementations. For example, Alfresco is a JCR-compliant (Level One) repository, but you don’t see too many people doing JCR-only interactions with Alfresco.

What is interesting to me, though, is the idea that you can abstract repositories at a higher level: the REST API. If we’re all going to talk to our repositories via REST, why not do it in a standard way?

Alfresco introduced a REST framework in 2.1 called “web scripts” (learn more). But Alfresco does not yet have a full-blown “REST API”. Yes, there are a few out-of-the-box REST calls but for the most part, when you interact with Alfresco via REST you are going to roll your own API. On Optaros projects, this has not yet been a huge burden. Quite the opposite, in fact–we’ve been able to develop everything from web script-backed JSR-168 portlets to a streamlined version of the Alfresco web client (soon to be released as an open source project), all on web scripts.

As part of 3.0, Alfresco anticipates rolling out additional out-of-the-box URLs to more fully establish the REST API. The new 3.0 web clients are based almost entirely on REST so they might as well build a REST API that we can all use.

When I look at Apache Sling, I’m thinking, why don’t we agree on a standard REST API for working with content repositories. Then, we could write a front-end once and theoretically use it with multiple back-end repositories. If someone then wants to use a JCR-compliant repository behind the scenes, then that’s cool, but it isn’t a requirement.

Obviously, there is a granularity challenge here. If the API is too granular the front-end ends up making too many calls. If you are aggregating multiple calls from within an intermediate application and then returning the result to the front-end (rather than making a bunch of AJAX calls initiated from the browser client), that’s not as much of an issue. If the API is too coarse, it is too hard to reuse across many different types of front-end applications.

Still, if we agree that REST is the preferred interaction model in the “content as a service” world, at least for the moment, and further, that front-end developers tend to want to have the option of using non-Java technologies for the presentation layer, a standard REST API for interacting with content repositories makes sense, whether that’s Sling, whatever Alfresco comes up with, or the best of both.

Maybe the Atom Publishing Protocol is close to what I’m thinking here. Maybe Alfresco thinks so too. I noticed the Abdera JAR was added to the Alfresco Community dependencies fairly recently. Abdera is an Apache incubator project for working with Atom.

We actually have an engagement with Alfresco right now to develop some of the new 3.0 web client modules. When I get some time I’ll explore this idea a little further by checking in on the 3.0 web client team, looking at Abdera, and doing a deeper dive on sling.

6 comments

  1. Andrei Filimonov says:

    Jeff,

    I think you shouldn’t look farther then Atom Publishing Protocol. Atom with extensions (which are part of the specification) covers pretty much all you need to support restful content services. And base on what other vendors are doing (e.g. IBM Quickr) it looks like emerging content API standard.

  2. Gaurav says:

    Jeff,

    I am new person in the alfresco world. I am working on a project where in I have to use the functionality most of the functionality by WCM but I also I wanted the document management style functionality like attaching meta data to the uploaded documents in a website.

    We were able to decide we could do this using the dashlet functionality that is available and then then calling some functional web scripts web scripts which will be extending the content model for.

    I was wondering if had nay suggestions regarding the same.

    Thanks,
    Gaurav

  3. jpotts says:

    Gaurav,

    You can use web scripts to work with content in the WCM (“AVM”) store. And, you can render dashlets with web scripts (you’d place an r:webScript tag on a JSP page and then tell the dashboard that your dashlet is rendered with that JSP).

    If you extend Alfresco’s content model, you should be able to use the web client to modify that metadata. So, I’m not sure what dashlets and web scripts buy you in this particular case unless you are talking about persisting metadata from a web page accessed by users who are not going through the web client.

    If that’s the case, dashlets don’t make sense because they only work within the web client. Web scripts without dashlets is a good approach for this kind of thing, though.

    Hope that helps,

    Jeff

Comments are closed.