Status Reports

Week 9 (27.08. - 02.09.) - Release 2

What has been done?

Wednesday, this week was the last "official" day of my internship. I didn't add any new functionality to my system this week. I tried to finish everything and make it ready for deployment. Moreover I updated the class diagrams of the system and finished the necessary internship report.


Week 8 (20.08. - 26.08.)

What has been done? 

This week was the final week of my internship project who's goal was to develop the mobile posting system for Firstlife. I didn't add much features this week, however I was able to do a lot of important improvements of my system, on the server as well as on the client side. I'll briefly list all done things below:

  1. Encryption

    For doing the password description, I've already developed last week a system, which basically uses message digests for hiding the user-password while it is send over the network to the server. Initially I wanted to avoid the usage of the "Bouncycastle" library and solve the problem by using system-internal algorithms. However in the meantime Markus has written his own encryption algorithm using Bouncycastle and so finally we decided to use his encryption which is based on an encryption(on mobile)/decryption(on server) method rather than by comparing digests 

  2. Display management

    I finally decided to switch to a stack-like management of the display on the mobile device. Till now I used to have a interface approach, where all Displayables implemented a common "view interface" having the appropriate methods for displaying the component on the Mobile device's screen. However I now found it more appropriate to use a stack datastructure for keeping track of displayed things.

  3. Spring Scheduler

    Some weeks ago I added to the system the functionality of specifying an expiry date for posts. I found this useful, especially for posts that have a timely constraint, so for instance notes about upcoming parties. For realizing this on the server, I just added a implemented a thread, which is launched at server-startup running continuously over the posts in the DB and removing the expired ones. After searching in the Spring reference documentation, I found appropriate schedulers managed by the Spring App framework. Since they seemed more appropriate for my implementation I switched to the Spring schedulers rather than having my own implementation of a thread. In this way I was able to just have a business class which is able to parse out and delete expired posts from the DB. After the correct configuration, the Spring scheduler manages automatically the launching of the class.

  4. Data retrieval optimizations

    After analyzing my system more deeply, I started to do some data retrieval optimizations. Assume for instance the case, where some location has several hundred posts (would be desirable, but doesn't sound very realistic ..anyway) and a user presses the appropriate button on firstlife for retrieving those post from the server. In this case all 100 or more posts would be send over the network down to the mobile client, where they are clearly kept in memory for displaying purposes. This wouldn't be desirable...and could also overstress the virtual memory causing an application crash.

    Therefore I decided to change the data-flow down to the client in a way that it is broken in little chunks, which are then retrieved and displayed separately. I took the underlying idea from the Google Reader team, which uses a similar strategy for faster loading of news feed items in their Google Reader product. I had to investigate some work, but now the data exchange runs smoothly resulting in lower memory charge on the mobile client, faster download (and therefore also displaying) and shorter connection times (less money to spend). The chunk-size is also customizable, till now only through the code, but it could also be made customizable through a user-settings interface.

  5. Real device testing

    Moreover this week I started to test my application (server & client) on a real-production like environment, where I installed Firstlife (especially my mobile posting system) on a Motorola mobile phone and installed my posting server on my homeserver which is accessible over the internet. This testing gave me a lot of benefits, since I discovered and solved a lot of problems, which didn't appear at all while testing the application with the WTK on the computer. Especially my newly implemented data retrieval mechanism was worth the work.

  6. General refactoring and logging

    Finally I also did some refactoring on both sides of my system as well as logging on the server-side. At the moment I've implemented the logging in a general way using the Apache Commons logging library, but this could also be changed to an AspectJ fashion using Spring's AOP framework.

What will be done next week?

The following week I'll see to conclude all of the work and make the application ready for deployment. Moreover I'll see to update all my Class diagrams as soon as I complete all the other stuff.



Problems were mainly related in figuring out configuration details for the Spring schedulers and for implementing the "small-chunk-based data retrieval". 


Week 7 (13.08. - 19.08.) 

What has been done?

This week I finally constructed a simple Location simulator which can be used by all First-Life components for testing purposes. I wrote the simulator in a way such that it can be substituted later on with the real location-retrieving code. The simulator contains several Location objects which hold data regarding the cell-id, latitude and longitude. The simulator can be accessed from the main First-Life menu. Locations can be selected randomly or manually.


As discussed in the last meeting I also finished the user-registration part of First Life by using the Social Network server which is also used for doing the user-login.


Another important thing to which I didn't pay much attention till now was to secure the information exchange between the server and client, especially to encrypt exchanged passwords and to secure the server by adding authentication functionalities. For the encryption part I developed a utility class which can be used by all First-life components (more details here). It basically creates a message digest out of a timestamp, a random number, the username and password. The mobile client has to send the timestamp, random number, user and the created digest to the server, which will on his side create a new digest out of the timestamp, random number and username from the client and with the user-password from the database. Finally both digest messages will be compared and evaluated. Different passwords on the client and server-side will result in different digest messages and therefore in an authentication failure (I'll post more details about how the other firstlife-components can use the encryption classes for their servers).

