diff --git a/doc/historyqueries.md b/doc/historyqueries.md index a2a11287..e0203781 100644 --- a/doc/historyqueries.md +++ b/doc/historyqueries.md @@ -30,6 +30,8 @@ iotbroker_embeddedagent_couchdbprotocol="http" iotbroker_embeddedagent_couchdbhost="127.0.0.1" iotbroker_embeddedagent_couchdbport=5984 iotbroker_embeddedagent_historicallyTrackQueryResponseAndNotifications=false +iotbroker_embeddedagent_storeOnlyLatestValue=false +iotbroker_embeddedagent_localagentid="embeddedagent1" ``` @@ -68,10 +70,14 @@ Body: }] } +``` Reponse: +``` {"errorCode":null,"contextResponses":null} ``` +Another update with a different timestamp + ``` HTTP POST to http://10.0.2.199:8060/ngsi10/updateContext Content-Type:application/json @@ -97,11 +103,15 @@ Body: }] }] } - +``` Response: + +``` {"errorCode":null,"contextResponses":null} ``` +Another update with a different timestamp and different attribute + ``` HTTP POST to http://10.0.2.199:8060/ngsi10/updateContext Content-Type:application/json @@ -127,12 +137,13 @@ Body: }] }] } - +``` Response: +``` {"errorCode":null,"contextResponses":null} ``` -The final update will not contain an explicit timestamp: +The final update does not contain an explicit timestamp: ``` HTTP POST to http://10.0.2.199:8060/ngsi10/updateContext @@ -154,8 +165,9 @@ Body: }] }] } - +``` Response: +``` {"errorCode":null,"contextResponses":null} ``` @@ -187,8 +199,9 @@ Body: }] } } - +``` Response: +``` { "contextResponses": [{ "contextElement": { @@ -253,8 +266,7 @@ Response: } ``` -The second query asks for all entities with attributes *temperature* and *noise*, but this time without specifying a time interval. In this case the IoT Broker will respond with -the list of the latest values matching the query. +The second query asks for all entities with attributes *temperature* and *noise*, but this time without specifying a time interval. In this case the IoT Broker will respond with the list of the latest values matching the query. ``` HTTP POST to http://10.0.2.199:8060/ngsi10/queryContext @@ -270,7 +282,10 @@ Body: "attributes": ["temperature","noise"] } +``` + Response: +``` { "contextResponses": [{ "contextElement": { diff --git a/doc/semanticgrounding.md b/doc/semanticgrounding.md index 6beabfc1..a9987e56 100644 --- a/doc/semanticgrounding.md +++ b/doc/semanticgrounding.md @@ -30,3 +30,321 @@ If not set, the default values in IoTBroker-runner/iotbroker.conf.deafult are * ``` ./setup.sh ``` + +Testing the entity subtype scenario +----------- + + +Assumption for this example: +* IoT Broker is running on localhost on port 8060. +* IoT Broker has the embedded Historical Agent enabled (https://github.com/Aeronbroker/Aeron/blob/master/doc/historyqueries.md#enable-historical-queries). +* All the databases are empty. +* It is used the NGSI ontology developed for the SmartSantander IoT deployment (see https://github.com/Aeronbroker/NECIoTKnowledge/blob/master/NGSI_Sparql_Examples/SmartSantanderNGSI-RDF.owl). + + +First we push data of an entity of type NoiseSensor + +``` +HTTP POST to http://localhost:8060/ngsi10/updateContext +Content-Type:application/json +Accept:application/json + +Body: +{ + "updateAction": "APPEND", + "contextElements": [{ + "entityId": { + "id": "noiseSensor1", + "type": "NoiseSensor", + "isPattern": false + }, + "attributes": [{ + "name": "noiselevel", + "type": "float", + "contextValue": "65", + "metadata": [{ + "name": "units", + "type": "units", + "value": "dB" + }] + }] + }] +} + +``` + +``` +{"errorCode":null,"contextResponses":null} +``` + +And we try to retrieve what has just been stored by using the convenience method for getting all data for all sensors of a certain type (http://docs.iotbrokerngsiinterface.apiary.io/#reference/0/convenience-interaction-with-entity-type/retrieve-all-context-information-about-entities-of-specified-type): + +``` +HTTP GET to http://localhost:8060/ngsi10/contextEntityTypes/NoiseSensor +Accept:application/json +``` +the exact same query can be executed by send a query request (http://docs.iotbrokerngsiinterface.apiary.io/#reference/0/standard-context-query): +``` +HTTP POST to http://localhost:8060/ngsi10/queryContext +Content-Type:application/json +Accept:application/json + +Body: +{ + "entities": [{ + "id": ".*", + "isPattern": true, + "type" : "NoiseSensor" + }] +} + +``` + +The response to both will look like: + +``` +{ + "contextResponses": [{ + "contextElement": { + "entityId": { + "id": "noiseSensor1", + "type": "NoiseSensor", + "isPattern": false + }, + "attributeDomainName": null, + "domainMetadata": [], + "attributes": [{ + "name": "noiselevel", + "type": "float", + "contextValue": "66", + "metadata": [{ + "name": "units", + "type": "units", + "value": "dB" + }] + }] + }, + "statusCode": { + "code": 200, + "reasonPhrase": "OK", + "details": "OK" + } + }] +} + +``` + +Since the ontology we are using is specifying that NoiseSensor is a subclass of Node, with the semantic feature enabled, we can request data of all entity of type Node: + +``` +HTTP GET to http://localhost:8060/ngsi10/contextEntityTypes/Node +Accept:application/json +``` +The response will look like the previous one: + +``` +{ + "contextResponses": [{ + "contextElement": { + "entityId": { + "id": "noiseSensor1", + "type": "NoiseSensor", + "isPattern": false + }, + "attributeDomainName": null, + "domainMetadata": [], + "attributes": [{ + "name": "noiselevel", + "type": "float", + "contextValue": "66", + "metadata": [{ + "name": "units", + "type": "units", + "value": "dB" + }] + }] + }, + "statusCode": { + "code": 200, + "reasonPhrase": "OK", + "details": "OK" + } + }] +} + +``` + +Let's now push data of a different kind of entity, in particual LightSensor which is a subclass of Node as well: + +``` +HTTP POST to http://localhost:8060/ngsi10/updateContext +Content-Type:application/json +Accept:application/json + +Body: +{ + "updateAction": "APPEND", + "contextElements": [{ + "entityId": { + "id": "lightSensor1", + "type": "LightSensor", + "isPattern": false + }, + "attributes": [{ + "name": "lightlevel", + "type": "float", + "contextValue": "4567", + "metadata": [{ + "name": "units", + "type": "units", + "value": "lux" + }] + }] + }] +} + +``` + +``` +{"errorCode":null,"contextResponses":null} +``` + +Let's try to request data only of entity of type LightSensor: + + +``` +HTTP GET to http://localhost:8060/ngsi10/contextEntityTypes/LightSensor +Accept:application/json +``` + +``` +{ + "contextResponses": [{ + "contextElement": { + "entityId": { + "id": "lightSensor1", + "type": "LightSensor", + "isPattern": false + }, + "attributeDomainName": null, + "domainMetadata": [], + "attributes": [{ + "name": "lightlevel", + "type": "float", + "contextValue": "4567", + "metadata": [{ + "name": "units", + "type": "units", + "value": "lux" + }] + }] + }, + "statusCode": { + "code": 200, + "reasonPhrase": "OK", + "details": "OK" + } + }] +} + +``` + +Now only of NoiseSensor again: +``` +HTTP GET to http://localhost:8060/ngsi10/contextEntityTypes/NoiseSensor +Accept:application/json +``` +``` +{ + "contextResponses": [{ + "contextElement": { + "entityId": { + "id": "noiseSensor1", + "type": "NoiseSensor", + "isPattern": false + }, + "attributeDomainName": null, + "domainMetadata": [], + "attributes": [{ + "name": "noiselevel", + "type": "float", + "contextValue": "66", + "metadata": [{ + "name": "units", + "type": "units", + "value": "dB" + }] + }] + }, + "statusCode": { + "code": 200, + "reasonPhrase": "OK", + "details": "OK" + } + }] +} + +``` + +And finally of the superclass Node: + +``` +HTTP GET to http://localhost:8060/ngsi10/contextEntityTypes/Node +Accept:application/json +``` +``` +{ + "contextResponses": [{ + "contextElement": { + "entityId": { + "id": "lightSensor1", + "type": "LightSensor", + "isPattern": false + }, + "attributeDomainName": null, + "domainMetadata": [], + "attributes": [{ + "name": "lightlevel", + "type": "float", + "contextValue": "4567", + "metadata": [{ + "name": "units", + "type": "units", + "value": "lux" + }] + }] + }, + "statusCode": { + "code": 200, + "reasonPhrase": "OK", + "details": "OK" + } + }, { + "contextElement": { + "entityId": { + "id": "noiseSensor1", + "type": "NoiseSensor", + "isPattern": false + }, + "attributeDomainName": null, + "domainMetadata": [], + "attributes": [{ + "name": "noiselevel", + "type": "float", + "contextValue": "66", + "metadata": [{ + "name": "units", + "type": "units", + "value": "dB" + }] + }] + }, + "statusCode": { + "code": 200, + "reasonPhrase": "OK", + "details": "OK" + } + }] +} + +``` diff --git a/doc/userprogrammersguide.md b/doc/userprogrammersguide.md index d138bb6f..3776af92 100644 --- a/doc/userprogrammersguide.md +++ b/doc/userprogrammersguide.md @@ -54,5 +54,8 @@ The IoT Broker is based on the OSGi framework and is composed of a number of dif Importantly, the IoT broker core has a dedicated extension point for custom data retrieval and data processing plugins. Please see [here](https://github.com/Aeronbroker/Aeron/blob/master/doc/extensionpoint.md) for details on how to write custom plugins. +NGSI Emulator +== +The Aeron project is including also a NGSI emulator which allows to easily emulate NGSI components in order to let them interworking with IoT Broker and the ConfMan. The puropose of this emulator is two-fold: testing the IoT Broker functionalities and example of implementation of NGSI players. See: https://github.com/Aeronbroker/Aeron/tree/master/eu.neclab.iotplatform.ngsiemulator diff --git a/docker/README.md b/docker/README.md index 7e18ac1c..1aab85ae 100644 --- a/docker/README.md +++ b/docker/README.md @@ -61,9 +61,9 @@ docker0 Link encap:Ethernet HWaddr 02:42:0e:f6:a6:67 ``` Then we need to instruct postgreSQL to accept requests from this virtual network: ``` -sudo echo -e 'host\tall\tall\t172.17.0.0/24\ttrust' >> /etc/postgresql/9.5/main/pg_hba.conf -sudo sed -i "s/^port/listen_addresses = '\*'\nport/g" /etc/postgresql/9.5/main/postgresql.conf -sudo service postgresql restart +echo -e 'host\tall\tall\t172.17.0.0/24\ttrust' >> /etc/postgresql/9.5/main/pg_hba.conf +sed -i "s/^port/listen_addresses = '\*'\nport/g" /etc/postgresql/9.5/main/postgresql.conf +service postgresql restart ``` Configure **CouchDB**: diff --git a/docker/develop-standalone/dockerfile b/docker/develop-standalone/dockerfile index dbcb6f8e..8dd028dd 100644 --- a/docker/develop-standalone/dockerfile +++ b/docker/develop-standalone/dockerfile @@ -12,7 +12,7 @@ RUN service postgresql start && su -c "psql -d postgres -c \"ALTER USER postgres RUN apt-get install couchdb -y RUN mkdir /var/run/couchdb RUN chown -R couchdb:couchdb /var/run/couchdb -RUN sed -i "s/^bind_address/;bind_address/g" /etc/couchdb/local.ini; sed -i "s/\[httpd\]/\[httpd\]\nbind_address = 0\.0\.0\.0/g" /etc/couchdb/local.ini; cat /etc/couchdb/local.ini +RUN sed -i "s/^bind_address/;bind_address/g" /etc/couchdb/local.ini; sed -i "s/\[httpd\]/\[httpd\]\nbind_address = 0\.0\.0\.0/g" /etc/couchdb/local.ini #install Maven, Java and GIT RUN apt-get update; apt-get install maven default-jdk git -y diff --git a/eu.neclab.iotplatform.iotbroker.client/src/main/java/eu/neclab/iotplatform/iotbroker/client/HttpConnectionClient.java b/eu.neclab.iotplatform.iotbroker.client/src/main/java/eu/neclab/iotplatform/iotbroker/client/HttpConnectionClient.java index 4ac3ca3f..2496bcc3 100644 --- a/eu.neclab.iotplatform.iotbroker.client/src/main/java/eu/neclab/iotplatform/iotbroker/client/HttpConnectionClient.java +++ b/eu.neclab.iotplatform.iotbroker.client/src/main/java/eu/neclab/iotplatform/iotbroker/client/HttpConnectionClient.java @@ -211,7 +211,9 @@ public String initializeConnection(URL url, String resource, String method, // logger.info("URL" + url + resource); - logger.info("Starting connection with: " + url + resource); + if (logger.isDebugEnabled()) { + logger.debug("Starting connection with: " + url + resource); + } // logger.info("Send the QUERY!"); @@ -236,7 +238,9 @@ public String initializeConnection(URL url, String resource, String method, } else { // connect using JSON message body - logger.info("Starting connection with: " + url + resource); + if (logger.isDebugEnabled()) { + logger.debug("Starting connection with: " + url + resource); + } // get the OutputStram form the connection os = connection.getOutputStream(); @@ -272,8 +276,11 @@ public String initializeConnection(URL url, String resource, String method, } } - logger.info("Output Stream to " + url + resource + " : " - + os.toString()); + + if (logger.isDebugEnabled()) { + logger.debug("Output Stream to " + url + resource + " : " + + os.toString()); + } // send Message os.flush(); @@ -290,7 +297,9 @@ public String initializeConnection(URL url, String resource, String method, is.close(); - logger.info("------------->Response = " + resp); + if (logger.isDebugEnabled()) { + logger.debug("Response = " + resp); + } if (connection.getResponseCode() == 415) { @@ -369,36 +378,14 @@ public String initializeUpdateContextConnectionToOrion(URL url, * "720" } ] } ], "updateAction": "APPEND" } */ - // List contextElementsForOrion = new - // ArrayList(); - // for (ContextElement contextElement : request.getContextElement()) { - // - // // List contextAttributesForOrion = new - // // ArrayList(); - // // for (ContextAttribute contextAttribute : contextElement - // // .getContextAttributeList()) { - // // - // // ContextAttribute contextAttributeForOrion = new ContextAttribute( - // // contextAttribute.getName(), contextAttribute.getType(), - // // contextAttribute.getContextValue()); - // // contextAttributesForOrion.add(contextAttributeForOrion); - // // - // // } - // - // ContextElement contextElementForOrion = new ContextElement( - // contextElement.getEntityId(), null, - // contextElement.getContextAttributeList(), null); - // contextElementsForOrion.add(contextElementForOrion); - // } - // UpdateContextRequest orionUpdateContextRequest = new - // UpdateContextRequest( - // contextElementsForOrion, request.getUpdateAction()); - UpdateContextRequest_OrionCustomization orionUpdateContextRequest = new UpdateContextRequest_OrionCustomization( request); - logger.info("Translating UpdateContextRequest :" - + request.toJsonString() + " to the Orion Customization:" - + orionUpdateContextRequest.toJsonString()); + + if (logger.isDebugEnabled()) { + logger.debug("Translating UpdateContextRequest :" + + request.toJsonString() + " to the Orion Customization:" + + orionUpdateContextRequest.toJsonString()); + } try { @@ -418,36 +405,12 @@ public String initializeUpdateContextConnectionToOrion(URL url, String string = ((NgsiStructure) orionUpdateContextRequest) .toJsonString(); - // string = string.replaceAll("contextValue", "value"); - - // // The first is for deleting if it is followed by a comma (other - // // fields next to it) - // string = string.replaceAll(".attributeDomainName.:\\[.*?\\],", - // ""); - // // The second is for deleting if it is followed by the bracket - // (end - // // of the structure) - // string = string.replaceAll(".attributeDomainName.:\\[.*?\\]}", - // "}"); - // - // // The first is for deleting if it is followed by a comma (other - // // fields next to it) - // string = string.replaceAll(".domainMetadata.:\\[.*?\\],", ""); - // // The second is for deleting if it is followed by the bracket - // (end - // // of the structure) - // string = string.replaceAll(".domainMetadata.:\\[.*?\\]}", "}"); - // - // // The first is for deleting if it is followed by a comma (other - // // fields next to it) - // string = string.replaceAll("\"metadata\"", "\"metadatas\""); - // - // string = this.levelUpEntityId(string); - os.write(string.getBytes(Charset.forName("UTF-8"))); - logger.info("Output Stream to " + url + resource + " : " - + os.toString()); + if (logger.isDebugEnabled()) { + logger.debug("Output Stream to " + url + resource + " : " + + os.toString()); + } // send Message os.flush(); @@ -464,7 +427,9 @@ public String initializeUpdateContextConnectionToOrion(URL url, is.close(); - logger.info("Response from " + url + resource + " : " + resp); + if (logger.isDebugEnabled()) { + logger.debug("Response from " + url + resource + " : " + resp); + } if (connection.getResponseCode() == 415) { @@ -521,42 +486,13 @@ public String initializeUpdateContextConnectionToOrion(URL url, connection.disconnect(); } - logger.info("Connection Closed!"); + if (logger.isDebugEnabled()) { + logger.debug("Connection Closed!"); + } } } - // public static void main(String[] args) { - // // String string = - // "{ \"updateAction\": \"UPDATE\", \"contextElements\": [{ \"entityId\": { \"id\": \"test\", \"isPattern\": false }, \"attributes\": [{ \"name\": \"temp\", \"type\": \"temp\", \"contextValue\": \"43\" }] }], \"contextElements\": [{ \"entityId\": { \"id\": \"test\", \"isPattern\": false }, \"attributes\": [{ \"name\": \"temp\", \"type\": \"temp\", \"contextValue\": \"43\" }] }] }"; - // String string = - // "{\"updateAction\":\"UPDATE\",\"contextElements\":[{\"id\":\"urn:x-iot:smartsantander:1:478\",\"isPattern\":false,\"domainMetadata\":[],\"attributes\":[{\"name\":\"temperature\",\"type\":\"temperature\",\"contextValue\":\"63.51\"}]}]}"; - // - // string = string.replaceAll("contextValue", "value"); - // System.out.println(string); - // - // - // // The first is for deleting if it is followed by a comma (other fields - // next to it) - // string = string.replaceAll(".attributeDomainName.:\\[.*?\\],",""); - // // The second is for deleting if it is followed by the bracket (end of - // the structure) - // string = string.replaceAll(".attributeDomainName.:\\[.*?\\]}","}"); - // - // // The first is for deleting if it is followed by a comma (other fields - // next to it) - // string = string.replaceAll(".domainMetadata.:\\[.*?\\],",""); - // // The second is for deleting if it is followed by the bracket (end of - // the structure) - // string = string.replaceAll(".domainMetadata.:\\[.*?\\]}","}"); - // - // System.out.println(string); - // - // // System.out.println(HttpConnectionClient.levelUpEntityId(string)); - // - // - // } - private String levelUpEntityId(String requestAsJsonString) { String entityIdRegex = "\\\"entityId\\\":(.+?)\\}"; diff --git a/eu.neclab.iotplatform.iotbroker.commons/src/main/java/eu/neclab/iotplatform/iotbroker/commons/FullHttpRequester.java b/eu.neclab.iotplatform.iotbroker.commons/src/main/java/eu/neclab/iotplatform/iotbroker/commons/FullHttpRequester.java index 961a5f86..accf7328 100644 --- a/eu.neclab.iotplatform.iotbroker.commons/src/main/java/eu/neclab/iotplatform/iotbroker/commons/FullHttpRequester.java +++ b/eu.neclab.iotplatform.iotbroker.commons/src/main/java/eu/neclab/iotplatform/iotbroker/commons/FullHttpRequester.java @@ -202,6 +202,11 @@ public static FullHttpResponse sendGet(URL url, String xAuthToken) { connection.getResponseMessage()); if (responseCode > 399) { + + if (logger.isDebugEnabled()) { + logger.debug("\nGET to URL : " + url + + "\nResponse Code : " + responseCode); + } connection.disconnect(); return httpResponse; diff --git a/eu.neclab.iotplatform.iotbroker.commons/src/main/java/eu/neclab/iotplatform/iotbroker/commons/ParseUtils.java b/eu.neclab.iotplatform.iotbroker.commons/src/main/java/eu/neclab/iotplatform/iotbroker/commons/ParseUtils.java new file mode 100644 index 00000000..dfce0ce7 --- /dev/null +++ b/eu.neclab.iotplatform.iotbroker.commons/src/main/java/eu/neclab/iotplatform/iotbroker/commons/ParseUtils.java @@ -0,0 +1,28 @@ +package eu.neclab.iotplatform.iotbroker.commons; + +import org.apache.log4j.Logger; + +public class ParseUtils { + + private static Logger logger = Logger.getLogger(ParseUtils.class); + + public static Integer parseIntOrDefault(Object string, int defaultInt) { + + Integer integer = null; + + if (string != null && string instanceof String) { + try { + integer = Integer.parseInt((String) string); + } catch (NumberFormatException e) { + logger.warn("Input format not valid: " + string + ". " + + e.getCause()); + integer = defaultInt; + } + } else { + integer = defaultInt; + } + + return integer; + + } +} diff --git a/eu.neclab.iotplatform.iotbroker.commons/src/main/java/eu/neclab/iotplatform/iotbroker/commons/Restriction.java b/eu.neclab.iotplatform.iotbroker.commons/src/main/java/eu/neclab/iotplatform/iotbroker/commons/Restriction.java index 2e3e0a86..0e9c9436 100644 --- a/eu.neclab.iotplatform.iotbroker.commons/src/main/java/eu/neclab/iotplatform/iotbroker/commons/Restriction.java +++ b/eu.neclab.iotplatform.iotbroker.commons/src/main/java/eu/neclab/iotplatform/iotbroker/commons/Restriction.java @@ -76,62 +76,6 @@ public class Restriction { private static Logger logger = Logger.getLogger(Restriction.class); private static final XmlFactory xmlFactory = new XmlFactory(); - // /** - // * Modifies a QueryContextResponse instance by applying a restriction to - // it, - // * eliminating all parts of the response that do not match the - // restriction. - // * - // * @param attributeExpr - // * The attribute expression representing the restriction - // * @param response - // * The QueryContextResponse where the restriction is to be - // * applied to. - // * - // * - // */ - // public static void applyRestriction(String attributeExpr, - // QueryContextResponse response) { - // - // // Apply the Restriction - // XPath xpath = XPathFactory.newInstance().newXPath(); - // - // try { - // XPathExpression expr = xpath.compile(attributeExpr); - // - // Document doc = xmlFactory.stringToDocument(response.toString()); - // Object result = expr.evaluate(doc, XPathConstants.NODESET); - // - // NodeList nodes = (NodeList) result; - // - // Iterator i = response - // .getListContextElementResponse().iterator(); - // - // while (i.hasNext()) { - // - // ContextElementResponse contextElresp = i.next(); - // boolean doesNotAppear = true; - // - // for (int j = 0; j < nodes.getLength(); j++) { - // if (contextElresp.getContextElement().getEntityId().getId() - // .equals(nodes.item(j).getTextContent())) { - // - // doesNotAppear = false; - // break; - // } - // } - // - // if (doesNotAppear) { - // i.remove(); // to be tested - // } - // } - // - // } catch (XPathExpressionException e) { - // logger.debug("XPathExpressionException", e); - // } - // - // } - public static List applyRestriction( String attributeExpr, List contextElementResponseList) { @@ -255,170 +199,4 @@ public static NotifyContextRequest applyRestriction( return filteredNotifyContextRequest; } -// public static List applyOnValueRestriction( -// List contextElementResponseList, -// String onValueAttributeExpr) { -// List filteredContextElementResponseList = new ArrayList(); -// -// for (ContextElementResponse contextElementResponse : contextElementResponseList) { -// -// ContextElementResponse filteredContextElementResponse = Restriction -// .applyOnValueRestriction(contextElementResponse, -// onValueAttributeExpr); -// -// if (filteredContextElementResponse != null) { -// filteredContextElementResponseList -// .add(filteredContextElementResponse); -// } -// -// } -// -// return filteredContextElementResponseList; -// -// } -// -// public static ContextElementResponse applyOnValueRestriction( -// ContextElementResponse contextElementResponse, -// String onValueAttributeExpr) { -// -// /* -// * Creating the new ContextElementResponse that will contain the -// * filtered ContextAttribute. The other fields will remain unchanged. -// */ -// ContextElementResponse filteredContextElementResponse = new ContextElementResponse( -// new ContextElement(contextElementResponse.getContextElement() -// .getEntityId(), contextElementResponse -// .getContextElement().getAttributeDomainName(), null, -// contextElementResponse.getContextElement() -// .getDomainMetadata()), -// contextElementResponse.getStatusCode()); -// -// // Filter out context attributes -// List filteredContextAttributeList = Restriction -// .applyOnValueRestriction(onValueAttributeExpr, -// contextElementResponse.getContextElement() -// .getContextAttributeList()); -// -// if (filteredContextAttributeList == null -// || filteredContextAttributeList.isEmpty()) { -// return null; -// } -// -// // Set the new context attribute -// filteredContextElementResponse.getContextElement() -// .setContextAttributeList(filteredContextAttributeList); -// -// return filteredContextElementResponse; -// -// } -// -// public static List applyOnValueRestriction( -// String onValueAttributeExpr, -// List contextAttributeList) { -// -// List filteredContextAttributeList = new ArrayList(); -// -// /* -// * Here we create a dummy ContextElement meant to contain the -// * ContextAttributeList. With this approach we need to apply the XPATH -// * only once for the full list of contextAttribute -// */ -// ContextElement contextElement = new ContextElement(); -// -// contextElement.setContextAttributeList(contextAttributeList); -// -// // Apply the Restriction -// XPath xpath = XPathFactory.newInstance().newXPath(); -// -// try { -// -// /* -// * Here we extract which attributes need to be extract from the -// * attributeExpression -// */ -// Set attributeToFilterSet = new HashSet(); -// Pattern pattern = Pattern -// .compile("name=[',\",\\\"](.*?)[',\",\\\"]"); -// Matcher matcher = pattern.matcher(onValueAttributeExpr); -// while (matcher.find()) { -// attributeToFilterSet.add(matcher.group(1)); -// } -// -// /* -// * Now we apply the XPATH -// */ -// XPathExpression expr = xpath.compile(onValueAttributeExpr); -// -// Document doc = xmlFactory.stringToDocument(contextElement -// .toString()); -// NodeList nodes = (NodeList) expr.evaluate(doc, -// XPathConstants.NODESET); -// -// Set selectedAttributes = new HashSet(); -// -// for (int j = 0; j < nodes.getLength(); j++) { -// -// NodeList childNodes = nodes.item(j).getChildNodes(); -// -// String attributeName = null; -// String attributeValue = null; -// -// for (int i = 0; i < childNodes.getLength(); i++) { -// if ("name".equalsIgnoreCase(childNodes.item(i) -// .getNodeName())) { -// -// attributeName = childNodes.item(i).getTextContent(); -// -// } else if ("contextValue".equalsIgnoreCase(childNodes.item( -// i).getNodeName())) { -// -// attributeValue = childNodes.item(i).getTextContent(); -// -// } -// -// if (attributeName != null && attributeValue != null) { -// selectedAttributes.add(attributeName + ":::::" -// + attributeValue); -// break; -// } -// } -// -// } -// -// for (ContextAttribute contextAttribute : contextElement -// .getContextAttributeList()) { -// -// /* -// * If the ContextAttribute is not in the attribute set to be -// * filtered add it. If it is in the attribute set to be filtered -// * then check if it is one of the selected ones -// */ -// if (!attributeToFilterSet.contains(contextAttribute.getName()) -// || selectedAttributes.contains(contextAttribute -// .getName() -// + ":::::" -// + contextAttribute.getContextValue())) { -// filteredContextAttributeList.add(contextAttribute); -// } -// -// } -// -// } catch (XPathExpressionException e) { -// logger.debug("XPathExpressionException", e); -// } -// -// return filteredContextAttributeList; -// -// } - -// public static void main(String[] args) { -// String mydata = "//contextAttribute[name='noise'][contextValue>68]|//contextAttribute[name=\"temperature\"][contextValue>68]"; -// Pattern pattern = Pattern.compile("name=[',\",\\\"](.*?)[',\",\\\"]"); -// Matcher matcher = pattern.matcher(mydata); -// while (matcher.find()) { -// System.out.println(matcher.group(1)); -// -// } -// -// } } diff --git a/eu.neclab.iotplatform.iotbroker.core/src/main/java/eu/neclab/iotplatform/iotbroker/core/IotBrokerCore.java b/eu.neclab.iotplatform.iotbroker.core/src/main/java/eu/neclab/iotplatform/iotbroker/core/IotBrokerCore.java index ca8bb7d7..93d3d1cd 100644 --- a/eu.neclab.iotplatform.iotbroker.core/src/main/java/eu/neclab/iotplatform/iotbroker/core/IotBrokerCore.java +++ b/eu.neclab.iotplatform.iotbroker.core/src/main/java/eu/neclab/iotplatform/iotbroker/core/IotBrokerCore.java @@ -679,7 +679,7 @@ public QueryContextResponse queryContext(QueryContextRequest request) { embeddedAgentContextRegistrations = embeddedIoTAgent .extractOwnContextRegistrations(discoveryResponse); - + } /* diff --git a/eu.neclab.iotplatform.iotbroker.core/src/main/java/eu/neclab/iotplatform/iotbroker/core/subscription/ConfManWrapper.java b/eu.neclab.iotplatform.iotbroker.core/src/main/java/eu/neclab/iotplatform/iotbroker/core/subscription/ConfManWrapper.java index 5ac66c22..e07000eb 100644 --- a/eu.neclab.iotplatform.iotbroker.core/src/main/java/eu/neclab/iotplatform/iotbroker/core/subscription/ConfManWrapper.java +++ b/eu.neclab.iotplatform.iotbroker.core/src/main/java/eu/neclab/iotplatform/iotbroker/core/subscription/ConfManWrapper.java @@ -552,7 +552,7 @@ public NotifyContextAvailabilityResponse receiveReqFrmConfigManager( logger.info("InterruptedException", e); } List lsubAvailID = linkAvSub - .getInIDs(notifyContextAvailabilityRequest.getSubscribeId()); + .getInIDs(notifyContextAvailabilityRequest.getSubscriptionId()); if (lsubAvailID.size() != 1) { logger.info("SUBSCRIPTION NOT FOUND!!"); @@ -656,7 +656,7 @@ public void run() { * subscription handler. */ NotifyContextAvailabilityRequest ncaReq = new NotifyContextAvailabilityRequest( - notifyContextAvailabilityRequest.getSubscribeId(), + notifyContextAvailabilityRequest.getSubscriptionId(), dcaRes.getContextRegistrationResponse(), new StatusCode(200, "Ok", null)); if (logger.isDebugEnabled()) { diff --git a/eu.neclab.iotplatform.iotbroker.core/src/main/java/eu/neclab/iotplatform/iotbroker/core/subscription/SubscriptionController.java b/eu.neclab.iotplatform.iotbroker.core/src/main/java/eu/neclab/iotplatform/iotbroker/core/subscription/SubscriptionController.java index 215dc31f..c75c1b33 100644 --- a/eu.neclab.iotplatform.iotbroker.core/src/main/java/eu/neclab/iotplatform/iotbroker/core/subscription/SubscriptionController.java +++ b/eu.neclab.iotplatform.iotbroker.core/src/main/java/eu/neclab/iotplatform/iotbroker/core/subscription/SubscriptionController.java @@ -1692,14 +1692,14 @@ public NotifyContextAvailabilityResponse receiveReqFrmConfManWrapper( availabilitySub.updateAvalabilitySubscription( notifyContextAvailabilityRequest, association, - notifyContextAvailabilityRequest.getSubscribeId()); + notifyContextAvailabilityRequest.getSubscriptionId()); /* * Now the id of the incoming subscription corresponding to this * availability notification is retrieved from storage. */ List inIDs = linkAvailabilitySubscription - .getInIDs(notifyContextAvailabilityRequest.getSubscribeId()); + .getInIDs(notifyContextAvailabilityRequest.getSubscriptionId()); logger.info("List Incoming Subscription Id ------------------>" + inIDs); diff --git a/eu.neclab.iotplatform.iotbroker.embeddediotagent.core/src/main/java/eu/neclab/iotplatform/iotbroker/embeddediotagent/agentcore/IoTAgentCore.java b/eu.neclab.iotplatform.iotbroker.embeddediotagent.core/src/main/java/eu/neclab/iotplatform/iotbroker/embeddediotagent/agentcore/IoTAgentCore.java index 906b369e..2ce9619f 100644 --- a/eu.neclab.iotplatform.iotbroker.embeddediotagent.core/src/main/java/eu/neclab/iotplatform/iotbroker/embeddediotagent/agentcore/IoTAgentCore.java +++ b/eu.neclab.iotplatform.iotbroker.embeddediotagent.core/src/main/java/eu/neclab/iotplatform/iotbroker/embeddediotagent/agentcore/IoTAgentCore.java @@ -168,25 +168,7 @@ public StatusCode storeData(final List contextElementList) { .isolateAttributes(contextElement)); } - // List of Task - // List> tasks = new ArrayList>(); - - // Iterator iter = contextElementList.iterator(); - - // List contextElementUnsuccessfullyStored = new - // ArrayList(); - - // while (iter.hasNext()) { - - // ContextElement contextElement = iter.next(); - - // Create a list of ContextElement where each ContextElement has - // exactly one ContextAttribute - // - // TODO change the isolatedContextElement to a new class called - // AtomicContextElement - // final List isolatedContextElementList = this - // .isolateAttributes(contextElement); + final Date localDate = new Date(); @@ -205,83 +187,15 @@ public StatusCode storeData(final List contextElementList) { isolatedContextElementList, isolatedContextElementList, localDate); } - - // // Iterate over the isolatedContextElement list in order to create - // // the tasks used to store data - // for (final ContextElement isolatedContextElement : - // isolatedContextElementList) { - // - // // tasks.add(Executors.callable(new Runnable() { - // - // // @Override - // // public void run() { - // - // if (logger.isDebugEnabled()) { - // logger.debug(String.format( - // "Storing historically contextElement %s", - // isolatedContextElement.toJsonString())); - // } - // - // iotAgentStorage.storeHistoricalData(isolatedContextElement, - // localDate); - // - // if (logger.isDebugEnabled()) { - // logger.debug(String.format("Storing latest contextElement %s", - // isolatedContextElement.toJsonString())); - // } - // - // boolean successfullyStored = iotAgentStorage - // .storeLatestData(isolatedContextElement); - // if (!successfullyStored) { - // contextElementUnsuccessfullyStored.add(isolatedContextElement); - // } - // - // // } - // - // // })); - // - // } - - // if (BundleUtils.isServiceRegistered(this, subscriptionHandler)) { - // // tasks.add(Executors.callable(new Runnable() { - // - // // @Override - // // public void run() { - // subscriptionHandler - // .checkSubscriptions(isolatedContextElementList); - // // } - // - // // })); - // } - // } - - // Execute the tasks used to store the data - // ExecutorService taskExecutor = Executors.newCachedThreadPool(); - // try { - // taskExecutor.invokeAll(tasks); - // } catch (InterruptedException e) { - // e.printStackTrace(); - // } + /* * Check registration */ if (BundleUtils.isServiceRegistered(this, registrationHandler)) { - // tasks.add(Executors.callable(new Runnable() { - // @Override - // public void run() { registrationHandler.checkRegistration(contextElementList); - // } - // - // })); - // taskExecutor = Executors.newCachedThreadPool(); - // try { - // taskExecutor.invokeAll(tasks); - // } catch (InterruptedException e) { - // e.printStackTrace(); - // } } else if (logger.isDebugEnabled()) { logger.debug("Registry not available"); } @@ -294,16 +208,12 @@ public StatusCode storeData(final List contextElementList) { } } - // if (contextElementUnsuccessfullyStored.isEmpty()) { if (details.length() == 0) { return new StatusCode(200, ReasonPhrase.OK_200.toString(), ""); } else { - // for (ContextElement isolatedContextElement : - // contextElementUnsuccessfullyStored) { - // details.append(isolatedContextElement.toJsonString() + "; "); - // } + return new StatusCode(472, ReasonPhrase.INVALIDPARAMETER_472.toString(), details.toString()); @@ -446,9 +356,19 @@ public List extractOwnContextRegistrations( * If there is no registry, just return null without any alteration of * the DiscoverContextAvailabilityResponse */ + if (logger.isDebugEnabled()) { + logger.debug("Checking if registrationHandler is present "); + } if (!BundleUtils.isServiceRegistered(this, registrationHandler)) { + if (logger.isDebugEnabled()) { + logger.debug("RegistrationHandler is not present "); + } return null; } + + if (logger.isDebugEnabled()) { + logger.debug("RegistrationHandler is present "); + } /* * Check registration diff --git a/eu.neclab.iotplatform.iotbroker.embeddediotagent.registry/src/main/java/eu/neclab/iotplatform/iotbroker/embeddediotagent/registry/Registry.java b/eu.neclab.iotplatform.iotbroker.embeddediotagent.registry/src/main/java/eu/neclab/iotplatform/iotbroker/embeddediotagent/registry/Registry.java index f5486533..f7fa00a6 100644 --- a/eu.neclab.iotplatform.iotbroker.embeddediotagent.registry/src/main/java/eu/neclab/iotplatform/iotbroker/embeddediotagent/registry/Registry.java +++ b/eu.neclab.iotplatform.iotbroker.embeddediotagent.registry/src/main/java/eu/neclab/iotplatform/iotbroker/embeddediotagent/registry/Registry.java @@ -351,9 +351,10 @@ private String getGenericRegistrationId() { } public void checkRegistration(List contextElementList) { - - if (logger.isDebugEnabled()){ - logger.debug("CheckingRegistration for contextElementList: "+contextElementList); + + if (logger.isDebugEnabled()) { + logger.debug("CheckingRegistration for contextElementList: " + + contextElementList); } if (contextElementList != null && !contextElementList.isEmpty()) { @@ -472,8 +473,9 @@ private boolean checkContextElementVsRegistrations( contextRegistration2); if (logger.isDebugEnabled()) { - logger.debug("CheckingRegistration "+ (comparison==0) +" for ContextElement: " - + contextElement + " versus Registration" + registration); + logger.debug("CheckingRegistration " + (comparison == 0) + + " for ContextElement: " + contextElement + + " versus Registration" + registration); } return comparison == 0; @@ -500,9 +502,10 @@ public void checkRegistration(ContextElement contextElement) { if (lockableRegisterContextRequest.getContextRegistration() .getListEntityId().isEmpty()) { - + if (logger.isDebugEnabled()) { - logger.debug("This needs a new registration ContextElement: " + contextElement); + logger.debug("This needs a new registration ContextElement: " + + contextElement); } List entityIdList = new ArrayList(); @@ -1003,6 +1006,12 @@ public List extractOwnContextRegistrations( } } + if (logger.isDebugEnabled()) { + logger.debug("Extracted Context Registration for agent " + + getEmbeddedAgentIdentifier() + ": " + + extractedContextRegistrations); + } + return extractedContextRegistrations; } } diff --git a/eu.neclab.iotplatform.iotbroker.restcontroller/src/main/java/eu/neclab/iotplatform/iotbroker/restcontroller/RestProviderController.java b/eu.neclab.iotplatform.iotbroker.restcontroller/src/main/java/eu/neclab/iotplatform/iotbroker/restcontroller/RestProviderController.java index 91ea1806..c831331f 100644 --- a/eu.neclab.iotplatform.iotbroker.restcontroller/src/main/java/eu/neclab/iotplatform/iotbroker/restcontroller/RestProviderController.java +++ b/eu.neclab.iotplatform.iotbroker.restcontroller/src/main/java/eu/neclab/iotplatform/iotbroker/restcontroller/RestProviderController.java @@ -92,7 +92,9 @@ import eu.neclab.iotplatform.ngsi.api.datamodel.NotifyContextRequest; import eu.neclab.iotplatform.ngsi.api.datamodel.NotifyContextResponse; import eu.neclab.iotplatform.ngsi.api.datamodel.QueryContextRequest; +import eu.neclab.iotplatform.ngsi.api.datamodel.QueryContextRequest_OrionCustomization; import eu.neclab.iotplatform.ngsi.api.datamodel.QueryContextResponse; +import eu.neclab.iotplatform.ngsi.api.datamodel.QueryContextResponse_OrionCustomization; import eu.neclab.iotplatform.ngsi.api.datamodel.ReasonPhrase; import eu.neclab.iotplatform.ngsi.api.datamodel.StatusCode; import eu.neclab.iotplatform.ngsi.api.datamodel.SubscribeContextRequest; @@ -358,6 +360,31 @@ private boolean validateMessageBody(HttpServletRequest request, } + /** + * Executes the standard NGSI 10 QueryContext method. + * + * @param requester + * Represents the request message body and header. + * @param request + * The request body. + * @return The response body. + * + */ + @RequestMapping(value = "/v1/queryContext", method = RequestMethod.POST, consumes = { CONTENT_TYPE_JSON }, produces = { CONTENT_TYPE_JSON }) + public ResponseEntity queryContextOrion( + HttpServletRequest requester, + @RequestBody QueryContextRequest_OrionCustomization request) { + + logger.info("\n\n <--- NGSI-10 has received request for Context query resource (v1.orion version) ---> \n"); + + ResponseEntity response = queryContext(requester, + request.toQueryContextRequest()); + + return new ResponseEntity( + new QueryContextResponse_OrionCustomization(response.getBody()), + response.getStatusCode()); + } + /** * Executes the standard NGSI 10 QueryContext method. * diff --git a/eu.neclab.iotplatform.knowledgebase/src/main/java/eu/neclab/iotplatform/iotbroker/knowledgebase/KnowledgeBase.java b/eu.neclab.iotplatform.knowledgebase/src/main/java/eu/neclab/iotplatform/iotbroker/knowledgebase/KnowledgeBase.java index c081b855..a2ce2b69 100644 --- a/eu.neclab.iotplatform.knowledgebase/src/main/java/eu/neclab/iotplatform/iotbroker/knowledgebase/KnowledgeBase.java +++ b/eu.neclab.iotplatform.knowledgebase/src/main/java/eu/neclab/iotplatform/iotbroker/knowledgebase/KnowledgeBase.java @@ -146,7 +146,8 @@ public Set getSubTypes(URI type) { } else { logger.info(String - .format("Problem when contacting the KnowledgeBase server. StatusCode: %s. ReasonPhrase: %s.", + .format("Problem when contacting the KnowledgeBase server for %s. StatusCode: %s. ReasonPhrase: %s.", + fullUrl.toString(), fullHttpResponse.getStatusLine() .getStatusCode(), fullHttpResponse .getStatusLine().getReasonPhrase())); @@ -210,8 +211,15 @@ private URI extractSubtypeFromBinding(JsonElement binding) { && binding.getAsJsonObject().getAsJsonObject("type") .get("value") != null) { try { - subtype = new URI(binding.getAsJsonObject() - .getAsJsonObject("type").get("value").getAsString()); + + String value = binding.getAsJsonObject() + .getAsJsonObject("type").get("value").getAsString(); + if (value.contains("#")) { + value = value.split("#")[1]; + } + + subtype = new URI(value); + } catch (URISyntaxException e) { logger.info("Bad uri as type"); } @@ -266,4 +274,4 @@ public Set getSuperTypes(URI type) { return superTypes; } -} +} diff --git a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextElementResponse_OrionCustomization.java b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextElementResponse_OrionCustomization.java index 2c708af6..492c4c0c 100644 --- a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextElementResponse_OrionCustomization.java +++ b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextElementResponse_OrionCustomization.java @@ -67,11 +67,13 @@ public class ContextElementResponse_OrionCustomization extends public ContextElementResponse_OrionCustomization() { } - - public ContextElementResponse_OrionCustomization(ContextElementResponse contextElementResponse) { - this.contextElement = new ContextElement_OrionCustomization(contextElementResponse.getContextElement()); - this.statusCode = contextElementResponse.getStatusCode(); + public ContextElementResponse_OrionCustomization( + ContextElementResponse contextElementResponse) { + + this.contextElement = new ContextElement_OrionCustomization( + contextElementResponse.getContextElement()); + this.statusCode = contextElementResponse.getStatusCode(); } public ContextElementResponse_OrionCustomization( @@ -82,6 +84,7 @@ public ContextElementResponse_OrionCustomization( } + public ContextElement_OrionCustomization getContextElement() { return contextElement; } @@ -101,8 +104,14 @@ public void setStatusCode(StatusCode statusCode) { public ContextElementResponse toContextElementResponse() { - return new ContextElementResponse(contextElement.toContextElement(), - statusCode); + if (contextElement != null) { + + return new ContextElementResponse( + contextElement.toContextElement(), statusCode); + } else { + + return new ContextElementResponse(null, statusCode); + } } diff --git a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextMetadata_OrionCustomization.java b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextMetadata_OrionCustomization.java new file mode 100644 index 00000000..39167b67 --- /dev/null +++ b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextMetadata_OrionCustomization.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) 2016, NEC Europe Ltd. + * All rights reserved. + * + * Authors: + * * NEC IoT Platform Team - iotplatform@neclab.eu + * * Flavio Cirillo - flavio.cirillo@neclab.eu + * * Tobias Jacobs - tobias.jacobs@neclab.eu + * * Gurkan Solmaz - gurkan.solmaz@neclab.eu + * * Salvatore Longo + * * Raihan Ul-Islam + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: This + * product includes software developed by NEC Europe Ltd. + * 4. Neither the name of NEC nor the names of its contributors may + * be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY NEC ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL NEC BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + ******************************************************************************/ + +package eu.neclab.iotplatform.ngsi.api.datamodel; + +import java.net.URI; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; + +/** + * Implements ContextMetadata as defined in OMA NGSI 9/10 approved version 1.0. + */ +@XmlRootElement(name = "contextMetadata") +@XmlAccessorType(XmlAccessType.FIELD) +public class ContextMetadata_OrionCustomization extends + NgsiStructureAlternative { + + @XmlElement(name = "name") + private String name = null; + + @XmlSchemaType(name = "anyURI") + private URI type = null; + + @XmlElement(name = "value") + private String value = null; + + public ContextMetadata_OrionCustomization() { + + } + + public ContextMetadata_OrionCustomization(String name, URI type, + String value) { + + this.name = name; + this.type = type; + this.value = value; + } + + public ContextMetadata_OrionCustomization(ContextMetadata contextMetadata) { + + this.name = contextMetadata.getName(); + this.type = contextMetadata.getType(); + if (contextMetadata.getValue() instanceof String){ + this.value = (String) contextMetadata.getValue(); + } else { + String string = contextMetadata.getValue().toString(); + string = string.replace("\n", "").replace("\r", ""); + string = string.replaceAll("<\\?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"\\?>", ""); + string = string.replaceAll("", "|"); + string = string.replaceAll("<", ""); + string = string.replaceAll(">", "|"); + this.value = string; + } + + } + + public ContextMetadata_OrionCustomization(MetadataTypes metadataType, + URI type, String value) { + + this.name = metadataType.toString(); + this.type = type; + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public URI getType() { + return type; + } + + public void setType(URI type) { + this.type = type; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Override + public boolean equals(Object obj) { + + if (this == obj) { + return true; + } + + if (obj == null || getClass() != obj.getClass()) { + return false; + } + + ContextMetadata_OrionCustomization other = (ContextMetadata_OrionCustomization) obj; + + return name.equals(other.name) && type.equals(other.type) + && value.toString().equals(other.value.toString()); + + } + + @Override + public int hashCode() { + return this.toJsonString().hashCode(); + } + + public ContextMetadata toContextMetadata() { + return new ContextMetadata(name, type, value); + } + + @Override + public NgsiStructure toStandardNgsiStructure() { + return toContextMetadata(); + } + +} diff --git a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextRegistration.java b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextRegistration.java index b7e8b701..585d0f1f 100644 --- a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextRegistration.java +++ b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextRegistration.java @@ -95,7 +95,7 @@ public ContextRegistration(List entityId, this.entityId = entityId; this.contextRegistrationAttribute = contextRegistrationAttribute; this.contextMetadata = contextMetadata; - providingApplication = provideApplication.toString(); + this.providingApplication = provideApplication.toString(); } diff --git a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextRegistrationResponse_OrionCustomization.java b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextRegistrationResponse_OrionCustomization.java new file mode 100644 index 00000000..50cb7f2f --- /dev/null +++ b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextRegistrationResponse_OrionCustomization.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2016, NEC Europe Ltd. + * All rights reserved. + * + * Authors: + * * NEC IoT Platform Team - iotplatform@neclab.eu + * * Flavio Cirillo - flavio.cirillo@neclab.eu + * * Tobias Jacobs - tobias.jacobs@neclab.eu + * * Gurkan Solmaz - gurkan.solmaz@neclab.eu + * * Salvatore Longo + * * Raihan Ul-Islam + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: This + * product includes software developed by NEC Europe Ltd. + * 4. Neither the name of NEC nor the names of its contributors may + * be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY NEC ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL NEC BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + ******************************************************************************/ + +package eu.neclab.iotplatform.ngsi.api.datamodel; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Implements ContextRegistrationResponse as defined in OMA NGSI 9/10 approved + * version 1.0. + */ +@XmlRootElement(name = "contextRegistrationResponse") +@XmlAccessorType(XmlAccessType.FIELD) +public class ContextRegistrationResponse_OrionCustomization extends + NgsiStructureAlternative { + + @XmlElement(name = "contextRegistration", required = true) + private ContextRegistration_OrionCustomization contextRegistration = null; + @XmlElement(name = "errorCode") + private StatusCode errorCode = null; + + public ContextRegistrationResponse_OrionCustomization() { + + } + + public ContextRegistrationResponse_OrionCustomization( + ContextRegistration_OrionCustomization contextRegistration, + StatusCode errorCode) { + + this.contextRegistration = contextRegistration; + this.errorCode = errorCode; + + } + + public ContextRegistrationResponse_OrionCustomization( + ContextRegistrationResponse contextRegistrationResponse) { + + this.contextRegistration = new ContextRegistration_OrionCustomization( + contextRegistrationResponse.getContextRegistration()); + this.errorCode = contextRegistrationResponse.getErrorCode(); + + } + + public ContextRegistration_OrionCustomization getContextRegistration() { + return contextRegistration; + } + + public void setContextRegistration( + ContextRegistration_OrionCustomization contextRegistration) { + this.contextRegistration = contextRegistration; + + } + + public StatusCode getErrorCode() { + return errorCode; + } + + public void setErrorCode(StatusCode errorCode) { + this.errorCode = errorCode; + + } + + @Override + public NgsiStructure toStandardNgsiStructure() { + return toContextRegistrationResponse(); + } + + public ContextRegistrationResponse toContextRegistrationResponse() { + return new ContextRegistrationResponse( + contextRegistration.toContextRegistration(), errorCode); + } +} diff --git a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextRegistration_OrionCustomization.java b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextRegistration_OrionCustomization.java new file mode 100644 index 00000000..c9d6bdee --- /dev/null +++ b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/ContextRegistration_OrionCustomization.java @@ -0,0 +1,224 @@ +/******************************************************************************* + * Copyright (c) 2016, NEC Europe Ltd. + * All rights reserved. + * + * Authors: + * * NEC IoT Platform Team - iotplatform@neclab.eu + * * Flavio Cirillo - flavio.cirillo@neclab.eu + * * Tobias Jacobs - tobias.jacobs@neclab.eu + * * Gurkan Solmaz - gurkan.solmaz@neclab.eu + * * Salvatore Longo + * * Raihan Ul-Islam + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: This + * product includes software developed by NEC Europe Ltd. + * 4. Neither the name of NEC nor the names of its contributors may + * be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY NEC ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL NEC BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + ******************************************************************************/ + +package eu.neclab.iotplatform.ngsi.api.datamodel; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * Implements ContextRegistration as defined in OMA NGSI 9/10 approved version + * 1.0. + */ +@XmlRootElement(name = "contextRegistration") +@XmlAccessorType(XmlAccessType.FIELD) +public class ContextRegistration_OrionCustomization extends + NgsiStructureAlternative { + + @XmlElementWrapper(name = "entityIdList") + @XmlElement(name = "entityId") + @JsonProperty("entities") + private List entityId = null; + + @XmlElementWrapper(name = "contextRegistrationAttributeList") + @XmlElement(name = "contextRegistrationAttribute") + @JsonProperty("attributes") + private List contextRegistrationAttribute = null; + + @XmlElementWrapper(name = "registrationMetadata") + @XmlElement(name = "contextMetadata") + @JsonProperty("metadatas") + private List contextMetadata = null; + + @XmlElement(name = "providingApplication", required = true) + // @XmlSchemaType(name = "anyURI") + private String providingApplication; + + public ContextRegistration_OrionCustomization() { + + } + + public ContextRegistration_OrionCustomization(List entityId, + List contextRegistrationAttribute, + List contextMetadata, + URI provideApplication) { + this.entityId = entityId; + this.contextRegistrationAttribute = contextRegistrationAttribute; + this.contextMetadata = contextMetadata; + this.providingApplication = provideApplication.toString(); + + } + + public ContextRegistration_OrionCustomization( + ContextRegistration contextRegistration) { + + this.entityId = contextRegistration.getListEntityId(); + this.contextRegistrationAttribute = contextRegistration + .getContextRegistrationAttribute(); + if (contextRegistration.getListContextMetadata() != null + && !contextRegistration.getListContextMetadata().isEmpty()) { + this.contextMetadata = new ArrayList(); + for (ContextMetadata contextMetadata : contextRegistration + .getListContextMetadata()) { + this.contextMetadata + .add(new ContextMetadata_OrionCustomization( + contextMetadata)); + } + } + String providingApp = contextRegistration + .getProvidingApplication().toString(); + if (providingApp.endsWith("/ngsi10")){ + providingApp = providingApp.replace("/ngsi10", "/v1"); + } else if (providingApp.endsWith("/ngsi10/")){ + providingApp = providingApp.replace("/ngsi10/", "/v1"); + } + this.providingApplication = providingApp; + + } + + @JsonIgnore + public List getListEntityId() { + + return entityId; + } + + @JsonIgnore + public void setListEntityId(List entityId) { + this.entityId = entityId; + + } + + @JsonIgnore + public List getContextRegistrationAttribute() { + if (contextRegistrationAttribute == null) { + contextRegistrationAttribute = new ArrayList(); + } + return contextRegistrationAttribute; + } + + @JsonIgnore + public void setListContextRegistrationAttribute( + List contextRegistrationAttribute) { + this.contextRegistrationAttribute = contextRegistrationAttribute; + + } + + @JsonIgnore + public List getListContextMetadata() { + if (contextMetadata == null) { + contextMetadata = new ArrayList(); + } + return contextMetadata; + } + + @JsonIgnore + public void setListContextMetadata( + List contextMetadata) { + this.contextMetadata = contextMetadata; + + } + + public URI getProvidingApplication() { + + if (providingApplication == null) { + return null; + } + + URI uri = null; + + try { + uri = new URI(providingApplication); + } catch (URISyntaxException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return uri; + + } + + public void setProvidingApplication(URI providingApplication) { + this.providingApplication = providingApplication.toString(); + + } + + @Override + public NgsiStructure toStandardNgsiStructure() { + return toContextRegistration(); + } + + public ContextRegistration toContextRegistration() { + ContextRegistration contextRegistration = null; + URI uri = null; + try { + uri = new URI(providingApplication); + } catch (URISyntaxException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + List contextMetadataList = new ArrayList(); + if (contextMetadata != null && !contextMetadata.isEmpty()) { + for (ContextMetadata_OrionCustomization contextMetadataOrion : contextMetadata) { + contextMetadataList.add(contextMetadataOrion + .toContextMetadata()); + } + } + + contextRegistration = new ContextRegistration(entityId, + contextRegistrationAttribute, contextMetadataList, uri); + + return contextRegistration; + } +} diff --git a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/NgsiStructure.java b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/NgsiStructure.java index e0c6f99a..cf492bf3 100644 --- a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/NgsiStructure.java +++ b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/NgsiStructure.java @@ -260,7 +260,7 @@ public static Object parseStringToJson(String json, /** * Parse the json string and perform a sanityCheck of the NGSI structure (if * sanityCheck set to true) and it tries to de-serialize the json object - * with other NGSI json serialization known) + * with other NGSI json serialization known * * @param json * @param clazz @@ -372,47 +372,4 @@ private static Object parseJsonWithDifferentSerialization(String json, public boolean sanityCheck() { return true; } - - public static void main(String[] args) { - String json = "{ \"contextResponses\" : [ { \"contextElement\" : { \"type\" : \"thermometer\", \"isPattern\" : \"false\", \"id\" : \"thermo1\", \"attributes\" : [ { \"name\" : \"temperature\", \"type\" : \"float\", \"value\" : \"300.00\" } ] }, \"statusCode\" : { \"code\" : \"200\", \"reasonPhrase\" : \"OK\" } } ]}"; - - Object object = NgsiStructure.parseStringToJson(json, - QueryContextResponse.class, true, true); - - if (object instanceof QueryContextResponse) { - System.out.println("funge: " + object); - } - - // QueryContextResponse queryContextResponse = (QueryContextResponse) - // NgsiStructure - // .parseStringToJson(json, QueryContextResponse.class); - // - // for (ContextElementResponse contextElementResponse : - // queryContextResponse - // .getListContextElementResponse()) { - // if (contextElementResponse.getContextElement() != null - // && (contextElementResponse.getContextElement() - // .getEntityId() == null - // || contextElementResponse.getContextElement() - // .getEntityId().getId() == null || contextElementResponse - // .getContextElement().getEntityId().getId() - // .isEmpty())) { - // - // System.out.println("Not a valid queryContextRequest"); - // - // break; - // } - // - // } - // - // QueryContextResponse_OrionCustomization - // queryContextResponse_OrionCustomizatio = - // (QueryContextResponse_OrionCustomization) NgsiStructure - // .parseStringToJson(json, - // QueryContextResponse_OrionCustomization.class); - // queryContextResponse = queryContextResponse_OrionCustomizatio - // .toQueryContextResponse(); - // - // System.out.println(queryContextResponse); - } } diff --git a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/NotifyContextAvailabilityRequest.java b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/NotifyContextAvailabilityRequest.java index c1ff26df..d6a91293 100644 --- a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/NotifyContextAvailabilityRequest.java +++ b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/NotifyContextAvailabilityRequest.java @@ -65,7 +65,7 @@ public class NotifyContextAvailabilityRequest extends NgsiStructure { @XmlElement(name = "subscriptionId", required = true) - private String subscribeId = null; + private String subscriptionId = null; @XmlElementWrapper(name = "contextRegistrationResponseList") @XmlElement(name = "contextRegistrationResponse", required = true) @@ -79,20 +79,20 @@ public NotifyContextAvailabilityRequest() { } - public NotifyContextAvailabilityRequest(String subscribeId, + public NotifyContextAvailabilityRequest(String subscriptionId, List contextRegistrationResponseList, StatusCode errorCode) { - this.subscribeId = subscribeId; + this.subscriptionId = subscriptionId; this.contextRegistrationResponse = contextRegistrationResponseList; this.errorCode = errorCode; } - public String getSubscribeId() { - return subscribeId; + public String getSubscriptionId() { + return subscriptionId; } - public void setSubscribeId(String subscribeId) { - this.subscribeId = subscribeId; + public void setSubscriptionId(String subscriptionId) { + this.subscriptionId =subscriptionId; } @JsonIgnore diff --git a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/NotifyContextAvailabilityRequest_OrionCustomization.java b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/NotifyContextAvailabilityRequest_OrionCustomization.java new file mode 100644 index 00000000..b150adc3 --- /dev/null +++ b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/NotifyContextAvailabilityRequest_OrionCustomization.java @@ -0,0 +1,164 @@ +/******************************************************************************* + * Copyright (c) 2016, NEC Europe Ltd. + * All rights reserved. + * + * Authors: + * * NEC IoT Platform Team - iotplatform@neclab.eu + * * Flavio Cirillo - flavio.cirillo@neclab.eu + * * Tobias Jacobs - tobias.jacobs@neclab.eu + * * Gurkan Solmaz - gurkan.solmaz@neclab.eu + * * Salvatore Longo + * * Raihan Ul-Islam + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: This + * product includes software developed by NEC Europe Ltd. + * 4. Neither the name of NEC nor the names of its contributors may + * be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY NEC ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL NEC BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + ******************************************************************************/ + +package eu.neclab.iotplatform.ngsi.api.datamodel; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * Implements NotifyContextAvailabilityRequest as defined in OMA NGSI 9/10 + * approved version 1.0. + */ +@XmlRootElement(name = "notifyContextAvailabilityRequest") +@XmlAccessorType(XmlAccessType.FIELD) +public class NotifyContextAvailabilityRequest_OrionCustomization extends + NgsiStructureAlternative { + + @XmlElement(name = "subscriptionId", required = true) + private String subscriptionId = null; + + @XmlElementWrapper(name = "contextRegistrationResponseList") + @XmlElement(name = "contextRegistrationResponse", required = true) + @JsonProperty("contextRegistrationResponses") + private List contextRegistrationResponse = null; + + // @XmlElement(name = "errorCode", required = true) + // private StatusCode errorCode = null; + + public NotifyContextAvailabilityRequest_OrionCustomization() { + + } + + public NotifyContextAvailabilityRequest_OrionCustomization( + String subscriptionId, + List contextRegistrationResponseList) { + this.subscriptionId = subscriptionId; + this.contextRegistrationResponse = contextRegistrationResponseList; + // this.errorCode = errorCode; + } + + public NotifyContextAvailabilityRequest_OrionCustomization( + NotifyContextAvailabilityRequest notifyContextAvailabilityRequest) { + this.subscriptionId = notifyContextAvailabilityRequest.getSubscriptionId(); + if (notifyContextAvailabilityRequest + .getContextRegistrationResponseList() != null + && !notifyContextAvailabilityRequest + .getContextRegistrationResponseList().isEmpty()) { + this.contextRegistrationResponse = new ArrayList(); + for (ContextRegistrationResponse contextRegistrationResp : notifyContextAvailabilityRequest + .getContextRegistrationResponseList()) { + this.contextRegistrationResponse + .add(new ContextRegistrationResponse_OrionCustomization( + contextRegistrationResp)); + } + } + // this.errorCode = notifyContextAvailabilityRequest.getErrorCode(); + } + + + public String getSubscriptionId() { + return subscriptionId; + } + + + public void setSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + } + + @JsonIgnore + public List getContextRegistrationResponseList() { + if (contextRegistrationResponse == null) { + contextRegistrationResponse = new ArrayList(); + } + return contextRegistrationResponse; + } + + @JsonIgnore + public void setContextRegistrationResponseList( + List contextRegistrationResponseList) { + this.contextRegistrationResponse = contextRegistrationResponseList; + } + + // public StatusCode getErrorCode() { + // return errorCode; + // } + // + // public void setErrorCode(StatusCode errorCode) { + // this.errorCode = errorCode; + // } + + public NotifyContextAvailabilityRequest toNotifyContextAvailabilityRequest() { + NotifyContextAvailabilityRequest notifyContextAvailabilityRequest = new NotifyContextAvailabilityRequest(); + if (contextRegistrationResponse != null + && !contextRegistrationResponse.isEmpty()) { + notifyContextAvailabilityRequest + .setContextRegistrationResponseList(new ArrayList()); + for (ContextRegistrationResponse_OrionCustomization contextRegistrationResponse_orion : contextRegistrationResponse) { + notifyContextAvailabilityRequest + .getContextRegistrationResponseList().add( + contextRegistrationResponse_orion + .toContextRegistrationResponse()); + } + } + notifyContextAvailabilityRequest.setErrorCode(new StatusCode(200, + ReasonPhrase.OK_200.toString(), "")); + return notifyContextAvailabilityRequest; + + } + + @Override + public NgsiStructure toStandardNgsiStructure() { + return toNotifyContextAvailabilityRequest(); + } +} diff --git a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/OperationScope_OrionCustomization.java b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/OperationScope_OrionCustomization.java new file mode 100644 index 00000000..05fbf511 --- /dev/null +++ b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/OperationScope_OrionCustomization.java @@ -0,0 +1,156 @@ +/******************************************************************************* + * Copyright (c) 2016, NEC Europe Ltd. + * All rights reserved. + * + * Authors: + * * NEC IoT Platform Team - iotplatform@neclab.eu + * * Flavio Cirillo - flavio.cirillo@neclab.eu + * * Tobias Jacobs - tobias.jacobs@neclab.eu + * * Gurkan Solmaz - gurkan.solmaz@neclab.eu + * * Salvatore Longo + * * Raihan Ul-Islam + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: This + * product includes software developed by NEC Europe Ltd. + * 4. Neither the name of NEC nor the names of its contributors may + * be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY NEC ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL NEC BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + ******************************************************************************/ + +package eu.neclab.iotplatform.ngsi.api.datamodel; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; + +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import eu.neclab.iotplatform.ngsi.api.serialization.json.MetadataObjectValueSerializer; +import eu.neclab.iotplatform.ngsi.api.serialization.json.MetadataValueDeserializer; + +/** + * Implements OperationScope as defined in OMA NGSI 9/10 approved version 1.0. + */ +@XmlRootElement(name = "operationScope") +@XmlSeeAlso({ Segment.class, Circle.class, Polygon.class, Point.class, + PEPCredentials.class }) +@XmlAccessorType(XmlAccessType.FIELD) +public class OperationScope_OrionCustomization extends NgsiStructureAlternative { + + @XmlElement(name = "type", required = true) + private String type = null; + + @XmlElement(name = "value", required = true) + @JsonSerialize(using = MetadataObjectValueSerializer.class) + @JsonDeserialize(using = MetadataValueDeserializer.class) + private Object value = null; + + public OperationScope_OrionCustomization() { + + } + + @JsonIgnore + public OperationScope_OrionCustomization(String type, Object value) { + this.type = type; + this.value = value; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @JsonSerialize(using = MetadataObjectValueSerializer.class) + public Object getValue() { + return value; + } + + @JsonDeserialize(using = MetadataValueDeserializer.class) + public void setValue(Object value) { + this.value = value; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (type == null ? 0 : type.hashCode()); + result = prime * result + (value == null ? 0 : value.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + OperationScope_OrionCustomization other = (OperationScope_OrionCustomization) obj; + if (type == null) { + if (other.type != null) { + return false; + } + } else if (!type.equals(other.type)) { + return false; + } + if (value == null) { + if (other.value != null) { + return false; + } + } + + else if (!value.equals(other.value)) { + return false; + } + return true; + } + + @Override + public NgsiStructure toStandardNgsiStructure() { + return toOperationScope(); + } + + public OperationScope toOperationScope() { + + return new OperationScope(type, value); + } + +} diff --git a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/QueryContextRequest_OrionCustomization.java b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/QueryContextRequest_OrionCustomization.java new file mode 100644 index 00000000..6809d2d9 --- /dev/null +++ b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/QueryContextRequest_OrionCustomization.java @@ -0,0 +1,194 @@ +/******************************************************************************* + * Copyright (c) 2016, NEC Europe Ltd. + * All rights reserved. + * + * Authors: + * * NEC IoT Platform Team - iotplatform@neclab.eu + * * Flavio Cirillo - flavio.cirillo@neclab.eu + * * Tobias Jacobs - tobias.jacobs@neclab.eu + * * Gurkan Solmaz - gurkan.solmaz@neclab.eu + * * Salvatore Longo + * * Raihan Ul-Islam + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: This + * product includes software developed by NEC Europe Ltd. + * 4. Neither the name of NEC nor the names of its contributors may + * be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY NEC ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL NEC BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + ******************************************************************************/ + +package eu.neclab.iotplatform.ngsi.api.datamodel; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonProperty; + +@XmlRootElement(name = "queryContextRequest") +@XmlAccessorType(XmlAccessType.FIELD) +/** + * Implements QueryContextRequest + * as defined in OMA NGSI 9/10 approved version 1.0. + */ +public class QueryContextRequest_OrionCustomization extends + NgsiStructureAlternative { + + @XmlElementWrapper(name = "entityIdList") + @XmlElement(name = "entityId", required = true) + @JsonProperty("entities") + protected List entityIdList; + + @XmlElementWrapper(name = "attributeList") + @XmlElement(name = "attribute", required = false) + @JsonProperty("attributes") + protected List attributeList; + + @XmlElement(name = "restriction") + protected Restriction_OrionCustomization restriction = null; + + public QueryContextRequest_OrionCustomization() { + + } + + public QueryContextRequest_OrionCustomization(List enityId, + List attributeList, + Restriction_OrionCustomization restriction) { + this.entityIdList = enityId; + this.attributeList = attributeList; + this.restriction = restriction; + + } + + @JsonIgnore + public List getEntityIdList() { + if (entityIdList == null) { + entityIdList = new ArrayList(); + } + return entityIdList; + } + + @JsonIgnore + public void setEntityIdList(List entityId) { + this.entityIdList = entityId; + + } + + @JsonIgnore + public List getAttributeList() { + if (attributeList == null) { + attributeList = new ArrayList(); + } + return attributeList; + } + + @JsonIgnore + public void setAttributeList(List attributeList) { + this.attributeList = attributeList; + } + + public Restriction_OrionCustomization getRestriction() { + return restriction; + } + + public void setRestriction(Restriction_OrionCustomization restriction) { + this.restriction = restriction; + + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + (attributeList == null ? 0 : attributeList.hashCode()); + result = prime * result + + (entityIdList == null ? 0 : entityIdList.hashCode()); + result = prime * result + + (restriction == null ? 0 : restriction.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + QueryContextRequest_OrionCustomization other = (QueryContextRequest_OrionCustomization) obj; + if (attributeList == null) { + if (other.attributeList != null) { + return false; + } + } else if (!attributeList.equals(other.attributeList)) { + return false; + } + if (entityIdList == null) { + if (other.entityIdList != null) { + return false; + } + } else if (!entityIdList.equals(other.entityIdList)) { + return false; + } + if (restriction == null) { + if (other.restriction != null) { + return false; + } + } else if (!restriction.equals(other.restriction)) { + return false; + } + return true; + } + + @Override + public NgsiStructure toStandardNgsiStructure() { + // TODO Auto-generated method stub + return null; + } + + public QueryContextRequest toQueryContextRequest() { + if (restriction != null) { + return new QueryContextRequest(entityIdList, attributeList, + restriction.toRestriction()); + } else { + return new QueryContextRequest(entityIdList, attributeList, null); + } + } + +} diff --git a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/QueryContextResponse_OrionCustomization.java b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/QueryContextResponse_OrionCustomization.java index 6f828fc8..870a70bd 100644 --- a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/QueryContextResponse_OrionCustomization.java +++ b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/QueryContextResponse_OrionCustomization.java @@ -85,6 +85,25 @@ public QueryContextResponse_OrionCustomization( this.errorCode = errorCode; } + public QueryContextResponse_OrionCustomization( + QueryContextResponse queryContextResponse) { + this(); + if (queryContextResponse != null) { + if (queryContextResponse.getListContextElementResponse() != null + && !queryContextResponse.getListContextElementResponse() + .isEmpty()) { + this.contextElementResponse = new ArrayList(); + for (ContextElementResponse contextElementResponse : queryContextResponse + .getListContextElementResponse()) { + this.contextElementResponse + .add(new ContextElementResponse_OrionCustomization( + contextElementResponse)); + } + } + this.errorCode = queryContextResponse.getErrorCode(); + } + } + public QueryContextResponse toQueryContextResponse() { List contextElementResponseList = null; @@ -109,19 +128,17 @@ public List getListContextElementResp } return contextElementResponse; } - + @JsonIgnore public void setContextResponseList( List ContextResponseList) { contextElementResponse = ContextResponseList; } - @JsonIgnore public StatusCode getErrorCode() { return errorCode; } - @JsonIgnore public void setErrorCode(StatusCode errorCode) { this.errorCode = errorCode; } diff --git a/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/Restriction_OrionCustomization.java b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/Restriction_OrionCustomization.java new file mode 100644 index 00000000..afdbb8e9 --- /dev/null +++ b/eu.neclab.iotplatform.ngsi.api/src/main/java/eu/neclab/iotplatform/ngsi/api/datamodel/Restriction_OrionCustomization.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2016, NEC Europe Ltd. + * All rights reserved. + * + * Authors: + * * NEC IoT Platform Team - iotplatform@neclab.eu + * * Flavio Cirillo - flavio.cirillo@neclab.eu + * * Tobias Jacobs - tobias.jacobs@neclab.eu + * * Gurkan Solmaz - gurkan.solmaz@neclab.eu + * * Salvatore Longo + * * Raihan Ul-Islam + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: This + * product includes software developed by NEC Europe Ltd. + * 4. Neither the name of NEC nor the names of its contributors may + * be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY NEC ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL NEC BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + ******************************************************************************/ + +package eu.neclab.iotplatform.ngsi.api.datamodel; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * Implements Restriction as defined in OMA NGSI 9/10 approved version 1.0. + */ +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class Restriction_OrionCustomization extends NgsiStructureAlternative { + + @XmlElement(name = "attributeExpression") + private String attributeExpression = null; + + @XmlElementWrapper(name = "scope") + @XmlElement(name = "operationScope") + @JsonProperty("scopes") + private List operationScope = null; + + public Restriction_OrionCustomization() { + + } + + @JsonIgnore + public Restriction_OrionCustomization(String attributeExpression, + List scope) { + this.attributeExpression = attributeExpression; + this.operationScope = scope; + + } + + public String getAttributeExpression() { + return attributeExpression; + } + + public void setAttributeExpression(String attributeExpression) { + this.attributeExpression = attributeExpression; + } + + @JsonIgnore + public List getOperationScope() { + if (operationScope == null) { + operationScope = new ArrayList(); + } + return operationScope; + } + + @JsonIgnore + public void setOperationScope(List scope) { + operationScope = scope; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime + * result + + (attributeExpression == null ? 0 : attributeExpression + .hashCode()); + result = prime * result + + (operationScope == null ? 0 : operationScope.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Restriction_OrionCustomization other = (Restriction_OrionCustomization) obj; + if (attributeExpression == null) { + if (other.attributeExpression != null) { + return false; + } + } else if (!attributeExpression.equals(other.attributeExpression)) { + return false; + } + if (operationScope == null) { + if (other.operationScope != null) { + return false; + } + } else if (!operationScope.equals(other.operationScope)) { + return false; + } + return true; + } + + @Override + public NgsiStructure toStandardNgsiStructure() { + return toRestriction(); + } + + public Restriction toRestriction() { + Restriction restriction = new Restriction(); + if (operationScope != null && !operationScope.isEmpty()) { + restriction.setOperationScope(new ArrayList()); + for (OperationScope_OrionCustomization scope : operationScope) { + restriction.getOperationScope().add(scope.toOperationScope()); + } + } + + if (attributeExpression != null) { + restriction.setAttributeExpression(attributeExpression); + } else { + restriction.setAttributeExpression(""); + } + + return restriction; + } +} diff --git a/eu.neclab.iotplatform.ngsi.api/src/test/java/eu/neclab/iotplatform/ngsi/api/datamodel/RegisterContextRequestTest.java b/eu.neclab.iotplatform.ngsi.api/src/test/java/eu/neclab/iotplatform/ngsi/api/datamodel/RegisterContextRequestTest.java index 1bf719b0..8e64ba2a 100644 --- a/eu.neclab.iotplatform.ngsi.api/src/test/java/eu/neclab/iotplatform/ngsi/api/datamodel/RegisterContextRequestTest.java +++ b/eu.neclab.iotplatform.ngsi.api/src/test/java/eu/neclab/iotplatform/ngsi/api/datamodel/RegisterContextRequestTest.java @@ -32,16 +32,5 @@ private RegisterContextRequest generateRegisterContextRequest() { return registerContextRequest; } - - public static void main(String[] args) { - - RegisterContextRequest registerContextRequest = new RegisterContextRequest(); - - registerContextRequest.setContextRegistrationList(NgsiObjectFactory - .generateContextRegistrationListOneValue()); - - System.out.println(registerContextRequest.toJsonString()); - - } } diff --git a/eu.neclab.iotplatform.ngsiemulator/README.md b/eu.neclab.iotplatform.ngsiemulator/README.md index 52d72441..9c010a4c 100644 --- a/eu.neclab.iotplatform.ngsiemulator/README.md +++ b/eu.neclab.iotplatform.ngsiemulator/README.md @@ -45,7 +45,7 @@ mvn clean install Afterwards you can proceed to generate the executable jar file: ``` -cd neclab.iotplatform.ngsiemulator/ +cd eu.neclab.iotplatform.ngsiemulator/ mvn clean install ``` @@ -180,7 +180,7 @@ java -cp ngsiemulator-$VERSION-jar-with-dependencies.jar \ -Deu.neclab.ioplatform.ngsiemulator.iotapplication.ports=8201 \ eu.neclab.iotplatform.ngsiemulator.server.MainIoTApplication ``` -This will open a server listening on port 8201 and exposing the *ngsi10/notifyContext resource*. +This will open a server listening on port 8201 and exposing the *ngsi10/notify* and *ngsi9/notify* resource. It is possible to open more than one server with only one command (one thread each server), by expressing more than one port. It is allowed ranges (e.g. 8001-8005) and single ports (e.g. 8001) separated by comma. E.g.: diff --git a/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/iotproducer/IoTProducer.java b/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/iotproducer/IoTProducer.java index fbc5a0cb..1381d61c 100644 --- a/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/iotproducer/IoTProducer.java +++ b/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/iotproducer/IoTProducer.java @@ -42,200 +42,203 @@ * DAMAGE. ******************************************************************************/ -package eu.neclab.iotplatform.ngsiemulator.iotproducer; - -import javax.ws.rs.Path; - -import org.apache.log4j.Logger; - -import eu.neclab.iotplatform.ngsiemulator.utils.Mode; - -@Path("ngsi10") -public class IoTProducer { - - // The logger - private static Logger logger = Logger.getLogger(IoTProducer.class); - - private static String path = System.getProperty( - "eu.neclab.ioplatform.ngsiemulator.iotproducer.path", "xml/"); - - private static Mode mode = Mode.fromString( - System.getProperty("eu.neclab.ioplatform.ngsiemulator.iotproducer.mode"), - Mode.RANDOM); - - private static int period = Integer - .parseInt( - System.getProperty("eu.neclab.ioplatform.ngsiemulator.iotproducer.period"), - 1000); - - private static String reference = System.getProperty( - "eu.neclab.ioplatform.ngsiemulator.iotproducer.reference", - "http://localhost:8060/ngsi10/updateContext"); - - // private static String notificationFile = "notification.xml"; -// private static String queryContextResponseFile = "queryContextResponse.xml"; -// private static String notifyContextRequestFile = "notifyContextRequest.xml"; -// private static String subscribeContextResponseFile = "subscribeContextResponse.xml"; - private static String updateContextRequestsFile = "updateContextRequests.xml"; - - -// public IoTProducer() { -// -// if (mode == Mode.FROMFILE) { -// -// ScheduledExecutorService executorService = Executors -// .newScheduledThreadPool(1); -// executorService.scheduleWithFixedDelay(new Runnable() { -// @Override -// public void run() { -// -// Connector conn = null; -// try { -// conn = new Connector(new URL(reference)); -// -// } catch (MalformedURLException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// conn.start("", "POST", readNotifyFromFile(id.toString())); -// -// } -// -// }, 1000, period, TimeUnit.MILLISECONDS); -// -// } else if (mode == Mode.RANDOM) { -// -// -// -// } -// -// } -// -// @GET -// @Path("/test") -// @Produces("application/xml") -// public String test() { -// -// return "test"; -// -// } -// -// @POST -// @Path("/testPost") -// @Produces("application/json") -// public String testPost(String body) { -// logger.info("Received a testPost:" + body); -// return "test"; -// -// } -// -// public static String readNotifyFromFile() { -// -// NotifyContextRequest response = new NotifyContextRequest(); -// String file = null; -// try { -// -// file = path + "/" + updateContextRequestsFile; -// InputStream is = new FileInputStream(file); -// -// JAXBContext context; -// context = JAXBContext.newInstance(NotifyContextRequest.class); -// -// // Create the marshaller, this is the nifty little thing that -// // will actually transform the object into XML -// Unmarshaller unmarshaller = context.createUnmarshaller(); -// response = (NotifyContextRequest) unmarshaller.unmarshal(is); -// -// response.setOriginator(urlIoTAgent); -// response.setSubscriptionId(id); -// -// } catch (JAXBException e) { -// logger.error("JAXB ERROR!", e); -// } catch (FileNotFoundException e) { -// logger.error("FILE NOT FOUND!: " + file); -// } -// -// String resp = response.toString(); -// -// return resp; -// } -// -// @POST -// @Path("/subscribeContext") -// @Produces("application/xml") -// public SubscribeContextResponse subscriptionResponse(String body) { -// -// logger.info("Received a NGSI-10 SubscribeContext"); -// if (logger.isDebugEnabled()) { -// logger.debug("Received a NGSI-10 SubscribeContext: " + body); -// } -// -// final String reference; -// Pattern pattern_reference = Pattern -// .compile("(\\S+)"); -// -// Matcher matcher = pattern_reference -// .matcher(body.replaceAll("\\s+", "")); -// -// if (matcher.find()) { -// reference = matcher.group(1); -// } else { -// return null; -// } -// -// UniqueIDGenerator idGenerator = new UniqueIDGenerator(); -// final String id = idGenerator.getNextUniqueId(); -// ScheduledExecutorService executorService = Executors -// .newScheduledThreadPool(1); -// executorService.scheduleWithFixedDelay(new Runnable() { -// @Override -// public void run() { -// -// Connector conn = null; -// try { -// conn = new Connector(new URL(reference)); -// -// } catch (MalformedURLException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// conn.start("", "POST", readNotifyFromFile(id.toString())); -// -// } -// -// }, 1, 2, TimeUnit.SECONDS); -// -// SubscribeContextResponse response = new SubscribeContextResponse(); -// -// String file = null; -// try { -// file = path + "/" + subscribeContextResponseFile; -// InputStream is = new FileInputStream(path + "/" -// + subscribeContextResponseFile); -// -// JAXBContext context; -// context = JAXBContext.newInstance(SubscribeContextResponse.class); -// -// // Create the marshaller, this is the nifty little thing that -// // will actually transform the object into XML -// Unmarshaller unmarshaller = context.createUnmarshaller(); -// response = (SubscribeContextResponse) unmarshaller.unmarshal(is); -// -// response.setSubscribeResponse(new SubscribeResponse(id.toString(), -// response.getSubscribeResponse().getDuration(), null)); -// -// if (logger.isDebugEnabled()) { -// logger.debug("NGSI-10 Subscribe response: " + response); -// } -// -// } catch (JAXBException e) { -// logger.error("JAXB ERROR!", e); -// } catch (FileNotFoundException e) { -// logger.error("FILE NOT FOUND!: " + file); -// } -// -// return response; -// -// } - -} +package eu.neclab.iotplatform.ngsiemulator.iotproducer; + +import javax.ws.rs.Path; + +import org.apache.log4j.Logger; + +import eu.neclab.iotplatform.iotbroker.commons.ParseUtils; +import eu.neclab.iotplatform.ngsiemulator.utils.Mode; + +@Path("ngsi10") +public class IoTProducer { + + // The logger + private static Logger logger = Logger.getLogger(IoTProducer.class); + + private static String path = System.getProperty( + "eu.neclab.ioplatform.ngsiemulator.iotproducer.path", "xml/"); + + private static Mode mode = Mode.fromString(System + .getProperty("eu.neclab.ioplatform.ngsiemulator.iotproducer.mode"), + Mode.RANDOM); + + private static int period = ParseUtils + .parseIntOrDefault( + System.getProperty("eu.neclab.ioplatform.ngsiemulator.iotproducer.period"), + 1000); + + private static String reference = System.getProperty( + "eu.neclab.ioplatform.ngsiemulator.iotproducer.reference", + "http://localhost:8060/ngsi10/updateContext"); + + // private static String notificationFile = "notification.xml"; + // private static String queryContextResponseFile = + // "queryContextResponse.xml"; + // private static String notifyContextRequestFile = + // "notifyContextRequest.xml"; + // private static String subscribeContextResponseFile = + // "subscribeContextResponse.xml"; + private static String updateContextRequestsFile = "updateContextRequests.xml"; + + // public IoTProducer() { + // + // if (mode == Mode.FROMFILE) { + // + // ScheduledExecutorService executorService = Executors + // .newScheduledThreadPool(1); + // executorService.scheduleWithFixedDelay(new Runnable() { + // @Override + // public void run() { + // + // Connector conn = null; + // try { + // conn = new Connector(new URL(reference)); + // + // } catch (MalformedURLException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + // conn.start("", "POST", readNotifyFromFile(id.toString())); + // + // } + // + // }, 1000, period, TimeUnit.MILLISECONDS); + // + // } else if (mode == Mode.RANDOM) { + // + // + // + // } + // + // } + // + // @GET + // @Path("/test") + // @Produces("application/xml") + // public String test() { + // + // return "test"; + // + // } + // + // @POST + // @Path("/testPost") + // @Produces("application/json") + // public String testPost(String body) { + // logger.info("Received a testPost:" + body); + // return "test"; + // + // } + // + // public static String readNotifyFromFile() { + // + // NotifyContextRequest response = new NotifyContextRequest(); + // String file = null; + // try { + // + // file = path + "/" + updateContextRequestsFile; + // InputStream is = new FileInputStream(file); + // + // JAXBContext context; + // context = JAXBContext.newInstance(NotifyContextRequest.class); + // + // // Create the marshaller, this is the nifty little thing that + // // will actually transform the object into XML + // Unmarshaller unmarshaller = context.createUnmarshaller(); + // response = (NotifyContextRequest) unmarshaller.unmarshal(is); + // + // response.setOriginator(urlIoTAgent); + // response.setSubscriptionId(id); + // + // } catch (JAXBException e) { + // logger.error("JAXB ERROR!", e); + // } catch (FileNotFoundException e) { + // logger.error("FILE NOT FOUND!: " + file); + // } + // + // String resp = response.toString(); + // + // return resp; + // } + // + // @POST + // @Path("/subscribeContext") + // @Produces("application/xml") + // public SubscribeContextResponse subscriptionResponse(String body) { + // + // logger.info("Received a NGSI-10 SubscribeContext"); + // if (logger.isDebugEnabled()) { + // logger.debug("Received a NGSI-10 SubscribeContext: " + body); + // } + // + // final String reference; + // Pattern pattern_reference = Pattern + // .compile("(\\S+)"); + // + // Matcher matcher = pattern_reference + // .matcher(body.replaceAll("\\s+", "")); + // + // if (matcher.find()) { + // reference = matcher.group(1); + // } else { + // return null; + // } + // + // UniqueIDGenerator idGenerator = new UniqueIDGenerator(); + // final String id = idGenerator.getNextUniqueId(); + // ScheduledExecutorService executorService = Executors + // .newScheduledThreadPool(1); + // executorService.scheduleWithFixedDelay(new Runnable() { + // @Override + // public void run() { + // + // Connector conn = null; + // try { + // conn = new Connector(new URL(reference)); + // + // } catch (MalformedURLException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + // conn.start("", "POST", readNotifyFromFile(id.toString())); + // + // } + // + // }, 1, 2, TimeUnit.SECONDS); + // + // SubscribeContextResponse response = new SubscribeContextResponse(); + // + // String file = null; + // try { + // file = path + "/" + subscribeContextResponseFile; + // InputStream is = new FileInputStream(path + "/" + // + subscribeContextResponseFile); + // + // JAXBContext context; + // context = JAXBContext.newInstance(SubscribeContextResponse.class); + // + // // Create the marshaller, this is the nifty little thing that + // // will actually transform the object into XML + // Unmarshaller unmarshaller = context.createUnmarshaller(); + // response = (SubscribeContextResponse) unmarshaller.unmarshal(is); + // + // response.setSubscribeResponse(new SubscribeResponse(id.toString(), + // response.getSubscribeResponse().getDuration(), null)); + // + // if (logger.isDebugEnabled()) { + // logger.debug("NGSI-10 Subscribe response: " + response); + // } + // + // } catch (JAXBException e) { + // logger.error("JAXB ERROR!", e); + // } catch (FileNotFoundException e) { + // logger.error("FILE NOT FOUND!: " + file); + // } + // + // return response; + // + // } + +} diff --git a/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/iotprovider/IoTProvider.java b/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/iotprovider/IoTProvider.java index ca4bf8d1..648b92f9 100644 --- a/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/iotprovider/IoTProvider.java +++ b/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/iotprovider/IoTProvider.java @@ -74,6 +74,7 @@ import eu.neclab.iotplatform.iotbroker.commons.ContentType; import eu.neclab.iotplatform.iotbroker.commons.FullHttpRequester; import eu.neclab.iotplatform.iotbroker.commons.FullHttpResponse; +import eu.neclab.iotplatform.iotbroker.commons.ParseUtils; import eu.neclab.iotplatform.ngsi.api.datamodel.Code; import eu.neclab.iotplatform.ngsi.api.datamodel.ContextAttribute; import eu.neclab.iotplatform.ngsi.api.datamodel.ContextElement; @@ -505,12 +506,8 @@ public String subscriptionResponse(@Context HttpHeaders headers, // Get the period of notification from configurations Integer period; Object contextPeriod = config.getProperty("notificationPeriod"); - if (contextPeriod != null && contextPeriod instanceof String) { - period = (Integer) Integer.parseInt((String) contextPeriod, - ServerConfiguration.DEFAULT_NOTIFICATIONPERIOD); - } else { - period = ServerConfiguration.DEFAULT_NOTIFICATIONPERIOD; - } + period = ParseUtils.parseIntOrDefault(contextPeriod, + ServerConfiguration.DEFAULT_NOTIFICATIONPERIOD); // Create the timer for the notification thread ScheduledExecutorService executorService = Executors diff --git a/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/server/MainIoTConsumer.java b/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/server/MainIoTConsumer.java index e5585a6d..ca6cef49 100644 --- a/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/server/MainIoTConsumer.java +++ b/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/server/MainIoTConsumer.java @@ -51,9 +51,6 @@ public class MainIoTConsumer { - // private static int portNumber = - // Integer.parseInt(System.getProperty("eu.neclab.ioplatform.ngsiemulator.iotconsumer.port", - // "8001")); private static String portNumbers = System.getProperty( "eu.neclab.ioplatform.ngsiemulator.iotconsumer.ports", "8001"); diff --git a/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/server/MainIoTProvider.java b/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/server/MainIoTProvider.java index c77f3a1e..5d1010dd 100644 --- a/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/server/MainIoTProvider.java +++ b/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/server/MainIoTProvider.java @@ -70,6 +70,7 @@ import eu.neclab.iotplatform.iotbroker.commons.ContentType; import eu.neclab.iotplatform.iotbroker.commons.FullHttpRequester; +import eu.neclab.iotplatform.iotbroker.commons.ParseUtils; import eu.neclab.iotplatform.ngsi.api.datamodel.ContextRegistration; import eu.neclab.iotplatform.ngsi.api.datamodel.ContextRegistrationAttribute; import eu.neclab.iotplatform.ngsi.api.datamodel.EntityId; @@ -320,15 +321,18 @@ private static ServerConfiguration getSpecificServerConfiguration( + portNumber + ".notifyContextRequestFile", notifyContextRequestFile)); - serverNotificationPeriod = parseOrDefault( - configurations.get("eu.neclab.ioplatform.ngsiemulator.iotprovider." - + portNumber + ".notificationPeriod"), - parseOrDefault( - properties - .getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider." + serverNotificationPeriod = ParseUtils + .parseIntOrDefault( + configurations + .get("eu.neclab.ioplatform.ngsiemulator.iotprovider." + portNumber + ".notificationPeriod"), - notificationPeriod)); + ParseUtils.parseIntOrDefault( + properties + .getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider." + + portNumber + + ".notificationPeriod"), + notificationPeriod)); serverIncomingContentType = ContentType .fromString( @@ -373,10 +377,13 @@ private static ServerConfiguration getSpecificServerConfiguration( + portNumber + ".notifyContextRequestFile", notifyContextRequestFile); - serverNotificationPeriod = parseOrDefault( - properties.getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider." - + portNumber + ".notificationPeriod"), - notificationPeriod); + serverNotificationPeriod = ParseUtils + .parseIntOrDefault( + properties + .getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider." + + portNumber + + ".notificationPeriod"), + notificationPeriod); serverIncomingContentType = ContentType .fromString( @@ -489,18 +496,20 @@ private static void setBasicConfigurations() { * Number of EntityIds to select amongst the EntityIds. */ if (configurations != null) { - numberOfEntityIdsToSelect = parseOrDefault( - configurations - .get("eu.neclab.ioplatform.ngsiemulator.iotprovider.numberOfEntityIdsToSelect"), - parseOrDefault( + numberOfEntityIdsToSelect = ParseUtils + .parseIntOrDefault( + configurations + .get("eu.neclab.ioplatform.ngsiemulator.iotprovider.numberOfEntityIdsToSelect"), + ParseUtils.parseIntOrDefault( + properties + .getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider.numberOfEntityIdsToSelect"), + ServerConfiguration.DEFAULT_NUMBEROFENTITYIDSTOSELECT)); + } else { + numberOfEntityIdsToSelect = ParseUtils + .parseIntOrDefault( properties .getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider.numberOfEntityIdsToSelect"), - ServerConfiguration.DEFAULT_NUMBEROFENTITYIDSTOSELECT)); - } else { - numberOfEntityIdsToSelect = parseOrDefault( - properties - .getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider.numberOfEntityIdsToSelect"), - ServerConfiguration.DEFAULT_NUMBEROFENTITYIDSTOSELECT); + ServerConfiguration.DEFAULT_NUMBEROFENTITYIDSTOSELECT); } /* @@ -525,18 +534,20 @@ private static void setBasicConfigurations() { * Number of Attributes to select amongst the Attributes. */ if (configurations != null) { - numberOfAttributesToSelect = parseOrDefault( - configurations - .get("eu.neclab.ioplatform.ngsiemulator.iotprovider.numberOfAttributesToSelect"), - parseOrDefault( + numberOfAttributesToSelect = ParseUtils + .parseIntOrDefault( + configurations + .get("eu.neclab.ioplatform.ngsiemulator.iotprovider.numberOfAttributesToSelect"), + ParseUtils.parseIntOrDefault( + properties + .getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider.numberOfAttributesToSelect"), + ServerConfiguration.DEFAULT_NUMBEROFATTRIBUTESTOSELECT)); + } else { + numberOfAttributesToSelect = ParseUtils + .parseIntOrDefault( properties .getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider.numberOfAttributesToSelect"), - ServerConfiguration.DEFAULT_NUMBEROFATTRIBUTESTOSELECT)); - } else { - numberOfAttributesToSelect = parseOrDefault( - properties - .getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider.numberOfAttributesToSelect"), - ServerConfiguration.DEFAULT_NUMBEROFATTRIBUTESTOSELECT); + ServerConfiguration.DEFAULT_NUMBEROFATTRIBUTESTOSELECT); } /* @@ -580,18 +591,20 @@ private static void setBasicConfigurations() { * notificationPeriod */ if (configurations != null) { - notificationPeriod = parseOrDefault( - configurations - .get("eu.neclab.ioplatform.ngsiemulator.iotprovider.notificationPeriod"), - parseOrDefault( + notificationPeriod = ParseUtils + .parseIntOrDefault( + configurations + .get("eu.neclab.ioplatform.ngsiemulator.iotprovider.notificationPeriod"), + ParseUtils.parseIntOrDefault( + properties + .getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider.notificationPeriod"), + ServerConfiguration.DEFAULT_NOTIFICATIONPERIOD)); + } else { + notificationPeriod = ParseUtils + .parseIntOrDefault( properties .getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider.notificationPeriod"), - ServerConfiguration.DEFAULT_NOTIFICATIONPERIOD)); - } else { - notificationPeriod = parseOrDefault( - properties - .getProperty("eu.neclab.ioplatform.ngsiemulator.iotprovider.notificationPeriod"), - ServerConfiguration.DEFAULT_NOTIFICATIONPERIOD); + ServerConfiguration.DEFAULT_NOTIFICATIONPERIOD); } /* @@ -686,21 +699,6 @@ private static void setBasicConfigurations() { } - private static Integer parseOrDefault(String string, Integer defaultValue) { - - Integer integer; - - try { - integer = Integer.parseInt(string); - - } catch (NumberFormatException e) { - integer = defaultValue; - } - - return integer; - - } - private static Set chooseEntityNames() { // This Set will contain the chosen entityIds Set diff --git a/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/server/ServerDummy.java b/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/server/ServerDummy.java index 0174aaf5..557cfbbd 100644 --- a/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/server/ServerDummy.java +++ b/eu.neclab.iotplatform.ngsiemulator/src/main/java/eu/neclab/iotplatform/ngsiemulator/server/ServerDummy.java @@ -59,26 +59,6 @@ public class ServerDummy { private ServletHolder sh; - // private static int numIoTagent; - - // private static Properties prop = new Properties(); - - // public static void loadPropAndSet() { - // - // try { - // prop.load(new FileInputStream(".\\config\\config.properties")); - // ServerDummy.numIoTagent = Integer.parseInt(prop - // .getProperty("numIoTagent")); - // } catch (FileNotFoundException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } catch (IOException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // - // } - public void startServer(int port, String classBound) throws BindException, Exception { sh = new ServletHolder(ServletContainer.class); @@ -112,10 +92,6 @@ public void startServer(int port, String classBound, sh.setInitParameter("com.sun.jersey.config.property.packages", classBound); - // custom parameters - // Map initParameters = getCustomInitParamters(port); - // sh.setInitParameters(initParameters); - // sh.setInitParameters(configurations.toMap()); for (Entry entry : configurations.toMap().entrySet()) { sh.setInitParameter(entry.getKey(), entry.getValue()); } @@ -129,33 +105,6 @@ public void startServer(int port, String classBound, } - // private Map getCustomInitParamters(int port, - // Map configurations) { - // - // Map initParameters = new HashMap(); - // - // String mode = configurations - // .get("eu.neclab.iotplaform.ngsiemulator.iotprovider." + port + ".mode"); - // if (mode != null) { - // - // initParameters.put("mode", Mode.fromString(mode, Mode.RANDOM)); - // - // } - // - // String queryContextResponseFile = System.getProperty( - // "eu.neclab.iotplaform.ngsiemulator.iotprovider." + port - // + ".queryContextResponseFile", - // "QueryContextResponse.xml"); - // if (queryContextResponseFile != null) { - // - // initParameters.put("queryContextResponseFile", - // queryContextResponseFile); - // - // } - // - // return initParameters; - // } - public void stopServer() { try { @@ -167,35 +116,6 @@ public void stopServer() { } - // public static void main(String[] args) { - // - // ServerDummy server = new ServerDummy(); - // loadPropAndSet(); - // - // try { - // // For Testing - // // server.startServer(8999, "eu.fiware.neclab.test.ngsi.configman"); - // // - // // for(int i=0;i