Give Alfresco a REST!

UPDATE (2/2014): This tutorial has been updated. Please use the latest version rather than the one linked to in this post.

A REST API, that is. The latest in the Alfresco Developer Series is an Introduction to the Web Script Framework which shows you how to create your own REST API to the Alfresco repository. As usual, the article has Example Source Code you can download and try out on your own.

The intent of the article is to walk through some hands-on examples using Alfresco’s Web Script Framework which became available in the 2.1 release of the product. The article extends the “SomeCo Whitepapers” example started in the Custom Content Model and Custom Behavior articles by using Web Scripts to create a REST API for creating user-contributed ratings. Front-end developers wire an AJAX ratings widget to the REST API to allow users to rate whitepapers on the SomeCo web site.

Give it a read, try out the code, and let me know what you think.

Read more about the Alfresco Developer Series.

20 comments

  1. Ven says:

    Hi Jeff, When is your article on advanced workflow with JBPM coming!! I’m waiting for that!!!

    Thanks,
    Ven

  2. jpotts says:

    Ven,

    Thanks for your enthusiasm. It’s next on my list. I had to get the web script article out first.

    I do have a decent start on the workflow article, though, because I can use a lot of the stuff I did when writing Optaros’ internal Alfresco Boot Camp curriculum.

    Jeff

  3. Yannick Schutz says:

    Great article! Like the others!

    Hope that with 2.2 we can deploy webscripts in the path dynamically

  4. Ghanshyam says:

    Hi Jeff,

    Actually I want to rate a document , like adding one menuItem called “Rate It” and, by click it , it will show one JSP having 5 radio buttons. and then can give rating. Is there any other good solution ??

    I want to rate document thats it !! any good and easy way ////

    Thanks

  5. Ghanshyam says:

    Jeff,

    Actually I don’t want it to show on WebScripts..
    Its better we can include it within Document Management Part.

  6. Thanks for the amazing article Jeff.

    I feel lucky to have spotted your article and after going through it and the source code, I already feel comfortable with Web Script.

  7. Ivo Costa says:

    Hi Jeff,

    Let me start by congratulate you for these excellent articles about Alfresco.

    Right now I’m new to Alfresco, it has only been a couple of weeks since my company became a partner for Alfresco, and since then I’ve been racing against the clock to get some knowledge on Alfresco.

    Thanks to your articles I’ve managed learn a lot in a relative short period of time, right now I’m stuck at the web script framework tutorial trying to understand why I get an InvalidReferenceException while using the example provided.

    Is there any reading material that you can recommend me for my learning stage while waiting for your book to come out?

    Hope to see more learning articles really soon
    Best wishes

  8. Robert Nguyen says:

    Hi Jeff,

    I am ready enjoy and learned from your article. It helps me to understand how webscript work in Alfresco. Alfresco is very new to me. I download your samples code and installed it in Alfresco, but I do not know how to create Somco/Whitepappers and upload some test whitepaper in Alfresco. Secondly, could you point me or send me sample of ui front end code.
    Thanks you so much,
    Robert

  9. abhishek pathak says:

    hello,
    sir i am new in alfrsco.
    i am fresher programmer of java in semaphore-softwar.
    i have enough knowldege of jsp/servlet
    now i am switch over to alfresco

    how would study the alfresco…
    how to use it,
    mainly what is REST API in alfrsco…
    thanx in advance..
    plz help me to understand the alfrsco..

    ABHISHEK PATHAK.

  10. Aakash Sharma says:

    hi Jeff

    Really Useful article. I have managed to customize the custom model and then i created the webscript to get the list of whitepapers.

    I was getting an error while running the webscript in the whitepaper.get.html.ftl file at the expression ${child.rating.average}”. I degugged and checked that the problems lies only at the place where i am using the (child.rating) expression for the other expression child.whitepaper everything was working fine. Infact after modifying the FTL and after removal of the experssions related to child.rating i was able to view the details of the whitepaper through webscript succefully but rating information was missing.

    Can you please help me to know what I am missing here. Any help is appreciated.

    Thanks and Regards,
    Aakash Sharma

  11. jpotts says:

    Aakash,

    Have you added any test ratings to the whitepaper? You might try using some server-side JavaScript to do that and then try the web script again. It is possible that the web script isn’t handling the case where there are no ratings.

    I’d also double-check your whitepapers.get.js controller. That’s where the child.rating object gets created.

    Jeff

  12. shikarishambu says:

    Jeff,
    I am trying to leverage your web scripts article to create a web script that does search.

    I am running into a few issues. I have custom content type that has some additional attributes. I seem to get error if the output does not have the custom attributes.

    I need the ability to specify values for specific attributes, define a date range and the output returned should have that plus other attributes.

    I am trying to tweak the default keyworksearch. Is that the right way to go about it. Or, is there a better example that I can look at?

    TIA

  13. Nirvan V. Jain says:

    Hey Jeff,

    I don’t know its proper to comment on this Article but still want some Article on Alfresco Share Development Environment Set Up (For say 5 to 10 members Team) /Alfresco Share Customization.

    How to begin with ?

    Please Help.

    Appreciate Your Help !!!

    Thanks!
    -Nirvan

Comments are closed.