In the case of my Mobile Posting server, I found after some research in the Spring reference documentation that Spring disposes of an abstract class HandlerInterceptorAdapter which has useful methods such as preHandle(HttpServletRequest, HttpServletResponse, Object) and postHandle(...). Inheriting from this class I was able to develop my authentication component on the server side in a way that all the incoming HTTP requests on the server-side are catched and authenticated before they arrive to my HttpController class where the request is then actually processed.

This has the big advantage that I don't have to deal with sessions or check continuously the authentication data on the actual server controllers since I can be sure that all requests arriving to the server controllers have already been checked before (more details can be found here).


Finally I did other things such as adding more information to post comments like user-information and the date of creation. This allowed me to change my code a little such that posts and comments are now delivered to the mobile client in descending order according to their creation date.


What will be done next week?

The following week I'll add another functionality to posts: visibility. I thought that it may be the case that a post should be visible regardless of the location of the current device, meaning that a post defined "global" should always be retrievable. On the mobile client there would be then the option to fetch just the posts of the current location or including also posts defined as "global".

Moreover I'll do some refactoring on the client (mobile) as well as on the server side. Especially on the client side there are some parts of the code which have become quite messy and have to be reorganized a little.

As a last point I'll focus more on the location-based order to find a definitive solution how the location could be retrieved on the mobile phone since we found out that the JSR-179 API will not be that convenient.



There were no notable problems this week.



Week 6 (06.08. - 12.08.)

What has been done?

Thursday this week we met for a 2nd meeting, since we had to put together all the single databases to the common firstlife database which will then be used by all the applications. We had to meet since there have been tables which may be used by several firstlife components for which reason we had to discuss on the needed table columns. As I announced last week, this week I changed my implementation of the posts such that they have now a creation-date associated. From one point of view this may be interesting to see how actual a post is, but it could also be used for filtering, such as for retrieving only posts created within the last 2 weeks or so. The date is added on the server-side and is therefore based on the timezone and date-configuration of the server-machine. Moreover I added the functionality of adding an expiry date to posts. As I already explained in the report of last week, this may be useful for posts which are only valid till a certain date, as for instance a post that announces that on the date xy there will be a party...after xy the post will basically be useless. For removing expired posts, I implemented a class on the server, which is launched at server-startup and runs as thread in the background, checking the DB for expired posts in a specified time interval.

A second feature which I added to my posting system was to add an "OR search" to the already implemented "AND search". To explain myself more clearly the user can now do the following:

A user can load the search-form on the mobile phone and enter the following query:

    "computer sell" (equivalent: "computer and sell")

This will be interpreted as "Computer and sell" and will intuitively return posts containing the string "computer" AND "sell".

The "OR search" allows the user to enter a query as follows:

    "computer or sell"

This will be interpreted as "inclusive or" and return posts which contain either the strings "computer" or "sell" or both of them. Moreover

the user can concatenate both types of search, by typing for instance

    "computer or sell party"

The query will be evaluated on the server side and return posts that contain the string "computer" or "sell" (or both) and a string "party".

