diff --git a/CMakeLists.txt b/CMakeLists.txt index 25025b563c..74c7c37443 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -194,11 +194,12 @@ SET (ORION_LIBS jsonParseV2 rest # this is repeated for linking str2Verb from parseSubscription@parseSubscription.cpp.o; # verbName(Verb) from setExtendedHttpInfo@MongoCommonSubscription.cpp.o + mongoBackend ngsi9 ngsi10 ngsi cache - mongoBackend + mongoBackend # repeated (probably due to some circular dependency between mongoBackend and ngsi) mongoDriver parse apiTypesV2 diff --git a/doc/manuals/devel/sourceCode.md b/doc/manuals/devel/sourceCode.md index 0ed246c75d..2b8cc1f740 100644 --- a/doc/manuals/devel/sourceCode.md +++ b/doc/manuals/devel/sourceCode.md @@ -248,8 +248,8 @@ The **ngsi10** library contains the top hierarchy classes for NGSI10 (NGSIv1) re * `QueryContextResponse` * `SubscribeContextRequest` * `SubscribeContextResponse` -* `UpdateContextSubscriptionRequest` -* `UpdateContextSubscriptionResponse` +* `UpdateContextSubscriptionRequest` - FIXME PR: removed +* `UpdateContextSubscriptionResponse` - FIXME PR: removed * `UnsubscribeContextRequest` * `UnsubscribeContextResponse` * `NotifyContextRequest` (outgoing request, sent by Orion, to notify subscribers) @@ -263,10 +263,10 @@ See the explanation of methods and hierarchy of the [**ngsi** library](#methods- ## src/lib/ngsi9/ Just like the ngsi10 library, the **ngsi9** library contains the top hierarchy classes for NGSI9 (NGSIv1) requests: -* `RegisterContextRequest` -* `RegisterContextResponse` +* `RegisterContextRequest` - FIXME PR: removed +* `RegisterContextResponse` - FIXME PR: removed * `DiscoverContextAvailabilityRequest` -* `DiscoverContextAvailabilityResponse` +* `DiscoverContextAvailabilityResponse` - FIXME PR: removed See the explanation of methods and hierarchy of the [**ngsi** library](#methods-and-hierarchy). diff --git a/scripts/accumulator-server.py b/scripts/accumulator-server.py index 44c4481581..48a8095706 100755 --- a/scripts/accumulator-server.py +++ b/scripts/accumulator-server.py @@ -544,6 +544,24 @@ def cpr_simulation(): "code": "200", "reasonPhrase": "OK" } + }, + { + "contextElement": { + "attributes": [ + { + "name": "pressure", + "type": "degree", + "value": "14" + } + ], + "id": "ConferenceRoom3", + "isPattern": "false", + "type": "Room" + }, + "statusCode": { + "code": "200", + "reasonPhrase": "OK" + } } ] } diff --git a/scripts/style_check_in_makefile.sh b/scripts/style_check_in_makefile.sh index cfb7845890..dbb01f7858 100755 --- a/scripts/style_check_in_makefile.sh +++ b/scripts/style_check_in_makefile.sh @@ -108,8 +108,6 @@ style_check test/unittests/serviceRoutines # o common/string.h (haderding/remove_ngsiv1_indent: 1 include, 1 external declaration) # o common/globals.h (feature/mqtt_notifications_poc: 1 external declaration) # o common/globals.h (haderding/remove_ngsiv1_indent: 1 new external declaration) -# o common/tag.cpp (haderding/remove_ngsiv1_indent: 'indent' removed from 6 signatures, slight change in 6 functions) -# o common/tag.h (haderding/remove_ngsiv1_indent: 'indent' removed from 6 signatures) # o common/macroSubstitute.cpp (haderding/remove_ngsiv1_indent: 2 lines: a param added to toJson()) # # o rest/httpRequestSend.cpp (feature/mqtt_notifications_poc: 1 include, 1 new function, addition in httpRequestSendWithCurl()) diff --git a/src/lib/apiTypesV2/Attribute.cpp b/src/lib/apiTypesV2/Attribute.cpp index 2986b5c157..45ccf441e5 100644 --- a/src/lib/apiTypesV2/Attribute.cpp +++ b/src/lib/apiTypesV2/Attribute.cpp @@ -25,7 +25,6 @@ #include #include -#include "common/tag.h" #include "common/errorMessages.h" #include "common/RenderFormat.h" #include "common/string.h" diff --git a/src/lib/apiTypesV2/Entity.cpp b/src/lib/apiTypesV2/Entity.cpp index 1ecc851ca1..87838ee4fe 100644 --- a/src/lib/apiTypesV2/Entity.cpp +++ b/src/lib/apiTypesV2/Entity.cpp @@ -28,7 +28,6 @@ #include "logMsg/traceLevels.h" #include "logMsg/logMsg.h" -#include "common/tag.h" #include "common/string.h" #include "common/globals.h" #include "common/JsonHelper.h" @@ -227,67 +226,6 @@ void Entity::filterAndOrderAttrs - -/* **************************************************************************** -* -* Entity::toJsonV1 - -* -* This method was ported from old ContextElement class. It was name render() there -* -*/ -std::string Entity::toJsonV1 -( - bool asJsonObject, - RequestType requestType, - const std::vector& attrsFilter, - bool blacklist, - const std::vector& metadataFilter, - bool comma, - bool omitAttributeValues -) -{ - std::string out = ""; - bool contextAttributeVectorRendered = attributeVector.size() != 0; - - out += startTag(requestType != UpdateContext? "contextElement" : ""); - - // Filter and order attributes - std::vector orderedAttrs; - filterAndOrderAttrs(attrsFilter, blacklist, &orderedAttrs); - - EntityId en(id, type, isPattern); - out += en.toJsonV1(contextAttributeVectorRendered, false); - out += attributeVector.toJsonV1(asJsonObject, requestType, orderedAttrs, metadataFilter, false, omitAttributeValues); - - out += endTag(comma, false); - - return out; -} - - - -/* **************************************************************************** -* -* Entity::toJsonV1 - -* -* Wrapper of toJsonV1 with empty attrsFilter and metadataFilter -* -*/ -std::string Entity::toJsonV1 -( - bool asJsonObject, - RequestType requestType, - bool blacklist, - bool comma, - bool omitAttributeValues -) -{ - std::vector emptyV; - return toJsonV1(asJsonObject, requestType, emptyV, blacklist, emptyV, comma, omitAttributeValues); -} - - - /* **************************************************************************** * * Entity::toJson - diff --git a/src/lib/apiTypesV2/Entity.h b/src/lib/apiTypesV2/Entity.h index ce6a65487c..3cf63d4e43 100644 --- a/src/lib/apiTypesV2/Entity.h +++ b/src/lib/apiTypesV2/Entity.h @@ -73,20 +73,6 @@ class Entity ~Entity(); - std::string toJsonV1(bool asJsonObject, - RequestType requestType, - const std::vector& attrsFilter, - bool blacklist, - const std::vector& metadataFilter, - bool comma, - bool omitAttributeValues = false); - - std::string toJsonV1(bool asJsonObject, - RequestType requestType, - bool blacklist, - bool comma, - bool omitAttributeValues = false); - std::string toJson(RenderFormat renderFormat, const std::vector& attrsFilter, bool blacklist, diff --git a/src/lib/apiTypesV2/EntityVector.cpp b/src/lib/apiTypesV2/EntityVector.cpp index 0de08e8320..2dc84e27e5 100644 --- a/src/lib/apiTypesV2/EntityVector.cpp +++ b/src/lib/apiTypesV2/EntityVector.cpp @@ -32,7 +32,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "common/JsonHelper.h" #include "alarmMgr/alarmMgr.h" @@ -96,40 +95,6 @@ std::string EntityVector::toJson(RenderFormat renderFormat) -/* **************************************************************************** -* -* EntityVector::toJsonV1 - -* -* Ported from old class ContextElementVector -*/ -std::string EntityVector::toJsonV1 -( - bool asJsonObject, - RequestType requestType, - bool comma -) -{ - std::string out = ""; - - if (vec.size() == 0) - { - return ""; - } - - out += startTag("contextElements", true); - - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - out += vec[ix]->toJsonV1(asJsonObject, requestType, false, ix != vec.size() - 1); - } - - out += endTag(comma, true); - - return out; -} - - - /* **************************************************************************** * * EntityVector::check - diff --git a/src/lib/apiTypesV2/EntityVector.h b/src/lib/apiTypesV2/EntityVector.h index f4420d4617..3c293236fd 100644 --- a/src/lib/apiTypesV2/EntityVector.h +++ b/src/lib/apiTypesV2/EntityVector.h @@ -48,8 +48,6 @@ typedef struct EntityVector std::string toJson(RenderFormat renderFormat); - std::string toJsonV1(bool asJsonObject, RequestType requestType, bool comma); - std::string check(RequestType requestType); void push_back(Entity* item); unsigned int size(void); diff --git a/src/lib/common/CMakeLists.txt b/src/lib/common/CMakeLists.txt index 07ba47566f..13d2594e2a 100644 --- a/src/lib/common/CMakeLists.txt +++ b/src/lib/common/CMakeLists.txt @@ -23,7 +23,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0) SET (SOURCES globals.cpp string.cpp - tag.cpp sem.cpp MimeType.cpp RenderFormat.cpp diff --git a/src/lib/common/statistics.cpp b/src/lib/common/statistics.cpp index 1a6dd710ff..a78aeca57a 100644 --- a/src/lib/common/statistics.cpp +++ b/src/lib/common/statistics.cpp @@ -23,7 +23,6 @@ * Author: Ken Zangelin */ #include "common/statistics.h" -#include "common/tag.h" #include "ngsi/Request.h" #include "logMsg/logMsg.h" #include "common/JsonHelper.h" diff --git a/src/lib/common/string.cpp b/src/lib/common/string.cpp index 2bfc72e99a..03930c6bf9 100644 --- a/src/lib/common/string.cpp +++ b/src/lib/common/string.cpp @@ -1139,3 +1139,113 @@ bool regComp(regex_t* re, const char* pattern, int flags) return false; } + + + +/* **************************************************************************** +* +* htmlEscape - +* +* Allocate a new buffer to hold an escaped version of the input buffer 's'. +* Escaping characters demands more space in the buffer, for some characters up to six +* characters - double-quote (") needs SIX chars: " +* So, when allocating room for the output (escaped) buffer, we need to consider the worst case +* and six times the length of the input buffer is allocated (plus one byte for the zero-termination. +* +* See http://www.anglesanddangles.com/asciichart.php for more info on the 'html-escpaing' of ASCII chars. +*/ +char* htmlEscape(const char* s) +{ + int newLen = strlen(s) * 6 + 1; // See function header comment + char* out = (char*) calloc(1, newLen); + int sIx = 0; + int outIx = 0; + + if (out == NULL) + { + LM_E(("Runtime Error (allocating %d bytes: %s)", newLen, strerror(errno))); + return NULL; + } + + while (s[sIx] != 0) + { + switch (s[sIx]) + { + case '<': + out[outIx++] = '&'; + out[outIx++] = 'l'; + out[outIx++] = 't'; + out[outIx++] = ';'; + ++sIx; + break; + + case '>': + out[outIx++] = '&'; + out[outIx++] = 'g'; + out[outIx++] = 't'; + out[outIx++] = ';'; + ++sIx; + break; + + case '(': + out[outIx++] = '&'; + out[outIx++] = '#'; + out[outIx++] = '4'; + out[outIx++] = '0'; + out[outIx++] = ';'; + ++sIx; + break; + + case ')': + out[outIx++] = '&'; + out[outIx++] = '#'; + out[outIx++] = '4'; + out[outIx++] = '1'; + out[outIx++] = ';'; + ++sIx; + break; + + case '=': + out[outIx++] = '&'; + out[outIx++] = '#'; + out[outIx++] = '6'; + out[outIx++] = '1'; + out[outIx++] = ';'; + ++sIx; + break; + + case '\'': + out[outIx++] = '&'; + out[outIx++] = '#'; + out[outIx++] = '3'; + out[outIx++] = '9'; + out[outIx++] = ';'; + ++sIx; + break; + + case '"': + out[outIx++] = '&'; + out[outIx++] = 'q'; + out[outIx++] = 'u'; + out[outIx++] = 'o'; + out[outIx++] = 't'; + out[outIx++] = ';'; + ++sIx; + break; + + case ';': + out[outIx++] = '&'; + out[outIx++] = '#'; + out[outIx++] = '5'; + out[outIx++] = '9'; + out[outIx++] = ';'; + ++sIx; + break; + + default: + out[outIx++] = s[sIx++]; + } + } + + return out; +} \ No newline at end of file diff --git a/src/lib/common/string.h b/src/lib/common/string.h index f3abcee416..c26464a5a0 100644 --- a/src/lib/common/string.h +++ b/src/lib/common/string.h @@ -36,6 +36,16 @@ // the same macro in parseArg library #define FT(x) (x == true)? "true" : "false" + + +/* **************************************************************************** +* +* Macros for JSON rendering +*/ +#define JSON_STR(value) std::string("\"" + std::string(value) + "\"") + + + /* **************************************************************************** * * isIPv6 - @@ -237,4 +247,12 @@ inline std::string removeQuotes(std::string s) +/* **************************************************************************** +* +* htmlEscape - +*/ +extern char* htmlEscape(const char* s); + + + #endif // SRC_LIB_COMMON_STRING_H_ diff --git a/src/lib/common/tag.cpp b/src/lib/common/tag.cpp deleted file mode 100644 index d9d084621d..0000000000 --- a/src/lib/common/tag.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include -#include -#include - -#include "logMsg/logMsg.h" -#include "common/tag.h" -#include "common/JsonHelper.h" - - - -/* **************************************************************************** -* -* htmlEscape - -* -* Allocate a new buffer to hold an escaped version of the input buffer 's'. -* Escaping characters demands more space in the buffer, for some characters up to six -* characters - double-quote (") needs SIX chars: " -* So, when allocating room for the output (escaped) buffer, we need to consider the worst case -* and six times the length of the input buffer is allocated (plus one byte for the zero-termination. -* -* See http://www.anglesanddangles.com/asciichart.php for more info on the 'html-escpaing' of ASCII chars. -*/ -char* htmlEscape(const char* s) -{ - int newLen = strlen(s) * 6 + 1; // See function header comment - char* out = (char*) calloc(1, newLen); - int sIx = 0; - int outIx = 0; - - if (out == NULL) - { - LM_E(("Runtime Error (allocating %d bytes: %s)", newLen, strerror(errno))); - return NULL; - } - - while (s[sIx] != 0) - { - switch (s[sIx]) - { - case '<': - out[outIx++] = '&'; - out[outIx++] = 'l'; - out[outIx++] = 't'; - out[outIx++] = ';'; - ++sIx; - break; - - case '>': - out[outIx++] = '&'; - out[outIx++] = 'g'; - out[outIx++] = 't'; - out[outIx++] = ';'; - ++sIx; - break; - - case '(': - out[outIx++] = '&'; - out[outIx++] = '#'; - out[outIx++] = '4'; - out[outIx++] = '0'; - out[outIx++] = ';'; - ++sIx; - break; - - case ')': - out[outIx++] = '&'; - out[outIx++] = '#'; - out[outIx++] = '4'; - out[outIx++] = '1'; - out[outIx++] = ';'; - ++sIx; - break; - - case '=': - out[outIx++] = '&'; - out[outIx++] = '#'; - out[outIx++] = '6'; - out[outIx++] = '1'; - out[outIx++] = ';'; - ++sIx; - break; - - case '\'': - out[outIx++] = '&'; - out[outIx++] = '#'; - out[outIx++] = '3'; - out[outIx++] = '9'; - out[outIx++] = ';'; - ++sIx; - break; - - case '"': - out[outIx++] = '&'; - out[outIx++] = 'q'; - out[outIx++] = 'u'; - out[outIx++] = 'o'; - out[outIx++] = 't'; - out[outIx++] = ';'; - ++sIx; - break; - - case ';': - out[outIx++] = '&'; - out[outIx++] = '#'; - out[outIx++] = '5'; - out[outIx++] = '9'; - out[outIx++] = ';'; - ++sIx; - break; - - default: - out[outIx++] = s[sIx++]; - } - } - - return out; -} - - - -/* **************************************************************************** -* -* startTag - -*/ -std::string startTag -( - const std::string& key, - bool isVector -) -{ - // Empty key is legal JSON. However, Orion doesn't use that kind of keys, - // so we can use an empty key string as argument instead of a showkey boolean - // parameter, keeping the function signature simpler - bool showKey = (!key.empty()); - - if (isVector && showKey) - { - return "\"" + key + "\":["; - } - else if (isVector && !showKey) - { - return "["; - } - else if (!isVector && showKey) - { - return "\"" + key + "\":{"; - } - - // else: !isVector && !showKey - - return "{"; -} - - - -/* **************************************************************************** -* -* endTag - -*/ -std::string endTag -( - bool comma, - bool isVector -) -{ - std::string out = ""; - - out += isVector? "]" : "}"; - out += comma? "," : ""; - - return out; -} - - - -/* **************************************************************************** -* -* valueTag - -* -* Function version for string values -* -*/ -std::string valueTag -( - const std::string& key, - const std::string& unescapedValue, - bool showComma, - bool isVectorElement, - bool withoutQuotes -) -{ - char* value; - - if (unescapedValue.empty()) - { - value = (char*) malloc(1); - - *value = 0; - } - else - { - value = htmlEscape(unescapedValue.c_str()); - } - - if (value == NULL) - { - return "ERROR: no memory"; - } - - std::string effectiveValue = toJsonString(value); - free(value); - - effectiveValue = withoutQuotes ? effectiveValue : std::string("\"") + effectiveValue + "\""; - - if (showComma == true) - { - if (isVectorElement == true) - { - std::string out = effectiveValue + ","; - return out; - } - else - { - std::string out = "\"" + key + "\":" + effectiveValue + ","; - return out; - } - } - else - { - if (isVectorElement == true) - { - std::string out = effectiveValue; - return out; - } - else - { - std::string out = "\"" + key + "\":" + effectiveValue; - return out; - } - } -} - - - -/* **************************************************************************** -* -* valueTag - -* -* Function version for integer values -* -*/ -std::string valueTag -( - const std::string& key, - int value, - bool showComma -) -{ - char val[32]; - - snprintf(val, sizeof(val), "%d", value); - - return valueTag(key, val, showComma, false, false); -} - - diff --git a/src/lib/common/tag.h b/src/lib/common/tag.h deleted file mode 100644 index caf90a6832..0000000000 --- a/src/lib/common/tag.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef SRC_LIB_COMMON_TAG_H_ -#define SRC_LIB_COMMON_TAG_H_ - -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include - -/* FIXME P2: this file (along with some other places around all the code) uses - * the old term "tag", coming from the XML days. Now we only support JSON and - * all the terminology should use "key" or "keyName". We have changed terminology - * in many places, but there are yet some remains (not so important, anyway). - */ - - -/* **************************************************************************** -* -* Macros for JSON rendering -*/ -#define JSON_STR(value) std::string("\"" + std::string(value) + "\"") - - - -/* **************************************************************************** -* -* htmlEscape - -*/ -extern char* htmlEscape(const char* s); - -/* **************************************************************************** -* -* jsonInvalidCharsTransformation - -* -* FIXME P5: this is a quick fix for #1172. A better fix should be developed. -*/ -extern std::string jsonInvalidCharsTransformation(const std::string& input); - - - -/* **************************************************************************** -* -* startTag - -* -*/ -extern std::string startTag -( - const std::string& key = "", - bool isVector = false -); - - - -/* **************************************************************************** -* -* endTag - -*/ -extern std::string endTag -( - bool comma = false, - bool isVector = false -); - - - -/* **************************************************************************** -* -* valueTag - -* -*/ -extern std::string valueTag -( - const std::string& key, - const std::string& value, - bool showComma = false, - bool isVectorElement = false, - bool withoutQuotes = false -); - -extern std::string valueTag -( - const std::string& key, - int value, - bool showComma = false -); - - - -/* **************************************************************************** -* -* startArray - -*/ -extern std::string startArray -( - const std::string& key, - bool showKey = true -); - - - -/* **************************************************************************** -* -* endArray - -*/ -extern std::string endArray(const std::string& key); - -#endif // SRC_LIB_COMMON_TAG_H_ diff --git a/src/lib/jsonParseV2/jsonRequestTreat.h b/src/lib/jsonParseV2/jsonRequestTreat.h index cad8b0db79..86f2b3f2a7 100644 --- a/src/lib/jsonParseV2/jsonRequestTreat.h +++ b/src/lib/jsonParseV2/jsonRequestTreat.h @@ -32,7 +32,6 @@ #include "ngsi/ParseData.h" #include "ngsi/Request.h" #include "ngsi10/SubscribeContextRequest.h" -#include "ngsi10/UpdateContextSubscriptionRequest.h" #include "apiTypesV2/Subscription.h" @@ -46,7 +45,6 @@ typedef struct JsonDelayedRelease Entity* entity; ContextAttribute* attribute; SubscribeContextRequest* scrP; - UpdateContextSubscriptionRequest* ucsrP; ngsiv2::Subscription* subsP; JsonDelayedRelease() @@ -54,7 +52,6 @@ typedef struct JsonDelayedRelease entity = NULL; attribute = NULL; scrP = NULL; - ucsrP = NULL; subsP = NULL; } } JsonDelayedRelease; diff --git a/src/lib/jsonParseV2/parseEntitiesResponseV1.cpp b/src/lib/jsonParseV2/parseEntitiesResponseV1.cpp index a8da23aff8..4b45f9027b 100644 --- a/src/lib/jsonParseV2/parseEntitiesResponseV1.cpp +++ b/src/lib/jsonParseV2/parseEntitiesResponseV1.cpp @@ -1,6 +1,6 @@ /* * -* Copyright 2019 Telefonica Investigacion y Desarrollo, S.A.U +* Copyright 2024 Telefonica Investigacion y Desarrollo, S.A.U * * This file is part of Orion Context Broker. * diff --git a/src/lib/jsonParseV2/parseEntitiesResponseV1.h b/src/lib/jsonParseV2/parseEntitiesResponseV1.h index ee52636190..49e7644dcc 100644 --- a/src/lib/jsonParseV2/parseEntitiesResponseV1.h +++ b/src/lib/jsonParseV2/parseEntitiesResponseV1.h @@ -3,7 +3,7 @@ /* * -* Copyright 2015 Telefonica Investigacion y Desarrollo, S.A.U +* Copyright 2024 Telefonica Investigacion y Desarrollo, S.A.U * * This file is part of Orion Context Broker. * diff --git a/src/lib/mongoBackend/CMakeLists.txt b/src/lib/mongoBackend/CMakeLists.txt index 7d57a0873f..25db1e03ae 100644 --- a/src/lib/mongoBackend/CMakeLists.txt +++ b/src/lib/mongoBackend/CMakeLists.txt @@ -23,7 +23,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0) SET (SOURCES MongoGlobal.cpp MongoCommonUpdate.cpp - MongoCommonRegister.cpp MongoCommonSubscription.cpp mongoUpdateContext.cpp mongoQueryContext.cpp @@ -48,7 +47,6 @@ SET (HEADERS dbConstants.h MongoGlobal.h MongoCommonUpdate.h - MongoCommonRegister.h MongoCommonSubscription.h mongoUpdateContext.h mongoQueryContext.h diff --git a/src/lib/mongoBackend/MongoCommonRegister.cpp b/src/lib/mongoBackend/MongoCommonRegister.cpp deleted file mode 100644 index ab496e7bd2..0000000000 --- a/src/lib/mongoBackend/MongoCommonRegister.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Fermín Galán -*/ -#include -#include -#include -#include -#include - -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "common/string.h" -#include "common/globals.h" -#include "common/statistics.h" -#include "common/sem.h" -#include "common/RenderFormat.h" -#include "common/defaultValues.h" -#include "alarmMgr/alarmMgr.h" - -#include "mongoBackend/MongoGlobal.h" -#include "mongoBackend/TriggeredSubscription.h" -#include "mongoBackend/dbConstants.h" -#include "mongoBackend/MongoCommonRegister.h" - -#include "mongoDriver/connectionOperations.h" -#include "mongoDriver/mongoConnectionPool.h" -#include "mongoDriver/safeMongo.h" -#include "mongoDriver/BSONArrayBuilder.h" -#include "mongoDriver/BSONObjBuilder.h" - - - -/* **************************************************************************** -* -* processRegisterContext - -* -* This function has a slightly different behaviour depending on whether the id -* parameter is null (new registration case) or not null (update case), in -* particular: -* -* - In the new registration case, the _id is generated and insert() is used to -* put the document in the DB. -* - In the update case, the _id is set according to the argument 'id' and update() is -* used to put the document in the DB. -*/ -HttpStatusCode processRegisterContext -( - RegisterContextRequest* requestP, - RegisterContextResponse* responseP, - orion::OID* id, - const std::string& tenant, - const std::string& servicePath, - const std::string& format, - const std::string& fiwareCorrelator -) -{ - std::string err; - - /* If expiration is not present, then use a default one */ - if (requestP->duration.isEmpty()) - { - requestP->duration.set(DEFAULT_DURATION); - } - - /* Calculate expiration (using the current time and the duration field in the request) */ - long long expiration = getCurrentTime() + requestP->duration.parse(); - - LM_T(LmtMongo, ("Registration expiration: %lu", expiration)); - - /* Create the mongoDB registration document */ - orion::BSONObjBuilder reg; - orion::OID oid; - - if (id == NULL) - { - oid.init(); - } - else - { - oid = *id; - } - - reg.append("_id", oid); - reg.append(REG_EXPIRATION, expiration); - - // FIXME P4: See issue #3078 - reg.append(REG_SERVICE_PATH, servicePath.empty() ? SERVICE_PATH_ROOT : servicePath); - reg.append(REG_FORMAT, format); - - // In NGISv1 forwarding mode is always "all" - reg.append(REG_FORWARDING_MODE, "all"); - - orion::BSONArrayBuilder contextRegistration; - - for (unsigned int ix = 0; ix < requestP->contextRegistrationVector.size(); ++ix) - { - ContextRegistration* cr = requestP->contextRegistrationVector[ix]; - orion::BSONArrayBuilder entities; - - for (unsigned int jx = 0; jx < cr->entityIdVector.size(); ++jx) - { - EntityId* en = cr->entityIdVector[jx]; - - - orion::BSONObjBuilder bob; - bob.append(REG_ENTITY_ID, en->id); - - if (en->type.empty()) - { - LM_T(LmtMongo, ("Entity registration: {id: %s}", en->id.c_str())); - } - else - { - bob.append(REG_ENTITY_TYPE, en->type); - LM_T(LmtMongo, ("Entity registration: {id: %s, type: %s}", en->id.c_str(), en->type.c_str())); - } - entities.append(bob.obj()); - } - - orion::BSONArrayBuilder attrs; - - for (unsigned int jx = 0; jx < cr->contextRegistrationAttributeVector.size(); ++jx) - { - ContextRegistrationAttribute* cra = cr->contextRegistrationAttributeVector[jx]; - - orion::BSONObjBuilder bob; - bob.append(REG_ATTRS_NAME, cra->name); - bob.append(REG_ATTRS_TYPE, cra->type); - - attrs.append(bob.obj()); - LM_T(LmtMongo, ("Attribute registration: {name: %s, type: %s}", - cra->name.c_str(), - cra->type.c_str())); - } - - // FIXME #3774: previously this part was based in streamming instead of append() - orion::BSONObjBuilder bob; - bob.append(REG_ENTITIES, entities.arr()); - bob.append(REG_ATTRS, attrs.arr()); - bob.append(REG_PROVIDING_APPLICATION, requestP->contextRegistrationVector[ix]->providingApplication.get()); - - contextRegistration.append(bob.obj()); - - LM_T(LmtMongo, ("providingApplication registration: %s", - requestP->contextRegistrationVector[ix]->providingApplication.c_str())); - } - reg.append(REG_CONTEXT_REGISTRATION, contextRegistration.arr()); - - /* Note that we are using upsert = "true". This means that if the document doesn't previously - * exist in the collection, it is created. Thus, this way both uses of registerContext are OK - * (either new registration or updating an existing one) - */ - orion::BSONObjBuilder bobId; - bobId.append("_id", oid); - if (!orion::collectionUpdate(composeDatabaseName(tenant), COL_REGISTRATIONS, bobId.obj(), reg.obj(), true, &err)) - { - responseP->errorCode.fill(SccReceiverInternalError, err); - return SccOk; - } - - // Fill the response element - responseP->duration = requestP->duration; - responseP->registrationId.set(oid.toString()); - responseP->errorCode.fill(SccOk); - - return SccOk; -} diff --git a/src/lib/mongoBackend/MongoCommonRegister.h b/src/lib/mongoBackend/MongoCommonRegister.h deleted file mode 100644 index 392224ef07..0000000000 --- a/src/lib/mongoBackend/MongoCommonRegister.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef SRC_LIB_MONGOBACKEND_MONGOCOMMONREGISTER_H_ -#define SRC_LIB_MONGOBACKEND_MONGOCOMMONREGISTER_H_ - -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Fermín Galán -*/ -#include - -#include "ngsi9/RegisterContextRequest.h" -#include "ngsi9/RegisterContextResponse.h" -#include "apiTypesV2/Registration.h" - -#include "mongoDriver/OID.h" - - -/* **************************************************************************** -* -* processRegisterContext - -*/ -extern HttpStatusCode processRegisterContext -( - RegisterContextRequest* requestP, - RegisterContextResponse* responseP, - orion::OID* id, - const std::string& tenant, - const std::string& servicePath, - const std::string& format, - const std::string& fiwareCorrelator -); - -#endif // SRC_LIB_MONGOBACKEND_MONGOCOMMONREGISTER_H_ diff --git a/src/lib/mongoBackend/MongoGlobal.h b/src/lib/mongoBackend/MongoGlobal.h index 54aff27269..0dd0deb015 100644 --- a/src/lib/mongoBackend/MongoGlobal.h +++ b/src/lib/mongoBackend/MongoGlobal.h @@ -45,8 +45,6 @@ #include "ngsi/Restriction.h" #include "ngsi/NotifyConditionVector.h" #include "ngsi10/UpdateContextResponse.h" -#include "ngsi9/RegisterContextRequest.h" -#include "ngsi9/RegisterContextResponse.h" #include "ngsiNotify/Notifier.h" #include "rest/uriParamNames.h" #include "apiTypesV2/Subscription.h" diff --git a/src/lib/ngsi/AttributeExpression.cpp b/src/lib/ngsi/AttributeExpression.cpp index d6d6c1d828..1149e6392b 100644 --- a/src/lib/ngsi/AttributeExpression.cpp +++ b/src/lib/ngsi/AttributeExpression.cpp @@ -28,7 +28,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/Request.h" #include "ngsi/AttributeExpression.h" @@ -82,22 +81,6 @@ std::string AttributeExpression::get(void) -/* **************************************************************************** -* -* AttributeExpression::toJsonV1 - -*/ -std::string AttributeExpression::toJsonV1(bool comma) -{ - if (string.empty()) - { - return ""; - } - - return valueTag("attributeExpression", string, comma); -} - - - /* **************************************************************************** * * AttributeExpression::c_str - diff --git a/src/lib/ngsi/AttributeExpression.h b/src/lib/ngsi/AttributeExpression.h index 5a642607b1..1e38924fde 100644 --- a/src/lib/ngsi/AttributeExpression.h +++ b/src/lib/ngsi/AttributeExpression.h @@ -42,7 +42,6 @@ typedef struct AttributeExpression void set(const std::string& value); std::string get(void); bool isEmpty(void); - std::string toJsonV1(bool comma); const char* c_str(); void release(void); diff --git a/src/lib/ngsi/ConditionValueList.cpp b/src/lib/ngsi/ConditionValueList.cpp index 2062cb0597..5c725348ef 100644 --- a/src/lib/ngsi/ConditionValueList.cpp +++ b/src/lib/ngsi/ConditionValueList.cpp @@ -30,38 +30,10 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/ConditionValueList.h" -/* **************************************************************************** -* -* toJsonV1 - -*/ -std::string ConditionValueList::toJsonV1(bool comma) -{ - std::string out = ""; - - if (vec.size() == 0) - { - return ""; - } - - out += startTag("condValueList", true); - - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - out += valueTag("", vec[ix], ix != vec.size() - 1, true); - } - - out += endTag(comma, true); - - return out; -} - - - /* **************************************************************************** * * ConditionValueList::check - diff --git a/src/lib/ngsi/ConditionValueList.h b/src/lib/ngsi/ConditionValueList.h index c3fd9cd8fb..97b2cd92f1 100644 --- a/src/lib/ngsi/ConditionValueList.h +++ b/src/lib/ngsi/ConditionValueList.h @@ -41,7 +41,6 @@ typedef struct ConditionValueList { std::vector vec; - std::string toJsonV1(bool comma); void release(void); void push_back(const std::string& attributeName); unsigned int size(void); diff --git a/src/lib/ngsi/ContextAttribute.cpp b/src/lib/ngsi/ContextAttribute.cpp index 2c0561491b..ccfb6d75dd 100644 --- a/src/lib/ngsi/ContextAttribute.cpp +++ b/src/lib/ngsi/ContextAttribute.cpp @@ -30,7 +30,6 @@ #include "common/string.h" #include "common/globals.h" -#include "common/tag.h" #include "common/limits.h" #include "common/RenderFormat.h" #include "common/JsonHelper.h" @@ -740,222 +739,6 @@ double ContextAttribute::getEvalPriority(void) -/* **************************************************************************** -* -* toJsonV1AsObject - -*/ -std::string ContextAttribute::toJsonV1AsObject -( - RequestType request, - const std::vector& orderedMetadata, - bool comma, - bool omitValue -) -{ - std::string out = ""; - bool commaAfterContextValue = metadataVector.size() != 0; - bool commaAfterType = !omitValue || commaAfterContextValue; - - out += startTag(name, false); - out += valueTag("type", type, commaAfterType); - - if (compoundValueP == NULL) - { - if (omitValue == false) - { - std::string effectiveValue = ""; - bool withoutQuotes = false; - - switch (valueType) - { - case orion::ValueTypeString: - effectiveValue = stringValue; - break; - - case orion::ValueTypeBoolean: - effectiveValue = boolValue? "true" : "false"; - withoutQuotes = true; - break; - - case orion::ValueTypeNumber: - if ((type == DATE_TYPE) || (type == DATE_TYPE_ALT)) - { - effectiveValue = isodate2str(numberValue); - } - else // regular number - { - effectiveValue = double2string(numberValue); - withoutQuotes = true; - } - break; - - case orion::ValueTypeNull: - effectiveValue = "null"; - withoutQuotes = true; - break; - - case orion::ValueTypeNotGiven: - LM_E(("Runtime Error (value not given in compound value)")); - break; - - default: - LM_E(("Runtime Error (unknown value type: %d)", valueType)); - } - - // - // NOTE - // renderAsJsonObject is used in v1 only. - // => we only need to care about stringValue (not boolValue, numberValue nor nullValue) - // - out += valueTag("value", - (request != RtUpdateContextResponse)? effectiveValue : "", - commaAfterContextValue, false, withoutQuotes); - } - } - else - { - out += JSON_STR("value") + ":" + compoundValueP->toJson(); - } - - if (omitValue == false) - { - out += metadataVector.toJsonV1(orderedMetadata, false); - } - - out += endTag(comma); - - return out; -} - - - -/* **************************************************************************** -* -* toJsonV1AsNameString - -*/ -std::string ContextAttribute::toJsonV1AsNameString(bool comma) -{ - std::string out = ""; - - if (comma) - { - out += "\"" + name + "\","; - } - else - { - out += "\"" + name + "\""; - } - - return out; - -} - - - -/* **************************************************************************** -* -* toJsonV1 - -*/ -std::string ContextAttribute::toJsonV1 -( - bool asJsonObject, - RequestType request, - const std::vector& metadataFilter, - bool comma, - bool omitValue -) -{ - // Filter and order metadata - std::vector orderedMetadata; - filterAndOrderMetadata(metadataFilter, &orderedMetadata); - - std::string out = ""; - bool valueRendered = (compoundValueP != NULL) || (omitValue == false) || (request == RtUpdateContextResponse); - bool commaAfterContextValue = orderedMetadata.size() != 0; - bool commaAfterType = valueRendered; - - if (asJsonObject) - { - return toJsonV1AsObject(request, orderedMetadata, comma, omitValue); - } - - out += startTag(); - out += valueTag("name", name, true); // attribute.type is always rendered - out += valueTag("type", type, commaAfterType); - - if (compoundValueP == NULL) - { - if (omitValue == false) - { - std::string effectiveValue = ""; - bool withoutQuotes = false; - - switch (valueType) - { - case orion::ValueTypeString: - effectiveValue = stringValue; - break; - - case orion::ValueTypeBoolean: - effectiveValue = boolValue? "true" : "false"; - withoutQuotes = true; - break; - - case orion::ValueTypeNumber: - if ((type == DATE_TYPE) || (type == DATE_TYPE_ALT)) - { - effectiveValue = isodate2str(numberValue); - } - else // regular number - { - effectiveValue = double2string(numberValue); - withoutQuotes = true; - } - break; - - case orion::ValueTypeNull: - effectiveValue = "null"; - withoutQuotes = true; - break; - - case orion::ValueTypeNotGiven: - LM_E(("Runtime Error (value not given in compound value)")); - break; - - default: - LM_E(("Runtime Error (unknown value type: %d)", valueType)); - } - - out += valueTag("value", - (request != RtUpdateContextResponse)? effectiveValue : "", - commaAfterContextValue, - false, - withoutQuotes); - - } - else if (request == RtUpdateContextResponse) - { - out += valueTag("value", "", commaAfterContextValue); - } - } - else - { - out += JSON_STR("value") + ":" + compoundValueP->toJson(); - - if (commaAfterContextValue) - { - out += ','; - } - } - - out += metadataVector.toJsonV1(orderedMetadata, false); - out += endTag(comma); - - return out; -} - - - /* **************************************************************************** * * ContextAttribute::filterAndOrderMetadata - diff --git a/src/lib/ngsi/ContextAttribute.h b/src/lib/ngsi/ContextAttribute.h index 4d23944a59..ea159501d2 100644 --- a/src/lib/ngsi/ContextAttribute.h +++ b/src/lib/ngsi/ContextAttribute.h @@ -97,19 +97,6 @@ typedef struct ContextAttribute double getEvalPriority(void); - std::string toJsonV1(bool asJsonObject, - RequestType request, - const std::vector& metadataFilter, - bool comma = false, - bool omitValue = false); - - std::string toJsonV1AsObject(RequestType request, - const std::vector& orderedMetadata, - bool comma, - bool omitValue = false); - - std::string toJsonV1AsNameString(bool comma); - std::string toJson(const std::vector& metadataFilter, bool renderNgsiField = false, ExprContextObject* exprContextObjectP = NULL); std::string toJsonValue(ExprContextObject* exprContextObjectP = NULL); diff --git a/src/lib/ngsi/ContextAttributeVector.cpp b/src/lib/ngsi/ContextAttributeVector.cpp index 4b8e39b757..bb88faffc5 100644 --- a/src/lib/ngsi/ContextAttributeVector.cpp +++ b/src/lib/ngsi/ContextAttributeVector.cpp @@ -31,7 +31,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "common/string.h" #include "common/RenderFormat.h" #include "common/JsonHelper.h" @@ -119,77 +118,6 @@ std::string ContextAttributeVector::toJsonTypes(void) -/* **************************************************************************** -* -* ContextAttributeVector::toJsonV1 - -* -* FIXME P5: this method doesn't depend on the class object. Should be moved out of the class? -* Maybe included in the Entiy class render logic. -*/ -std::string ContextAttributeVector::toJsonV1 -( - bool asJsonObject, - RequestType request, - const std::vector& orderedAttrs, - const std::vector& metadataFilter, - bool comma, - bool omitValue, - bool attrsAsName -) -{ - std::string out = ""; - - if (orderedAttrs.size() == 0) - { - return ""; - } - - // - // NOTE: - // If the URI parameter 'attributeFormat' is set to 'object', then the attribute vector - // is to be rendered as objects for JSON, and not as a vector. - // - if (asJsonObject) - { - // Note that in the case of attribute as name, we have to use a vector, thus using - // attrsAsName variable as value for isVector parameter - out += startTag("attributes", attrsAsName); - for (unsigned int ix = 0; ix < orderedAttrs.size(); ++ix) - { - bool comma = (ix != orderedAttrs.size() -1); - if (attrsAsName) - { - out += orderedAttrs[ix]->toJsonV1AsNameString(comma); - } - else - { - out += orderedAttrs[ix]->toJsonV1(asJsonObject, request, metadataFilter, comma, omitValue); - } - } - out += endTag(comma, attrsAsName); - } - else - { - out += startTag("attributes", true); - for (unsigned int ix = 0; ix < orderedAttrs.size(); ++ix) - { - if (attrsAsName) - { - out += orderedAttrs[ix]->toJsonV1AsNameString(ix != orderedAttrs.size() - 1); - } - else - { - out += orderedAttrs[ix]->toJsonV1(asJsonObject, request, metadataFilter, ix != orderedAttrs.size() - 1, omitValue); - } - } - out += endTag(comma, true); - } - - return out; -} - - - /* **************************************************************************** * * ContextAttributeVector::check - diff --git a/src/lib/ngsi/ContextAttributeVector.h b/src/lib/ngsi/ContextAttributeVector.h index 327b7a60fc..59dc8f4c57 100644 --- a/src/lib/ngsi/ContextAttributeVector.h +++ b/src/lib/ngsi/ContextAttributeVector.h @@ -61,14 +61,6 @@ typedef struct ContextAttributeVector std::string check(RequestType requestType); - std::string toJsonV1(bool asJsonObject, - RequestType requestType, - const std::vector& orderedAttrs, - const std::vector& metadataFilter, - bool comma = false, - bool omitValue = false, - bool attrsAsName = false); - std::string toJsonTypes(void); void toBson(double now, diff --git a/src/lib/ngsi/ContextElementResponse.cpp b/src/lib/ngsi/ContextElementResponse.cpp index 50f81b1260..451f8b2d5a 100644 --- a/src/lib/ngsi/ContextElementResponse.cpp +++ b/src/lib/ngsi/ContextElementResponse.cpp @@ -27,7 +27,6 @@ #include "logMsg/logMsg.h" #include "logMsg/traceLevels.h" -#include "common/tag.h" #include "common/RenderFormat.h" #include "alarmMgr/alarmMgr.h" #include "ngsi/ContextElementResponse.h" @@ -151,60 +150,6 @@ ContextElementResponse::ContextElementResponse(Entity* eP, bool useDefaultType) -/* **************************************************************************** -* -* ContextElementResponse::toJsonV1 - -*/ -std::string ContextElementResponse::toJsonV1 -( - bool asJsonObject, - RequestType requestType, - const std::vector& attrsFilter, - bool blacklist, - const std::vector& metadataFilter, - bool comma, - bool omitAttributeValues -) -{ - std::string out = ""; - - out += startTag(); - out += entity.toJsonV1(asJsonObject, requestType, attrsFilter, blacklist, metadataFilter, true, omitAttributeValues); - out += statusCode.toJsonV1(false); - out += endTag(comma, false); - - return out; -} - - - -/* **************************************************************************** -* -* ContextElementResponse::toJsonV1 - -* -* Wrapper of toJsonV1 with empty attrsFilter and metadataFilter -*/ -std::string ContextElementResponse::toJsonV1 -( - bool asJsonObject, - RequestType requestType, - bool blacklist, - bool comma, - bool omitAttributeValues -) -{ - std::string out = ""; - - out += startTag(); - out += entity.toJsonV1(asJsonObject, requestType, blacklist, true, omitAttributeValues); - out += statusCode.toJsonV1(false); - out += endTag(comma, false); - - return out; -} - - - /* **************************************************************************** * * ContextElementResponse::toJson - diff --git a/src/lib/ngsi/ContextElementResponse.h b/src/lib/ngsi/ContextElementResponse.h index 5901c67ae5..a787198bbb 100644 --- a/src/lib/ngsi/ContextElementResponse.h +++ b/src/lib/ngsi/ContextElementResponse.h @@ -65,20 +65,6 @@ typedef struct ContextElementResponse const StringList& attrL); ContextElementResponse(Entity* eP, bool useDefaultType = false); - std::string toJsonV1(bool asJsonObject, - RequestType requestType, - const std::vector& attrsFilter, - bool blacklist, - const std::vector& metadataFilter, - bool comma = false, - bool omitAttributeValues = false); - - std::string toJsonV1(bool asJsonObject, - RequestType requestType, - bool blacklist, - bool comma = false, - bool omitAttributeValues = false); - std::string toJson(RenderFormat renderFormat, const std::vector& attrsFilter, bool blacklist, diff --git a/src/lib/ngsi/ContextElementResponseVector.cpp b/src/lib/ngsi/ContextElementResponseVector.cpp index 2dd08b537d..607d9867bc 100644 --- a/src/lib/ngsi/ContextElementResponseVector.cpp +++ b/src/lib/ngsi/ContextElementResponseVector.cpp @@ -30,85 +30,12 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "common/RenderFormat.h" #include "common/JsonHelper.h" #include "ngsi/ContextElementResponseVector.h" -/* **************************************************************************** -* -* ContextElementResponseVector::toJsonV1 - -*/ -std::string ContextElementResponseVector::toJsonV1 -( - bool asJsonObject, - RequestType requestType, - const std::vector& attrsFilter, - bool blacklist, - const std::vector& metadataFilter, - bool comma, - bool omitAttributeValues -) -{ - std::string out = ""; - - if (vec.size() == 0) - { - return ""; - } - - out += startTag("contextResponses", true); - - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - out += vec[ix]->toJsonV1(asJsonObject, requestType, attrsFilter, blacklist, metadataFilter, ix < (vec.size() - 1), omitAttributeValues); - } - - out += endTag(comma, true); - - return out; -} - - - -/* **************************************************************************** -* -* ContextElementResponseVector::toJsonV1 - -* -* Wrapper of toJsonV1 with empty attrsFilter and metadataFilter -*/ -std::string ContextElementResponseVector::toJsonV1 -( - bool asJsonObject, - RequestType requestType, - bool blacklist, - bool comma, - bool omitAttributeValues -) -{ - std::string out = ""; - - if (vec.size() == 0) - { - return ""; - } - - out += startTag("contextResponses", true); - - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - out += vec[ix]->toJsonV1(asJsonObject, requestType, blacklist, ix < (vec.size() - 1), omitAttributeValues); - } - - out += endTag(comma, true); - - return out; -} - - - /* **************************************************************************** * * ContextElementResponseVector::toJson - diff --git a/src/lib/ngsi/ContextElementResponseVector.h b/src/lib/ngsi/ContextElementResponseVector.h index 2063702175..c4d3ff7ba8 100644 --- a/src/lib/ngsi/ContextElementResponseVector.h +++ b/src/lib/ngsi/ContextElementResponseVector.h @@ -43,20 +43,6 @@ typedef struct ContextElementResponseVector { std::vector vec; - std::string toJsonV1(bool asJsonObject, - RequestType requestType, - const std::vector& attrsFilter, - bool blacklist, - const std::vector& metadataFilter, - bool comma = false, - bool omitAttributeValues = false); - - std::string toJsonV1(bool asJsonObject, - RequestType requestType, - bool blacklist, - bool comma = false, - bool omitAttributeValues = false); - std::string toJson(RenderFormat renderFormat, const std::vector& attrsFilter, bool blacklist, diff --git a/src/lib/ngsi/ContextRegistration.cpp b/src/lib/ngsi/ContextRegistration.cpp index 20ee6eedaa..46486cb8c7 100644 --- a/src/lib/ngsi/ContextRegistration.cpp +++ b/src/lib/ngsi/ContextRegistration.cpp @@ -29,7 +29,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/Request.h" #include "ngsi/ContextRegistration.h" #include "ngsi/ContextRegistrationAttribute.h" @@ -47,30 +46,6 @@ ContextRegistration::ContextRegistration() entityIdVectorPresent = false; } -/* **************************************************************************** -* -* ContextRegistration::toJsonV1 - -*/ -std::string ContextRegistration::toJsonV1(bool comma, bool isInVector) -{ - std::string out = ""; - - // - // About JSON commas; - // As providingApplication is MANDATORY and it is the last item in ContextRegistration, - // the problem with the JSON commas disappear. All fields will have 'comma set to true'. - // All, except providingApplication of course :-) - // - - out += startTag(!isInVector? "contextRegistration" : ""); - out += entityIdVector.toJsonV1(true); - out += contextRegistrationAttributeVector.toJsonV1(true); - out += providingApplication.toJsonV1(false); - out += endTag(comma); - - return out; -} - /* **************************************************************************** diff --git a/src/lib/ngsi/ContextRegistration.h b/src/lib/ngsi/ContextRegistration.h index 988418a15a..0ba6a3a4a6 100644 --- a/src/lib/ngsi/ContextRegistration.h +++ b/src/lib/ngsi/ContextRegistration.h @@ -48,7 +48,6 @@ typedef struct ContextRegistration bool entityIdVectorPresent; // entityIdList present during parsing ContextRegistration(); - std::string toJsonV1(bool comma, bool isInVector); void release(); std::string check(RequestType requestType, diff --git a/src/lib/ngsi/ContextRegistrationAttribute.cpp b/src/lib/ngsi/ContextRegistrationAttribute.cpp index 6e4dca2014..b75778f20f 100644 --- a/src/lib/ngsi/ContextRegistrationAttribute.cpp +++ b/src/lib/ngsi/ContextRegistrationAttribute.cpp @@ -29,7 +29,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/ContextRegistrationAttribute.h" @@ -60,22 +59,6 @@ ContextRegistrationAttribute::ContextRegistrationAttribute type = _type; } -/* **************************************************************************** -* -* ContextRegistrationAttribute::toJsonV1 - -*/ -std::string ContextRegistrationAttribute::toJsonV1(bool comma) -{ - std::string out = ""; - - out += startTag(); - out += valueTag("name", name, true); - out += valueTag("type", type, false); - out += endTag(comma); - - return out; -} - /* **************************************************************************** diff --git a/src/lib/ngsi/ContextRegistrationAttribute.h b/src/lib/ngsi/ContextRegistrationAttribute.h index 7bcb3ec526..7de5832924 100644 --- a/src/lib/ngsi/ContextRegistrationAttribute.h +++ b/src/lib/ngsi/ContextRegistrationAttribute.h @@ -46,7 +46,6 @@ typedef struct ContextRegistrationAttribute ContextRegistrationAttribute(); ContextRegistrationAttribute(const std::string& _name, const std::string& _type); - std::string toJsonV1(bool comma); std::string check(void); } ContextRegistrationAttribute; diff --git a/src/lib/ngsi/ContextRegistrationAttributeVector.cpp b/src/lib/ngsi/ContextRegistrationAttributeVector.cpp index c75e279878..c2ab970d58 100644 --- a/src/lib/ngsi/ContextRegistrationAttributeVector.cpp +++ b/src/lib/ngsi/ContextRegistrationAttributeVector.cpp @@ -30,36 +30,10 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/ContextRegistrationAttributeVector.h" -/* **************************************************************************** -* -* ContextRegistrationAttributeVector::toJsonV1 - -*/ -std::string ContextRegistrationAttributeVector::toJsonV1(bool comma) -{ - std::string out = ""; - - if (vec.size() == 0) - { - return ""; - } - - out += startTag("attributes", true); - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - out += vec[ix]->toJsonV1(ix != vec.size() - 1); - } - out += endTag(comma, true); - - return out; -} - - - /* **************************************************************************** * * ContextRegistrationAttributeVector::check - diff --git a/src/lib/ngsi/ContextRegistrationAttributeVector.h b/src/lib/ngsi/ContextRegistrationAttributeVector.h index 0b6d39a85a..e86d3407d4 100644 --- a/src/lib/ngsi/ContextRegistrationAttributeVector.h +++ b/src/lib/ngsi/ContextRegistrationAttributeVector.h @@ -40,7 +40,6 @@ typedef struct ContextRegistrationAttributeVector { std::vector vec; - std::string toJsonV1(bool comma); void push_back(ContextRegistrationAttribute* item); unsigned int size(void); void release(); diff --git a/src/lib/ngsi/ContextRegistrationResponse.cpp b/src/lib/ngsi/ContextRegistrationResponse.cpp index d207082830..0eb44a45c0 100644 --- a/src/lib/ngsi/ContextRegistrationResponse.cpp +++ b/src/lib/ngsi/ContextRegistrationResponse.cpp @@ -24,7 +24,6 @@ */ #include -#include "common/tag.h" #include "ngsi/StatusCode.h" #include "ngsi/ContextRegistrationResponse.h" #include "ngsi/Request.h" @@ -42,31 +41,6 @@ ContextRegistrationResponse::ContextRegistrationResponse() -/* **************************************************************************** -* -* ContextRegistrationResponse::toJsonV1 - -*/ -std::string ContextRegistrationResponse::toJsonV1(bool comma) -{ - std::string out = ""; - bool errorCodeRendered = errorCode.code != SccNone; - - out += startTag(); - - out += contextRegistration.toJsonV1(errorCodeRendered, false); - - if (errorCodeRendered) - { - out += errorCode.toJsonV1(false); - } - - out += endTag(comma); - - return out; -} - - - /* **************************************************************************** * * ContextRegistrationResponse::check - diff --git a/src/lib/ngsi/ContextRegistrationResponse.h b/src/lib/ngsi/ContextRegistrationResponse.h index 3c517289b8..a73517ead6 100644 --- a/src/lib/ngsi/ContextRegistrationResponse.h +++ b/src/lib/ngsi/ContextRegistrationResponse.h @@ -47,7 +47,6 @@ typedef struct ContextRegistrationResponse ContextRegistrationResponse(); - std::string toJsonV1(bool comma); void release(void); std::string check(RequestType requestType, diff --git a/src/lib/ngsi/ContextRegistrationResponseVector.cpp b/src/lib/ngsi/ContextRegistrationResponseVector.cpp index e4fe8019f3..c2efc519b1 100644 --- a/src/lib/ngsi/ContextRegistrationResponseVector.cpp +++ b/src/lib/ngsi/ContextRegistrationResponseVector.cpp @@ -29,7 +29,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/ContextRegistrationResponseVector.h" @@ -45,33 +44,6 @@ void ContextRegistrationResponseVector::push_back(ContextRegistrationResponse* i -/* **************************************************************************** -* -* ContextRegistrationResponseVector::toJsonV1 - -*/ -std::string ContextRegistrationResponseVector::toJsonV1(bool comma) -{ - std::string out = ""; - - if (vec.size() == 0) - { - return ""; - } - - out += startTag("contextRegistrationResponses", true); - - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - out += vec[ix]->toJsonV1((ix != vec.size() - 1)); - } - - out += endTag(comma, true); - - return out; -} - - - /* **************************************************************************** * * ContextRegistrationResponseVector::release - diff --git a/src/lib/ngsi/ContextRegistrationResponseVector.h b/src/lib/ngsi/ContextRegistrationResponseVector.h index 600bd6e1c7..14ad4b9ed5 100644 --- a/src/lib/ngsi/ContextRegistrationResponseVector.h +++ b/src/lib/ngsi/ContextRegistrationResponseVector.h @@ -42,7 +42,6 @@ typedef struct ContextRegistrationResponseVector void push_back(ContextRegistrationResponse* item); unsigned int size(void) const; - std::string toJsonV1(bool comma); void release(void); ContextRegistrationResponse* operator[](unsigned int ix) const; diff --git a/src/lib/ngsi/ContextRegistrationVector.cpp b/src/lib/ngsi/ContextRegistrationVector.cpp index 03577bd2e7..9e5d1307bf 100644 --- a/src/lib/ngsi/ContextRegistrationVector.cpp +++ b/src/lib/ngsi/ContextRegistrationVector.cpp @@ -29,7 +29,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/ContextRegistrationVector.h" @@ -45,33 +44,6 @@ void ContextRegistrationVector::push_back(ContextRegistration* item) -/* **************************************************************************** -* -* ContextRegistrationVector::toJsonV1 - -*/ -std::string ContextRegistrationVector::toJsonV1(bool comma) -{ - std::string out = ""; - - if (vec.size() == 0) - { - return ""; - } - - out += startTag("contextRegistrations", true); - - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - out += vec[ix]->toJsonV1(ix != vec.size() - 1, true); - } - - out += endTag(comma, comma); - - return out; -} - - - /* **************************************************************************** * * ContextRegistrationVector::release - diff --git a/src/lib/ngsi/ContextRegistrationVector.h b/src/lib/ngsi/ContextRegistrationVector.h index 02b56fb93a..13e814af45 100644 --- a/src/lib/ngsi/ContextRegistrationVector.h +++ b/src/lib/ngsi/ContextRegistrationVector.h @@ -42,7 +42,6 @@ typedef struct ContextRegistrationVector void push_back(ContextRegistration* item); unsigned int size(void); - std::string toJsonV1(bool comma); void release(void); std::string check(RequestType requestType, diff --git a/src/lib/ngsi/Duration.cpp b/src/lib/ngsi/Duration.cpp index 5d58df3c1e..23cd099707 100644 --- a/src/lib/ngsi/Duration.cpp +++ b/src/lib/ngsi/Duration.cpp @@ -31,7 +31,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "alarmMgr/alarmMgr.h" #include "ngsi/Request.h" #include "ngsi/Duration.h" @@ -134,27 +133,6 @@ int64_t Duration::parse(void) -/* **************************************************************************** -* -* Duration::toJsonV1 - -*/ -std::string Duration::toJsonV1(bool comma) -{ - if (string.empty()) - { - return ""; - } - - if (valid == false) - { - return ""; - } - - return valueTag("duration", string, comma); -} - - - /* **************************************************************************** * * release - diff --git a/src/lib/ngsi/Duration.h b/src/lib/ngsi/Duration.h index 9a87c2fe8d..b6b5c9d719 100644 --- a/src/lib/ngsi/Duration.h +++ b/src/lib/ngsi/Duration.h @@ -53,7 +53,6 @@ class Duration void set(const std::string& value); std::string get(void); bool isEmpty(void); - std::string toJsonV1(bool comma); int64_t parse(void); void release(void); diff --git a/src/lib/ngsi/EntityId.cpp b/src/lib/ngsi/EntityId.cpp index 82ff46ecf0..7fcaa74881 100644 --- a/src/lib/ngsi/EntityId.cpp +++ b/src/lib/ngsi/EntityId.cpp @@ -32,7 +32,6 @@ #include "common/string.h" #include "common/JsonHelper.h" #include "ngsi/EntityId.h" -#include "common/tag.h" #include "common/JsonHelper.h" @@ -107,42 +106,6 @@ std::string EntityId::toJson(void) -/* **************************************************************************** -* -* EntityId::toJsonV1 - -* -*/ -std::string EntityId::toJsonV1(bool comma, bool isInVector) -{ - std::string out = ""; - char* isPatternEscaped = htmlEscape(isPattern.c_str()); - char* typeEscaped = htmlEscape(type.c_str()); - char* idEscaped = htmlEscape(id.c_str()); - - out += (isInVector? "{" : ""); - out = out + "\"type\":\"" + typeEscaped + "\","; - out = out + "\"isPattern\":\"" + isPatternEscaped + "\","; - out = out + "\"id\":\"" + idEscaped + "\""; - - if ((comma == true) && (isInVector == false)) - { - out += ","; - } - else - { - out += (isInVector? "}" : ""); - out += (comma == true)? "," : ""; - } - - free(typeEscaped); - free(idEscaped); - free(isPatternEscaped); - - return out; -} - - - /* **************************************************************************** * * EntityId::toJson - @@ -181,11 +144,6 @@ std::string EntityId::check(RequestType requestType) return std::string("invalid isPattern value for entity: /") + isPattern + "/"; } - if ((requestType == RegisterContext) && (isTrue(isPattern))) - { - return "isPattern set to true for registrations is currently not supported"; - } - if (isTrue(isPattern)) { regex_t re; diff --git a/src/lib/ngsi/EntityId.h b/src/lib/ngsi/EntityId.h index bd1bb24398..cc45b540be 100644 --- a/src/lib/ngsi/EntityId.h +++ b/src/lib/ngsi/EntityId.h @@ -65,7 +65,6 @@ class EntityId bool isPatternIsTrue(void); std::string toJson(void); - std::string toJsonV1(bool comma, bool isInVector = false); std::string check(RequestType requestType); diff --git a/src/lib/ngsi/EntityIdVector.cpp b/src/lib/ngsi/EntityIdVector.cpp index 4477f27723..33db663617 100644 --- a/src/lib/ngsi/EntityIdVector.cpp +++ b/src/lib/ngsi/EntityIdVector.cpp @@ -30,7 +30,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "common/JsonHelper.h" #include "alarmMgr/alarmMgr.h" #include "apiTypesV2/EntityVector.h" @@ -58,32 +57,6 @@ std::string EntityIdVector::toJson(void) -/* **************************************************************************** -* -* EntityIdVector::toJsonV1 - -*/ -std::string EntityIdVector::toJsonV1(bool comma) -{ - std::string out = ""; - - if (vec.size() == 0) - { - return ""; - } - - out += startTag("entities", true); - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - out += vec[ix]->toJsonV1(ix != vec.size() - 1, true); - } - - out += endTag(comma, true); - - return out; -} - - - /* **************************************************************************** * * EntityIdVector::check - diff --git a/src/lib/ngsi/EntityIdVector.h b/src/lib/ngsi/EntityIdVector.h index c7d9bb1dc3..c78b011799 100644 --- a/src/lib/ngsi/EntityIdVector.h +++ b/src/lib/ngsi/EntityIdVector.h @@ -49,7 +49,6 @@ typedef struct EntityIdVector { std::vector vec; - std::string toJsonV1(bool comma); std::string toJson(void); void push_back(EntityId* item); bool push_back_if_absent(EntityId* item); diff --git a/src/lib/ngsi/Metadata.cpp b/src/lib/ngsi/Metadata.cpp index e62f7236d1..eda14df04e 100644 --- a/src/lib/ngsi/Metadata.cpp +++ b/src/lib/ngsi/Metadata.cpp @@ -30,7 +30,6 @@ #include "common/globals.h" #include "common/limits.h" -#include "common/tag.h" #include "common/string.h" #include "common/JsonHelper.h" #include "alarmMgr/alarmMgr.h" @@ -234,55 +233,6 @@ Metadata::Metadata(const std::string& _name, const orion::BSONObj& mdB) -/* **************************************************************************** -* -* Metadata::toJsonV1 - -*/ -std::string Metadata::toJsonV1(bool comma) -{ - std::string out = ""; - std::string xValue = toStringValue(); - - out += startTag(); - out += valueTag("name", name, true); - out += valueTag("type", type, true); - - if (compoundValueP != NULL) - { - out += JSON_STR("value") + ":" + compoundValueP->toJson(); - } - else if (valueType == orion::ValueTypeString) - { - out += valueTag("value", xValue, false); - } - else if (valueType == orion::ValueTypeNumber) - { - out += JSON_STR("value") + ":" + xValue; - } - else if (valueType == orion::ValueTypeBoolean) - { - out += JSON_STR("value") + ":" + xValue; - } - else if (valueType == orion::ValueTypeNull) - { - out += JSON_STR("value") + ":" + xValue; - } - else if (valueType == orion::ValueTypeNotGiven) - { - out += JSON_STR("value") + ":" + JSON_STR("not given"); - } - else - { - out += JSON_STR("value") + ":" + JSON_STR("unknown json type"); - } - - out += endTag(comma); - - return out; -} - - - /* **************************************************************************** * * Metadata::check - diff --git a/src/lib/ngsi/Metadata.h b/src/lib/ngsi/Metadata.h index 2d0189fa46..1e141f4229 100644 --- a/src/lib/ngsi/Metadata.h +++ b/src/lib/ngsi/Metadata.h @@ -89,7 +89,6 @@ typedef struct Metadata Metadata(const std::string& _name, const orion::BSONObj& mdB); ~Metadata(); - std::string toJsonV1(bool comma); std::string toJson(void); void release(void); void fill(const struct Metadata& md); diff --git a/src/lib/ngsi/MetadataVector.cpp b/src/lib/ngsi/MetadataVector.cpp index 8f082ba094..82c2813c8e 100644 --- a/src/lib/ngsi/MetadataVector.cpp +++ b/src/lib/ngsi/MetadataVector.cpp @@ -30,7 +30,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "common/string.h" #include "common/JsonHelper.h" #include "ngsi/MetadataVector.h" @@ -48,34 +47,6 @@ MetadataVector::MetadataVector(void) -/* **************************************************************************** -* -* MetadataVector::toJsonV1 - -* -* FIXME P5: this method doesn't depend on the class object. Should be moved out of the class? -*/ -std::string MetadataVector::toJsonV1(const std::vector& orderedMetadata, bool comma) -{ - std::string out = ""; - - if (orderedMetadata.size() == 0) - { - return ""; - } - - out += startTag("metadatas", true); - for (unsigned int ix = 0; ix < orderedMetadata.size(); ++ix) - { - out += orderedMetadata[ix]->toJsonV1(ix != orderedMetadata.size() - 1); - } - out += endTag(comma, true); - - - return out; -} - - - /* **************************************************************************** * * MetadataVector::matchFilter - diff --git a/src/lib/ngsi/MetadataVector.h b/src/lib/ngsi/MetadataVector.h index b39e630d6c..55b488aff9 100644 --- a/src/lib/ngsi/MetadataVector.h +++ b/src/lib/ngsi/MetadataVector.h @@ -48,7 +48,6 @@ typedef struct MetadataVector MetadataVector(void); - std::string toJsonV1(const std::vector& orderedMetadata, bool comma); std::string toJson(const std::vector& orderedMetadata); std::string check(void); diff --git a/src/lib/ngsi/NotifyCondition.cpp b/src/lib/ngsi/NotifyCondition.cpp index 86453686a2..cb9f4823c0 100644 --- a/src/lib/ngsi/NotifyCondition.cpp +++ b/src/lib/ngsi/NotifyCondition.cpp @@ -30,7 +30,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/Request.h" #include "ngsi/NotifyCondition.h" @@ -59,31 +58,6 @@ NotifyCondition::NotifyCondition(NotifyCondition* ncP) -/* **************************************************************************** -* -* NotifyCondition::toJsonV1 - -*/ -std::string NotifyCondition::toJsonV1(bool notLastInVector) -{ - std::string out = ""; - - bool condValueListRendered = condValueList.size() != 0; - bool restrictionRendered = !restriction.get().empty(); - bool commaAfterRestriction = false; // last element - bool commaAfterCondValueList = restrictionRendered; - bool commaAfterType = condValueListRendered || restrictionRendered; - - out += startTag(); - out += valueTag("type", type, commaAfterType); - out += condValueList.toJsonV1(commaAfterCondValueList); - out += restriction.toJsonV1(commaAfterRestriction); - out += endTag(); - - return out; -} - - - /* **************************************************************************** * * NotifyCondition::check - diff --git a/src/lib/ngsi/NotifyCondition.h b/src/lib/ngsi/NotifyCondition.h index 8b44308005..8c762907f5 100644 --- a/src/lib/ngsi/NotifyCondition.h +++ b/src/lib/ngsi/NotifyCondition.h @@ -48,7 +48,6 @@ typedef struct NotifyCondition NotifyCondition(); NotifyCondition(NotifyCondition* ncP); - std::string toJsonV1(bool notLastInVector); void release(void); std::string check(RequestType requestType, diff --git a/src/lib/ngsi/NotifyConditionVector.cpp b/src/lib/ngsi/NotifyConditionVector.cpp index 5f9799c521..1cb9f159b4 100644 --- a/src/lib/ngsi/NotifyConditionVector.cpp +++ b/src/lib/ngsi/NotifyConditionVector.cpp @@ -30,7 +30,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/NotifyConditionVector.h" @@ -45,31 +44,6 @@ NotifyConditionVector::NotifyConditionVector() -/* **************************************************************************** -* -* NotifyConditionVector::toJsonV1 - -*/ -std::string NotifyConditionVector::toJsonV1(bool comma) -{ - std::string out = ""; - - if (vec.size() == 0) - { - return ""; - } - - out += startTag("notifyConditions", true); - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - out += vec[ix]->toJsonV1(ix != vec.size() - 1); - } - out += endTag(comma, true); - - return out; -} - - - /* **************************************************************************** * * NotifyConditionVector::check - diff --git a/src/lib/ngsi/NotifyConditionVector.h b/src/lib/ngsi/NotifyConditionVector.h index 0a77d6e231..8e4489ddec 100644 --- a/src/lib/ngsi/NotifyConditionVector.h +++ b/src/lib/ngsi/NotifyConditionVector.h @@ -42,7 +42,6 @@ typedef struct NotifyConditionVector NotifyConditionVector(); - std::string toJsonV1(bool comma); void push_back(NotifyCondition* item); unsigned int size(void) const; void release(void); diff --git a/src/lib/ngsi/Originator.cpp b/src/lib/ngsi/Originator.cpp index 97d6c1052c..a696ce64d0 100644 --- a/src/lib/ngsi/Originator.cpp +++ b/src/lib/ngsi/Originator.cpp @@ -28,7 +28,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/Request.h" #include "ngsi/Originator.h" @@ -78,22 +77,6 @@ std::string Originator::get(void) -/* **************************************************************************** -* -* Originator::toJsonV1 - -*/ -std::string Originator::toJsonV1(bool comma) -{ - if (string.empty()) - { - return ""; - } - - return valueTag("originator", string, comma); -} - - - /* **************************************************************************** * * Originator::c_str - diff --git a/src/lib/ngsi/Originator.h b/src/lib/ngsi/Originator.h index fa6e67d01a..b3637ce473 100644 --- a/src/lib/ngsi/Originator.h +++ b/src/lib/ngsi/Originator.h @@ -42,7 +42,6 @@ typedef struct Originator void set(const std::string& value); std::string get(void); bool isEmpty(void); - std::string toJsonV1(bool comma); const char* c_str(); std::string check(void); diff --git a/src/lib/ngsi/ParseData.h b/src/lib/ngsi/ParseData.h index f4296323d6..7999ae7afe 100644 --- a/src/lib/ngsi/ParseData.h +++ b/src/lib/ngsi/ParseData.h @@ -32,17 +32,13 @@ #include "ngsi/ContextRegistrationAttribute.h" #include "ngsi/ContextElementResponse.h" #include "ngsi/Metadata.h" -#include "ngsi9/RegisterContextRequest.h" -#include "ngsi9/RegisterContextResponse.h" #include "ngsi9/DiscoverContextAvailabilityRequest.h" -#include "ngsi9/DiscoverContextAvailabilityResponse.h" #include "ngsi10/SubscribeContextRequest.h" #include "ngsi10/QueryContextRequest.h" #include "ngsi10/QueryContextResponse.h" #include "ngsi10/UnsubscribeContextRequest.h" #include "ngsi10/UpdateContextRequest.h" #include "ngsi10/UpdateContextResponse.h" -#include "ngsi10/UpdateContextSubscriptionRequest.h" #include "ngsi10/NotifyContextRequest.h" #include "apiTypesV2/Entity.h" #include "apiTypesV2/BatchQuery.h" @@ -52,34 +48,6 @@ -/* **************************************************************************** -* -* RegisterContextData - output data and help pointers for RegisterContextRequest -*/ -struct RegisterContextData -{ - RegisterContextData(): crP(NULL), entityIdP(NULL), attributeP(NULL), attributeMetadataP(NULL), registrationMetadataP(NULL) {} - RegisterContextRequest res; - ContextRegistration* crP; - EntityId* entityIdP; - ContextRegistrationAttribute* attributeP; - Metadata* attributeMetadataP; - Metadata* registrationMetadataP; -}; - - - -/* **************************************************************************** -* -* RegisterContextResponseData - output data and help pointers for RegisterContextRequest -*/ -typedef struct RegisterContextResponseData -{ - RegisterContextResponse res; -} RegisterContextResponseData; - - - /* **************************************************************************** * * DiscoverContextAvailabilityData - @@ -94,17 +62,6 @@ struct DiscoverContextAvailabilityData -/* **************************************************************************** -* -* DiscoverContextAvailabilityResponseData - -*/ -typedef struct DiscoverContextAvailabilityResponseData -{ - DiscoverContextAvailabilityResponse res; -} DiscoverContextAvailabilityResponseData; - - - /* **************************************************************************** * * QueryContextData - @@ -220,7 +177,6 @@ struct UpdateContextResponseData struct UpdateContextSubscriptionData { UpdateContextSubscriptionData(): notifyConditionP(NULL), scopeP(NULL), vertexP(NULL) {} - UpdateContextSubscriptionRequest res; NotifyCondition* notifyConditionP; Scope* scopeP; orion::Point* vertexP; @@ -294,7 +250,6 @@ typedef struct ParseData std::string errorString; ContextAttribute* lastContextAttribute; - RegisterContextData rcr; DiscoverContextAvailabilityData dcar; QueryContextData qcr; @@ -304,8 +259,6 @@ typedef struct ParseData UpdateContextSubscriptionData ucsr; NotifyContextData ncr; - RegisterContextResponseData rcrs; - DiscoverContextAvailabilityResponseData dcars; QueryContextResponseData qcrs; UpdateContextResponseData upcrs; diff --git a/src/lib/ngsi/ProvidingApplication.cpp b/src/lib/ngsi/ProvidingApplication.cpp index d4927f12fb..99bab3907a 100644 --- a/src/lib/ngsi/ProvidingApplication.cpp +++ b/src/lib/ngsi/ProvidingApplication.cpp @@ -28,7 +28,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/Request.h" #include "ngsi/ProvidingApplication.h" @@ -140,22 +139,6 @@ std::string ProvidingApplication::get(void) -/* **************************************************************************** -* -* ProvidingApplication::toJsonV1 - -*/ -std::string ProvidingApplication::toJsonV1(bool comma) -{ - if (string.empty()) - { - return ""; - } - - return valueTag("providingApplication", string, comma); -} - - - /* **************************************************************************** * * ProvidingApplication::c_str - diff --git a/src/lib/ngsi/ProvidingApplication.h b/src/lib/ngsi/ProvidingApplication.h index 4437dc4408..09808d5761 100644 --- a/src/lib/ngsi/ProvidingApplication.h +++ b/src/lib/ngsi/ProvidingApplication.h @@ -63,7 +63,6 @@ typedef struct ProvidingApplication ProviderFormat getProviderFormat(void); std::string getRegId(void); bool isEmpty(void); - std::string toJsonV1(bool comma); const char* c_str(void); void release(void); std::string check(void); diff --git a/src/lib/ngsi/Reference.cpp b/src/lib/ngsi/Reference.cpp index 2d66653048..3667d9ee36 100644 --- a/src/lib/ngsi/Reference.cpp +++ b/src/lib/ngsi/Reference.cpp @@ -28,7 +28,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "common/string.h" #include "ngsi/Request.h" #include "ngsi/Reference.h" @@ -98,22 +97,6 @@ std::string Reference::get(void) -/* **************************************************************************** -* -* Reference::toJsonV1 - -*/ -std::string Reference::toJsonV1(bool comma) -{ - if (string.empty()) - { - return ""; - } - - return valueTag("reference", string, comma); -} - - - /* **************************************************************************** * * Reference::c_str - diff --git a/src/lib/ngsi/Reference.h b/src/lib/ngsi/Reference.h index 0e8b24b294..b1b6ddd67c 100644 --- a/src/lib/ngsi/Reference.h +++ b/src/lib/ngsi/Reference.h @@ -42,7 +42,6 @@ typedef struct Reference void set(const std::string& value); std::string get(void); bool isEmpty(void); - std::string toJsonV1(bool comma); const char* c_str(); std::string check(RequestType requestType); diff --git a/src/lib/ngsi/RegistrationId.cpp b/src/lib/ngsi/RegistrationId.cpp index fed6c7caef..4c546bf96c 100644 --- a/src/lib/ngsi/RegistrationId.cpp +++ b/src/lib/ngsi/RegistrationId.cpp @@ -29,7 +29,6 @@ #include "common/globals.h" #include "common/idCheck.h" -#include "common/tag.h" #include "ngsi/Request.h" #include "ngsi/RegistrationId.h" @@ -106,30 +105,6 @@ std::string RegistrationId::get(void) const -/* **************************************************************************** -* -* RegistrationId::toJsonV1 - -*/ -std::string RegistrationId::toJsonV1(RequestType requestType, bool comma) -{ - if (string.empty()) - { - if (requestType == RegisterResponse) // registrationId is MANDATORY for RegisterContextResponse - { - string = "000000000000000000000000"; - LM_T(LmtOldInfo, ("No registrationId - setting the registrationId to 24 zeroes")); - } - else - { - return ""; - } - } - - return valueTag("registrationId", string, comma); -} - - - /* **************************************************************************** * * release - diff --git a/src/lib/ngsi/RegistrationId.h b/src/lib/ngsi/RegistrationId.h index 6a9ba149e0..5e5e63e3bb 100644 --- a/src/lib/ngsi/RegistrationId.h +++ b/src/lib/ngsi/RegistrationId.h @@ -45,7 +45,6 @@ typedef struct RegistrationId void set(const std::string& value); std::string get(void) const; bool isEmpty(void); - std::string toJsonV1(RequestType requestType, bool comma); void release(void); std::string check(void); diff --git a/src/lib/ngsi/Request.cpp b/src/lib/ngsi/Request.cpp index 15185ed4f6..0164265666 100644 --- a/src/lib/ngsi/Request.cpp +++ b/src/lib/ngsi/Request.cpp @@ -41,13 +41,10 @@ const char* requestType(RequestType rt) switch (rt) { case NoRequest: return "NoRequest"; - case RegisterContext: return "RegisterContextRequest"; - case RegisterResponse: return "RegisterContextResponse"; case DiscoverContextAvailability: return "DiscoverContextAvailabilityRequest"; case QueryContext: return "QueryContextRequest"; case RtQueryContextResponse: return "QueryContextResponse"; case SubscribeContext: return "SubscribeContextRequest"; - case UpdateContextSubscription: return "UpdateContextSubscriptionRequest"; case UnsubscribeContext: return "UnsubscribeContextRequest"; case NotifyContext: return "NotifyContextRequest"; case NotifyContextSent: return "NotifyContextRequestSent"; @@ -186,7 +183,6 @@ std::string requestTypeForCounter(RequestType rt, const std::string& _prefix) //case EntityByIdAttributeByName: return "/v1/registry/contextEntities/{id}/attributes/{name}"; //case EntityByIdAttributeByNameIdAndType: return "/v1/registry/contextEntities/type/{type}/id/{id}/attributes/{name}"; //case EntityTypes: return "/v1/contextTypes"; - case RegisterContext: case ContextEntitiesByEntityId: case ContextEntitiesByEntityIdAndType: case ContextEntityAttributes: @@ -253,7 +249,6 @@ std::string requestTypeForCounter(RequestType rt, const std::string& _prefix) case SubscribeContext: case UnsubscribeContext: //case UpdateContext: - case UpdateContextSubscription: return "skip"; // v2, v1 or NGSIv2 diff --git a/src/lib/ngsi/Request.h b/src/lib/ngsi/Request.h index 5ce4cb2bf7..d6edfadd8b 100644 --- a/src/lib/ngsi/Request.h +++ b/src/lib/ngsi/Request.h @@ -37,14 +37,12 @@ struct ConnectionInfo; */ typedef enum RequestType { - NoRequest, - RegisterContext = 1, + NoRequest = 0, DiscoverContextAvailability, QueryContext = 11, RtQueryContextResponse, SubscribeContext, - UpdateContextSubscription, UnsubscribeContext, RtUnsubscribeContextResponse, NotifyContext, @@ -83,7 +81,6 @@ typedef enum RequestType LeakRequest, StatisticsRequest, - RegisterResponse, RtSubscribeResponse, RtSubscribeError, diff --git a/src/lib/ngsi/ResponseData.h b/src/lib/ngsi/ResponseData.h index 3f80fe2c7b..4e84441b5e 100644 --- a/src/lib/ngsi/ResponseData.h +++ b/src/lib/ngsi/ResponseData.h @@ -31,13 +31,10 @@ #include "ngsi/ContextRegistrationAttribute.h" #include "ngsi/Metadata.h" -#include "ngsi9/RegisterContextResponse.h" -#include "ngsi9/DiscoverContextAvailabilityResponse.h" #include "ngsi10/SubscribeContextResponse.h" #include "ngsi10/QueryContextResponse.h" #include "ngsi10/UnsubscribeContextResponse.h" #include "ngsi10/UpdateContextResponse.h" -#include "ngsi10/UpdateContextSubscriptionResponse.h" @@ -47,13 +44,11 @@ */ typedef struct ResponseData { - RegisterContextResponse rcr; DiscoverContextAvailabilityResponse dcar; QueryContextResponse qcr; SubscribeContextResponse scr; UnsubscribeContextResponse uncr; UpdateContextResponse upcr; - UpdateContextSubscriptionResponse ucsr; } ResponseData; #endif // SRC_LIB_NGSI_RESPONSEDATA_H_ diff --git a/src/lib/ngsi/Restriction.cpp b/src/lib/ngsi/Restriction.cpp index 4f5cdf4374..dce18e66b3 100644 --- a/src/lib/ngsi/Restriction.cpp +++ b/src/lib/ngsi/Restriction.cpp @@ -28,7 +28,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "alarmMgr/alarmMgr.h" #include "ngsi/Request.h" #include "ngsi/Restriction.h" @@ -71,31 +70,6 @@ std::string Restriction::check(int counter) -/* **************************************************************************** -* -* Restriction::toJsonV1 - -*/ -std::string Restriction::toJsonV1(int restrictions, bool comma) -{ - std::string tag = "restriction"; - std::string out = ""; - bool scopeVectorRendered = scopeVector.size() != 0; - - if (restrictions == 0) - { - return ""; - } - - out += startTag(tag); - out += attributeExpression.toJsonV1(scopeVectorRendered); - out += scopeVector.toJsonV1(false); - out += endTag(comma); - - return out; -} - - - /* **************************************************************************** * * Restriction::release - diff --git a/src/lib/ngsi/Restriction.h b/src/lib/ngsi/Restriction.h index c27c7dbdb7..cef97233ee 100644 --- a/src/lib/ngsi/Restriction.h +++ b/src/lib/ngsi/Restriction.h @@ -43,7 +43,6 @@ typedef struct Restriction AttributeExpression attributeExpression; // Optional (FI-WARE changes - MANDATORY in OMA spec) ScopeVector scopeVector; // Optional - std::string toJsonV1(int restrictions, bool comma); void release(); void fill(Restriction* rP); diff --git a/src/lib/ngsi/RestrictionString.cpp b/src/lib/ngsi/RestrictionString.cpp index 1045a2a106..6cc7c03886 100644 --- a/src/lib/ngsi/RestrictionString.cpp +++ b/src/lib/ngsi/RestrictionString.cpp @@ -28,7 +28,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/Request.h" #include "ngsi/RestrictionString.h" @@ -78,22 +77,6 @@ std::string RestrictionString::get(void) -/* **************************************************************************** -* -* RestrictionString::toJsonV1 - -*/ -std::string RestrictionString::toJsonV1(bool comma) -{ - if (string.empty()) - { - return ""; - } - - return valueTag("restriction", string, comma); -} - - - /* **************************************************************************** * * RestrictionString::c_str - diff --git a/src/lib/ngsi/RestrictionString.h b/src/lib/ngsi/RestrictionString.h index 3a7fc72cf3..f5c5fd3005 100644 --- a/src/lib/ngsi/RestrictionString.h +++ b/src/lib/ngsi/RestrictionString.h @@ -42,7 +42,6 @@ typedef struct RestrictionString void set(const std::string& value); std::string get(void); bool isEmpty(void); - std::string toJsonV1(bool comma); const char* c_str(); std::string check(void); diff --git a/src/lib/ngsi/Scope.cpp b/src/lib/ngsi/Scope.cpp index d2bf65e8b4..de013f9fc9 100644 --- a/src/lib/ngsi/Scope.cpp +++ b/src/lib/ngsi/Scope.cpp @@ -28,7 +28,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "common/string.h" #include "common/limits.h" #include "alarmMgr/alarmMgr.h" @@ -353,26 +352,6 @@ int Scope::fill -/* **************************************************************************** -* -* Scope::toJsonV1 - -*/ -std::string Scope::toJsonV1(bool notLastInVector) -{ - std::string out = ""; - const char* tTag = "type"; - const char* vTag = "value"; - - out += startTag(); - out += valueTag(tTag, type, true); - out += valueTag(vTag, value); - out += endTag(notLastInVector); - - return out; -} - - - /* **************************************************************************** * * Scope::check - diff --git a/src/lib/ngsi/Scope.h b/src/lib/ngsi/Scope.h index 86192fd2e7..ae92aeb465 100644 --- a/src/lib/ngsi/Scope.h +++ b/src/lib/ngsi/Scope.h @@ -81,7 +81,6 @@ typedef struct Scope const std::string& georelString, std::string* errorString); - std::string toJsonV1(bool notLastInVector); void release(void); std::string check(void); diff --git a/src/lib/ngsi/ScopeVector.cpp b/src/lib/ngsi/ScopeVector.cpp index a83e58e1e6..cc7e5edc61 100644 --- a/src/lib/ngsi/ScopeVector.cpp +++ b/src/lib/ngsi/ScopeVector.cpp @@ -30,38 +30,12 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "common/limits.h" #include "alarmMgr/alarmMgr.h" #include "ngsi/ScopeVector.h" -/* **************************************************************************** -* -* ScopeVector::toJsonV1 - -*/ -std::string ScopeVector::toJsonV1(bool comma) -{ - std::string out = ""; - - if (vec.size() == 0) - { - return ""; - } - - out += startTag("scope", true); - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - out += vec[ix]->toJsonV1(ix != vec.size() - 1); - } - out += endTag(comma, true); - - return out; -} - - - /* **************************************************************************** * * ScopeVector::check - diff --git a/src/lib/ngsi/ScopeVector.h b/src/lib/ngsi/ScopeVector.h index d092c1c362..27b43811e9 100644 --- a/src/lib/ngsi/ScopeVector.h +++ b/src/lib/ngsi/ScopeVector.h @@ -40,7 +40,6 @@ typedef struct ScopeVector { std::vector vec; - std::string toJsonV1(bool comma); void push_back(Scope* item); unsigned int size(void) const; void release(); diff --git a/src/lib/ngsi/StatusCode.cpp b/src/lib/ngsi/StatusCode.cpp index d072386891..139b4c2eae 100644 --- a/src/lib/ngsi/StatusCode.cpp +++ b/src/lib/ngsi/StatusCode.cpp @@ -32,7 +32,6 @@ #include "common/globals.h" #include "common/string.h" -#include "common/tag.h" #include "common/JsonHelper.h" #include "common/limits.h" #include "ngsi/Request.h" @@ -84,46 +83,6 @@ StatusCode::StatusCode(HttpStatusCode _code, const std::string& _details, const -/* **************************************************************************** -* -* StatusCode::toJsonV1 - -*/ -std::string StatusCode::toJsonV1(bool comma, bool showKey) -{ - std::string out = ""; - - if (strstr(details.c_str(), "\"") != NULL) - { - int len = details.length() * 2; - char* s = (char*) calloc(1, len + 1); - - strReplace(s, len, details.c_str(), "\"", "\\\""); - details = s; - free(s); - } - - if (code == SccNone) - { - fill(SccReceiverInternalError, ""); - details += " - ZERO code set to 500"; - } - - out += startTag(showKey? keyName : ""); - out += valueTag("code", code, true); - out += valueTag("reasonPhrase", reasonPhrase, !details.empty()); - - if (!details.empty()) - { - out += valueTag("details", details, false); - } - - out += endTag(comma); - - return out; -} - - - /* **************************************************************************** * * StatusCode::toJson - diff --git a/src/lib/ngsi/StatusCode.h b/src/lib/ngsi/StatusCode.h index 2c034536e4..0dfb889e5f 100644 --- a/src/lib/ngsi/StatusCode.h +++ b/src/lib/ngsi/StatusCode.h @@ -56,7 +56,6 @@ typedef struct StatusCode StatusCode(const std::string& _keyName); StatusCode(HttpStatusCode _code, const std::string& _details, const std::string& _keyName = "statusCode"); - std::string toJsonV1(bool comma, bool showKey = true); std::string toJson(void); void fill(HttpStatusCode _code, const std::string& _details = ""); void fill(StatusCode* scP); diff --git a/src/lib/ngsi/StringList.cpp b/src/lib/ngsi/StringList.cpp index 50ca06628d..87aa03f647 100644 --- a/src/lib/ngsi/StringList.cpp +++ b/src/lib/ngsi/StringList.cpp @@ -30,7 +30,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "common/string.h" #include "common/JsonHelper.h" #include "ngsi/StringList.h" @@ -80,33 +79,6 @@ std::string StringList::toJson(void) -/* **************************************************************************** -* -* StringList::toJsonV1 - -*/ -std::string StringList::toJsonV1(bool comma, const std::string& fieldName) -{ - std::string out = ""; - - if (stringV.size() == 0) - { - return ""; - } - - out += startTag(fieldName, true); - - for (unsigned int ix = 0; ix < stringV.size(); ++ix) - { - out += valueTag(fieldName, stringV[ix], ix != stringV.size() - 1, true); - } - - out += endTag(comma, true); - - return out; -} - - - /* **************************************************************************** * * StringList::check - diff --git a/src/lib/ngsi/StringList.h b/src/lib/ngsi/StringList.h index 94ec82029e..553b4a9225 100644 --- a/src/lib/ngsi/StringList.h +++ b/src/lib/ngsi/StringList.h @@ -43,7 +43,6 @@ typedef struct StringList void fill(const std::vector& aVec); void fill(const std::string& commaSeparatedList); - std::string toJsonV1(bool comma, const std::string& fieldName); std::string toJson(void); std::string toString(void); void release(void); diff --git a/src/lib/ngsi/SubscribeError.cpp b/src/lib/ngsi/SubscribeError.cpp index 128c08c08c..8c55be656d 100644 --- a/src/lib/ngsi/SubscribeError.cpp +++ b/src/lib/ngsi/SubscribeError.cpp @@ -24,7 +24,6 @@ */ #include -#include "common/tag.h" #include "common/JsonHelper.h" #include "ngsi/StatusCode.h" #include "ngsi/Request.h" @@ -59,46 +58,6 @@ std::string SubscribeError::toJson(void) -/* **************************************************************************** -* -* SubscribeError::toJsonV1 - -*/ -std::string SubscribeError::toJsonV1(RequestType requestType, bool comma) -{ - std::string out = ""; - - out += startTag("subscribeError", false); - - // subscriptionId is Mandatory if part of updateContextSubscriptionResponse - // errorCode is Mandatory so, the JSON comma is always TRUE - if (requestType == UpdateContextSubscription) - { - // - // NOTE: the subscriptionId must have come from the request. - // If the field is empty, we are in unit tests and I here set it to all zeroes - // - if (subscriptionId.get().empty()) - { - subscriptionId.set("000000000000000000000000"); - } - out += subscriptionId.toJsonV1(requestType, true); - } - else if ((requestType == SubscribeContext) && - (subscriptionId.get() != "000000000000000000000000") && - (!subscriptionId.get().empty())) - { - out += subscriptionId.toJsonV1(requestType, true); - } - - out += errorCode.toJsonV1(false); - - out += endTag(comma); - - return out; -} - - - /* **************************************************************************** * * check - diff --git a/src/lib/ngsi/SubscribeError.h b/src/lib/ngsi/SubscribeError.h index 08c25db483..8e7e5b65ac 100644 --- a/src/lib/ngsi/SubscribeError.h +++ b/src/lib/ngsi/SubscribeError.h @@ -43,7 +43,6 @@ typedef struct SubscribeError StatusCode errorCode; // Mandatory SubscribeError(); - std::string toJsonV1(RequestType requestType, bool comma); std::string toJson(void); std::string check(void); } SubscribeError; diff --git a/src/lib/ngsi/SubscribeResponse.cpp b/src/lib/ngsi/SubscribeResponse.cpp index d105282ff5..2a9c726588 100644 --- a/src/lib/ngsi/SubscribeResponse.cpp +++ b/src/lib/ngsi/SubscribeResponse.cpp @@ -25,7 +25,6 @@ #include #include "common/globals.h" -#include "common/tag.h" #include "ngsi/SubscribeResponse.h" @@ -36,26 +35,4 @@ */ SubscribeResponse::SubscribeResponse() { -} - - - -/* **************************************************************************** -* -* SubscribeResponse::toJsonV1 - -*/ -std::string SubscribeResponse::toJsonV1(bool comma) -{ - std::string out = ""; - std::string tag = "subscribeResponse"; - bool durationRendered = !duration.isEmpty(); - bool throttlingRendered = !throttling.isEmpty(); - - out += startTag(tag); - out += subscriptionId.toJsonV1(RtSubscribeResponse, durationRendered || throttlingRendered); - out += duration.toJsonV1(throttlingRendered); - out += throttling.toJsonV1(false); - out += endTag(comma); - - return out; -} +} \ No newline at end of file diff --git a/src/lib/ngsi/SubscribeResponse.h b/src/lib/ngsi/SubscribeResponse.h index 56179a4b07..5106b32c33 100644 --- a/src/lib/ngsi/SubscribeResponse.h +++ b/src/lib/ngsi/SubscribeResponse.h @@ -45,7 +45,6 @@ typedef struct SubscribeResponse SubscribeResponse(); - std::string toJsonV1(bool comma); } SubscribeResponse; #endif // SRC_LIB_NGSI_SUBSCRIBERESPONSE_H_ diff --git a/src/lib/ngsi/SubscriptionId.cpp b/src/lib/ngsi/SubscriptionId.cpp index c2aa841b32..f37aeac02f 100644 --- a/src/lib/ngsi/SubscriptionId.cpp +++ b/src/lib/ngsi/SubscriptionId.cpp @@ -29,7 +29,6 @@ #include "common/globals.h" #include "common/idCheck.h" -#include "common/tag.h" #include "ngsi/Request.h" #include "ngsi/SubscriptionId.h" @@ -119,37 +118,6 @@ const char* SubscriptionId::c_str(void) const -/* **************************************************************************** -* -* SubscriptionId::toJsonV1 - -*/ -std::string SubscriptionId::toJsonV1(RequestType container, bool comma) -{ - std::string xString = string; - - if (xString.empty()) - { - if ((container == UpdateContextSubscription) || - (container == UnsubscribeContext) || - (container == RtUnsubscribeContextResponse) || - (container == NotifyContext) || - (container == RtSubscribeResponse) || - (container == RtSubscribeError)) - { - // subscriptionId is Mandatory - xString = "000000000000000000000000"; - } - else - { - return ""; // subscriptionId is Optional - } - } - - return valueTag("subscriptionId", xString, comma); -} - - - /* **************************************************************************** * * release - @@ -170,8 +138,7 @@ bool SubscriptionId::rendered(RequestType container) { if ((string.empty()) || (string == "000000000000000000000000")) { - if ((container == UpdateContextSubscription) || - (container == UnsubscribeContext) || + if ((container == UnsubscribeContext) || (container == RtUnsubscribeContextResponse) || (container == NotifyContext) || (container == RtSubscribeResponse) || diff --git a/src/lib/ngsi/SubscriptionId.h b/src/lib/ngsi/SubscriptionId.h index eab55627d9..7a938866c2 100644 --- a/src/lib/ngsi/SubscriptionId.h +++ b/src/lib/ngsi/SubscriptionId.h @@ -46,7 +46,6 @@ typedef struct SubscriptionId std::string get(void) const; const char* c_str(void) const; bool isEmpty(void); - std::string toJsonV1(RequestType container, bool comma); void release(void); bool rendered(RequestType container); diff --git a/src/lib/ngsi/Throttling.cpp b/src/lib/ngsi/Throttling.cpp index 85f22eb8b3..334b8b3e0a 100644 --- a/src/lib/ngsi/Throttling.cpp +++ b/src/lib/ngsi/Throttling.cpp @@ -28,7 +28,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/Request.h" #include "ngsi/Throttling.h" @@ -99,19 +98,3 @@ const std::string Throttling::get(void) { return string; } - - - -/* **************************************************************************** -* -* Throttling::toJsonV1 - -*/ -std::string Throttling::toJsonV1(bool comma) -{ - if (string.empty()) - { - return ""; - } - - return valueTag("throttling", string, comma); -} diff --git a/src/lib/ngsi/Throttling.h b/src/lib/ngsi/Throttling.h index a06ea794ea..adbbc5ad1e 100644 --- a/src/lib/ngsi/Throttling.h +++ b/src/lib/ngsi/Throttling.h @@ -46,7 +46,6 @@ typedef struct Throttling void set(const std::string& value); const std::string get(void); bool isEmpty(void); - std::string toJsonV1(bool comma); std::string check(void); diff --git a/src/lib/ngsi10/CMakeLists.txt b/src/lib/ngsi10/CMakeLists.txt index 4b18063d00..af96a6fdd8 100644 --- a/src/lib/ngsi10/CMakeLists.txt +++ b/src/lib/ngsi10/CMakeLists.txt @@ -31,8 +31,6 @@ SET (SOURCES UnsubscribeContextResponse.cpp UpdateContextRequest.cpp UpdateContextResponse.cpp - UpdateContextSubscriptionRequest.cpp - UpdateContextSubscriptionResponse.cpp ) SET (HEADERS @@ -46,8 +44,6 @@ SET (HEADERS UnsubscribeContextResponse.h UpdateContextRequest.h UpdateContextResponse.h - UpdateContextSubscriptionRequest.h - UpdateContextSubscriptionResponse.h ) diff --git a/src/lib/ngsi10/NotifyContextRequest.cpp b/src/lib/ngsi10/NotifyContextRequest.cpp index ba67f12399..988b4e1254 100644 --- a/src/lib/ngsi10/NotifyContextRequest.cpp +++ b/src/lib/ngsi10/NotifyContextRequest.cpp @@ -28,7 +28,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "common/RenderFormat.h" #include "common/JsonHelper.h" #include "ngsi10/NotifyContextRequest.h" @@ -38,38 +37,6 @@ -/* **************************************************************************** -* -* NotifyContextRequest::toJsonV1 - -*/ -std::string NotifyContextRequest::toJsonV1 -( - bool asJsonObject, - const std::vector& attrsFilter, - bool blacklist, - const std::vector& metadataFilter -) -{ - std::string out = ""; - bool contextElementResponseVectorRendered = contextElementResponseVector.size() != 0; - - // - // Note on JSON commas: - // subscriptionId and originator are MANDATORY. - // The only doubt here if whether originator should end in a comma. - // This doubt is taken care of by the variable 'contextElementResponseVectorRendered' - // - out += startTag(); - out += subscriptionId.toJsonV1(NotifyContext, true); - out += originator.toJsonV1(contextElementResponseVectorRendered); - out += contextElementResponseVector.toJsonV1(asJsonObject, NotifyContext, attrsFilter, blacklist, metadataFilter, false); - out += endTag(); - - return out; -} - - - /* **************************************************************************** * * NotifyContextRequest::toJson - @@ -130,35 +97,6 @@ std::string NotifyContextRequest::toJson -/* **************************************************************************** -* -* NotifyContextRequest::check -*/ -std::string NotifyContextRequest::check(const std::string& predetectedError) -{ - std::string res; - NotifyContextResponse response; - - if (!predetectedError.empty()) - { - response.responseCode.fill(SccBadRequest, predetectedError); - } - else if (((res = subscriptionId.check()) != "OK") || - ((res = originator.check()) != "OK") || - ((res = contextElementResponseVector.check(QueryContext, predetectedError, 0)) != "OK")) - { - response.responseCode.fill(SccBadRequest, res); - } - else - { - return "OK"; - } - - return response.toJsonV1(); -} - - - /* **************************************************************************** * * NotifyContextRequest::release - diff --git a/src/lib/ngsi10/NotifyContextRequest.h b/src/lib/ngsi10/NotifyContextRequest.h index d7d9f49ba3..ca65fa7212 100644 --- a/src/lib/ngsi10/NotifyContextRequest.h +++ b/src/lib/ngsi10/NotifyContextRequest.h @@ -45,16 +45,11 @@ typedef struct NotifyContextRequest Originator originator; // Mandatory ContextElementResponseVector contextElementResponseVector; // Optional - std::string toJsonV1(bool asJsonObject, - const std::vector& attrsFilter, - bool blacklist, - const std::vector& metadataFilter); std::string toJson(RenderFormat renderFormat, const std::vector& attrsFilter, bool blacklist, const std::vector& metadataFilter, ExprContextObject* exprContextObjectP = NULL); - std::string check(const std::string& predetectedError); void release(void); NotifyContextRequest* clone(void); } NotifyContextRequest; diff --git a/src/lib/ngsi10/NotifyContextResponse.cpp b/src/lib/ngsi10/NotifyContextResponse.cpp index bfb3218793..238eba6879 100644 --- a/src/lib/ngsi10/NotifyContextResponse.cpp +++ b/src/lib/ngsi10/NotifyContextResponse.cpp @@ -28,7 +28,6 @@ #include "logMsg/logMsg.h" #include "logMsg/traceLevels.h" -#include "common/tag.h" #include "common/globals.h" #include "ngsi/StatusCode.h" #include "ngsi10/NotifyContextResponse.h" @@ -58,25 +57,6 @@ NotifyContextResponse::NotifyContextResponse(StatusCode& sc) -/* **************************************************************************** -* -* NotifyContextResponse::toJsonV1 - -*/ -std::string NotifyContextResponse::toJsonV1(void) -{ - std::string out = ""; - - responseCode.keyNameSet("responseCode"); - - out += startTag(); - out += responseCode.toJsonV1(false); - out += endTag(); - - return out; -} - - - /* **************************************************************************** * * NotifyContextResponse::release - diff --git a/src/lib/ngsi10/NotifyContextResponse.h b/src/lib/ngsi10/NotifyContextResponse.h index 88848dc84e..377119cd8f 100644 --- a/src/lib/ngsi10/NotifyContextResponse.h +++ b/src/lib/ngsi10/NotifyContextResponse.h @@ -36,6 +36,7 @@ /* **************************************************************************** * * NotifyContextResponse - +* */ typedef struct NotifyContextResponse { @@ -44,7 +45,6 @@ typedef struct NotifyContextResponse NotifyContextResponse(); NotifyContextResponse(StatusCode& sc); - std::string toJsonV1(void); void release(void); } NotifyContextResponse; diff --git a/src/lib/ngsi10/QueryContextRequest.cpp b/src/lib/ngsi10/QueryContextRequest.cpp index c36a724143..173b41a4a0 100644 --- a/src/lib/ngsi10/QueryContextRequest.cpp +++ b/src/lib/ngsi10/QueryContextRequest.cpp @@ -28,7 +28,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" #include "common/JsonHelper.h" -#include "common/tag.h" #include "alarmMgr/alarmMgr.h" #include "ngsi/Request.h" #include "ngsi/StringList.h" @@ -113,52 +112,52 @@ std::string QueryContextRequest::toJson(void) /* **************************************************************************** * * QueryContextRequest::toJsonV1 - +* +* This is used only in the legacyForwarding:true logic. It would remove once that deprecated feature +* would be removed. +* +* Example: +* { +* "entities": [ +* { +* "type": "Room", +* "isPattern": "true", +* "id": "ConferenceRoom.*" +* } +* ], +* "attributes": [ +* "temperature", +* "pressure", +* "lightstatus" +* ] +} */ std::string QueryContextRequest::toJsonV1(void) { - std::string out = ""; - bool attributeListRendered = attributeList.size() != 0; - bool restrictionRendered = restrictions != 0; - bool commaAfterAttributeList = restrictionRendered; - bool commaAfterEntityIdVector = attributeListRendered || restrictionRendered; - - out += startTag(); - out += entityIdVector.toJsonV1(commaAfterEntityIdVector); - out += attributeList.toJsonV1(commaAfterAttributeList, "attributes"); - out += restriction.toJsonV1(restrictions, false); - out += endTag(); - - return out; -} - + // Diferent from original toJsonV1() we don't render restriction field (as it is not needed in the forwarding functionality) + JsonObjectHelper jh; -/* **************************************************************************** -* -* QueryContextRequest::check - -*/ -std::string QueryContextRequest::check(bool asJsonObject, const std::string& predetectedError) -{ - std::string res; - QueryContextResponse response; - - if (!predetectedError.empty()) - { - response.errorCode.fill(SccBadRequest, predetectedError); - } - else if (((res = entityIdVector.check(QueryContext)) != "OK") || - ((res = attributeList.check()) != "OK") || - ((res = restriction.check(restrictions)) != "OK")) + JsonVectorHelper jhEntities; + for (unsigned int ix = 0; ix < entityIdVector.size(); ++ix) { - alarmMgr.badInput(clientIp, res); - response.errorCode.fill(SccBadRequest, res); + JsonObjectHelper jhEntity; + jhEntity.addString("id", entityIdVector[ix]->id); + jhEntity.addString("type", entityIdVector[ix]->type); + jhEntity.addString("isPattern", entityIdVector[ix]->isPattern); + + jhEntities.addRaw(jhEntity.str()); } - else + jh.addRaw("entities", jhEntities.str()); + + JsonVectorHelper jhAttributes; + for (unsigned int ix = 0; ix < attributeList.size(); ++ix) { - return "OK"; + jhAttributes.addString(attributeList[ix]); } + jh.addRaw("attributes", jhAttributes.str()); - return response.toJsonV1(asJsonObject); + return jh.str(); } diff --git a/src/lib/ngsi10/QueryContextRequest.h b/src/lib/ngsi10/QueryContextRequest.h index cc1841e23a..737151c40d 100644 --- a/src/lib/ngsi10/QueryContextRequest.h +++ b/src/lib/ngsi10/QueryContextRequest.h @@ -67,7 +67,6 @@ typedef struct QueryContextRequest std::string toJsonV1(void); std::string toJson(void); - std::string check(bool asJsonObject, const std::string& predetectedError); void release(void); void fill(const std::string& entityId, const std::string& entityType, const std::string& attributeName); void fill(const std::string& entityId, diff --git a/src/lib/ngsi10/QueryContextResponse.cpp b/src/lib/ngsi10/QueryContextResponse.cpp index ea1541f9bf..561e7f8af8 100644 --- a/src/lib/ngsi10/QueryContextResponse.cpp +++ b/src/lib/ngsi10/QueryContextResponse.cpp @@ -28,7 +28,6 @@ #include "logMsg/logMsg.h" #include "common/string.h" -#include "common/tag.h" #include "alarmMgr/alarmMgr.h" #include "rest/HttpStatusCode.h" #include "ngsi/StatusCode.h" @@ -90,100 +89,6 @@ QueryContextResponse::~QueryContextResponse() -/* **************************************************************************** -* -* QueryContextResponse::toJsonV1 - -*/ -std::string QueryContextResponse::toJsonV1(bool asJsonObject) -{ - std::string out = ""; - bool errorCodeRendered = false; - - // - // 01. Decide whether errorCode should be rendered - // - if ((errorCode.code != SccNone) && (errorCode.code != SccOk)) - { - errorCodeRendered = true; - } - else if (contextElementResponseVector.size() == 0) - { - errorCodeRendered = true; - } - else if (!errorCode.details.empty()) - { - if (errorCode.code == SccNone) - { - errorCode.code = SccOk; - } - - errorCodeRendered = true; - } - - - // - // 02. render - // - out += startTag(); - - if (contextElementResponseVector.size() > 0) - { - out += contextElementResponseVector.toJsonV1(asJsonObject, QueryContext, false, errorCodeRendered); - } - - if (errorCodeRendered == true) - { - out += errorCode.toJsonV1(false); - } - - - // - // 03. Safety Check - // - // If neither errorCode nor CER vector was filled by mongoBackend, then we - // report a special kind of error. - // - if ((errorCode.code == SccNone) && (contextElementResponseVector.size() == 0)) - { - LM_E(("Runtime Error (Both error-code and response vector empty)")); - errorCode.fill(SccReceiverInternalError, "Both the error-code structure and the response vector were empty"); - out += errorCode.toJsonV1(false); - } - - out += endTag(); - - return out; -} - - - -/* **************************************************************************** -* -* QueryContextResponse::check - -*/ -std::string QueryContextResponse::check(bool asJsonObject, const std::string& predetectedError) -{ - std::string res; - - if (!predetectedError.empty()) - { - errorCode.fill(SccBadRequest, predetectedError); - } - else if ((res = contextElementResponseVector.check(QueryContext, predetectedError, 0)) != "OK") - { - alarmMgr.badInput(clientIp, res); - errorCode.fill(SccBadRequest, res); - } - else - { - return "OK"; - } - - return toJsonV1(asJsonObject); -} - - - /* **************************************************************************** * * QueryContextResponse::release - diff --git a/src/lib/ngsi10/QueryContextResponse.h b/src/lib/ngsi10/QueryContextResponse.h index 70ff32efdf..541d88edbd 100644 --- a/src/lib/ngsi10/QueryContextResponse.h +++ b/src/lib/ngsi10/QueryContextResponse.h @@ -53,8 +53,6 @@ typedef struct QueryContextResponse QueryContextResponse(StatusCode& _errorCode); ~QueryContextResponse(); - std::string toJsonV1(bool asJsonObject); - std::string check(bool asJsonObject, const std::string& predetectedError); void release(void); void fill(QueryContextResponse* qcrsP); void fill(const Entities& entities); diff --git a/src/lib/ngsi10/SubscribeContextRequest.cpp b/src/lib/ngsi10/SubscribeContextRequest.cpp index e36fa0f55b..c86eb4b1f7 100644 --- a/src/lib/ngsi10/SubscribeContextRequest.cpp +++ b/src/lib/ngsi10/SubscribeContextRequest.cpp @@ -25,7 +25,6 @@ #include #include "common/globals.h" -#include "common/tag.h" #include "ngsi/Request.h" #include "ngsi/StatusCode.h" #include "rest/EntityTypeInfo.h" @@ -39,36 +38,6 @@ using namespace ngsiv2; -/* **************************************************************************** -* -* SubscribeContextRequest::check - -*/ -std::string SubscribeContextRequest::check(const std::string& predetectedError, int counter) -{ - SubscribeContextResponse response; - std::string res; - - /* First, check optional fields only in the case they are present */ - /* Second, check the other (mandatory) fields */ - - if (((res = entityIdVector.check(SubscribeContext)) != "OK") || - ((res = attributeList.check()) != "OK") || - ((res = reference.check(SubscribeContext)) != "OK") || - ((res = duration.check()) != "OK") || - ((res = restriction.check(restrictions)) != "OK") || - ((res = notifyConditionVector.check(SubscribeContext, predetectedError, counter)) != "OK") || - ((res = throttling.check()) != "OK")) - { - alarmMgr.badInput(clientIp, res); - response.subscribeError.errorCode.fill(SccBadRequest, std::string("invalid payload: ") + res); - return response.toJsonV1(); - } - - return "OK"; -} - - - /* **************************************************************************** * * SubscribeContextRequest::release - diff --git a/src/lib/ngsi10/SubscribeContextRequest.h b/src/lib/ngsi10/SubscribeContextRequest.h index ed3abd4346..0c054b4732 100644 --- a/src/lib/ngsi10/SubscribeContextRequest.h +++ b/src/lib/ngsi10/SubscribeContextRequest.h @@ -60,7 +60,6 @@ typedef struct SubscribeContextRequest SubscribeContextRequest(): restrictions(0) {} - std::string check(const std::string& predetectedError, int counter); void release(void); void fill(EntityTypeInfo typeInfo); diff --git a/src/lib/ngsi10/SubscribeContextResponse.cpp b/src/lib/ngsi10/SubscribeContextResponse.cpp index 69baa9a8ba..b8c631b223 100644 --- a/src/lib/ngsi10/SubscribeContextResponse.cpp +++ b/src/lib/ngsi10/SubscribeContextResponse.cpp @@ -26,7 +26,6 @@ #include "logMsg/traceLevels.h" #include "logMsg/logMsg.h" -#include "common/tag.h" #include "common/JsonHelper.h" #include "ngsi10/SubscribeContextResponse.h" @@ -71,7 +70,7 @@ std::string SubscribeContextResponse::toJson(void) // FIXME P5: it is a bit weird to call a toJsonV1() method from a toJson() method. However, // SubscribeResponse doesn't have another option. This should be looked into detail. out += "{"; - out += subscribeResponse.toJsonV1(false); + //out += subscribeResponse.toJsonV1(false); // FIXME PR out += "}"; return out; } @@ -80,28 +79,4 @@ std::string SubscribeContextResponse::toJson(void) return subscribeError.toJson(); } -} - -/* **************************************************************************** -* -* SubscribeContextResponse::toJsonV1 - -*/ -std::string SubscribeContextResponse::toJsonV1(void) -{ - std::string out = ""; - - out += startTag(); - - if (subscribeError.errorCode.code == SccNone) - { - out += subscribeResponse.toJsonV1(false); - } - else - { - out += subscribeError.toJsonV1(SubscribeContext, false); - } - - out += endTag(false); - - return out; -} +} \ No newline at end of file diff --git a/src/lib/ngsi10/SubscribeContextResponse.h b/src/lib/ngsi10/SubscribeContextResponse.h index dc795040dc..5e51bea1b0 100644 --- a/src/lib/ngsi10/SubscribeContextResponse.h +++ b/src/lib/ngsi10/SubscribeContextResponse.h @@ -46,7 +46,6 @@ typedef struct SubscribeContextResponse SubscribeContextResponse(StatusCode& errorCode); ~SubscribeContextResponse(); - std::string toJsonV1(void); std::string toJson(void); } SubscribeContextResponse; diff --git a/src/lib/ngsi10/UnsubscribeContextRequest.cpp b/src/lib/ngsi10/UnsubscribeContextRequest.cpp index af727ad495..d77e5e0df1 100644 --- a/src/lib/ngsi10/UnsubscribeContextRequest.cpp +++ b/src/lib/ngsi10/UnsubscribeContextRequest.cpp @@ -25,49 +25,11 @@ #include #include "common/globals.h" -#include "common/tag.h" #include "ngsi10/UnsubscribeContextResponse.h" #include "ngsi10/UnsubscribeContextRequest.h" -/* **************************************************************************** -* -* UnsubscribeContextRequest::toJsonV1 - -*/ -std::string UnsubscribeContextRequest::toJsonV1(void) -{ - std::string out = ""; - - out += startTag(); - out += subscriptionId.toJsonV1(UnsubscribeContext, false); - out += endTag(); - - return out; -} - - - -/* **************************************************************************** -* -* UnsubscribeContextRequest::check - -*/ -std::string UnsubscribeContextRequest::check() -{ - UnsubscribeContextResponse response; - std::string res; - - if ((res = subscriptionId.check()) != "OK") - { - response.statusCode.fill(SccBadRequest, std::string("Invalid Subscription Id: /") + subscriptionId.get() + "/: " + res); - return response.toJsonV1(); - } - - return "OK"; -} - - - /* **************************************************************************** * * UnsubscribeContextRequest::release - diff --git a/src/lib/ngsi10/UnsubscribeContextRequest.h b/src/lib/ngsi10/UnsubscribeContextRequest.h index d8b9d2a101..4f2a3f82e0 100644 --- a/src/lib/ngsi10/UnsubscribeContextRequest.h +++ b/src/lib/ngsi10/UnsubscribeContextRequest.h @@ -39,8 +39,6 @@ typedef struct UnsubscribeContextRequest { SubscriptionId subscriptionId; // Mandatory - std::string toJsonV1(void); - std::string check(void); void release(void); } UnsubscribeContextRequest; diff --git a/src/lib/ngsi10/UnsubscribeContextResponse.cpp b/src/lib/ngsi10/UnsubscribeContextResponse.cpp index 1e8b80d37c..c8e8aeacba 100644 --- a/src/lib/ngsi10/UnsubscribeContextResponse.cpp +++ b/src/lib/ngsi10/UnsubscribeContextResponse.cpp @@ -26,7 +26,6 @@ #include "logMsg/traceLevels.h" #include "logMsg/logMsg.h" -#include "common/tag.h" #include "ngsi/StatusCode.h" #include "ngsi10/UnsubscribeContextResponse.h" @@ -62,22 +61,6 @@ UnsubscribeContextResponse::~UnsubscribeContextResponse() LM_T(LmtDestructor,("destroyed")); } -/* **************************************************************************** -* -* UnsubscribeContextResponse::toJsonV1 - -*/ -std::string UnsubscribeContextResponse::toJsonV1(void) -{ - std::string out = ""; - - out += startTag(); - out += subscriptionId.toJsonV1(RtUnsubscribeContextResponse, true); - out += statusCode.toJsonV1(false); - out += endTag(); - - return out; -} - /* **************************************************************************** diff --git a/src/lib/ngsi10/UnsubscribeContextResponse.h b/src/lib/ngsi10/UnsubscribeContextResponse.h index 732e12280d..c3483893de 100644 --- a/src/lib/ngsi10/UnsubscribeContextResponse.h +++ b/src/lib/ngsi10/UnsubscribeContextResponse.h @@ -49,7 +49,6 @@ typedef struct UnsubscribeContextResponse UnsubscribeContextResponse(StatusCode& statusCode); ~UnsubscribeContextResponse(); - std::string toJsonV1(void); void release(void); } UnsubscribeContextResponse; diff --git a/src/lib/ngsi10/UpdateContextRequest.cpp b/src/lib/ngsi10/UpdateContextRequest.cpp index 7d23708088..80cda08d87 100644 --- a/src/lib/ngsi10/UpdateContextRequest.cpp +++ b/src/lib/ngsi10/UpdateContextRequest.cpp @@ -29,7 +29,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "common/JsonHelper.h" #include "alarmMgr/alarmMgr.h" #include "ngsi/ContextAttribute.h" @@ -83,47 +82,108 @@ std::string UpdateContextRequest::toJson(void) /* **************************************************************************** * * UpdateContextRequest::toJsonV1 - +* +* This is used only in the legacyForwarding:true logic. It would remove once that deprecated feature +* would be removed +* +* Example: +* +* { +* "contextElements": [ +* { +* "type": "Room", +* "isPattern": "false", +* "id": "ConferenceRoom", +* "attributes": [ +* { +* "name": "temperature", +* "type": "degree", +* "value": "c23", +* "metadatas": [ +* { +* "name": "ID", +* "type": "integer", +* "value": "3" +* } +* ] +* } +* ] +* } +* ], +* "updateAction": "APPEND" +* } */ std::string UpdateContextRequest::toJsonV1(bool asJsonObject) { - std::string out = ""; - - // - // About JSON commas: - // Both fields are MANDATORY, so, always comma after "entityVector" - // - out += startTag(); - out += entityVector.toJsonV1(asJsonObject, UpdateContext, true); - out += valueTag("updateAction", actionTypeString(updateActionType), false); - out += endTag(false); - - return out; -} + JsonObjectHelper jh; + JsonVectorHelper jhContextElements; + for (unsigned int ix = 0; ix < entityVector.size(); ++ix) + { + JsonObjectHelper jhEntity; + Entity* eP = entityVector[ix]; + jhEntity.addString("id", eP->id); + jhEntity.addString("type", eP->type); + jhEntity.addString("isPattern", eP->isPattern); -/* **************************************************************************** -* -* UpdateContextRequest::check - -*/ -std::string UpdateContextRequest::check(bool asJsonObject, const std::string& predetectedError) -{ - std::string res; - UpdateContextResponse response; + JsonVectorHelper jhAttributes; + for (unsigned int jx = 0; jx < eP->attributeVector.size(); ++jx) + { + JsonObjectHelper jhAttribute; + ContextAttribute* caP = eP->attributeVector[jx]; - if (!predetectedError.empty()) - { - response.errorCode.fill(SccBadRequest, predetectedError); - return response.toJsonV1(asJsonObject); + jhAttribute.addString("name", caP->name); + jhAttribute.addString("type", caP->type); + jhAttribute.addRaw("value", caP->toJsonValue()); + + if (caP->metadataVector.size() > 0) + { + JsonVectorHelper jhMetadatas; + for (unsigned int kx = 0; kx < caP->metadataVector.size(); ++kx) + { + JsonObjectHelper jhMetadata; + Metadata *mdP = caP->metadataVector[kx]; + + jhMetadata.addString("name", mdP->name); + jhMetadata.addString("type", mdP->type); + jhMetadata.addRaw("value", mdP->toJson()); + + jhMetadatas.addRaw(jhMetadata.str()); + } + jhAttribute.addRaw("metadatas", jhMetadatas.str()); + } + + jhAttributes.addRaw(jhAttribute.str()); + } + jhEntity.addRaw("attributes", jhAttributes.str()); + + jhContextElements.addRaw(jhEntity.str()); } + jh.addRaw("contextElements", jhContextElements.str()); - if ((res = entityVector.check(UpdateContext)) != "OK") + switch (updateActionType) { - response.errorCode.fill(SccBadRequest, res); - return response.toJsonV1(asJsonObject); + case ActionTypeUpdate: + jh.addString("updateAction", "UPDATE"); + break; + case ActionTypeAppend: + jh.addString("updateAction", "APPEND"); + break; + case ActionTypeAppendStrict: + jh.addString("updateAction", "APPEND_STRICT"); + break; + case ActionTypeDelete: + jh.addString("updateAction", "DELETE"); + break; + case ActionTypeReplace: + jh.addString("updateAction", "REPLACE"); + break; + default: + jh.addString("updateAction", "UNKNOWN"); } - return "OK"; + return jh.str(); } diff --git a/src/lib/ngsi10/UpdateContextRequest.h b/src/lib/ngsi10/UpdateContextRequest.h index c5c45609d0..9af9cfc293 100644 --- a/src/lib/ngsi10/UpdateContextRequest.h +++ b/src/lib/ngsi10/UpdateContextRequest.h @@ -52,7 +52,6 @@ typedef struct UpdateContextRequest std::string toJsonV1(bool asJsonObject); std::string toJson(void); - std::string check(bool asJsonObject, const std::string& predetectedError); void release(void); ContextAttribute* attributeLookup(Entity* eP, const std::string& attributeName); diff --git a/src/lib/ngsi10/UpdateContextResponse.cpp b/src/lib/ngsi10/UpdateContextResponse.cpp index 8c6141b3c8..1b7c6b8152 100644 --- a/src/lib/ngsi10/UpdateContextResponse.cpp +++ b/src/lib/ngsi10/UpdateContextResponse.cpp @@ -30,7 +30,6 @@ #include "common/globals.h" #include "common/string.h" -#include "common/tag.h" #include "alarmMgr/alarmMgr.h" #include "ngsi/ContextElementResponse.h" @@ -76,71 +75,6 @@ UpdateContextResponse::~UpdateContextResponse() -/* **************************************************************************** -* -* UpdateContextResponse::toJsonV1 - -*/ -std::string UpdateContextResponse::toJsonV1(bool asJsonObject) -{ - std::string out = ""; - - out += startTag(); - - if ((errorCode.code != SccNone) && (errorCode.code != SccOk)) - { - out += errorCode.toJsonV1(false); - } - else - { - if (contextElementResponseVector.size() == 0) - { - errorCode.fill(SccContextElementNotFound, errorCode.details); - out += errorCode.toJsonV1(false); - } - else - { - out += contextElementResponseVector.toJsonV1(asJsonObject, RtUpdateContextResponse, false, false); - } - } - - out += endTag(); - - return out; -} - - - -/* **************************************************************************** -* -* UpdateContextResponse::check - -*/ -std::string UpdateContextResponse::check -( - bool asJsonObject, - const std::string& predetectedError -) -{ - std::string res; - - if (!predetectedError.empty()) - { - errorCode.fill(SccBadRequest, predetectedError); - } - else if (contextElementResponseVector.check(UpdateContext, predetectedError, 0) != "OK") - { - alarmMgr.badInput(clientIp, res); - errorCode.fill(SccBadRequest, res); - } - else - { - return "OK"; - } - - return toJsonV1(asJsonObject); -} - - - /* **************************************************************************** * * UpdateContextResponse::release - diff --git a/src/lib/ngsi10/UpdateContextResponse.h b/src/lib/ngsi10/UpdateContextResponse.h index 65fc313a7c..d3233a330b 100644 --- a/src/lib/ngsi10/UpdateContextResponse.h +++ b/src/lib/ngsi10/UpdateContextResponse.h @@ -51,8 +51,6 @@ typedef struct UpdateContextResponse UpdateContextResponse(StatusCode& _errorCode); ~UpdateContextResponse(); - std::string toJsonV1(bool asJsonObject); - std::string check(bool asJsonObject, const std::string& predetectedError); void release(void); void fill(UpdateContextResponse* upcrsP); void fill(UpdateContextRequest* upcrP, HttpStatusCode sc); // Needed by NGSIv2 forwarding logic diff --git a/src/lib/ngsi10/UpdateContextSubscriptionRequest.cpp b/src/lib/ngsi10/UpdateContextSubscriptionRequest.cpp deleted file mode 100644 index 721eaabdfe..0000000000 --- a/src/lib/ngsi10/UpdateContextSubscriptionRequest.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include -#include - -#include "common/globals.h" -#include "common/tag.h" -#include "ngsi/StatusCode.h" -#include "ngsi10/UpdateContextSubscriptionResponse.h" -#include "ngsi10/UpdateContextSubscriptionRequest.h" -#include "ngsi10/SubscribeContextRequest.h" - -using namespace ngsiv2; - - - -/* **************************************************************************** -* -* UpdateContextSubscriptionRequest::UpdateContextSubscriptionRequest -* -* Explicit constructor needed to initialize primitive types so they don't get -* random values from the stack -*/ -UpdateContextSubscriptionRequest::UpdateContextSubscriptionRequest() -{ - restrictions = 0; -} - - - -/* **************************************************************************** -* -* UpdateContextSubscriptionRequest::check - -*/ -std::string UpdateContextSubscriptionRequest::check(const std::string& predetectedError, int counter) -{ - std::string res; - UpdateContextSubscriptionResponse response; - - if (!predetectedError.empty()) - { - response.subscribeError.subscriptionId = subscriptionId; - response.subscribeError.errorCode.fill(SccBadRequest, predetectedError); - } - else if (((res = duration.check()) != "OK") || - ((res = restriction.check(restrictions)) != "OK") || - ((res = subscriptionId.check()) != "OK") || - ((res = notifyConditionVector.check(UpdateContextSubscription, predetectedError, counter)) != "OK") || - ((res = throttling.check()) != "OK")) - { - response.subscribeError.subscriptionId = subscriptionId; - response.subscribeError.errorCode.fill(SccBadRequest, res); - } - else - return "OK"; - - return response.toJsonV1(); -} - - - -/* **************************************************************************** -* -* UpdateContextSubscriptionRequest::release - -*/ -void UpdateContextSubscriptionRequest::release(void) -{ - restriction.release(); - notifyConditionVector.release(); -} \ No newline at end of file diff --git a/src/lib/ngsi10/UpdateContextSubscriptionRequest.h b/src/lib/ngsi10/UpdateContextSubscriptionRequest.h deleted file mode 100644 index a0d3ecf9d3..0000000000 --- a/src/lib/ngsi10/UpdateContextSubscriptionRequest.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef SRC_LIB_NGSI10_UPDATECONTEXTSUBSCRIPTIONREQUEST_H_ -#define SRC_LIB_NGSI10_UPDATECONTEXTSUBSCRIPTIONREQUEST_H_ - -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include - -#include "ngsi/Request.h" -#include "ngsi/EntityId.h" -#include "ngsi/Duration.h" -#include "ngsi/NotifyCondition.h" -#include "ngsi/Restriction.h" -#include "ngsi/SubscriptionId.h" -#include "ngsi/NotifyConditionVector.h" -#include "ngsi/Throttling.h" -#include "ngsi10/SubscribeContextRequest.h" -#include "apiTypesV2/SubscriptionUpdate.h" - - -/* **************************************************************************** -* -* UpdateContextSubscriptionRequest - -*/ -struct UpdateContextSubscriptionRequest : public SubscribeContextRequest -{ - SubscriptionId subscriptionId; // Mandatory - - UpdateContextSubscriptionRequest(); - std::string check(const std::string& predetectedError, int counter); - void release(void); -}; - -#endif // SRC_LIB_NGSI10_UPDATECONTEXTSUBSCRIPTIONREQUEST_H_ diff --git a/src/lib/ngsi10/UpdateContextSubscriptionResponse.cpp b/src/lib/ngsi10/UpdateContextSubscriptionResponse.cpp deleted file mode 100644 index 8acf4835ab..0000000000 --- a/src/lib/ngsi10/UpdateContextSubscriptionResponse.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include - -#include "logMsg/traceLevels.h" -#include "logMsg/logMsg.h" -#include "common/tag.h" -#include "ngsi/StatusCode.h" -#include "ngsi/SubscribeResponse.h" -#include "ngsi/SubscribeError.h" -#include "ngsi10/UpdateContextSubscriptionResponse.h" - - -/* **************************************************************************** -* -* UpdateContextSubscriptionResponse::UpdateContextSubscriptionResponse - -*/ -UpdateContextSubscriptionResponse::UpdateContextSubscriptionResponse() { - subscribeError.errorCode.keyNameSet("errorCode"); -} - -/* **************************************************************************** -* -* UpdateContextSubscriptionResponse::UpdateContextSubscriptionResponse - -*/ -UpdateContextSubscriptionResponse::UpdateContextSubscriptionResponse(StatusCode& errorCode) { - subscribeError.subscriptionId.set("000000000000000000000000"); - subscribeError.errorCode.fill(&errorCode); - subscribeError.errorCode.keyNameSet("errorCode"); -} - -/* **************************************************************************** -* -* UpdateContextSubscriptionResponse::~UpdateContextSubscriptionResponse - -*/ -UpdateContextSubscriptionResponse::~UpdateContextSubscriptionResponse() { - LM_T(LmtDestructor,("destroyed")); -} - -/* **************************************************************************** -* -* UpdateContextSubscriptionResponse::toJsonV1 - -*/ -std::string UpdateContextSubscriptionResponse::toJsonV1(void) -{ - std::string out = ""; - - out += startTag(); - - if (subscribeError.errorCode.code == SccNone) - { - out += subscribeResponse.toJsonV1(false); - } - else - { - out += subscribeError.toJsonV1(UpdateContextSubscription, false); - } - - out += endTag(); - - return out; -} diff --git a/src/lib/ngsi10/UpdateContextSubscriptionResponse.h b/src/lib/ngsi10/UpdateContextSubscriptionResponse.h deleted file mode 100644 index 2a01fc4379..0000000000 --- a/src/lib/ngsi10/UpdateContextSubscriptionResponse.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef SRC_LIB_NGSI10_UPDATECONTEXTSUBSCRIPTIONRESPONSE_H_ -#define SRC_LIB_NGSI10_UPDATECONTEXTSUBSCRIPTIONRESPONSE_H_ - -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include - -#include "ngsi/SubscribeResponse.h" -#include "ngsi/SubscribeError.h" -#include "ngsi/StatusCode.h" - - - -/* **************************************************************************** -* -* UpdateContextSubscriptionResponse - -*/ -typedef struct UpdateContextSubscriptionResponse -{ - SubscribeResponse subscribeResponse; // Optional - but one of the two MUST be present! - SubscribeError subscribeError; // Optional - but one of the two MUST be present! - - UpdateContextSubscriptionResponse(); - UpdateContextSubscriptionResponse(StatusCode& errorCode); - ~UpdateContextSubscriptionResponse(); - - std::string toJsonV1(void); -} UpdateContextSubscriptionResponse; - -#endif // SRC_LIB_NGSI10_UPDATECONTEXTSUBSCRIPTIONRESPONSE_H_ diff --git a/src/lib/ngsi9/CMakeLists.txt b/src/lib/ngsi9/CMakeLists.txt index 3d1d676c15..195b6eade6 100644 --- a/src/lib/ngsi9/CMakeLists.txt +++ b/src/lib/ngsi9/CMakeLists.txt @@ -21,17 +21,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0) SET (SOURCES - RegisterContextRequest.cpp - RegisterContextResponse.cpp DiscoverContextAvailabilityRequest.cpp - DiscoverContextAvailabilityResponse.cpp ) SET (HEADERS DiscoverContextAvailabilityRequest.h - DiscoverContextAvailabilityResponse.h - RegisterContextRequest.h - RegisterContextResponse.h ) diff --git a/src/lib/ngsi9/DiscoverContextAvailabilityRequest.cpp b/src/lib/ngsi9/DiscoverContextAvailabilityRequest.cpp index 699e0807e3..3fbf927b91 100644 --- a/src/lib/ngsi9/DiscoverContextAvailabilityRequest.cpp +++ b/src/lib/ngsi9/DiscoverContextAvailabilityRequest.cpp @@ -32,7 +32,6 @@ #include "ngsi/StringList.h" #include "ngsi/Restriction.h" #include "ngsi9/DiscoverContextAvailabilityRequest.h" -#include "ngsi9/DiscoverContextAvailabilityResponse.h" /* **************************************************************************** * @@ -59,37 +58,6 @@ void DiscoverContextAvailabilityRequest::release(void) -/* **************************************************************************** -* -* DiscoverContextAvailabilityRequest::check - -*/ -std::string DiscoverContextAvailabilityRequest::check(const std::string& predetectedError) -{ - DiscoverContextAvailabilityResponse response; - std::string res; - - if (!predetectedError.empty()) - { - response.errorCode.fill(SccBadRequest, predetectedError); - } - else if (entityIdVector.size() == 0) - { - response.errorCode.fill(SccContextElementNotFound); - } - else if (((res = entityIdVector.check(DiscoverContextAvailability)) != "OK") || - ((res = attributeList.check()) != "OK") || - ((restrictions != 0) && ((res = restriction.check(restrictions)) != "OK"))) - { - response.errorCode.fill(SccBadRequest, res); - } - else - return "OK"; - - return response.toJsonV1(); -} - - - /* **************************************************************************** * * DiscoverContextAvailabilityRequest::fill - diff --git a/src/lib/ngsi9/DiscoverContextAvailabilityRequest.h b/src/lib/ngsi9/DiscoverContextAvailabilityRequest.h index 211e975a6a..0578f8ea4d 100644 --- a/src/lib/ngsi9/DiscoverContextAvailabilityRequest.h +++ b/src/lib/ngsi9/DiscoverContextAvailabilityRequest.h @@ -51,8 +51,6 @@ typedef struct DiscoverContextAvailabilityRequest void release(void); - std::string check(const std::string& predetectedError); - void fill(EntityId& eid, const std::vector& attributeV, const Restriction& restriction); diff --git a/src/lib/ngsi9/DiscoverContextAvailabilityResponse.cpp b/src/lib/ngsi9/DiscoverContextAvailabilityResponse.cpp deleted file mode 100644 index 30a8fbd61a..0000000000 --- a/src/lib/ngsi9/DiscoverContextAvailabilityResponse.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include -#include - -#include "logMsg/traceLevels.h" -#include "logMsg/logMsg.h" -#include "common/globals.h" -#include "common/string.h" -#include "common/tag.h" -#include "ngsi9/DiscoverContextAvailabilityResponse.h" - - - -/* **************************************************************************** -* -* DiscoverContextAvailabilityResponse::DiscoverContextAvailabilityResponse - -*/ -DiscoverContextAvailabilityResponse::DiscoverContextAvailabilityResponse() -{ - errorCode.keyNameSet("errorCode"); -} - -/* **************************************************************************** -* -* DiscoverContextAvailabilityResponse::~DiscoverContextAvailabilityResponse - -*/ -DiscoverContextAvailabilityResponse::~DiscoverContextAvailabilityResponse() -{ - responseVector.release(); - errorCode.release(); -} - - -/* **************************************************************************** -* -* DiscoverContextAvailabilityResponse::DiscoverContextAvailabilityResponse - -*/ -DiscoverContextAvailabilityResponse::DiscoverContextAvailabilityResponse(StatusCode& _errorCode) -{ - errorCode.fill(&_errorCode); - errorCode.keyNameSet("errorCode"); -} - - - -/* **************************************************************************** -* -* DiscoverContextAvailabilityResponse::toJsonV1 - -*/ -std::string DiscoverContextAvailabilityResponse::toJsonV1(void) -{ - std::string out = ""; - - // - // JSON commas: - // Exactly ONE of responseVector|errorCode is included in the discovery response so, - // no JSON commas necessary - // - out += startTag(); - - if (responseVector.size() > 0) - { - bool commaNeeded = (errorCode.code != SccNone); - out += responseVector.toJsonV1(commaNeeded); - } - - if (errorCode.code != SccNone) - { - out += errorCode.toJsonV1(false); - } - - /* Safety check: neither errorCode nor CER vector was filled by mongoBackend */ - if (errorCode.code == SccNone && responseVector.size() == 0) - { - errorCode.fill(SccReceiverInternalError, "Both the error-code structure and the response vector were empty"); - out += errorCode.toJsonV1(false); - } - - out += endTag(); - - return out; -} - - - -/* **************************************************************************** -* -* DiscoverContextAvailabilityResponse::release - -*/ -void DiscoverContextAvailabilityResponse::release(void) -{ - responseVector.release(); - errorCode.release(); - errorCode.keyNameSet("errorCode"); -} diff --git a/src/lib/ngsi9/DiscoverContextAvailabilityResponse.h b/src/lib/ngsi9/DiscoverContextAvailabilityResponse.h deleted file mode 100644 index c8e86c4f5b..0000000000 --- a/src/lib/ngsi9/DiscoverContextAvailabilityResponse.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef SRC_LIB_NGSI9_DISCOVERCONTEXTAVAILABILITYRESPONSE_H_ -#define SRC_LIB_NGSI9_DISCOVERCONTEXTAVAILABILITYRESPONSE_H_ - -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include -#include -#include - -#include "ngsi/ContextRegistrationResponseVector.h" -#include "ngsi/StatusCode.h" - - - -/* **************************************************************************** -* -* DiscoverContextAvailabilityResponse - -*/ -typedef struct DiscoverContextAvailabilityResponse -{ - ContextRegistrationResponseVector responseVector; // Optional - StatusCode errorCode; // Optional - - DiscoverContextAvailabilityResponse(); - ~DiscoverContextAvailabilityResponse(); - DiscoverContextAvailabilityResponse(StatusCode& _errorCode); - - std::string toJsonV1(void); - void release(void); -} DiscoverContextAvailabilityResponse; - -#endif // SRC_LIB_NGSI9_DISCOVERCONTEXTAVAILABILITYRESPONSE_H_ diff --git a/src/lib/ngsi9/RegisterContextRequest.cpp b/src/lib/ngsi9/RegisterContextRequest.cpp deleted file mode 100644 index 6a8aad4d90..0000000000 --- a/src/lib/ngsi9/RegisterContextRequest.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include - -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "common/globals.h" -#include "common/tag.h" -#include "alarmMgr/alarmMgr.h" -#include "ngsi/StatusCode.h" -#include "ngsi/Duration.h" -#include "ngsi/ContextRegistrationVector.h" -#include "ngsi9/RegisterContextResponse.h" -#include "ngsi9/RegisterContextRequest.h" - - - -/* **************************************************************************** -* -* RegisterContextRequest::toJsonV1 - -*/ -std::string RegisterContextRequest::toJsonV1(void) -{ - std::string out = ""; - bool durationRendered = !duration.get().empty(); - bool registrationIdRendered = !registrationId.get().empty(); - bool commaAfterRegistrationId = false; // Last element - bool commaAfterDuration = registrationIdRendered; - bool commaAfterContextRegistrationVector = registrationIdRendered || durationRendered; - - out += startTag(); - - out += contextRegistrationVector.toJsonV1( commaAfterContextRegistrationVector); - out += duration.toJsonV1( commaAfterDuration); - out += registrationId.toJsonV1(RegisterContext, commaAfterRegistrationId); - - out += endTag(false); - - return out; -} - - - -/* **************************************************************************** -* -* RegisterContextRequest::check - -*/ -std::string RegisterContextRequest::check(const std::string& predetectedError, int counter) -{ - RegisterContextResponse response(this); - std::string res; - - if (!predetectedError.empty()) - { - alarmMgr.badInput(clientIp, predetectedError); - response.errorCode.fill(SccBadRequest, predetectedError); - } - else if (contextRegistrationVector.size() == 0) - { - alarmMgr.badInput(clientIp, "empty contextRegistration list"); - response.errorCode.fill(SccBadRequest, "Empty Context Registration List"); - } - else if (((res = contextRegistrationVector.check(RegisterContext, predetectedError, counter)) != "OK") || - ((res = duration.check()) != "OK") || - ((res = registrationId.check()) != "OK")) - { - alarmMgr.badInput(clientIp, res); - response.errorCode.fill(SccBadRequest, res); - } - else - { - return "OK"; - } - - return response.toJsonV1(); -} - - - -/* **************************************************************************** -* -* RegisterContextRequest::release - -*/ -void RegisterContextRequest::release(void) -{ - contextRegistrationVector.release(); - duration.release(); - registrationId.release(); -} diff --git a/src/lib/ngsi9/RegisterContextRequest.h b/src/lib/ngsi9/RegisterContextRequest.h deleted file mode 100644 index 6008e33dde..0000000000 --- a/src/lib/ngsi9/RegisterContextRequest.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef SRC_LIB_NGSI9_REGISTERCONTEXTREQUEST_H_ -#define SRC_LIB_NGSI9_REGISTERCONTEXTREQUEST_H_ - -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include -#include - -#include "ngsi/ContextRegistrationVector.h" -#include "ngsi/Duration.h" -#include "ngsi/RegistrationId.h" - - - -/* **************************************************************************** -* -* RegisterContextRequest - -* -* FIXME PR: empty class? -*/ -typedef struct RegisterContextRequest -{ - ContextRegistrationVector contextRegistrationVector; // Mandatory - Duration duration; // Optional - RegistrationId registrationId; // Optional - - std::string servicePath; // Not part of payload, just an internal field - - std::string toJsonV1(void); - std::string check(const std::string& predetectedError, int counter); - void release(void); -} RegisterContextRequest; - -#endif // SRC_LIB_NGSI9_REGISTERCONTEXTREQUEST_H_ diff --git a/src/lib/ngsi9/RegisterContextResponse.cpp b/src/lib/ngsi9/RegisterContextResponse.cpp deleted file mode 100644 index 34281467ee..0000000000 --- a/src/lib/ngsi9/RegisterContextResponse.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include - -#include "logMsg/traceLevels.h" -#include "logMsg/logMsg.h" -#include "common/globals.h" -#include "common/tag.h" -#include "ngsi/StatusCode.h" -#include "ngsi/StatusCode.h" -#include "ngsi9/RegisterContextRequest.h" -#include "ngsi9/RegisterContextResponse.h" - - - -/* **************************************************************************** -* -* RegisterContextResponse::RegisterContextResponse - -*/ -RegisterContextResponse::RegisterContextResponse() -{ - registrationId.set(""); - duration.set(""); - errorCode.keyNameSet("errorCode"); -} - -/* **************************************************************************** -* -* RegisterContextResponse::~RegisterContextResponse - -*/ -RegisterContextResponse::~RegisterContextResponse() -{ - LM_T(LmtDestructor,("destroyed")); -} - - -/* **************************************************************************** -* -* RegisterContextResponse::RegisterContextResponse - -*/ -RegisterContextResponse::RegisterContextResponse(RegisterContextRequest* rcrP) -{ - registrationId.set(rcrP->registrationId.get()); - duration.set(rcrP->duration.get()); - errorCode.keyNameSet("errorCode"); -} - - - -/* **************************************************************************** -* -* RegisterContextResponse::RegisterContextResponse - -*/ -RegisterContextResponse::RegisterContextResponse(const std::string& _registrationId, const std::string& _duration) -{ - registrationId.set(_registrationId); - duration.set(_duration); - errorCode.keyNameSet("errorCode"); -} - - - -/* **************************************************************************** -* -* RegisterContextResponse::RegisterContextResponse - -*/ -RegisterContextResponse::RegisterContextResponse(const std::string& _registrationId, StatusCode& _errorCode) -{ - registrationId.set(_registrationId); - errorCode = _errorCode; - errorCode.keyNameSet("errorCode"); -} - - - -/* **************************************************************************** -* -* RegisterContextResponse::toJsonV1 - -*/ -std::string RegisterContextResponse::toJsonV1(void) -{ - std::string out = ""; - bool errorCodeRendered = (errorCode.code != SccNone) && (errorCode.code != SccOk); - - out += startTag(); - - if (!errorCodeRendered) - { - out += duration.toJsonV1(true); - } - - out += registrationId.toJsonV1(RegisterResponse, errorCodeRendered); - - if (errorCodeRendered) - { - out += errorCode.toJsonV1(false); - } - - out += endTag(); - - return out; -} - - - -/* **************************************************************************** -* -* RegisterContextResponse::check - -*/ -std::string RegisterContextResponse::check(const std::string& predetectedError) -{ - RegisterContextResponse response; - std::string res; - - if (!predetectedError.empty()) - { - response.errorCode.fill(SccBadRequest, predetectedError); - } - else if (((res = duration.check()) != "OK") || - ((res = registrationId.check()) != "OK")) - { - response.errorCode.fill(SccBadRequest, res); - } - else - return "OK"; - - return response.toJsonV1(); -} - - - -/* **************************************************************************** -* -* release - -*/ -void RegisterContextResponse::release(void) -{ - duration.release(); - registrationId.release(); - errorCode.release(); -} diff --git a/src/lib/ngsi9/RegisterContextResponse.h b/src/lib/ngsi9/RegisterContextResponse.h deleted file mode 100644 index 15c7134d6e..0000000000 --- a/src/lib/ngsi9/RegisterContextResponse.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef SRC_LIB_NGSI9_REGISTERCONTEXTRESPONSE_H_ -#define SRC_LIB_NGSI9_REGISTERCONTEXTRESPONSE_H_ - -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include - -#include "ngsi/StatusCode.h" -#include "ngsi/RegistrationId.h" -#include "ngsi/Duration.h" -#include "ngsi9/RegisterContextRequest.h" - - - -/* **************************************************************************** -* -* RegisterContextResponse - -*/ -typedef struct RegisterContextResponse -{ - Duration duration; // Optional - RegistrationId registrationId; // Mandatory - StatusCode errorCode; // Optional - - RegisterContextResponse(); - ~RegisterContextResponse(); - RegisterContextResponse(RegisterContextRequest* rcrP); - RegisterContextResponse(const std::string& _registrationId, const std::string& _duration); - RegisterContextResponse(const std::string& _registrationId, StatusCode& _errorCode); - - std::string toJsonV1(void); - std::string check(const std::string& predetectedError); - void release(void); -} RegisterContextResponse; - -#endif // SRC_LIB_NGSI9_REGISTERCONTEXTRESPONSE_H_ diff --git a/src/lib/orionTypes/EntityType.cpp b/src/lib/orionTypes/EntityType.cpp index 4bd309bb74..ab7fdfcee0 100755 --- a/src/lib/orionTypes/EntityType.cpp +++ b/src/lib/orionTypes/EntityType.cpp @@ -29,7 +29,6 @@ #include "logMsg/traceLevels.h" #include "logMsg/logMsg.h" -#include "common/tag.h" #include "common/limits.h" #include "common/JsonHelper.h" #include "ngsi/Request.h" @@ -58,57 +57,6 @@ EntityType::EntityType(std::string _type): type(_type), count(0) } -/* **************************************************************************** -* -* EntityType::toJsonV1 - -* -* This method is used by: -* o EntityTypeVector -* o EntityTypeResponse -* -* 'typeNameBefore' is set to TRUE when called from EntityTypeResponse -*/ -std::string EntityType::toJsonV1 -( - bool asJsonObject, - bool asJsonOut, - bool collapsed, - bool comma, - bool typeNameBefore -) -{ - std::string out = ""; - - // No metadata filter in this case, an empty vector is used to fulfil method signature. - // For attribute filter, we use the ContextAttributeVector itself - std::vector emptyMdV; - - if (typeNameBefore && asJsonOut) - { - out += valueTag("name", type, true); - out += contextAttributeVector.toJsonV1(asJsonObject, EntityTypes, contextAttributeVector.vec, emptyMdV, true, true, true); - } - else - { - out += startTag(); - - if (collapsed || contextAttributeVector.size() == 0) - { - out += valueTag("name", type, false); - } - else - { - out += valueTag("name", type, true); - out += contextAttributeVector.toJsonV1(asJsonObject, EntityTypes, contextAttributeVector.vec, emptyMdV, false, true, true); - } - - out += endTag(comma, false); - } - - return out; -} - - /* **************************************************************************** * diff --git a/src/lib/orionTypes/EntityType.h b/src/lib/orionTypes/EntityType.h index 9e6a8bbabe..e20107fa7c 100644 --- a/src/lib/orionTypes/EntityType.h +++ b/src/lib/orionTypes/EntityType.h @@ -46,11 +46,6 @@ class EntityType explicit EntityType(std::string _type); std::string check(const std::string& predetectedError); - std::string toJsonV1(bool asJsonObject, - bool asJsonOut, - bool collapsed, - bool comma = false, - bool typeNameBefore = false); void release(void); std::string toJson(bool includeType = false); }; diff --git a/src/lib/orionTypes/EntityTypeResponse.cpp b/src/lib/orionTypes/EntityTypeResponse.cpp index 97d19571d8..b850ed6d81 100755 --- a/src/lib/orionTypes/EntityTypeResponse.cpp +++ b/src/lib/orionTypes/EntityTypeResponse.cpp @@ -30,7 +30,6 @@ #include "logMsg/logMsg.h" #include "common/globals.h" -#include "common/tag.h" #include "common/limits.h" #include "common/JsonHelper.h" #include "alarmMgr/alarmMgr.h" @@ -40,62 +39,6 @@ -/* **************************************************************************** -* -* EntityTypeResponse::toJsonV1 - -*/ -std::string EntityTypeResponse::toJsonV1 -( - bool asJsonObject, - bool asJsonOut, - bool collapsed -) -{ - std::string out = ""; - - out += startTag(); - - out += entityType.toJsonV1(asJsonObject, asJsonOut, collapsed, true, true); - out += statusCode.toJsonV1(false); - - out += endTag(); - - return out; -} - - - -/* **************************************************************************** -* -* EntityTypeResponse::check - -*/ -std::string EntityTypeResponse::check -( - bool asJsonObject, - bool asJsonOut, - bool collapsed, - const std::string& predetectedError -) -{ - std::string res; - - if (!predetectedError.empty()) - { - statusCode.fill(SccBadRequest, predetectedError); - } - else if ((res = entityType.check(predetectedError)) != "OK") - { - alarmMgr.badInput(clientIp, res); - statusCode.fill(SccBadRequest, res); - } - else - return "OK"; - - return toJsonV1(asJsonObject, asJsonOut, collapsed); -} - - - /* **************************************************************************** * * EntityTypeResponse::release - diff --git a/src/lib/orionTypes/EntityTypeResponse.h b/src/lib/orionTypes/EntityTypeResponse.h index 43d564664c..26046b4b31 100644 --- a/src/lib/orionTypes/EntityTypeResponse.h +++ b/src/lib/orionTypes/EntityTypeResponse.h @@ -44,14 +44,7 @@ class EntityTypeResponse EntityType entityType; StatusCode statusCode; - std::string toJsonV1(bool asJsonObject, - bool asJsonOut, - bool collapsed); std::string toJson(void); - std::string check(bool asJsonObject, - bool asJsonOut, - bool collapsed, - const std::string& predetectedError); void release(void); }; diff --git a/src/lib/orionTypes/EntityTypeVector.cpp b/src/lib/orionTypes/EntityTypeVector.cpp index 410f9f1daa..27c710f19a 100755 --- a/src/lib/orionTypes/EntityTypeVector.cpp +++ b/src/lib/orionTypes/EntityTypeVector.cpp @@ -31,7 +31,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "ngsi/Request.h" #include "orionTypes/EntityType.h" #include "orionTypes/EntityTypeVector.h" @@ -48,35 +47,6 @@ EntityTypeVector::EntityTypeVector() } -/* **************************************************************************** -* -* EntityTypeVector::toJsonV1 - -*/ -std::string EntityTypeVector::toJsonV1 -( - bool asJsonObject, - bool asJsonOut, - bool collapsed, - bool comma -) -{ - std::string out = ""; - - if (vec.size() > 0) - { - out += startTag("types", true); - - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - out += vec[ix]->toJsonV1(asJsonObject, asJsonOut, collapsed, ix != vec.size() - 1); - } - out += endTag(comma, true); - } - - return out; -} - - /* **************************************************************************** * diff --git a/src/lib/orionTypes/EntityTypeVector.h b/src/lib/orionTypes/EntityTypeVector.h index d35670cfa6..f01c353574 100644 --- a/src/lib/orionTypes/EntityTypeVector.h +++ b/src/lib/orionTypes/EntityTypeVector.h @@ -47,10 +47,6 @@ class EntityTypeVector unsigned int size(void); void release(void); std::string check(const std::string& predetectedError); - std::string toJsonV1(bool asJsonObject, - bool asJsonOut, - bool collapsed, - bool comma = false); EntityType* operator[] (unsigned int ix) const; diff --git a/src/lib/orionTypes/EntityTypeVectorResponse.cpp b/src/lib/orionTypes/EntityTypeVectorResponse.cpp index c22c9b6ac2..08f6c16809 100755 --- a/src/lib/orionTypes/EntityTypeVectorResponse.cpp +++ b/src/lib/orionTypes/EntityTypeVectorResponse.cpp @@ -30,7 +30,6 @@ #include "logMsg/logMsg.h" #include "common/globals.h" -#include "common/tag.h" #include "common/JsonHelper.h" #include "alarmMgr/alarmMgr.h" @@ -39,67 +38,6 @@ -/* **************************************************************************** -* -* EntityTypeVectorResponse::toJsonV1 - -*/ -std::string EntityTypeVectorResponse::toJsonV1 -( - bool asJsonObject, - bool asJsonOut, - bool collapsed -) -{ - std::string out = ""; - - out += startTag(); - - if (entityTypeVector.size() > 0) - { - out += entityTypeVector.toJsonV1(asJsonObject, asJsonOut, collapsed, true); - } - - out += statusCode.toJsonV1(false); - - out += endTag(); - - return out; -} - - - -/* **************************************************************************** -* -* EntityTypeVectorResponse::check - -*/ -std::string EntityTypeVectorResponse::check -( - bool asJsonObject, - bool asJsonOut, - bool collapsed, - const std::string& predetectedError) -{ - std::string res; - - if (!predetectedError.empty()) - { - statusCode.fill(SccBadRequest, predetectedError); - } - else if ((res = entityTypeVector.check(predetectedError)) != "OK") - { - alarmMgr.badInput(clientIp, res); - statusCode.fill(SccBadRequest, res); - } - else - { - return "OK"; - } - - return toJsonV1(asJsonObject, asJsonOut, collapsed); -} - - - /* **************************************************************************** * * EntityTypeVectorResponse::release - diff --git a/src/lib/orionTypes/EntityTypeVectorResponse.h b/src/lib/orionTypes/EntityTypeVectorResponse.h index 3ab6ae1c06..63752799f5 100644 --- a/src/lib/orionTypes/EntityTypeVectorResponse.h +++ b/src/lib/orionTypes/EntityTypeVectorResponse.h @@ -44,14 +44,6 @@ class EntityTypeVectorResponse EntityTypeVector entityTypeVector; StatusCode statusCode; - std::string toJsonV1(bool asJsonObject, - bool asJsonOut, - bool collapsed); - - std::string check(bool asJsonObject, - bool asJsonOut, - bool collapsed, - const std::string& predetectedError); void release(void); std::string toJson(bool values); }; diff --git a/src/lib/orionTypes/QueryContextRequestVector.cpp b/src/lib/orionTypes/QueryContextRequestVector.cpp index 472a67b75d..cfb1119b2b 100644 --- a/src/lib/orionTypes/QueryContextRequestVector.cpp +++ b/src/lib/orionTypes/QueryContextRequestVector.cpp @@ -30,7 +30,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "orionTypes/QueryContextRequestVector.h" #include "ngsi/Request.h" diff --git a/src/lib/orionTypes/QueryContextResponseVector.cpp b/src/lib/orionTypes/QueryContextResponseVector.cpp index 4a6f21ba8d..35877ec3d8 100644 --- a/src/lib/orionTypes/QueryContextResponseVector.cpp +++ b/src/lib/orionTypes/QueryContextResponseVector.cpp @@ -30,7 +30,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "orionTypes/QueryContextResponseVector.h" #include "ngsi/Request.h" @@ -84,127 +83,6 @@ void QueryContextResponseVector::release(void) -/* **************************************************************************** -* -* QueryContextResponseVector::toJsonV1 - -*/ -std::string QueryContextResponseVector::toJsonV1(bool asJsonObject, bool details, const std::string& detailsString) -{ - QueryContextResponse* responseP = new QueryContextResponse(); - std::string answer; - - // - // Here we have a vector of QueryContextResponse. - // What we need is ONE QueryContextResponse, so, we'll take all the - // contextElementResponses from each of the QueryContextResponses in the vector and - // move them to ONE QueryContextResponse (responseP) - // - // [ This might give me some problems with freeing the memory afterwards ...] - // - - - if (vec.size() == 0) - { - // - // Special case: vector is empty: translate to 404 - // - if ((responseP->errorCode.code == SccOk) || (responseP->errorCode.code == SccNone)) - { - responseP->errorCode.fill(SccContextElementNotFound); - } - } - else if ((vec.size() == 1) && (vec[0]->contextElementResponseVector.size() == 0)) - { - // - // Special case: only one QueryContextResponse in vec, and it has 0 contextElementResponses - // This is clearly a Not Found ... - // - if ((responseP->errorCode.code == SccOk) || (responseP->errorCode.code == SccNone)) - { - responseP->errorCode.fill(SccContextElementNotFound); - } - - if ((vec[0]->errorCode.code == SccOk) ||(vec[0]->errorCode.code == SccNone)) - { - vec[0]->errorCode.fill(SccContextElementNotFound); - } - - // - // Also, if same errorCode.code but no details ... - // - if ((responseP->errorCode.code == vec[0]->errorCode.code) && (responseP->errorCode.details.empty())) - { - responseP->errorCode.details = vec[0]->errorCode.details; - } - } - else - { - // - // We have found something, so, all good - // - responseP->errorCode.fill(SccOk); - } - - if (details) - { - responseP->errorCode.fill(SccOk, detailsString); - } - - for (unsigned int qIx = 0; qIx < vec.size(); ++qIx) - { - // - // If the response vector is empty and the errorCode also, then a 404 Not Found - // is inserted. - // - if (vec[qIx]->contextElementResponseVector.size() == 0) - { - if ((vec[qIx]->errorCode.code == SccOk) || (vec[qIx]->errorCode.code == SccNone)) - { - ContextElementResponse* cerP = new ContextElementResponse(); - - cerP->statusCode.fill(SccContextElementNotFound); - responseP->contextElementResponseVector.push_back(cerP); - } - } - - for (unsigned int cerIx = 0; cerIx < vec[qIx]->contextElementResponseVector.size(); ++cerIx) - { - ContextElementResponse* cerP = vec[qIx]->contextElementResponseVector[cerIx]; - - if ((cerP->statusCode.code != SccOk) && (cerP->statusCode.code != SccNone)) // Error - not to be added to output - { - continue; - } - - // - // Does the EntityId of cerP already exist in any of the contextElementResponses in the contextElementResponseVector? - // If so, we just add the attributes of cerP to that contextElementResponse - // - ContextElementResponse* targetCerP = responseP->contextElementResponseVector.lookup(&cerP->entity); - - if (targetCerP != NULL) - { - targetCerP->entity.attributeVector.push_back(cerP->entity.attributeVector, true); - } - else // Not found so we will have to create a new ContextElementResponse - { - ContextElementResponse* newCerP = new ContextElementResponse(cerP, true); - - newCerP->statusCode.fill(SccOk); - responseP->contextElementResponseVector.push_back(newCerP); - } - } - } - - answer = responseP->toJsonV1(asJsonObject); - responseP->release(); - delete responseP; - - return answer; -} - - - /* **************************************************************************** * * QueryContextResponseVector::populate - diff --git a/src/lib/orionTypes/QueryContextResponseVector.h b/src/lib/orionTypes/QueryContextResponseVector.h index beeca40b2e..80030a5470 100644 --- a/src/lib/orionTypes/QueryContextResponseVector.h +++ b/src/lib/orionTypes/QueryContextResponseVector.h @@ -43,7 +43,6 @@ typedef struct QueryContextResponseVector unsigned int size(void); void push_back(QueryContextResponse* item); void release(void); - std::string toJsonV1(bool asJsonObject, bool details, const std::string& detailsString); void populate(QueryContextResponse* responseP); QueryContextResponse* operator[](unsigned int ix) const; diff --git a/src/lib/orionTypes/UpdateContextRequestVector.cpp b/src/lib/orionTypes/UpdateContextRequestVector.cpp index b9c499adb5..e6b4931569 100644 --- a/src/lib/orionTypes/UpdateContextRequestVector.cpp +++ b/src/lib/orionTypes/UpdateContextRequestVector.cpp @@ -30,7 +30,6 @@ #include "logMsg/traceLevels.h" #include "common/globals.h" -#include "common/tag.h" #include "orionTypes/UpdateContextRequestVector.h" #include "ngsi/Request.h" diff --git a/src/lib/parse/CompoundValueNode.cpp b/src/lib/parse/CompoundValueNode.cpp index fdf0fa2008..601c4531e1 100644 --- a/src/lib/parse/CompoundValueNode.cpp +++ b/src/lib/parse/CompoundValueNode.cpp @@ -29,7 +29,6 @@ #include "common/globals.h" #include "common/string.h" -#include "common/tag.h" #include "common/JsonHelper.h" #include "common/macroSubstitute.h" #include "alarmMgr/alarmMgr.h" diff --git a/src/lib/rest/OrionError.cpp b/src/lib/rest/OrionError.cpp index c7d767cbaa..1454eef5b9 100644 --- a/src/lib/rest/OrionError.cpp +++ b/src/lib/rest/OrionError.cpp @@ -25,7 +25,7 @@ #include #include -#include "common/tag.h" +#include "common/string.h" #include "common/JsonHelper.h" #include "rest/ConnectionInfo.h" #include "ngsi/StatusCode.h" diff --git a/src/lib/rest/RestService.cpp b/src/lib/rest/RestService.cpp index 602691c537..eacc5dfcc5 100644 --- a/src/lib/rest/RestService.cpp +++ b/src/lib/rest/RestService.cpp @@ -148,12 +148,6 @@ static void delayedRelease(JsonDelayedRelease* releaseP) releaseP->scrP = NULL; } - if (releaseP->ucsrP != NULL) - { - releaseP->ucsrP->release(); - releaseP->ucsrP = NULL; - } - if (releaseP->subsP != NULL) { delete releaseP->subsP; @@ -372,10 +366,6 @@ static void scopeFilter { restrictionP = &parseDataP->scr.res.restriction; } - else if (ciP->restServiceP->request == UpdateContextSubscription) - { - restrictionP = &parseDataP->ucsr.res.restriction; - } else { return; diff --git a/src/lib/rest/orionLogReply.cpp b/src/lib/rest/orionLogReply.cpp index 322ad9e14f..851897f335 100644 --- a/src/lib/rest/orionLogReply.cpp +++ b/src/lib/rest/orionLogReply.cpp @@ -24,7 +24,6 @@ */ #include -#include "common/tag.h" #include "rest/ConnectionInfo.h" #include "rest/restReply.h" @@ -36,11 +35,10 @@ */ std::string orionLogReply(ConnectionInfo* ciP, const std::string& what, const std::string& value) { - std::string out = ""; + JsonObjectHelper jh; - out += '{'; - out += valueTag(what, value); - out += '}'; + jh.addString(what, value); + std::string out = jh.str(); ciP->httpStatusCode = SccOk; restReply(ciP, out); diff --git a/src/lib/rest/rest.cpp b/src/lib/rest/rest.cpp index e266876e54..b2d6572410 100644 --- a/src/lib/rest/rest.cpp +++ b/src/lib/rest/rest.cpp @@ -43,7 +43,6 @@ #include "common/defaultValues.h" #include "common/clockFunctions.h" #include "common/statistics.h" -#include "common/tag.h" #include "common/limits.h" // SERVICE_NAME_MAX_LEN #include "common/logTracing.h" diff --git a/src/lib/rest/restReply.cpp b/src/lib/rest/restReply.cpp index 62ad51b121..36b8f0e508 100644 --- a/src/lib/rest/restReply.cpp +++ b/src/lib/rest/restReply.cpp @@ -31,14 +31,10 @@ #include "ngsi/StatusCode.h" #include "metricsMgr/metricsMgr.h" -#include "ngsi9/DiscoverContextAvailabilityResponse.h" -#include "ngsi9/RegisterContextResponse.h" - #include "ngsi10/QueryContextResponse.h" #include "ngsi10/SubscribeContextResponse.h" #include "ngsi10/UnsubscribeContextResponse.h" #include "ngsi10/UpdateContextResponse.h" -#include "ngsi10/UpdateContextSubscriptionResponse.h" #include "ngsi10/NotifyContextResponse.h" #include "rest/rest.h" diff --git a/src/lib/serviceRoutines/postNotifyContext.cpp b/src/lib/serviceRoutines/postNotifyContext.cpp index 5a1ec9a8ab..8b929e667e 100644 --- a/src/lib/serviceRoutines/postNotifyContext.cpp +++ b/src/lib/serviceRoutines/postNotifyContext.cpp @@ -62,7 +62,9 @@ std::string postNotifyContext ciP->servicePathV, ciP->httpHeaders.correlator, ciP->httpHeaders.ngsiv2AttrsFormat)); - TIMED_RENDER(answer = ncr.toJsonV1()); + + //FIXME PR: this should be toJSON() + //TIMED_RENDER(answer = ncr.toJsonV1()); return answer; } diff --git a/src/lib/serviceRoutines/postQueryContext.cpp b/src/lib/serviceRoutines/postQueryContext.cpp index a240f3d232..0f229552a0 100644 --- a/src/lib/serviceRoutines/postQueryContext.cpp +++ b/src/lib/serviceRoutines/postQueryContext.cpp @@ -191,7 +191,7 @@ static bool queryForward { LM_W(("Deprecated usage of legacyForwarding mode in query forwarding operation (regId: %s)", regId.c_str())); } - + TIMED_RENDER(payload = qcrP->toJsonV1()); } else diff --git a/src/lib/serviceRoutines/postUpdateContext.cpp b/src/lib/serviceRoutines/postUpdateContext.cpp index 861071d858..552c8a1900 100644 --- a/src/lib/serviceRoutines/postUpdateContext.cpp +++ b/src/lib/serviceRoutines/postUpdateContext.cpp @@ -115,6 +115,7 @@ static bool updateForward int port; std::string prefix; + // FIXME PR: not really needed... bool asJsonObject = (ciP->uriParam[URI_PARAM_ATTRIBUTE_FORMAT] == "object" && ciP->outMimeType == JSON); // diff --git a/src/lib/serviceRoutines/statisticsTreat.cpp b/src/lib/serviceRoutines/statisticsTreat.cpp index ec734f51a9..bbbdc76649 100644 --- a/src/lib/serviceRoutines/statisticsTreat.cpp +++ b/src/lib/serviceRoutines/statisticsTreat.cpp @@ -30,7 +30,6 @@ #include "common/string.h" #include "common/globals.h" -#include "common/tag.h" #include "common/statistics.h" #include "common/sem.h" #include "metricsMgr/metricsMgr.h" diff --git a/src/lib/serviceRoutines/versionTreat.cpp b/src/lib/serviceRoutines/versionTreat.cpp index 1b71e28125..ea0f7cfac5 100644 --- a/src/lib/serviceRoutines/versionTreat.cpp +++ b/src/lib/serviceRoutines/versionTreat.cpp @@ -30,7 +30,6 @@ #include "common/string.h" #include "common/globals.h" -#include "common/tag.h" #include "common/compileInfo.h" #include "common/defaultValues.h" #include "rest/HttpHeaders.h" diff --git a/src/lib/serviceRoutinesV2/entryPointsTreat.cpp b/src/lib/serviceRoutinesV2/entryPointsTreat.cpp index 7f4beb6c7d..25b43e726d 100644 --- a/src/lib/serviceRoutinesV2/entryPointsTreat.cpp +++ b/src/lib/serviceRoutinesV2/entryPointsTreat.cpp @@ -30,7 +30,6 @@ #include "common/string.h" #include "common/globals.h" -#include "common/tag.h" #include "common/JsonHelper.h" #include "ngsi/ParseData.h" diff --git a/src/lib/serviceRoutinesV2/patchSubscription.cpp b/src/lib/serviceRoutinesV2/patchSubscription.cpp index 529fe2ac77..df00c4435a 100644 --- a/src/lib/serviceRoutinesV2/patchSubscription.cpp +++ b/src/lib/serviceRoutinesV2/patchSubscription.cpp @@ -32,7 +32,6 @@ #include "ngsi/ParseData.h" #include "rest/OrionError.h" #include "mongoBackend/mongoUpdateSubscription.h" -#include "ngsi10/UpdateContextSubscriptionResponse.h" #include "serviceRoutinesV2/patchSubscription.h" diff --git a/src/lib/serviceRoutinesV2/semStateTreat.cpp b/src/lib/serviceRoutinesV2/semStateTreat.cpp index 45c8387f6f..1219bf3e7e 100644 --- a/src/lib/serviceRoutinesV2/semStateTreat.cpp +++ b/src/lib/serviceRoutinesV2/semStateTreat.cpp @@ -30,7 +30,6 @@ #include "common/statistics.h" #include "common/clockFunctions.h" -#include "common/tag.h" #include "common/JsonHelper.h" #include "ngsi/ParseData.h" diff --git a/test/functionalTest/cases/3068_cprs_full_functional_v2/fwd_v1_ngsiv2_query_forward.test b/test/functionalTest/cases/3068_cprs_full_functional_v2/fwd_v1_ngsiv2_query_forward.test index e83d860554..c2f2098446 100644 --- a/test/functionalTest/cases/3068_cprs_full_functional_v2/fwd_v1_ngsiv2_query_forward.test +++ b/test/functionalTest/cases/3068_cprs_full_functional_v2/fwd_v1_ngsiv2_query_forward.test @@ -35,8 +35,11 @@ accumulatorStart --pretty-print # # 01. Register ConferenceRoom on CB with accumulator as providing application # 02. Register ConferenceRoom2 on CB with accumulator as providing application -# 03. Query ConferenceRoom in CB -# 04. Query ConferenceRoom2 in CB +# 03. Register ConferenceRoom3 pressure on CB with accumulator as providing application +# 04. Query ConferenceRoom in CB +# 05. Query ConferenceRoom2 in CB +# 06. Query ConferenceRoom3 pressure in CB +# 07. Check three forwarded requests in logs # echo "01. Register ConferenceRoom on CB with accumulator as providing application" @@ -62,6 +65,9 @@ echo echo +REG1_ID=$(echo "$_responseHeaders" | grep Location | awk -F/ '{ print $4 }' | tr -d "\r\n") + + echo "02. Register ConferenceRoom2 on CB with accumulator as providing application" echo "============================================================================" payload='{ @@ -85,20 +91,64 @@ echo echo -echo "03. Query ConferenceRoom in CB" +REG2_ID=$(echo "$_responseHeaders" | grep Location | awk -F/ '{ print $4 }' | tr -d "\r\n") + + +echo "03. Register ConferenceRoom3 pressure on CB with accumulator as providing application" +echo "=====================================================================================" +payload='{ + "dataProvided": { + "entities": [ + { + "type": "Room", + "id": "ConferenceRoom3" + } + ], + "attrs": [ "pressure" ] + }, + "provider": { + "http": { + "url": "http://localhost:'${LISTENER_PORT}'/cpr" + }, + "legacyForwarding": true + } +}' +orionCurl --url /v2/registrations --payload "$payload" +echo +echo + + +REG3_ID=$(echo "$_responseHeaders" | grep Location | awk -F/ '{ print $4 }' | tr -d "\r\n") + + +echo "04. Query ConferenceRoom in CB" echo "==============================" orionCurl --url /v2/entities/ConferenceRoom echo echo -echo "04. Query ConferenceRoom2 in CB" +echo "05. Query ConferenceRoom2 in CB" echo "===============================" orionCurl --url /v2/entities/ConferenceRoom2 echo echo +echo "06. Query ConferenceRoom3 pressure in CB" +echo "=======================================" +orionCurl --url /v2/entities/ConferenceRoom3/attrs/pressure +echo +echo + + +echo "07. Check three forwarded requests in logs" +echo "==========================================" +cat /tmp/contextBroker.log | grep "Request forwarded" | awk -F 'msg=' '{print $2}' | sed "s/${REG1_ID}/REG1_ID/" | sed "s/${REG2_ID}/REG2_ID/" | sed "s/${REG3_ID}/REG3_ID/" +echo +echo + + --REGEXPECT-- 01. Register ConferenceRoom on CB with accumulator as providing application =========================================================================== @@ -120,7 +170,17 @@ Content-Length: 0 -03. Query ConferenceRoom in CB +03. Register ConferenceRoom3 pressure on CB with accumulator as providing application +===================================================================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/registrations/REGEX([0-9a-f\-]{24}) +Content-Length: 0 + + + +04. Query ConferenceRoom in CB ============================== HTTP/1.1 200 OK Date: REGEX(.*) @@ -176,7 +236,7 @@ Content-Length: 375 } -04. Query ConferenceRoom2 in CB +05. Query ConferenceRoom2 in CB =============================== HTTP/1.1 200 OK Date: REGEX(.*) @@ -195,6 +255,28 @@ Content-Length: 97 } +06. Query ConferenceRoom3 pressure in CB +======================================= +HTTP/1.1 200 OK +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 44 + +{ + "metadata": {}, + "type": "degree", + "value": "14" +} + + +07. Check three forwarded requests in logs +========================================== +Request forwarded (regId: REG1_ID): POST http://localhost:9997/cpr/queryContext, request payload (88 bytes): {"entities":[{"id":"ConferenceRoom","type":"Room","isPattern":"false"}],"attributes":[]}, response payload (3912 bytes): +Request forwarded (regId: REG2_ID): POST http://localhost:9997/cpr/queryContext, request payload (89 bytes): {"entities":[{"id":"ConferenceRoom2","type":"Room","isPattern":"false"}],"attributes":[]}, response payload (3912 bytes): +Request forwarded (regId: REG3_ID): POST http://localhost:9997/cpr/queryContext, request payload (99 bytes): {"entities":[{"id":"ConferenceRoom3","type":"Room","isPattern":"false"}],"attributes":["pressure"]}, response payload (3912 bytes): + + --TEARDOWN-- brokerStop CB accumulatorStop $LISTENER_PORT diff --git a/test/functionalTest/cases/3068_cprs_full_functional_v2/fwd_v1_ngsiv2_update_forward.test b/test/functionalTest/cases/3068_cprs_full_functional_v2/fwd_v1_ngsiv2_update_forward.test index 7c0bec1147..eb25ee3ec2 100644 --- a/test/functionalTest/cases/3068_cprs_full_functional_v2/fwd_v1_ngsiv2_update_forward.test +++ b/test/functionalTest/cases/3068_cprs_full_functional_v2/fwd_v1_ngsiv2_update_forward.test @@ -35,6 +35,7 @@ accumulatorStart --pretty-print # # 01. Register ConferenceRoom on CB with accumulator as providing application # 02. Update ConferenceRoom in CB +# 03. Check one forwarded requests in logs # echo "01. Register ConferenceRoom on CB with accumulator as providing application" @@ -60,12 +61,43 @@ echo echo +REG1_ID=$(echo "$_responseHeaders" | grep Location | awk -F/ '{ print $4 }' | tr -d "\r\n") + + echo "02. Update ConferenceRoom in CB" echo "===============================" payload='{ + "lightstatus": { + "type": "StructuredValue", + "value": { + "x": 1, + "y": 2 + } + }, + "pressure": { + "type": "StructuredValue", + "value": ["a", "b", "c"] + }, "temperature": { - "value": 4, - "type": "Number" + "value": 14, + "type": "Number", + "metadata": { + "ID1": { + "type": "Text", + "value": { + "x": 1, + "y": 2 + } + }, + "ID2": { + "type": "Text", + "value": ["a", "b", "c"] + }, + "ID3": { + "type": "Text", + "value": "ThisIsID3" + } + } } }' orionCurl --url /v2/entities/ConferenceRoom/attrs?type=Room --payload "$payload" -X PATCH @@ -73,6 +105,13 @@ echo echo +echo "03. Check one forwarded requests in logs" +echo "========================================" +cat /tmp/contextBroker.log | grep "Request forwarded" | awk -F 'msg=' '{print $2}' | sed "s/${REG1_ID}/REG1_ID/" +echo +echo + + --REGEXPECT-- 01. Register ConferenceRoom on CB with accumulator as providing application =========================================================================== @@ -92,6 +131,11 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}) +03. Check one forwarded requests in logs +======================================== +Request forwarded (regId: REG1_ID): POST http://localhost:9997/cpr/updateContext, request payload (542 bytes): {"contextElements":[{"id":"ConferenceRoom","type":"Room","isPattern":"false","attributes":[{"name":"lightstatus","type":"StructuredValue","value":{"x":1,"y":2}},{"name":"pressure","type":"StructuredValue","value":["a","b","c"]},{"name":"temperature","type":"Number","value":14,"metadatas":[{"name":"ID1","type":"Text","value":{"type":"Text","value":{"x":1,"y":2}}},{"name":"ID2","type":"Text","value":{"type":"Text","value":["a","b","c"]}},{"name":"ID3","type":"Text","value":{"type":"Text","value":"ThisIsID3"}}]}]}],"updateAction":"UPDATE"}, response payload (3899 bytes): { + + --TEARDOWN-- brokerStop CB accumulatorStop $LISTENER_PORT diff --git a/test/functionalTest/cases/3068_cprs_full_functional_v2/fwd_v1_ngsiv2_update_forward_with_fail.test b/test/functionalTest/cases/3068_cprs_full_functional_v2/fwd_v1_ngsiv2_update_forward_with_fail.test index 438e01e4ab..858cfc0f25 100644 --- a/test/functionalTest/cases/3068_cprs_full_functional_v2/fwd_v1_ngsiv2_update_forward_with_fail.test +++ b/test/functionalTest/cases/3068_cprs_full_functional_v2/fwd_v1_ngsiv2_update_forward_with_fail.test @@ -36,6 +36,7 @@ accumulatorStart --pretty-print # 01. Register ConferenceRoom on CB with accumulator as providing application # 02. Update ConferenceRoom in CB # 03. Check the error in CB logs +# 04. Check one forwarded requests in logs # echo "01. Register ConferenceRoom on CB with accumulator as providing application" @@ -61,12 +62,43 @@ echo echo +REG1_ID=$(echo "$_responseHeaders" | grep Location | awk -F/ '{ print $4 }' | tr -d "\r\n") + + echo "02. Update ConferenceRoom in CB" echo "===============================" payload='{ + "lightstatus": { + "type": "StructuredValue", + "value": { + "x": 1, + "y": 2 + } + }, + "pressure": { + "type": "StructuredValue", + "value": ["a", "b", "c"] + }, "temperature": { - "value": 4, - "type": "Number" + "value": 14, + "type": "Number", + "metadata": { + "ID1": { + "type": "Text", + "value": { + "x": 1, + "y": 2 + } + }, + "ID2": { + "type": "Text", + "value": ["a", "b", "c"] + }, + "ID3": { + "type": "Text", + "value": "ThisIsID3" + } + } } }' orionCurl --url /v2/entities/ConferenceRoom/attrs?type=Room --payload "$payload" -X PATCH @@ -82,6 +114,13 @@ echo echo +echo "04. Check one forwarded requests in logs" +echo "========================================" +cat /tmp/contextBroker.log | grep "Request forwarded" | awk -F 'msg=' '{print $2}' | sed "s/${REG1_ID}/REG1_ID/" +echo +echo + + --REGEXPECT-- 01. Register ConferenceRoom on CB with accumulator as providing application =========================================================================== @@ -113,6 +152,11 @@ Raising alarm BadInput REGEX((0.0.0.0|127.0.0.1)): JSON Parse Error |non-200 cod Raising alarm ForwardingError localhost:9997/cprfail/updateContext: error parsing reply from context provider: BadRequest |non-200 code: 422| +04. Check one forwarded requests in logs +======================================== +Request forwarded (regId: REG1_ID): POST http://localhost:9997/cprfail/updateContext, request payload (542 bytes): {"contextElements":[{"id":"ConferenceRoom","type":"Room","isPattern":"false","attributes":[{"name":"lightstatus","type":"StructuredValue","value":{"x":1,"y":2}},{"name":"pressure","type":"StructuredValue","value":["a","b","c"]},{"name":"temperature","type":"Number","value":14,"metadatas":[{"name":"ID1","type":"Text","value":{"type":"Text","value":{"x":1,"y":2}}},{"name":"ID2","type":"Text","value":{"type":"Text","value":["a","b","c"]}},{"name":"ID3","type":"Text","value":{"type":"Text","value":"ThisIsID3"}}]}]}],"updateAction":"UPDATE"}, response payload (3188 bytes): { + + --TEARDOWN-- brokerStop CB accumulatorStop $LISTENER_PORT