Skip to content

Commit

Permalink
Merge pull request telefonicaid#1007 from FIWARE/feature/key-values01
Browse files Browse the repository at this point in the history
Feature/key values01
  • Loading branch information
kzangeli authored Jan 30, 2022
2 parents c0ee2f5 + 31ae418 commit d50ac76
Show file tree
Hide file tree
Showing 12 changed files with 934 additions and 83 deletions.
7 changes: 4 additions & 3 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
* Issue #280 Preparations for the complete removal of ConnectionInfo (Refactor + Performance)
* Issue #954 Broker crashes with too big attribute values (Orion-LD limit for an attribute value is 64k right now)
* Issue #280 Complete removal of ConnectionInfo (Refactor + Performance)
* Issue #954 Broker crashes with too big attribute values (Orion-LD's limit for the size of an attribute value is 64k right now)
* Issue #986 Username and Password for the mongo C driver connection to the MongoDB server
* Issue #990 mongo::Timestamp support
* Issue #989 Deprecated bson_append_symbol still in use - change for bson_append_utf8
* Issue #992 100% reliable implementation of existence check of entities (mongoEntityExists)
* Issue #992 More reliable (100% I'd say) implementation of existence check of entities (mongoEntityExists)
* Issue #127 Implemented keyValues support for PATCH /ngsi-ld/v1/entities/{entityId}/attrs/{attributeName}
5 changes: 4 additions & 1 deletion src/lib/orionld/common/orionldState.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ typedef struct OrionldUriParams
char* timeAt;
char* endTimeAt;
bool details;
uint32_t mask;
bool prettyPrint;
int spaces;
char* subscriptionId;
Expand All @@ -158,6 +157,10 @@ typedef struct OrionldUriParams
bool reset;
char* attributeFormat;
char* level;
char* relationships;
char* geoproperties;
char* languageproperties;
uint64_t mask;
} OrionldUriParams;


Expand Down
2 changes: 1 addition & 1 deletion src/lib/orionld/common/performance.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern "C"
//
// REQUEST_PERFORMANCE
//
#define REQUEST_PERFORMANCE 1
// #define REQUEST_PERFORMANCE 1

#ifdef REQUEST_PERFORMANCE

Expand Down
6 changes: 5 additions & 1 deletion src/lib/orionld/rest/OrionLdRestService.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ typedef struct OrionLdRestServiceSimplifiedVector
#define ORIONLD_URIPARAM_URL (1 << 27)
#define ORIONLD_URIPARAM_RELOAD (1 << 28)
#define ORIONLD_URIPARAM_NOTEXISTS (1 << 29)
#define ORIONLD_URIPARAM_RELATIONSHIPS (1 << 30)
#define ORIONLD_URIPARAM_GEOPROPERTIES (1 << 31)
#define ORIONLD_URIPARAM_LANGUAGEPROPERTIES (1UL << 32)



// -----------------------------------------------------------------------------
Expand All @@ -164,7 +168,7 @@ typedef struct OrionLdRestService
char matchForSecondWildcard[16]; // E.g. "/attrs/" for [/ngsi-ld/v1]/entities/*/attrs/*
int matchForSecondWildcardLen; // strlen of last path to match
uint32_t options; // Peculiarities of this type of requests (bitmask)
uint32_t uriParams; // Supported URI parameters (bitmask)
uint64_t uriParams; // Supported URI parameters (bitmask)
} OrionLdRestService;


Expand Down
20 changes: 17 additions & 3 deletions src/lib/orionld/rest/orionldMhdConnectionInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,6 @@ MHD_Result orionldUriArgumentGet(void* cbDataP, MHD_ValueKind kind, const char*
}

orionldState.uriParams.limit = atoi(value);

if (orionldState.uriParams.limit > 1000)
{
LM_W(("Bad Input (too big value for /limit/ URI param: %d - max allowed is 1000)", orionldState.uriParams.limit));
Expand Down Expand Up @@ -764,6 +763,21 @@ MHD_Result orionldUriArgumentGet(void* cbDataP, MHD_ValueKind kind, const char*
if (strcmp(value, "object") == 0)
orionldState.in.attributeFormatAsObject = true;
}
else if (strcmp(key, "relationships") == 0)
{
orionldState.uriParams.relationships = (char*) value;
orionldState.uriParams.mask |= ORIONLD_URIPARAM_RELATIONSHIPS;
}
else if (strcmp(key, "geoproperties") == 0)
{
orionldState.uriParams.geoproperties = (char*) value;
orionldState.uriParams.mask |= ORIONLD_URIPARAM_GEOPROPERTIES;
}
else if (strcmp(key, "languageproperties") == 0)
{
orionldState.uriParams.languageproperties = (char*) value;
orionldState.uriParams.mask |= ORIONLD_URIPARAM_LANGUAGEPROPERTIES;
}
else if (strcmp(key, "reset") == 0)
{
if (strcmp(value, "true") == 0)
Expand Down Expand Up @@ -865,7 +879,7 @@ MHD_Result orionldMhdConnectionInit
{
++requestNo;

// if (requestNo % 1000 == 0)
// if ((requestNo % 100 == 0) || (requestNo == 1))
LM_TMP(("------------------------- Servicing NGSI-LD request %03d: %s %s --------------------------", requestNo, method, url)); // if not REQUEST_PERFORMANCE

//
Expand Down Expand Up @@ -1031,7 +1045,7 @@ MHD_Result orionldMhdConnectionInit
{
if ((orionldState.in.contentType != JSON) && (orionldState.in.contentType != JSONLD))
{
LM_W(("Bad Input (invalid Content-Type: '%s'", mimeTypeToString(orionldState.in.contentType)));
LM_W(("Bad Input (invalid Content-Type: '%s')", orionldState.in.contentTypeString));
orionldErrorResponseCreate(OrionldBadRequestData,
"unsupported format of payload",
"only application/json and application/ld+json are supported");
Expand Down
8 changes: 8 additions & 0 deletions src/lib/orionld/rest/orionldMhdConnectionTreat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,14 @@ MHD_Result orionldMhdConnectionTreat(void)
if (orionldState.httpStatusCode != 200)
goto respond;

if ((orionldState.in.contentLength > 0) && ((orionldState.verb != POST) && (orionldState.verb != PATCH)))
{
LM_W(("Bad Input (payload body - of %d bytes - for a %s request", orionldState.in.contentLength, verbName(orionldState.verb)));
orionldErrorResponseCreate(OrionldBadRequestData, "Unexpected payload body", verbName(orionldState.verb));
orionldState.httpStatusCode = 400;
goto respond;
}

//
// Any URI param given but not supported?
//
Expand Down
6 changes: 5 additions & 1 deletion src/lib/orionld/rest/orionldServiceInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ static void restServicePrepare(OrionLdRestService* serviceP, OrionLdRestServiceS
}
else if (serviceP->serviceRoutine == orionldPatchAttribute)
{
serviceP->options |= ORIONLD_SERVICE_OPTION_CLONE_PAYLOAD;
serviceP->options |= ORIONLD_SERVICE_OPTION_CLONE_PAYLOAD;
serviceP->uriParams |= ORIONLD_URIPARAM_OPTIONS;
serviceP->uriParams |= ORIONLD_URIPARAM_RELATIONSHIPS;
serviceP->uriParams |= ORIONLD_URIPARAM_GEOPROPERTIES;
serviceP->uriParams |= ORIONLD_URIPARAM_LANGUAGEPROPERTIES;
}
else if (serviceP->serviceRoutine == orionldDeleteAttribute)
{
Expand Down
Loading

0 comments on commit d50ac76

Please sign in to comment.