Sunday, October 14, 2007

Discussion of sakai prototype

So its been a while, however i expect to do this as deatiled as i have recorded in my code and as part of SVN..

Firstly the task at hand was to move from and Spring MVC application into a fully integrated Sakai application. Now there are two approches here:
  1. Simply convert the system, into a sakai app by adding some extra information in the web.xml file, and register the tool with sakai using a registration file.
  2. The more complicated thing to do is to redesign the directory strucutre and enforce the full sakai tool, this separates api, tool, implementation, and model. Further create nested POM files.
It was clear from the start the second would be very hard to get working as it required a complete redesign of the system. At first it was daunting but I thought i'd try.

The Full Story
The first task was to install sakai, i downloaded the source of sakai, and then complied it using Maven. That was an issue in itself. Maven required several aspects that needed to be set up, at first I installed maven 2 and configured. On doing this i then fond out that Sakai 2.2.3 uses Maven 1.0.2. Thus i had to uninstall it and then remove the repoistory. All along i was using the eclipse plugin for maven. Now this became probalamatic as it included versions that were not comaptable with Sakai and was forcing sakai to use them.

On removing this and then using the correct version i realised that all this would be too much to get working in windows. So i decided to use my Linux box instead. I put maven on this, and then complied Sakai and was able to deploy it ease (LInux working i know its scary). It was now time to try and get the tool built. It was daunting to try and make the dir structure by hand. So at that point i decided to try and look for help from the Sakai community and everyones freind Google. On doing this i found the Sakai App Builder plugin for eclipse. This was perfect as it built the directory strucutre, and also was capable of building all the POM files, as well as the authentication service integration.

The Sakai App builder was used and it generated the whole structure that was needed. It was then my task to fill in the gaps. The following is what i had to change:
  • Change the Sakai registration file to include some new description and titles.
  • The base object that holds most of my logic i.e. the model data. This was the Club, and i also had to rewrite the hbm.xml file for it to ensure the mapping is correct.
  • The file to allow it to use the DB, at first MySQL was going to be used, but after some playing around HSQLDB was easier and quicker, so we used that.
  • The ClubBean that was responsible for control of the web app. It played the role as the connection between teh JSP and the Java files. Using dependency injection we are able to give it everything it needs. This was the Logic classes that allow for the saving, editing of Clubs. Secruity function via the external logic class, and finally performing searches using the searchingtool. Each of these have an interface and then an implmentation.
  • THe interfaces then became part of a libaray that was then added to the global Sakai shared library. This means that my tool can be used by others via the API. This is what i do with the Authz module, i simple use the API and the impl is hidden from me.
  • The JSP files were created to fit directly into the sakai format using certain classes for the CSS, and special Sakai-style tables. Using these we are able to create a tool with the SAkai look and feel.
  • The searching tool was played with alot, first i implemented a simple DB search tool, that wasnt very good at getting results. Next a regex version was used and this was much more succesful, this was finally used as the other versions did not work! This version used the search tool within sakai however it required me to implemnt a horible interface! Also relied on Enity tracking and producers which were quite difficult to grasp without much documentation. The search tool is run within the jsp, via the ClubBean which has the tool injected into it at start up.
At home it ended up working after alot of time and effortit was able to work, Maven proved to be difficult (again) it was unable to download the ocrrect version of the generic dao object. i wanted 0.91 but for some reason it could NOT! So i manually changed the POM files to only refer to 0.9. This then fixed that issue.

Then i got to uni and thought sweet its all good, just need to rebuild it all :) . How wrong i was it took forever and didn't work!
After a great deal of apin and anguisg it was because Maven dpl task was not copying the JSP and WEB-INF directory. This was manually fixed by moving the files over, however since i was using a full Sakai tool the files were split over many files. These include compoents folder for the package itself, and then the lib folder for the api. And most importantly the acutal web app that tomcat uses this is the JSP files and the beans.

So there it is simple if you use maven (1.0.2 and its nice and you configure some stuff and you great stressed) and SAKAI APP BUILDER this IS a life saver as it makes the dir structure and maven files as well as many of config xml files.

No comments: