You are here: 52°North>Wiki>Projects Web>Android>GeoAR>GeoARCodebase (17 Jan 2013, HolgerHopmann)Edit Attach

GeoAR Codebase

The GeoAR codebase is an online storage system for extensions/plugins to be used within the augmented reality client software GeoAR. Currently it supports the download of GeoAR data sources (see also GeoARDatasource) based on Android packages (APK files). The codebase provides methods to list available resources, inspect single resources, upload new resources, and update/change the binary file and metadata of a resource.

Features

  • RESTful service interface
    • Retrieve resource listing
    • Retrieve resource descriptions
    • Retrieve resource file
    • Upload resource
    • Update resource
  • HTML, plain text, and JSON response formats
  • Content negotiation with HTTP Accept headers

Example Deployment

An online deployment of a GeoAR Codebase can be found here: http://geoviqua.dev.52north.org/geoar/

Using the Codebase

Server Installation

The installation of a GeoAR Codebase requires the following steps:
  1. Check out source code
    See below for instructions.
  2. Configure properties
    • Open the file pom.xml and set the following properties according to your setup:
[...]
<service.url>http://localhost:8080</service.url>
<service.path>/geoar</service.path>
[...]
<finalName>geoar</finalName>
[...]
    • Open.../src/main/java/resources/codebase.properties with a text editor and set respectively change all required parameters, see Configuration.
    • Adjust the config parameters in the file .../src/main/webapp/WEB-INF/web.xml to your needs, see Configuration.
  1. Run mvn clean package.
  2. Deploy the created web application archive (WAR file) into your Tomcat.
  3. Browse to the welcome page.

Configuration

codebase.properties

  • uploadToken: The token is used to allow upload of new and changes to existing resources, see also section Authentication and Upload. Default value is maven property conf.geoar.codebase.uploadToken.

web.xml

The web.xml is the generic configuration file for the webapp, but also allows the configuration of context parameters, which are used for variables that must be accessed from JSP files.

Context parameters for GeoAR Codebase
  • serviceUrl: This parameter is used in the JSP file content.jsp to load the correct base URL for the service and to create correct example links on the website, and (most importantly) in the application ( InfoResource.java) to generate the download links. Example value for local testing: http://localhost:8080/geoar
  • codebasePath: Default and suggested not to change: codebase
  • serviceInfo: Short description of the service, which is included in the responses to describe the source of the information. Change this to a suitable description to your own deployment. Example: Codebase for 52°North GeoAR Augmented Reality Application

Source Code

You can check out the source code from the 52°North Subversion repository:

https://svn.52north.org/svn/geostatistics/main/geoviqua/52n-geoar-codebase/

The SVN follows the typical trunk/branch/tag layout, details here. As of writing this tutorial, all development happens within the trunk.

Browse the code here.

Authentication and Upload

Authentication is handled using simple tokens appended to the query part of the URL.

URL: http://server.url/<webapp_name>/codebase?token=<token_goes_here>

The tokens are stored in the file codebase.properties. Currently there is only one token, uploadToken, which allows users to upload new resources to the codebase listing endpoint and to edit existing resources on the resource view endpoint. For defining tokens we strongly recommend using long and arbitrary text, for example from here.

Upload a new Resource

You can also overwrite exsiting resources with this form. Upload uses a regular HTTP POST request, so you can also implement upload with an arbitrary client (not just the HTML form below).

codebase_screenshot_03_-_upload_listing.PNG

URL Patterns and Response Examples

Landing Page

URL: http://server.url/<webapp_ name>/

Example: http://geoviqua.dev.52north.org/geoar/

HTML Response

codebase_screenshot_01.PNG

Codebase Listing

The contents of the codepage, i.e. an index file.

URL: http://server.url/<webapp name>/codebase/

Example: http://geoviqua.dev.52north.org/geoar/codebase

HTML Response

codebase_screenshot_02_-_HTML_listing.PNG

JSON Response

