Information

Documentation

Get OpenRDK at SourceForge.net. Fast, secure and Free Open Source software downloads

edit SideBar

The HttpManager module

This module implements an HTTP server that exposes the whole repository using standard HTTP/1.1 requests and responses. Thanks to this module, you can access to the repository of an OpenRDK agent using a common browser. The module is able to manage both GET and POST requests, so you can read and write properties.

Properties

  • params
    • serverPort the port where the server listens for connections
    • webPagesDir the directory where the webpages are stored
    • webPagesEnabled if this is set to false, the server does not serve web pages, but only allows to access to the repository
    • webPagesListAllowed pointing your browser to /webpages/ lists the web pages that resides on the server; if this property is set to false, the listing is not allowed

Description

This module starts a very simple web server that exposes the whole repository to HTTP clients. The server listens for connection on port params/serverPort: from now on, we will assume that this port is 8080 (the default).

If the server is on IP 192.168.0.123, it is thus accessible using the URL http://192.168.0.123:8080. This is the homepage of the agent, from which you can go to other pages to see the repository tree and the webpages.

Repository and properties

The repository tree is accessible using the URL http://192.168.0.123:8080/repository: this page shows the whole list of properties. You can click on one of them in order to see its value. In the page with the property value, you can find two links: if you click on [update], the property value will be retrieved again; if you click on [edit], a page with a text box will appear, in which you can enter the new value for the property. This applies only for properties that have a string representation (e.g., booleans, strings, integers, double, but not images and maps).

Webpages

This module also have the option of serving webpages. In order to see the webpages (if the webpages listing is allowed), you have to point your browser to the URL http://192.168.0.123:8080/webpages. Webpages are standard HTML pages, that can contain AJAX code to retrieve and update property values. In ${OpenRDK}/data/config/examples/httpmanager directory, you can find an example webpage, that uses AJAX calls to repeatedly update an integer and an image, without reloading the page.

Protocol

Webpages do not allow for POST requests and webpages can be only of standard HTML. No PHP or other server-side scripting system is allowed. Anyway, you can also embed the HttpManager module in a standard web server (e.g., Apache), using a proxy or relaying configuration.

Requests in the /repository/ virtual directory can use GET or POST methods. For GET methods, you are able to add some parameters, encoding them in the URL in the usual HTTP way. Currently, you can ask for every property value using an URL like this:

  http://192.168.0.123:8080/repository/moduleName/propertyName

In this case (by default) you will receive only the property value (translated into textual representation using the getStringForVisualization() function of the object). If you want a better visualization, you can add the format=html parameter in the request:

  http://192.168.0.123:8080/repository/moduleName/propertyName?format=html

Finally, if you want to edit the property value, you can add the action=edit parameter (that implies the format=html):

  http://192.168.0.123:8080/repository/moduleName/propertyName?action=edit

The small HTML form that appears in this last case is able to send a POST request to the server. The form should contain input boxes that have, as name parameter, the property URL to update. This is an example:

<form method="POST" action="/repository/moduleName/propertyName?format=html">
<input type="text" name="/moduleName/propertyName"/>
<input type="submit" value="Update"/>
</form>

The POST request (the action parameter of the <form> tag) can be sent to every page inside the /repository/ directory (that means /repository/ itself, i.e., the property list, or any other property URL).

© 2004-2009 RoCoCo Laboratory Powered by PmWiki
Edit - History - Printable View - Recent Changes - Search
Page last modified on June 04, 2009, at 02:55 PM