So the following posts will be returned:

  • post containing: computer, party
  • post containing: sell party
  • post containing: computer, sell, party

Beside this I also tried to develop custom items for displaying for instance user-comments on posts. For doing so I've extended the

CustomItem of J2ME which disposes of a Graphics object for directly drawing things on the display.


What will be done next week?

The next week I will implement the registration of a non-existing user by using the Social Network server which does the user-management

(login, registering of users). I will try to implement a simple Location Simulator which I was not able to implement this week due to

time constraints.



The only problems were related to writing my own UI item. J2ME disposes of the CustomItem class which can be extended

by inheriting from it to create personalized items. I wanted basically to create a UI item for displaying user comments, where there is a

picture on the left and the user-comment flowing along on the left side of the picture. The difficulty was basically to let the comment-string

wrap on the lines since all line-breaks have to be done manually by measuring the string and cutting it on space symbols if it is too long.

Here's a sample of the successful implementation of my comment-item:


Week 5 (30.07. - 05.08.) - Release 1

What has been done?

On Tuesday this week we had the 1st "firstlife" meeting (see here). Therefore one of the things that have been done this week were to configure the common SVN repository and to move the source-code of all Firstlife components to the common repository. Moreover I collect the single databases of all the project members and started to combine them to the single Firstlife database that will be shared by all server-side components.

For the Mobile Posting system I implemented a function that allows users to leave comments on posts, similar as it is done on online blogs. This encourages the communication between Firstlife-users' using the Mobile Posting system. Lets take for instance the old sample of the restaurant (see scenario): a user posts that he found a good restaurant in some street...Others read the entry, maybe they also go to eat there but they may not agree with the opinion of the post-writer. With the possibility to leave a comment on the post, users can express what they think. Getting feedback on posts is much nicer.

The second major functionality I added is the post-search. Users have the possibility to enter search-queries by typing in keywords. At the moment it is a simple "AND" search, meaning that the query "computer sell" will be interpreted as "computer AND sell" resulting in posts that contain the keywords "computer" and "sell".

Beside of the location-feature the system is fully functional and could be defined as the first release of the Mobile Posting System.

Till now the following functions are available:

  • create a post and submit it to the server
  • "personal" posts can be retrieved, edited and re-submitted
  • the user can fetch just all posts, his personal posts, or posts based on the current location (simulated till now)
  • leaving comments on posts
  • searching for posts


What will be done next week?

The next week I'll improve the search by adding the option of specifying "OR" queries and also to use filters (for time, only posts of current cell,...). Moreover I'll add date information to posts, such that one can fetch posts also based on time-data (i.e. fetching posts made in the last 7 days). I would also like to add an "expiry date" to posts. This could be especially useful for posts that are only valid (or useful) till a certain date...For instance one could make a post that a party is taking place, say, the 15th of August...So after the date, the post is useless...However if it would have an expiry date associated, the server could check the DB periodically and delete such posts.

Moreover I want to create a Location-Simulator that can be used by all Firstlife team members to test their components. Lastly I'll do some refactoring on my code on the mobile side and improve the user-interface.



There were no big problems!


Week 4 (23.07. - 29.07.)

What has been done?

I finished all the things which I planned for this week. I added several functionalities. So the user has now the possibility to retrieve all the posts he has written. Moreover he's not only able to retrieve them, but also to edit and recommit or to delete them. In this way the users of Firstlife's Mobile Posting System can fully manage their made posts. This week I also refactored a little my system on the mobile side since some parts of the system got a little messy.

I also started handling all errors I started to display the relevant ones to the user, by using Alerts. For instance if an "error" happens on the server side, because for example a user has not the permission to delete a post, the server will encode the message (error) into XML, send it back to the client, where the message will be displayed as an alert. This makes the system much more interactive and improves the usability. I also developed a general ProgressBarForm, which can then also be used by other parts of Firstlife on the mobile side. Moreover I finally also wrote all the unit-tests for the mobile side of the MPS using J2MEUnit.


What will be done next week?

