Modules‎ > ‎

REST

Student learning objectives

The learning objectives for this module include:
  • To understand basic concepts of the Representational State Transfer (REST) architectural paradigm, including resources, representations, URIs, "nouns" vs. "verbs", how these map to the HTTP protocol, the pros and  cons of this architectural paradigm, and how to identify whether a web API is "restful" or not.
  • To gain facility with the Restlet Framework for implementing Java systems according to REST principles. You should be able to quickly and effectively implement a RESTful client and server system given a specification of the API that satisfies our quality assurance standards (Checkstyle, PMD, FindBugs, JUnit, Jacoco).

Resources

Readings

Helpful introductory readings for learning about REST and Restlet include:

Software

Screencasts

This first screencast is my 50 minute introduction to both the REST architectural style and to the restlet-dateservice system, the example Restlet system you will be using as a basis for experiential learning assignment A04.  If the video does not appear below, you may need to upgrade Adobe Flash.

This second screencast is only 13 minutes long and provides a complementary introduction to REST that focuses on how REST architectures can take advantage of the HTTP protocol and its support for caching (among other things).

Slides

(Note that these slides introduce, but do not encompass all of the material in their associated screencasts.)



Experiential learning

Assignment A04: Restlet Code Katas

Code katas are exercises in programming that help you to refine your skills.  This assignment will help you achieve the student learning objectives by actively working with an example REST architecture: the restlet-dateservice.  

To start, download the .zip distribution of restlet-dateservice to your local system.  Edit the build.xml file so that the project name is no longer restlet-dateservice, but rather restlet-dateservice-<username>, where <username> is your uhunix account name.  Run "ant -f verify.build.xml" on your local copy of restlet-dateservice to make sure that it compiles and passes all quality assurance tests.  Next, bring up Eclipse, import the project, then select the project name and use the "refactor" menu item to change the Eclipse project name from restlet-dateservice to restlet-dateservice-<username>.

Now modify your local copy in the following ways.  I am guesstimating that it will require 6 hours of work to complete these 4 Katas.  After publishing your blog entries, we will find out the accuracy of this prediction!

For each of these katas, record how long it took you to complete the assignment. 

Kata 1: Time resources

Add three new resources called "hour", "minute" and "second" that return the current hour, minute and second.  
  • Write unit tests for each of these resources and make sure they pass, and make sure you can run them both from within Eclipse and using Ant.  
  • Make sure the DateClient system accepts these parameters. 
  • Ensure that "ant -f verify.build.xml" passes with no errors.  

Kata 2: Logging

By default, Restlet logs data about each request to the command line using the Java Logging API.  Read a tutorial (and/or google) to get familiar with the API, then do the following:
  • define a ~/.dateservice/logging.properties file that enables the user to specify (among other things) that the logging information should go to a file, not the command line.
  • tell the restlet-dateservice application to read and use the logging properties file in  ~/.dateservice/logging.properties

Kata 3: Authentication

The current restlet-dateservice system performs no authentication.  Check the user guide (and/or google) for guidance, then implement HTTP Basic authentication for all the resources in the restlet-dateservice system.  To simplify things, all resources should be available as long as the requesting system uses HTTP Basic authentication and passes the username "guest" and password "pw". (You can hardcode that password into both the client and server sides of the system if you like.)

Kata 4: Wicket

For this Kata, create a new client for the DateService server that is a web application using Wicket rather than a command line application.  The web application should bring up a single page with a single form that requests what aspect of the date (year, month, day, hour, minute second) the user desires. When the user submits the form, the web application uses Restlet to obtain the appropriate information from the DateService server, then presents the results to the user in the page.  

The web application should be placed in its own package.  Note that you will have to modify the build.xml file to include Ivy-based retrieval of the Wicket libraries. 

Modify the jar.build.xml to build a third jar file called restlet-dateservice-webapp.jar containing just the client classes and libraries required to run the web application.  

Make sure to provide a JUnit test case for your web application, and that 'ant -f verify.build.xml' passes without errors. 

Submission instructions

By noon on the date indicated on the schedule page, publish a technical article using your blog in which you describe your understanding of REST and your experience with each of these Restlet Katas.  Your technical article should follow the guidelines in the Professional Persona module.

You must take special care to not let this technical article devolve into a "homework submission report".  Think about how to present the information in such a way that it is of general interest.

For each Kata, describe what you did, indicate whether or not you finished it, how long it took you to do it, and what issues you ran into while doing it.  

Provide a link to a distribution zip file for your local copy (using "ant -f dist.build.xml") so that it can be downloaded and reviewed. If you have followed the instructions correctly, your zip file will be created with a name that includes your UH account name. (Do not simply rename the file to include your UH account name--go back and re-read the instructions so that the project itself, not only the file name, is changed.)
Comments