ngsi-client

NGSI v1 API server and client library

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.orange.fiware
ArtifactId

ArtifactId

ngsi-client
Last Version

Last Version

0.1.3
Release Date

Release Date

Type

Type

jar
Description

Description

ngsi-client
NGSI v1 API server and client library
Project Organization

Project Organization

Orange

Download ngsi-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.orange.fiware/ngsi-client/ -->
<dependency>
    <groupId>com.orange.fiware</groupId>
    <artifactId>ngsi-client</artifactId>
    <version>0.1.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.orange.fiware/ngsi-client/
implementation 'com.orange.fiware:ngsi-client:0.1.3'
// https://jarcasting.com/artifacts/com.orange.fiware/ngsi-client/
implementation ("com.orange.fiware:ngsi-client:0.1.3")
'com.orange.fiware:ngsi-client:jar:0.1.3'
<dependency org="com.orange.fiware" name="ngsi-client" rev="0.1.3">
  <artifact name="ngsi-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.orange.fiware', module='ngsi-client', version='0.1.3')
)
libraryDependencies += "com.orange.fiware" % "ngsi-client" % "0.1.3"
[com.orange.fiware/ngsi-client "0.1.3"]

Dependencies

compile (13)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-annotations jar 2.6.4
org.apache.httpcomponents : httpclient jar 4.4.1
org.apache.httpcomponents : httpasyncclient jar 4.1
org.springframework : spring-context jar 4.1.6.RELEASE
org.springframework : spring-web jar 4.1.6.RELEASE
org.springframework : spring-webmvc jar 4.1.6.RELEASE
org.slf4j : slf4j-api jar 1.7.7
ch.qos.logback : logback-classic jar 1.1.2
ch.qos.logback : logback-core jar 1.1.2
javax.inject : javax.inject jar 1
com.fasterxml.jackson.core : jackson-databind jar 2.6.4
com.fasterxml.jackson.dataformat : jackson-dataformat-xml jar 2.6.4
org.codehaus.woodstox : woodstox-core-asl jar 4.4.1

provided (1)

Group / Artifact Type Version
javax.servlet : servlet-api jar 2.5

Project Modules

There are no modules declared in this project.

FIWARE NGSI v1 API

Build Status Coverity Scan Status Coverage Status Client Doc Server Doc Apache Version 2 Licence

This project is the library of the NGSI v1 API

This library was originally created for the Fiware-Cepheus project and the original version is still available here under the GPLv2 Licence.

A library implementing NGSI v2 API can be found at Orange-OpenSource/fiware-ngsi2-api

Usage

From Maven

<dependency>
    <groupId>com.orange.fiware</groupId>
    <artifactId>ngsi-client</artifactId>
    <version>X.Y.Z</version>
</dependency>
<dependency>
    <groupId>com.orange.fiware</groupId>
    <artifactId>ngsi-server</artifactId>
    <version>X.Y.Z</version>
</dependency>

For java 7, you must add the classifier:

<dependency>
   <groupId>com.orange.fiware</groupId>
   <artifactId>ngsi-client</artifactId>
   <classifier>java7</classifier>
    <version>X.Y.Z</version>
</dependency>
<dependency>
   <groupId>com.orange.fiware</groupId>
   <artifactId>ngsi-server</artifactId>
   <classifier>java7</classifier>
    <version>X.Y.Z</version>
</dependency>

where X.Y.Z is the version of the library to use (check git tags).

Download the jar from Sonatype Central repository using wget

If you don't have maven installed on your machine, you can still download the standalone JAR using wget or any browser:

wget -O ngsi-client.jar "https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=com.orange.fiware&a=ngsi-client&v=LATEST"
wget -O ngsi-server.jar "https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=com.orange.fiware&a=ngsi-server&v=LATEST"

Client

The implementation provides the NgsiClient class for the standard operations and the NgsiRestClient` class for the convenient REST operations.

The client uses ListenableFuture to handle requests synchronously or asynchronously.

Example: to send a synchronous updateContext

    @Autowired
    NgsiClient ngsiClient;

    /* [...] */

    UpdateContext update = new UpdateContext();
    // [...] add context information

    ngsiClient.updateContext(providerUrl, httpHeaders, update).get();

Example: to send an asynchronous updateContext

    ngsiClient.updateContext(brokerUrl, httpHeaders, update)
              .addCallback(updateContextResponse -> logUpdateContextResponse(updateContextResponse, brokerUrl),
                       throwable -> logger.warn("UpdateContext failed for {}", brokerUrl, throwable));

Server

The implementation provides the NgsiBaseController class that is a controller class for the standard operations and the NgsiRestBaseController class used for the convenient REST operations. The two classes validate the specification rules and return errors if an exception is thrown.

Your controller class must override the methods you want to implement. By default the methods return an error "not implemented operation".

    public class MyNgsiController extends NgsiBaseController {
        @Override
        public UpdateContextResponse updateContext(final UpdateContext update) throws Exception {
            // implement updateContext
        }
    }

and

    public class NgsiRestController extends NgsiRestBaseController {
        @Override
        protected AppendContextElementResponse appendContextElement(String entityID, AppendContextElement appendContextElement) throws Exception {
                    // implement appendContextElement
        }
    }

License

This project is under the Apache License version 2.0

com.orange.fiware

Orange

Open Source by Orange

Versions

Version
0.1.3
0.1.2
0.1.1
0.1.0
0.0.3
0.0.2
0.0.1