Tuesday, January 18, 2011

REST

Classes just started which means a new semester of learning is coming. It didn't take that long before we actually dive deep into this learning experience. The first week of my class in Software Engineering focuses on REST and no, not that kind of rest, but Representation State Transfer. Wikipedia defines it as a style of software architecture for distributed hypermedia systems such as the World Wide Web. This is the first time that I've seen and heard of it and I'm sure most of the class too. We are learning REST to incorporate the project that we did last semester which is the front-end for the Team Hawaii's house's Home Management System. To be able to get familiarize with REST, we were ask to do some Katas.  Basically we have a DateClient and DateServer that we need to add/modify to be able to accomplish these Katas. Below are the 4 different Katas that we need to do.


TO DO : 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.  
 RESULT: This is fairly easy. There's already a Day resources that exist that we need to copy and change part of it to retrieve/show hour, minute and second. It took me about 15 mins to finish this.

TO DO: 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

    RESULT: This is a lot harder than the first one. Researching and reading tutorials took most of the time to accomplish this Kata. Some tutorial also varies and sometimes don't work on the current version or task that we needed to do. I have to create a property file inside a hidden folder in our home directory. I also needed to add a line inside the main method on the server to direct all logs into the same folder of the property file that I created. It took me about an hour to read tutorials and 30 minutes to actually code it. 

     

    TO DO: 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.)

     

    RESULT: Of course this is harder than the previous ones. I was able to find some tutorials online to help me accomplished this but none of them really are straight forward. I've tried different codes but none of them worked. I found this link that explained and showed the basic authentication in REST. It took me about 2 hours of searching and trying out tutorials and another 30 minutes to finish it once I found the tutorial that worked.

     

    TO DO: 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.  

     

    RESULT: To be honest, this Kata is the most I'm worried about. I wasn't able to figure this out. I tried couple solution like importing wicket in the build.xml file but no success. I'm currently still working on it, so the current distribution file for my program is incomplete. It took me about 3-4 hrs so far for this Kata.


    Download: Restlet Katas

    No comments:

    Post a Comment