JavaFX CMIS Browser

Thursday, February 12th, 2009

A while back my colleague, Shane Johnson, blogged about a CMIS browser he had written using Flex/AIR.

If you’ve come to this post for the “JavaFX”, or if you’re me from a week ago, here’s a bit of context: CMIS (Content Management Interoperability Services) is a specification that defines a set of Web Services which can be used to interface with a content repository.

So I went ahead and wrote a complementary visual browser in JavaFX. Flex’s strength is surely in its rich widget toolkit, and since JavaFX is currently lacking in this area, I decided to concentrate on a more visual approach. Incidentally, I developed this browser on a local instance of Alfresco Labs.

Here’s a screen shot of the browser after it first connects:

The “node” in the center of the screen is the root, or “Main Repository”, with the children nodes fanning out in front. Clicking on any of the children nodes will promote the child to the center and retrieve its children. Here’s a screen shot of what it looks like when the child “Data Dictionary” is clicked on:

Note that the previous parent “Main Repository” is promoted to the top and pushed to the background. Clicking on the parent will allow the user to browse up the hierarchy.

The Visual Look

I was going for a 3D-ish look for the nodes. Each node has a three color Radial Gradient, which helps fake a specular highlight (as if the light source were off to the left). The connectors are a two color Linear Gradient that fade to black as they approach the center node so as to add to the illusion of depth.

The CMIS Part

Alfresco does seem to have some Java bindings for a CMIS API, but they seemed a bit incomplete, so I settled on using the ATOM bindings as the path of least resistance. Unfortunately though, not completely resistance-free as JavaFX’s PullParser does not yet support ATOM feeds (although it supports raw XML). So I ended up using Apache Abdera wrapped in JavaFX’s HttpRequest object for transport.

The Sob Story

The browser is functional as I’ve described it, but I had bigger plans. For example, since this is a visual browser for content, I wanted to graphically show previews of the images and documents, as evidenced by the following screen shot:

So in this case when the user navigated down to say, their favorite band pictures, they would actually see the pictures (this would also apply to favorite PDFs or text documents). (Incidentally, the astute reader may look at these two pictures, and look at my Gravatar and wonder: does this guy wear the same thing at every show?)

But it turns out that this is actually a very difficult feature to implement. JavaFX’s Image object will only take a URL as a String, not an InputStream. Since Document Repositories generally require authentication, the content (images in this case) would have to be retrieved via the HttpRequest object (in order to stuff the credentials in the HttpHeader).

It would have been nice to be able to pipe the InputStream from the HttpRequest to an Image object, but such is not the case. So there was no easy way (that I could see) to render an image from a password protected URL (if anyone knows of a better way, please let me know).

Update: Josh aptly informs me that there is indeed a “fromBufferedImage” utility method in the Image class. Thanks, Josh. If only I would have scrolled down that far in the API docs…

Anyway, so there it is. I imagine the ideas in this visual browser could be applied to any type of tree structure.

Tags: , ,

6 Responses to “JavaFX CMIS Browser”

  1. doliver wrote:
    February 12th, 2009 at 2:58 pm |

    Wow, that is really cool. I was thinking the only thing you could do is use the HTTPHeader to store credentials, just like you said. Interesting problem. Cool idea, Sten.

  2. Shane Johnson wrote:
    February 12th, 2009 at 2:58 pm |

    That is just plain awesome. I love the visual approach you went with.

  3. sanderson wrote:
    February 12th, 2009 at 3:26 pm |

    Thanks, Shane. And thanks for the advice on the CMIS nuts and bolts.

  4. Josh Marinacci wrote:
    February 12th, 2009 at 8:45 pm |

    Hi Sten. JavaFX’s image class has a utility method to use a regular Java BufferedImage, which could be created from an input stream with normal Java code.

  5. sanderson wrote:
    February 12th, 2009 at 9:36 pm |

    Thanks, Josh. I don’t know how I missed that…

  6. Daniel Manzke wrote:
    March 29th, 2009 at 7:14 am |

    Hi,

    your visual approaches looking very nice. :) I know the problems with alfresco. They often have nice ideas, but only the half implementation. It’s more a marketing aspect.
    Also a nice API for your things could be the JCR. (but lacking with Web Services)
    Is there a chance to have a look at your code? :)

    Bye,
    Daniel

Leave a Reply