There are several steps you should do.
1. You need a working Bazaar client - a distributed version control system.
You can download and find instructions how to install it here:
http://bazaar-vcs.org/Download
After you get a working Bazaar initialize the directory where you will branch the wannatrak project. Here is the instruction:
http://doc.bazaar-vcs.org/bzr.dev/en/user-guide/index.html#branching-a-project.
2. From your local repository execute Bazaar branch command to get wannatrak project:(Optional) Read Bazaar docs to ensure you understand how it works.
http://bazaar-vcs.org/Documentation
bzr branch http://bzr.wannatrak.org/main
3. Configure Maven - a project management tool that builds and deploys Wannatrak application.
Using link below you can find detailed instructions on how to install it: http://maven.apache.org/download.html
To make maven work and to ease its usage create
M2_HOMEandM2environment variables. Also add maven dir toPATH. You can read how to do it at the bottom of the page: http://maven.apache.org/download.html
4. Install DBMS PostgreSQL 8.3. Here are the instructions:
http://www.postgresql.org/download/
5. You need JBoss 4.2.3 Application Server. You can download it from developers site: http://jboss.org/jbossas/downloads/
or right away from SourceForge: http://sourceforge.net/projects/jboss/files/JBoss/JBoss-4.2.3.GA/
To install unzip it, for example to the
c:\JBosses\JBoss-4.2.3.GA
Add new environment variable
WT_JBOSS_HOMEwith the JBoss installation path value. As in the example above it can bec:\JBosses\JBoss-4.2.3.GA
6. (Optional) In order to develop mobile Java application you need to install WTK 2.5.2. All necessary information you can find here:
http://www.j2ee.me/products/sjwtoolkit/download.html
Add new environment variable WTK_HOME with the WTK installation path value.
If you have installed and configured programs described in part I, you can deploy Wannatrak project with maven.
1. First of all you need to initialize PostgreSQL database, load demonstration data if need and init JBoss (copy libs).
Execute this command from the root of the project to initialize wannatrak:mvn install -P InitDB,LoadDemo,InitJBoss
<properties>
<db.url>jdbc:postgresql://127.0.0.1</db.url>
<db.driver>org.postgresql.Driver</db.driver>
<db.type>PostgreSQL 8.3</db.type>
<db.username>postgres</db.username>
<db.password>postgres</db.password>
<db.name>wannatrak</db.name>
...
</properties>
-D key as shown below (keep in mind they are case sensitive):mvn install -Ddb.username=myname -Ddb.password=1234
mvn install -P InitDB,LoadDemo,InitJBoss -Ddb.username=myname -Ddb.password=1234
2. Build the Wannatrak.
Executemvn install command that builds project - middleware and device. If you want to rebuild project:
mvn clean install
There are some profiles for building wannatrak project:
WithClient- web interface based on GWT.
WithClientAndJ2ME- includes client and mobile modules.
Deploy2JBoss- copies middleware, device and client to JBoss
You can combine any of these profiles according to what you need, for example to update mobile client and deploy to JBoss, use this command:
UpdateJ2MEInClient- copies last mobile Jar and Jad files to client/war/download.
mvn clean install -P UpdateJ2MEInClient,Deploy2JBoss
3. It's time to run the project.
Check whether PostgreSQL service started.
Launch JBoss.
Open link below in your browser (be sure firewall doesn't block 8080 port): http://localhost:8080
Login to post GPS data to Wannatrak server.
You'll receive the DEVICE_KEY on successful login.
You'll use this DEVICE_KEY for further interactions with server as your unique identifier.
If you login for the first time and you don't have previous tracks on the server there will be created a new one with your login name.
If you already have tracks then you will be linked to the last used track. Your GPS data will be attached to it.
To find out a name of your current track call Get track info.
To see your existing tracks use Get list of existing tracks.
If you want to post data to a new track, first of all, Create new track.
To switch to one of existing tracks use Continue existing track.
Request:
POST /device/api/login HTTP/1.1
Content-Type: text/json
{"login":"LOGIN","password":"PASSWORD"}
Response:
HTTP/1.1 200 OK Content-Type: */* %DEVICE_KEY%
Request:
POST /device/api/login HTTP/1.1
Content-Type: text/json
{"login":"WRONG LOGIN","password":"WRONG PASSWORD"}
Response:
HTTP/1.1 403 Forbidden
Request:
POST /device/api/logout HTTP/1.1 Content-Type: text/json %DEVICE_KEY%
Response:
HTTP/1.1 204 No Content
Request:
POST /device/api/logout HTTP/1.1 Content-Type: text/json %WRONG_DEVICE_KEY%
Response:
HTTP/1.1 400 Bad Request
Request:
POST /device/api/trak/%DEVICE_KEY% HTTP/1.1 Content-Type: text/json [[Timestamp,Longitude,Latitude,Speed,Course,Altitude],[Timestamp,Longitude,Latitude,Speed,Course,Altitude], ...]
Timestamp- integer number of millis since 1/1/1970
Longitude,LatitudeandCourse- float degrees
Speed- float number of kilometers per hour
Example on js:
Altitude- float number of meters above sea level
1 var http = new XMLHttpRequest();
2 http.open("POST", "http://www.wannatrak.com/device/api/trak/%DEVICE_KEY%", true);
3 var params = '[[127000000,2.5,3.4,4,5,6],[127000001,2.4,3.5,4,5,6]]';
4 http.setRequestHeader("Content-type", "text/json");
5 http.setRequestHeader("Content-length", params.length);
6 http.setRequestHeader("Connection", "close");
7 http.onreadystatechange = function() {
8 if(http.readyState == 4 && http.status == 200) {
9 alert(http.responseText);
10 }
11 }
12 http.send(params);
Response:
HTTP/1.1 204 No Content
Response:
HTTP/1.1 400 Bad Request
sendPeriod elapsed server will reject your track.¶Response:
HTTP/1.1 409 Conflict
Read more about sendPeriod here.
Request:
GET /device/api/trak/create/%DEVICE_KEY%/%TRACK_NAME% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 200 OK
Content-Type: text/json
{"id":"%TRACK_ID%","name":"Track name"}
Response:
HTTP/1.1 400 Bad Request
Request:
GET /device/api/trak/list/%DEVICE_KEY% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 200 OK
Content-Type: text/json
[{"id":"%TRACK_ID%","name":"Track name"}, {"id":"%TRACK_ID_2%","name":"Track name 2"}, ...]
Response:
HTTP/1.1 400 Bad Request
Request:
GET /device/api/trak/continue/%DEVICE_KEY%/%TRACK_ID% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 200 OK Content-Type: */* %NEW_DEVICE_KEY%
Response:
HTTP/1.1 400 Bad Request
Request:
GET /device/api/trak/get/%DEVICE_KEY% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 200 OK
Content-Type: text/json
{"id":"%TRACK_ID%","name":"Track name"}
Response:
HTTP/1.1 400 Bad Request
Request:
GET /device/api/trak/settings/%DEVICE_KEY% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 200 OK
Content-Type: text/json
{"savePeriod":5,"sendPeriod":5,"name":"Track name"}
savePeriod- seconds between points in track
sendPeriod- minutes between sending part of track to server
Warning! If you try to send track before sendPeriod elapsed server will reject your track.
Response:
HTTP/1.1 400 Bad Request
Request:
POST /device/api/trak/settings/%DEVICE_KEY% HTTP/1.1
Content-Type: text/json
{"savePeriod":1,"sendPeriod":2,"name":"New track"}
savePeriod- seconds between points in track
sendPeriod- minutes between sending part of track to server
Warning! If you try to send track before sendPeriod elapsed server will reject your track.
Response:
HTTP/1.1 204 No Content
Response:
HTTP/1.1 400 Bad Request
Response:
HTTP/1.1 409 Conflict
Request:
GET /device/api/trak/%DEVICE_KEY%/%TRACK_ID%/%FROM%/%TO%/%WITH_NOISE% HTTP/1.1 Accept: text/json
FROM- start time in milliseconds since Jan 1 1970
TO- end time in milliseconds since Jan 1 1970
WITH_NOISE- include noise movements in track (true/false)
Number of returned points is limited to 4000.
GET /device/api/trak/%DEVICE_KEY%/%TRACK_ID%/%WITH_NOISE% HTTP/1.1 Accept: text/json
From Jan 1 1970 to now
Response:
HTTP/1.1 200 OK Content-Type: text/json [[Timestamp,Longitude,Latitude,Speed,Course,Altitude],[Timestamp,Longitude,Latitude,Speed,Course,Altitude], ...]
Request:
DELETE /device/api/trak/remove/%DEVICE_KEY%/%TRACK_ID% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 204 No Content
Request:
DELETE /device/api/trak/remove/%WRONG_DEVICE_KEY%/%TRACK_ID% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 400 Bad Request