The following week I will probably add functionalities regarding the searching of posts by giving some keywords. I will also try to make the system more usable by giving the possibility to leave comments on read posts, such that using MPS will be more interactive. Moreover I'll start to write a Location simulator which in some way is able to simulate changing cells, such that all the components of Firstlife which are location-based can use it to test their parts.



I had to read through some tutorials for understanding how J2MEUnit tests work. But with a sample from Matthias Braunhofer and a good tutorial, which I found online, I understood everything quite quickly. There were no other problems.



Week 3 (16.07. - 22.07.)

What has been done?

This week I implemented the user-story "Fetch posts based on location". The user can now start Firstlife on his mobile phone and retrieve all posts of the current location. Clearly I'm till now only simulating the location, by programmatically setting the location-data (cellid, lat, long). For this reason I had to modify my model on the server as well as on the client side. Furthermore I added more information to the DB and had to change the XML-model.

I have to postpone the other scheduled stories for next week, since I didn't manage to implement them this week.

The MPS system runs and there are currently the following features available:

  • Create a new post (which is submitted to the server and stored persistently in the DB)

  • Fetch all posts from the server

  • Fetch only posts which match the current location of the mobile device


What will be done next week?

The next week I'll add the functionalities that the user can edit and republish his personal posts. This will include also the possibility of deleting and fetch his personal posts.



Problems were mainly related to understand how the persistency mapping of foreign key relationships are done with Hibernate. It needed some time and reading after I successfully understood it. Despite this effort, Hibernate gives many advantages, where the most substantial ones are cleaner java code and mainly the decoupling of the code with the DB layer. It would be easy to switch to another DB system by just changing the hibernate mapping files, without having to touch any line of code.



Week 2 (09.07. - 15.07.) 

What has been done?



