Guide for Extensions

3 Testbed Provider Services (Testbed to FIESTA-IoT)

3.3 TPS Implementation (Wildfly Container)

A TPS instance may be implemented in any language and or environment the Testbed provider chooses to as long as it follows the above API as a REST web service. Shall you choose to implement it in Java we provide a skeleton Java project in order to help you bootstrap the process. Information where this project can be found and to be used is provided in the following sections.



Code Availability and Structure

The Testbed Provider Interface components are offered at FIESTA-IoT GitHub repository, and more specifically under the testbed.tpi repository. The latest version of the components are under the “develop branch”.

The project is divided into two main packages. The “eu.fiestaiot.tpi.api.tps.rest” and “eu.fiestaiot.tpi.api.tps.impl.dataservices”:

1) eu.fiestaiot.tpi.api.tps.rest

Within this package, the “TpiApiTestbedProviderServices.java”[1]  class can be found which is the entry point for the Services described at the TPS API above.

The two main methods of interest are:

  • public Response getLastObservations(String getLastObservationsPayload)
  • public Response getObservations(String getObservationsPayload)
  • public Response pushLastObservations(String pushLastObservationsPayload)
  • public Response stopPushOfObservations(String stopPushOfObservationsPayload)

These methods analyse the payload and forwards it to the implementation of them, which resides in the following package.

2) eu.fiestaiot.tpi.api.tps.impl.dataservices

In this package, we have a list of the implementations classes of the different web services exposed from the TPS instance. The Testbed provider needs to implement at least one of themthem (or two of them in the case of pushLastObservations since it needs the stopPushOfObservations as well). The two four classes are:

• GetLastObservationsImpl.java GetLastObservationsImpl.java [2]
• GetObservationsImpl.java GetObservationsImpl.java [3]
• PushLastObservationsImpl.java [4]
• StopPushOfObservationsImpl.java [5]



Push Observations Implementation Details

In order to enable the option of a Testbed to push its observations, FIESTA-IoT platform is exposing an interface that accept various annotated document types which that is called “pushObservationsStreamProxy”. The endpoint URI of the “pushObservationsStreamProxy” is received within the payload of “pushLastObservations” as shown at the TPS API description above. As soon as the testbed has new data (or based on a specific schedule defined by the testbed) from the “pushLastObservations” received sensor ID list it should send the annotated measurements within the body of the message and the document type as the header of the message. An example endpoint would be: https://{{domain}}/tpi.api.dms/rest/dataservices/pushObservationsStreamProxy

And the header should contain:

• Content-Type: DocumentType (for example: application/rdf+xml)
• iPlanetDirectoryPro : {{UserCookie}}


The accepted content types (Content-Type) are:

• application/ld+json
• application/n-quads
• application/n-triples
• application/n3
• application/rdf+json
• application/rdf+thrift
• application/rdf+xml
• application/trig
• application/trix
• application/trix+xml
• application/turtle
• application/x-trig
• application/x-turtle
• null/rdf
• text/csv
• text/n-quads
• text/n3
• text/nquads
• text/plain
• text/rdf+n3
• text/trig
• text/turtle

The UserCookie SHOULD be generated by using the credentials of the user as described above (3.3.2 Invoking the OpenAM Authentication API to obtain a SSO token). For Example by sending as a header the Username and Password:

  • X-OpenAM-Username : UserX
  • X-OpenAM-Password : PasswordOfUserX

To the following URL:

  • http://{{domain}}:8090/openam/json/authenticate

System Requirements

The TPS component described above is deployed within a WildFly container and is using Maven as project management.

The prototype runs on Windows, Linux, Mac OS X, and Solaris. In order to run the prototype, you need to ensure that Java 8 and WildFly are installed and/or available on your system. In order to build the prototype you will also need Maven. Before attempting to deploy and run the prototype applications, make sure that you have started WildFly. More details about the specific versions of the tools and libraries that have been used for the development or that are required for the deployment and execution of the prototypes are given in the section below.



Install & Run

The prototype has been implemented as a Maven-based web application. Below WILDFLY_HOME indicates the root directory of the WildFly distribution, and PROJECT_HOME indicates the root directory of the project (tpi.api.tps).

In order to build the prototype, run the following command in PROJECT_HOME:
mvn clean package

Finally, in order to deploy the prototype, run the following command in PROJECT_HOME:
mvn wildfly:deploy

The last step assumes that WildFly is already running on the machine where you run the command.

The produced, from the build process above (mvn clean package), project can be found within PROJECT_HOME/target/ folder and is the tpi.api.tps.war file. Alternatively copy the produced (from the build process above) tpi.api.tps.war file from the target directory (PROJECT_HOME/target/), into the WILDFLY_HOME/standalone/deployments directory of the WildFly distribution, in order to be automatically deployed.

If the deployment has been successfully completed, the implemented web services described in the section above will be exposed under the following URLs:

• http://[HOST]:[PORT]/tpi.api.tps/rest/tps/getLastObservations
• http://[HOST]:[PORT]/tpi.api.tps/rest/tps/getObservations
• http://[HOST]:[PORT]/tpi.api.tps/rest/tps/pushLastObservations
• http://[HOST]:[PORT]/tpi.api.tps/rest/tps/stopPushOfObservations

where [HOST] is the host and [PORT] the port that WildFly uses.





[1] /tpi.api.tps/src/main/java/eu/fiestaiot/tpi/api/tps/rest/TpiApiTestbedProviderServices.java

[2] /tpi.api.tps/src/main/java/eu/fiestaiot/tpi/api/tps/impl/dataservices/GetLastObservationsImpl.java

[3] /tpi.api.tps/src/main/java/eu/fiestaiot/tpi/api/tps/impl/dataservices/GetObservationsImpl.java

[4] /tpi.api.tps/src/main/java/eu/fiestaiot/tpi/api/tps/impl/dataservices/PushLastObservationsImpl.java

[5] /tpi.api.tps/src/main/java/eu/fiestaiot/tpi/api/tps/impl/dataservices/StopPushOfObservationsImpl.java