Skip to content

Commit

Permalink
REMOVE MongoCommonRegister, UpdateContextSubscriptionRequest, UpdateC…
Browse files Browse the repository at this point in the history
…ontextSubscriptionResponse, DiscoverContextAvailabilityResponse, RegisterContextRequest, RegisterContextResponse, tag module, toJsonV1() methods and several check() methods (unit tests still not working)
  • Loading branch information
fgalan committed Aug 12, 2024
1 parent 55f97a0 commit b4cee10
Show file tree
Hide file tree
Showing 155 changed files with 476 additions and 3,832 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,12 @@ SET (ORION_LIBS
jsonParseV2
rest # this is repeated for linking str2Verb from [email protected];
# verbName(Verb) from [email protected]
mongoBackend
ngsi9
ngsi10
ngsi
cache
mongoBackend
mongoBackend # repeated (probably due to some circular dependency between mongoBackend and ngsi)
mongoDriver
parse
apiTypesV2
Expand Down
10 changes: 5 additions & 5 deletions doc/manuals/devel/sourceCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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).

Expand Down
18 changes: 18 additions & 0 deletions scripts/accumulator-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
}
Expand Down
2 changes: 0 additions & 2 deletions scripts/style_check_in_makefile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
1 change: 0 additions & 1 deletion src/lib/apiTypesV2/Attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <string>
#include <vector>

#include "common/tag.h"
#include "common/errorMessages.h"
#include "common/RenderFormat.h"
#include "common/string.h"
Expand Down
62 changes: 0 additions & 62 deletions src/lib/apiTypesV2/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<std::string>& attrsFilter,
bool blacklist,
const std::vector<std::string>& metadataFilter,
bool comma,
bool omitAttributeValues
)
{
std::string out = "";
bool contextAttributeVectorRendered = attributeVector.size() != 0;

out += startTag(requestType != UpdateContext? "contextElement" : "");

// Filter and order attributes
std::vector<ContextAttribute*> 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<std::string> emptyV;
return toJsonV1(asJsonObject, requestType, emptyV, blacklist, emptyV, comma, omitAttributeValues);
}



/* ****************************************************************************
*
* Entity::toJson -
Expand Down
14 changes: 0 additions & 14 deletions src/lib/apiTypesV2/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,6 @@ class Entity

~Entity();

std::string toJsonV1(bool asJsonObject,
RequestType requestType,
const std::vector<std::string>& attrsFilter,
bool blacklist,
const std::vector<std::string>& 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<std::string>& attrsFilter,
bool blacklist,
Expand Down
35 changes: 0 additions & 35 deletions src/lib/apiTypesV2/EntityVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "logMsg/traceLevels.h"

#include "common/globals.h"
#include "common/tag.h"
#include "common/JsonHelper.h"
#include "alarmMgr/alarmMgr.h"

Expand Down Expand Up @@ -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 -
Expand Down
2 changes: 0 additions & 2 deletions src/lib/apiTypesV2/EntityVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/lib/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
SET (SOURCES
globals.cpp
string.cpp
tag.cpp
sem.cpp
MimeType.cpp
RenderFormat.cpp
Expand Down
1 change: 0 additions & 1 deletion src/lib/common/statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
110 changes: 110 additions & 0 deletions src/lib/common/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: &quot;
* 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;
}
18 changes: 18 additions & 0 deletions src/lib/common/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down Expand Up @@ -237,4 +247,12 @@ inline std::string removeQuotes(std::string s)



/* ****************************************************************************
*
* htmlEscape -
*/
extern char* htmlEscape(const char* s);



#endif // SRC_LIB_COMMON_STRING_H_
Loading

0 comments on commit b4cee10

Please sign in to comment.