diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 013a085391..4813b12adb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,7 +12,7 @@ env: IMAGE_NAME: orion-ld IMAGE_TAG_LATEST: latest IMAGE_TAG_DEBUG: debug - IMAGE_TAG_PRE: 1.9.0-PRE-${{ github.run_number }} + IMAGE_TAG_PRE: 1.8.0-PRE-${{ github.run_number }} jobs: diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 829b0bd4a8..4f689531bc 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,6 +1,7 @@ ## Fixed Issues: #XXXX: Complex @contexts of subscriptions weren't persisted in mongodb #1707: Support for local=true in the type discovery endpoints (GET /ngsi-ld/v1/types[/{typeName}] + #XXXX: Support for local=true in the ATTRIBUTE discovery endpoints (GET /ngsi-ld/v1/attributes}] #1708: Reloaded hosted contexts were not persisted in mongo, only the context cache ## New Features: diff --git a/src/lib/orionld/db/dbEntityAttributesGet.cpp b/src/lib/orionld/db/dbEntityAttributesGet.cpp index c2f919ddae..1b7b832414 100644 --- a/src/lib/orionld/db/dbEntityAttributesGet.cpp +++ b/src/lib/orionld/db/dbEntityAttributesGet.cpp @@ -200,7 +200,7 @@ static void remoteAttrNamesExtract(KjNode* outArray, KjNode* remote) // // dbEntityAttributesGetWithoutDetails - // -static KjNode* dbEntityAttributesGetWithoutDetails(OrionldProblemDetails* pdP) +static KjNode* dbEntityAttributesGetWithoutDetails(OrionldProblemDetails* pdP, bool local) { // // This is a bit ugly ... @@ -238,9 +238,9 @@ static KjNode* dbEntityAttributesGetWithoutDetails(OrionldProblemDetails* pdP) // // GET external attributes - i.e. from the "registrations" collection // - KjNode* remote = entityTypesFromRegistrationsGet(true, NULL); + KjNode* remote = (local == false)? entityTypesFromRegistrationsGet(true) : NULL; - if (remote) + if (remote != NULL) remoteAttrNamesExtract(outArray, remote); return getEntityAttributesResponse(outArray); @@ -577,12 +577,12 @@ static KjNode* dbEntityAttributesGetWithDetails(OrionldProblemDetails* pdP, char // // dbEntityAttributesGet - // -KjNode* dbEntityAttributesGet(OrionldProblemDetails* pdP, char* attribute, bool details) +KjNode* dbEntityAttributesGet(OrionldProblemDetails* pdP, char* attribute, bool details, bool local) { bzero(pdP, sizeof(OrionldProblemDetails)); if (details == false) - return dbEntityAttributesGetWithoutDetails(pdP); + return dbEntityAttributesGetWithoutDetails(pdP, local); else return dbEntityAttributesGetWithDetails(pdP, attribute); } diff --git a/src/lib/orionld/db/dbEntityAttributesGet.h b/src/lib/orionld/db/dbEntityAttributesGet.h index f7b5e8d4ba..b23f36322b 100644 --- a/src/lib/orionld/db/dbEntityAttributesGet.h +++ b/src/lib/orionld/db/dbEntityAttributesGet.h @@ -39,6 +39,6 @@ extern "C" // // dbEntityAttributesGet - // -extern KjNode* dbEntityAttributesGet(OrionldProblemDetails* pdP, char* attribute, bool details); +extern KjNode* dbEntityAttributesGet(OrionldProblemDetails* pdP, char* attribute, bool details, bool local); #endif // SRC_LIB_ORIONLD_DB_DBENTITYATTRIBUTESGET_H_ diff --git a/src/lib/orionld/serviceRoutines/orionldGetEntityAttribute.cpp b/src/lib/orionld/serviceRoutines/orionldGetEntityAttribute.cpp index 2c84f74acb..a3ed0b67bf 100644 --- a/src/lib/orionld/serviceRoutines/orionldGetEntityAttribute.cpp +++ b/src/lib/orionld/serviceRoutines/orionldGetEntityAttribute.cpp @@ -46,7 +46,7 @@ bool orionldGetEntityAttribute(void) OrionldProblemDetails pd; char* attrLongName = orionldAttributeExpand(orionldState.contextP, orionldState.wildcard[0], true, NULL); - orionldState.responseTree = dbEntityAttributesGet(&pd, attrLongName, true); + orionldState.responseTree = dbEntityAttributesGet(&pd, attrLongName, true, orionldState.uriParams.local); if (orionldState.responseTree == NULL) { diff --git a/src/lib/orionld/serviceRoutines/orionldGetEntityAttributes.cpp b/src/lib/orionld/serviceRoutines/orionldGetEntityAttributes.cpp index fdf6d6ad01..75ed0fda1f 100644 --- a/src/lib/orionld/serviceRoutines/orionldGetEntityAttributes.cpp +++ b/src/lib/orionld/serviceRoutines/orionldGetEntityAttributes.cpp @@ -45,7 +45,7 @@ bool orionldGetEntityAttributes(void) { OrionldProblemDetails pd; - orionldState.responseTree = dbEntityAttributesGet(&pd, NULL, orionldState.uriParams.details); + orionldState.responseTree = dbEntityAttributesGet(&pd, NULL, orionldState.uriParams.details, orionldState.uriParams.local); if (orionldState.responseTree == NULL) { // dbEntityAttributesGet calls orionldError diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_entity_attributes.test b/test/functionalTest/cases/0000_ngsild/ngsild_entity_attributes.test index 62e79ba9f2..8b2c066400 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_entity_attributes.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_entity_attributes.test @@ -39,6 +39,7 @@ orionldStart CB # 07. GET Entity Attributes - see four attributes (P1, P2, P3, and R1) # 08. Create a registration R2 with attributes P4 and R2 # 09. GET Entity Attributes - see six attributes (P1-P4, and R1-R2) +# 10. GET Entity Attributes with local=true - see four attributes (P1, P2, P3, and R1) # 10. Create a registration R3 with attributes P1-P5 and R1-R5 # 11. GET Entity Attributes - see ten attributes (P1-P5, and R1-R5) # 12. Remove R3, R1, E0 and E1 @@ -177,6 +178,13 @@ echo echo +echo "10. GET Entity Attributes with local=true - see four attributes (P1, P2, P3, and R1)" +echo "====================================================================================" +orionCurl --url /ngsi-ld/v1/attributes?local=true +echo +echo + + echo "10. Create a registration R3 with attributes P1-P5 and R1-R5" echo "============================================================" payload='{ @@ -366,6 +374,26 @@ Link: