Tag Archives: REST

Firebug REST Client

Debugging web scripts with the Firefox REST Client

Firebug REST Client

The Firebug REST Client

Because Web Scripts involve two computers talking to each other, they are potentially hard to debug. We’ve found that it pays to test the scripts from a web browser before writing any code. We iron out our exact understanding of what parameters the script needs and what it returns before doing it from within our application. There’s an add-on to Firefox called “REST Client”. You specify the URL, method (PUT, POST, GET) and optionally any request headers and body (for example CMIS XML). The REST Client will then tell you if the request succeeded and you can examine the response.  Take care to specify the correct content type in the header for xml or json.

In the example above you can see the URL, http://epsilon.nuhrise.org/alfresco/service/cmis/i/2c62291d-2e9f-4ac3-83a1-157406ffb2aa/children and the verbose response. In this case the response describes files in the Company Home space.

In the next article we’ll describe the web services our application Documas uses to view, upload and download files from Alfresco and we’ll also cover assigning and accepting/rejecting workflow tasks on documents from our external application.

Example Alfresco Web Service

Employing Alfresco web scripts to answer RESTful calls

Example Alfresco Web Service

REST is a set of ideas that promise to simplify communication between applications. 

If you have not come across REST before, there is an entertaining description here.

Conventionally applications use something like Remote Procedure Calls to call on each other for services, but every single call tends to have different parameters and return values making it hard to generalise and fiddly to use. In REST, the interesting parts of an application are available as ‘resources’.  Alfresco offers resources such as spaces (folders), files, people, tasks etc. Each resource can only do a strictly limited number of things, it can be created, deleted, changed or just read.  That’s it.  (The technical success of the World Wide Web can be largely attributed to REST, the resources are things with URLs, pages, pictures, tables of data, music etc. The operations in HTTP are PUT, POST and DELETE).

The designers of Alfresco have opened up the monolithic Java jungle inside Alfresco to expose the important resources. They have even documented it, a full list of approximately 370 Web Scripts (REST services) available from our Alfresco server is available at http://epsilon.nuhrise.org/alfresco/service/index, but you need to log in with the admin password!

In my opinion Alfresco also clutters the REST API with methods that return GUI elements, strictly speaking this is not REST because the resources are embelished with javascript for the user interface. The Forms Service in v3.4 is an example.

Inside Alfresco, the units of code that answer RESTful calls are called Web Scripts. They are written in Java and/or Javascript. The use of Javascript on the server side is clever because more people understand Javascript, and changes can be deployed with just a refresh of the web scripts rather than compiling and deploying Java class files. Otherwise one would have to maintain a Java build environment for the Web Scripts and employ at least half of somebody’s time just to develop and maintain the Java Web Scripts.

web-client

Opening up Alfresco to other web applications

Example page from the Alfresco Web Client

We’ve built a web application, Documas, on the solid foundation of the Alfresco Document Management system.   In this article we’ll explain why and how we did it.

Using Alfresco from another web application

Alfresco is a solid platform for managing documents and the events that happen to them during their lifecycle, but the ‘Web Client’ user interface is not suitable for most purposes because it was built by people like me, programmers, instead of by normal people. (The Web Client is also called Alfresco Explorer). As an example of the problems, try deleting ten files quickly.  There is no way to do a bulk operation and remove all ten in one go.

Alfresco Explorer

The Web Client is written in Java using a technology called Java Server Faces which in my opinion values gratuitous complexity over getting the job done.   (I think the adoption of JSF was the very reason the Web Client had proved to be hard to use, so much attention went into the JSF that little resource was left for usability testing).

Alfresco have addressed this problem by developing the ‘Share’ front end, a very Web 2.0, responsive and popular alternative to the clunky Web Client. But the Share web application is very closely tied to Alfresco and the kinds of document operations that Alfresco does. Our application needs to do those things, but also something called CRUD. Share, being AJAX, Javascript and REST based, is a sound choice for pure document management uses of Alfresco, but for our application we needed a little bit more. Over the next few articles I’ll explain how we went about it.