Giter Site home page Giter Site logo

fiware-ngsi-api's Introduction

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

fiware-ngsi-api's People

Contributors

fsuc avatar marcc-orange avatar pascaleborscia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.