The JSON response is very similar to the index file. It contains a list of datasources, which are the resources. There is also a description text field.
{
   "datasources": [
      {
         "description": "just another one", 
         "downloadLink": "http://geoviqua.dev.52north.org/geoar/codebase/test/apk", 
         "id": "test", 
         "imageLink": "http://52north.org/templates/52n/images/52n-logo.gif", 
         "name": "Small test", 
         "platform": "2.3", 
         "version": 1
      }, 
      {
         "description": "For testing only, if a apk is recognized by Android...", 
         "downloadLink": "http://geoviqua.dev.52north.org/geoar/codebase/noisedroidsigned/apk", 
         "id": "noisedroidsigned", 
         "imageLink": "http://www.opennoisemap.org/images/noiseDroid.png", 
         "name": "Noise Droid App", 
         "platform": "2.3", 
         "version": 1
      }
   ], 
   "service": "Codebase for 52&#176;North GeoAR Augmented Reality Application"
}

Plain Text Response

Codebase for 52&#176;North GeoAR Augmented Reality Application


Small test
==========
Id: test
Description: just another one
Download: http://geoviqua.dev.52north.org/geoar/codebase/test/apk
Image: http://52north.org/templates/52n/images/52n-logo.gif

Noise Droid App
===============
Id: noisedroidsigned
Description: For testing only, if a apk is recognized by Android...
Download: http://geoviqua.dev.52north.org/geoar/codebase/noisedroidsigned/apk
Image: http://www.opennoisemap.org/images/noiseDroid.png

Single Resource

This response hold the description of a single resource and a link to the binary file for download.

URL: http://server.url/<webapp name>/codebase/<resource identifier>

Example: http://geoviqua.dev.52north.org/geoar/codebase/noisedroidsigned

HTML Response

This view is the same as the listing, but with just one element.

If you are authenticated with a token for uploading resources, then the HTML page contains a prepared form to edit the properties of the shown resource. You can upload a new file and leave other fields untouched as well as change only one of the available fields.

codebase_screenshot_04_-_edit_resource.PNG

JSON Response

The JSON format is the same as for the resource listing (see above), just with only a single resource.

Plain Text Response

The plain text format is the same as for the resource listing (see above), just with only a single resource.

Support

If you have a problem, please check the 52°North Geostatistics Community forum and mailing list: http://52north.org/resources/mailing-list-and-forums/ (Forum link in the left hand side menu, mailing list subscription and archive in the center. Please note that forum and mailing list are synchronized!)

If you don't find a solution, take a short look at the guidelines and ask your question - you'll be helped!

Development

Dependencies

GeoAR Codebase uses Apache Maven for all dependency management. However, a short list of libraries that are used is shown below. For a full and updated list please take a look at the POM file: https://svn.52north.org/svn/geostatistics/main/geoviqua/52n-geoar-codebase/trunk/pom.xml

Development Setup

You can check out the source code (see above) right into your Eclipse workspace. Recommended Eclipse extensions are m2e and Subversive.

Version Numbering

Please follow the guidelines of Semantic Versioning (http://semver.org/) for naming new versions.

In addition to that, the project uses the Buildnumber Maven Plugin ( buildnumber-maven-plugin) for automatically attaching a revision number to each build, e.g. . The current build number is stored in the file .../src/main/config/buildNumber.properties.

Persistent Storage

At the time of writing this tutorial, GeoAR Codebase does not use any database but utilizes a manual approach.

Uploaded resources (the code binaries) are stored in the folder .../<webabb_name>/codebase/ on the server.

The resource metadata are stored in the file .../src/main/java/resources/datasources.json in the source, and in the file .../.../datasources.json on the server.

Only resources with both metadata information and binary resource file are listed/accessible!

It is possible to add new resources by editing the index file manually and store the correctly named source binary in the resource folder, however it is recommended to use the upload form or the REST interface to be sure everything is properly tested.

Resource Attributes

  • id: Identifier of the resource. This must be tha same as the name of the APK file in the codebase directory.
  • name: Name of the resource.
  • description: Human-readable short desription of the resource.
  • imageLink: Descriptive picture to show in resource listings.
  • version: Version of the resource, can be used to detect in a client if a new version of a plugin is available.
  • platform: The minimal Android platform version number.

Tasks

  • Add "Delete" button to a single resource HTML rendering
  • Add image upload (storing the image on the server and putting a link to that file in the resource description)
  • Change persistent storage to simple (file) database
  • Content negotiation change to extension (.json, .xml, .txt), especially .apk and .png (just a Restlet setting!!)
  • ...

Metadata

  • Topic created by: DanielNuest
  • Topic created on: 2012-06-20
Topic revision: r6 - 17 Jan 2013 12:01:04, HolgerHopmann
This site is powered by FoswikiCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Wiki? Send feedback