I started developing the application. First I had to decide how to structure my system on the server-side where I've come to the decision to use the Spring application framework. One reason for using it was to get in touch with something new, I've never used before, but the main reason was that it nicely fits into my application. Since for the Mobile Posting System the communication between the mobile client and the server takes place over the HTTP protocol, I made use of the Spring Web MVC framework which has a couple of controllers available for implementing a nice MVC pattern on your web application. Specifically, I used the Spring Dispatcher Servlet, which takes all the HTTP requests and forwards them to my main application-controller-class which then processes all of them (I'll provide a class diagram of the server side soon here). This gives me the benefit that I don't really have to care about having a servlet and about creating a Web application. I can build a normal java application on the server side which has to be structured and configured such that it cooperates with the Spring framework and takes the forwarded HTTPServletRequests and respondes over the corresponding HTTPServletResponse. For this reason my main application controller has to inherit from the necessary Spring controller.

For managing my objects I used the Spring IoC Container, which takes care of instantiating the objects in a bean-fashion, by using the setter-based dependency injection style (Martin Fowler's article). Another advantage of Spring came up when writing my Unit tests. So for instance I could use the available Mock-objects, specifically the org.springframework.mock.web.MockHttpServletRequest and MockHttpServletResponse, for simulating the behaviour of a HttpRequest/Response to the server. In this way I can unit-test my application without having to deploy it every time on a running Tomcat.

For the ORM (Object Relational Mapping) I used Hibernate. There would be the possibility to directly integrate Hibernate with the Spring framework, but since I'm new to both of the technologies and for other simplicity matters I decided to use Hibernate in a declarative way, by explicitly giving it the instructions for persisting objects. Maybe later on I can try to directly integrate both technologies.


Mobile client:

On the mobile client I created a general Midlet called "FirstLife", where I attached my mobile application controller class "MPSMain". The idea would be that later the other Firstlife components could be added to that Midlet "Firstlife" and launched from it, such that we have a single Midlet for Firstlife on the mobile client. However this has still to be discussed with the other team members. Here is a first draft of the according class diagram on the mobile side (yet still without any method and field declarations).


Beside technology and architectural stuff, I was able to successfully implement the first user-stories and to integrate them such that I've now a running system. The user is now able to launch Firstlife, create and submit a new post. The created post is sent to the server where it is processed and saved into the DB. Moreover the user has now the possibility to download all available posts from the server and to display them on his mobile device.

During this week I'll add more information about the chosen XML information exchange format here.


What will be done next week?

The next week I plan to implement the location-stuff. I will figure out how to simulate location-data with the Sun Wireless Toolkit and how to write Unit-tests on the mobile client by using J2MEUnit, since Junit doesn't since J2ME doesn't support reflection, which is necessary.


Moreover I'll implement the following user-stories:

  • Fetch posts based on location
  • Retrieve personal posts (Posts written by the user, which is logged in)
  • Remove committed post
  • Edit a committed post (Modify on mobile device and repost again)



There were no real problems. The only difficulties were initially in understanding how the kXML 2 parser works on the mobile side. Another thing was also to understand how the dependency injection of Spring works and how Hibernate has to be configured for the MySql DB.



Week 1 (02.07. - 08.07.) 

What has been done?

This week was mainly intended to perform experiments related to new technologies which are probably going to be used during the development of the project.

The following experiments have been done:

  • Servlets

    I tried to create and deploy a basic Servlet on a Tomcat Server. Furthermore I created a simple Midlet, which connects with the Servlet using a HttpConnection. I used the POST and GET method to send a dummy data. For the project I'll probably use the POST method. It is a little more complicated when coding, but more elegant since the parameters are directly embedded in the body of the request and therefore not visible on the URL. For seing if the communication with the server worked, I've sent an arbitrary Integer number to the servlet, which - after incrementing the number by one - sent it back to the midlet, where I displayed it on the Cellphone screen.

  • Parsing XML documents on Mobile phone

    I also performed some tests for parsing XML files (which later will be used for the communication between the Mobile Client and Server). For parsing I used the kXML (vers. 1.21) parser which can be found on

  • Midlet UI

    I played around with midlets on the mobile phone in order to get a feeling of how the UI design works.

  • Spring Application Framework and Hibernate

    I started by reading tutorials and online references regarding the Spring Framework ( which I intend to use on the server-side since it gives quite a lot of advantages such as easier testing, modular design through dependeny injection, etc... I'll use the framework, especially its IoC Container, to manage my server-side objects, also because I found out that it nicely fits into my application and facilitates a MVC design. Also extending the application with, for instance, JSP pages in the future (if needed) will be a lot easier.

    I also did some tests for using Hibernate for the ORM (Object-Relational-Mapping) and it works quite fine. The advantage will be that a lot of SQL code can be obmitted and once all the configuration stuff is done, the Java code is a lot simpler and cleaner.

  • Ant

    I experimented also with Ant-scripts since they were new to me. I created some test-scripts which deploy my application on the Tomcat server. This helps a lot during the development since everything regarding deployment etc. will be automated.

  • General Setups

    This includes everything related to the preparation of the working environment such as

    • installing an Apache Tomcat Server and connecting it using it from within Eclipse

    • downloading the necessary Eclipse Plugins needed for the development with J2ME and also on the Server-side with Hibernate and Spring

    • creating a SVN repository for version control (and for backup reasons )

    • installing the MySQL DB Server (with Administration tools)

What will be done next week?

In the following week I will start developing the application. The first thing will certainly be to create the working environment such as creating a clean Tomcat installation and integrating my project with Spring and Hibernate to be ready for development.

I will also create a first draft of a possible architecture of the application which I will post on the Wiki. Moreover I will start creating a bunch of User stories, model a general XML structure which will be used for communication and I'll start implementing the most essential User stories such as creating a post and retrieving a post. I thought to add the location-stuff later, once the exchanging of the XML documents works fine.



There were no big problems during the experimentation with the different technologies. The only tricky part was to understand how the Spring Application Framework integrates with my application, how it forwards HttpRequests and how it generates and manages Java Beans. Moreover the integration of Hibernate was not that easy, however once done, the Java code for accessing the DB and retrieving objects is much nicer (that was also the reason why I wanted to use Hibernate ).

The parsing of the XML on the mobile client using kXML was also not really simple and straightforward initially since there is just a simple parser available and no DOM model as for example JDom provides.