diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 6cbb84ae51..6fb469aee3 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -5,3 +5,4 @@ Fixed issues: * #280 - Changed all error codes from InvalidRequest to BadRequestData, except for JSON Parse Error that is still an InvalidRequest * #280 - Giving errors for expiresAt in the past (for registrations and subscriptions) * #280 - Fixed a bug in error detection of downloading errors in arrays of contexts, at lower nesting levels + * #280 - Better 501 handling of temporal operations diff --git a/docker/Dockerfile-test b/docker/Dockerfile-test index c0db1ce2bb..695442baf9 100644 --- a/docker/Dockerfile-test +++ b/docker/Dockerfile-test @@ -14,6 +14,8 @@ WORKDIR lcov-1.14 RUN make install WORKDIR ${PATH_TO_SRC} +RUN yum-config-manager --disable pgdg10 + RUN yum install -y gnupg RUN yum install -y https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-database-tools-100.4.1.x86_64.rpm diff --git a/docker/build-ubi/install-gnutls.sh b/docker/build-ubi/install-gnutls.sh index 6023353aa6..9b65d612df 100755 --- a/docker/build-ubi/install-gnutls.sh +++ b/docker/build-ubi/install-gnutls.sh @@ -35,8 +35,8 @@ yum -y install https://rpmfind.net/linux/centos/8-stream/BaseOS/x86_64/os/Packag yum -y install https://rpmfind.net/linux/centos/8-stream/AppStream/x86_64/os/Packages/nettle-devel-3.4.1-7.el8.x86_64.rpm yum -y install https://rpmfind.net/linux/centos/8-stream/AppStream/x86_64/os/Packages/libidn2-devel-2.2.0-1.el8.x86_64.rpm yum -y install https://rpmfind.net/linux/centos/8-stream/AppStream/x86_64/os/Packages/libtasn1-devel-4.13-3.el8.x86_64.rpm -yum -y install https://dl.rockylinux.org/pub/rocky/8/AppStream/x86_64/os/Packages/g/gnutls-c++-3.6.16-5.el8_6.x86_64.rpm -yum -y install https://dl.rockylinux.org/pub/rocky/8/AppStream/x86_64/os/Packages/g/gnutls-devel-3.6.16-5.el8_6.x86_64.rpm +yum -y install https://dl.rockylinux.org/pub/rocky/8/AppStream/x86_64/os/Packages/g/gnutls-c++-3.6.16-6.el8_7.x86_64.rpm +yum -y install https://dl.rockylinux.org/pub/rocky/8/AppStream/x86_64/os/Packages/g/gnutls-devel-3.6.16-6.el8_7.x86_64.rpm #yum -y install http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/gmp-devel-6.1.2-10.el8.x86_64.rpm #yum -y install http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/pkgconf-pkg-config-1.4.2-1.el8.x86_64.rpm diff --git a/src/app/orionld/orionldRestServices.cpp b/src/app/orionld/orionldRestServices.cpp index 4c4bdb3ccc..2c518b0e41 100644 --- a/src/app/orionld/orionldRestServices.cpp +++ b/src/app/orionld/orionldRestServices.cpp @@ -50,7 +50,6 @@ #include "orionld/serviceRoutines/orionldGetContexts.h" #include "orionld/serviceRoutines/orionldGetVersion.h" #include "orionld/serviceRoutines/orionldGetPing.h" -#include "orionld/serviceRoutines/orionldNotImplemented.h" #include "orionld/serviceRoutines/orionldPostBatchUpsert.h" #include "orionld/serviceRoutines/orionldPostBatchCreate.h" #include "orionld/serviceRoutines/orionldPostBatchUpdate.h" @@ -61,16 +60,22 @@ #include "orionld/serviceRoutines/orionldGetTenants.h" #include "orionld/serviceRoutines/orionldGetDbIndexes.h" #include "orionld/serviceRoutines/orionldPostQuery.h" -#include "orionld/serviceRoutines/orionldGetTemporalEntities.h" -#include "orionld/serviceRoutines/orionldGetTemporalEntity.h" -#include "orionld/serviceRoutines/orionldPostTemporalQuery.h" -#include "orionld/serviceRoutines/orionldPostTemporalEntities.h" #include "orionld/serviceRoutines/orionldPostContexts.h" #include "orionld/serviceRoutines/orionldDeleteContext.h" #include "orionld/serviceRoutines/orionldOptions.h" #include "orionld/serviceRoutines/orionldPutEntity.h" #include "orionld/serviceRoutines/orionldPutAttribute.h" +#include "orionld/serviceRoutines/orionldGetTemporalEntities.h" +#include "orionld/serviceRoutines/orionldGetTemporalEntity.h" +#include "orionld/serviceRoutines/orionldPostTemporalQuery.h" +#include "orionld/serviceRoutines/orionldPostTemporalEntities.h" +#include "orionld/serviceRoutines/orionldDeleteTemporalAttribute.h" // orionldDeleteTemporalAttribute +#include "orionld/serviceRoutines/orionldDeleteTemporalAttributeInstance.h" // orionldDeleteTemporalAttributeInstance +#include "orionld/serviceRoutines/orionldDeleteTemporalEntity.h" // orionldDeleteTemporalEntity +#include "orionld/serviceRoutines/orionldPatchTemporalAttributeInstance.h" // orionldPatchTemporalAttributeInstance +#include "orionld/serviceRoutines/orionldPostTemporalAttributes.h" // orionldPostTemporalAttributes + #include "orionld/rest/OrionLdRestService.h" // OrionLdRestServiceSimplified #include "orionld/orionldRestServices.h" // Own Interface @@ -111,20 +116,20 @@ static const int getServices = (sizeof(getServiceV) / sizeof(getServiceV[0])); // static OrionLdRestServiceSimplified postServiceV[] = { - { "/ngsi-ld/v1/entities/*/attrs", orionldPostEntity }, - { "/ngsi-ld/v1/entities", orionldPostEntities }, - { "/ngsi-ld/ex/v1/notify", orionldPostNotify }, - { "/ngsi-ld/v1/entityOperations/create", orionldPostBatchCreate }, - { "/ngsi-ld/v1/entityOperations/upsert", orionldPostBatchUpsert }, - { "/ngsi-ld/v1/entityOperations/update", orionldPostBatchUpdate }, - { "/ngsi-ld/v1/entityOperations/delete", orionldPostBatchDelete }, - { "/ngsi-ld/v1/entityOperations/query", orionldPostQuery }, - { "/ngsi-ld/v1/subscriptions", orionldPostSubscriptions }, - { "/ngsi-ld/v1/csourceRegistrations", orionldPostRegistrations }, - { "/ngsi-ld/v1/temporal/entities/*/attrs", orionldNotImplemented }, - { "/ngsi-ld/v1/temporal/entities", orionldPostTemporalEntities }, - { "/ngsi-ld/v1/temporal/entityOperations/query", orionldPostTemporalQuery }, - { "/ngsi-ld/v1/jsonldContexts", orionldPostContexts } + { "/ngsi-ld/v1/entities/*/attrs", orionldPostEntity }, + { "/ngsi-ld/v1/entities", orionldPostEntities }, + { "/ngsi-ld/ex/v1/notify", orionldPostNotify }, + { "/ngsi-ld/v1/entityOperations/create", orionldPostBatchCreate }, + { "/ngsi-ld/v1/entityOperations/upsert", orionldPostBatchUpsert }, + { "/ngsi-ld/v1/entityOperations/update", orionldPostBatchUpdate }, + { "/ngsi-ld/v1/entityOperations/delete", orionldPostBatchDelete }, + { "/ngsi-ld/v1/entityOperations/query", orionldPostQuery }, + { "/ngsi-ld/v1/subscriptions", orionldPostSubscriptions }, + { "/ngsi-ld/v1/csourceRegistrations", orionldPostRegistrations }, + { "/ngsi-ld/v1/temporal/entities/*/attrs", orionldPostTemporalAttributes }, + { "/ngsi-ld/v1/temporal/entities", orionldPostTemporalEntities }, + { "/ngsi-ld/v1/temporal/entityOperations/query", orionldPostTemporalQuery }, + { "/ngsi-ld/v1/jsonldContexts", orionldPostContexts } }; static const int postServices = (sizeof(postServiceV) / sizeof(postServiceV[0])); @@ -136,12 +141,12 @@ static const int postServices = (sizeof(postServiceV) / sizeof(postServiceV[0])) // static OrionLdRestServiceSimplified patchServiceV[] = { - { "/ngsi-ld/v1/entities/*/attrs/*", orionldPatchAttribute }, - { "/ngsi-ld/v1/entities/*/attrs", orionldPatchEntity }, - { "/ngsi-ld/v1/entities/*", orionldPatchEntity2 }, - { "/ngsi-ld/v1/subscriptions/*", orionldPatchSubscription }, - { "/ngsi-ld/v1/csourceRegistrations/*", orionldPatchRegistration }, - { "/ngsi-ld/v1/temporal/entities/*/attrs/*/*", orionldNotImplemented } + { "/ngsi-ld/v1/entities/*/attrs/*", orionldPatchAttribute }, + { "/ngsi-ld/v1/entities/*/attrs", orionldPatchEntity }, + { "/ngsi-ld/v1/entities/*", orionldPatchEntity2 }, + { "/ngsi-ld/v1/subscriptions/*", orionldPatchSubscription }, + { "/ngsi-ld/v1/csourceRegistrations/*", orionldPatchRegistration }, + { "/ngsi-ld/v1/temporal/entities/*/attrs/*/*", orionldPatchTemporalAttributeInstance } }; static const int patchServices = (sizeof(patchServiceV) / sizeof(patchServiceV[0])); @@ -166,13 +171,13 @@ static const int putServices = (sizeof(putServiceV) / sizeof(putServiceV[0])); // static OrionLdRestServiceSimplified deleteServiceV[] = { - { "/ngsi-ld/v1/entities/*/attrs/*", orionldDeleteAttribute }, - { "/ngsi-ld/v1/entities/*", orionldDeleteEntity }, - { "/ngsi-ld/v1/subscriptions/*", orionldDeleteSubscription }, - { "/ngsi-ld/v1/csourceRegistrations/*", orionldDeleteRegistration }, - { "/ngsi-ld/v1/jsonldContexts/*", orionldDeleteContext }, - { "/ngsi-ld/v1/temporal/entities/*/attrs/*", orionldNotImplemented }, - { "/ngsi-ld/v1/temporal/entities/*", orionldNotImplemented } + { "/ngsi-ld/v1/entities/*/attrs/*", orionldDeleteAttribute }, + { "/ngsi-ld/v1/entities/*", orionldDeleteEntity }, + { "/ngsi-ld/v1/subscriptions/*", orionldDeleteSubscription }, + { "/ngsi-ld/v1/csourceRegistrations/*", orionldDeleteRegistration }, + { "/ngsi-ld/v1/jsonldContexts/*", orionldDeleteContext }, + { "/ngsi-ld/v1/temporal/entities/*/attrs/*", orionldDeleteTemporalAttribute }, + { "/ngsi-ld/v1/temporal/entities/*", orionldDeleteTemporalEntity }, }; static const int deleteServices = (sizeof(deleteServiceV) / sizeof(deleteServiceV[0])); diff --git a/src/lib/orionld/rest/OrionLdRestService.h b/src/lib/orionld/rest/OrionLdRestService.h index c8b762d0c0..358ec62459 100644 --- a/src/lib/orionld/rest/OrionLdRestService.h +++ b/src/lib/orionld/rest/OrionLdRestService.h @@ -179,6 +179,8 @@ typedef struct OrionLdRestService uint32_t options; // Peculiarities of this type of requests (bitmask) uint64_t uriParams; // Supported URI parameters (bitmask) bool isBatchOp; // true for BATCH operations + bool notImplemented; // Flags that the service hasn't been implemented + bool mintaka; // Flags that the service is not for Orion-LD but for Mintaka } OrionLdRestService; diff --git a/src/lib/orionld/rest/orionldMhdConnectionInit.cpp b/src/lib/orionld/rest/orionldMhdConnectionInit.cpp index a76d361295..737b1b663d 100644 --- a/src/lib/orionld/rest/orionldMhdConnectionInit.cpp +++ b/src/lib/orionld/rest/orionldMhdConnectionInit.cpp @@ -1049,6 +1049,13 @@ MHD_Result orionldMhdConnectionInit if (orionldState.serviceP == NULL) // 405 or 404 - no need to continue - prettyPrint not possible here return MHD_YES; + if (orionldState.serviceP->mintaka == true) + return MHD_YES; + + if (orionldState.serviceP->notImplemented == true) + return MHD_YES; + + // // 5. GET URI params // diff --git a/src/lib/orionld/rest/orionldMhdConnectionTreat.cpp b/src/lib/orionld/rest/orionldMhdConnectionTreat.cpp index b898eded56..135efc628e 100644 --- a/src/lib/orionld/rest/orionldMhdConnectionTreat.cpp +++ b/src/lib/orionld/rest/orionldMhdConnectionTreat.cpp @@ -940,6 +940,21 @@ MHD_Result orionldMhdConnectionTreat(void) promCounterIncrease(promNgsildRequests); + if (orionldState.serviceP == NULL) + goto respond; + + if (orionldState.serviceP->mintaka == true) + { + serviceRoutineResult = orionldState.serviceP->serviceRoutine(); + goto respond; + } + + if (orionldState.serviceP->notImplemented == true) + { + serviceRoutineResult = orionldState.serviceP->serviceRoutine(); + goto respond; + } + // If OPTIONS verb, we skip all checks, go straight to the service routine if (orionldState.verb == OPTIONS) goto serviceRoutine; diff --git a/src/lib/orionld/rest/orionldServiceInit.cpp b/src/lib/orionld/rest/orionldServiceInit.cpp index 3b03e0654e..002329331f 100644 --- a/src/lib/orionld/rest/orionldServiceInit.cpp +++ b/src/lib/orionld/rest/orionldServiceInit.cpp @@ -73,13 +73,23 @@ #include "orionld/serviceRoutines/orionldGetEntityType.h" // orionldGetEntityType #include "orionld/serviceRoutines/orionldGetEntityAttributes.h" // orionldGetEntityAttributes #include "orionld/serviceRoutines/orionldGetEntityAttribute.h" // orionldGetEntityAttribute -#include "orionld/serviceRoutines/orionldPostTemporalEntities.h" // orionldPostTemporalEntities + #include "orionld/serviceRoutines/orionldGetContexts.h" // orionldGetContexts #include "orionld/serviceRoutines/orionldGetContext.h" // orionldGetContext #include "orionld/serviceRoutines/orionldPostContexts.h" // orionldPostContexts #include "orionld/serviceRoutines/orionldDeleteContext.h" // orionldDeleteContext #include "orionld/serviceRoutines/orionldPostNotify.h" // orionldPostNotify +#include "orionld/serviceRoutines/orionldGetTemporalEntities.h" // orionldGetTemporalEntities +#include "orionld/serviceRoutines/orionldGetTemporalEntity.h" // orionldGetTemporalEntity +#include "orionld/serviceRoutines/orionldPostTemporalQuery.h" // orionldPostTemporalQuery +#include "orionld/serviceRoutines/orionldPostTemporalEntities.h" // orionldPostTemporalEntities +#include "orionld/serviceRoutines/orionldDeleteTemporalAttribute.h" // orionldDeleteTemporalAttribute +#include "orionld/serviceRoutines/orionldDeleteTemporalAttributeInstance.h" // orionldDeleteTemporalAttributeInstance +#include "orionld/serviceRoutines/orionldDeleteTemporalEntity.h" // orionldDeleteTemporalEntity +#include "orionld/serviceRoutines/orionldPatchTemporalAttributeInstance.h" // orionldPatchTemporalAttributeInstance +#include "orionld/serviceRoutines/orionldPostTemporalAttributes.h" // orionldPostTemporalAttributes + #include "orionld/troe/troePostEntities.h" // troePostEntities #include "orionld/troe/troePostBatchDelete.h" // troePostBatchDelete #include "orionld/troe/troeDeleteAttribute.h" // troeDeleteAttribute @@ -403,6 +413,24 @@ static void restServicePrepare(OrionLdRestService* serviceP, OrionLdRestServiceS serviceP->options |= ORIONLD_SERVICE_OPTION_PREFETCH_ID_AND_TYPE; serviceP->options |= ORIONLD_SERVICE_OPTION_EXPAND_TYPE; } + else if (serviceP->serviceRoutine == orionldGetTemporalEntities) + serviceP->mintaka = true; + else if (serviceP->serviceRoutine == orionldGetTemporalEntity) + serviceP->mintaka = true; + else if (serviceP->serviceRoutine == orionldPostTemporalQuery) + serviceP->mintaka = true; + else if (serviceP->serviceRoutine == orionldDeleteTemporalAttribute) + serviceP->notImplemented = true; + else if (serviceP->serviceRoutine == orionldDeleteTemporalAttributeInstance) + serviceP->notImplemented = true; + else if (serviceP->serviceRoutine == orionldDeleteTemporalEntity) + serviceP->notImplemented = true; + else if (serviceP->serviceRoutine == orionldPatchTemporalAttributeInstance) + serviceP->notImplemented = true; + else if (serviceP->serviceRoutine == orionldPostTemporalAttributes) + serviceP->notImplemented = true; + + else if (serviceP->serviceRoutine == orionldGetVersion) { serviceP->options = 0; // Tenant is Ignored diff --git a/src/lib/orionld/serviceRoutines/CMakeLists.txt b/src/lib/orionld/serviceRoutines/CMakeLists.txt index e31ce26b03..2d0b103cba 100644 --- a/src/lib/orionld/serviceRoutines/CMakeLists.txt +++ b/src/lib/orionld/serviceRoutines/CMakeLists.txt @@ -44,7 +44,6 @@ SET (SOURCES orionldGetContext.cpp orionldGetContexts.cpp orionldGetVersion.cpp - orionldNotImplemented.cpp orionldPostBatchCreate.cpp orionldPostBatchUpsert.cpp orionldPostBatchUpdate.cpp @@ -67,6 +66,11 @@ SET (SOURCES orionldOptions.cpp orionldPutEntity.cpp orionldPutAttribute.cpp + orionldDeleteTemporalAttribute.cpp + orionldDeleteTemporalAttributeInstance.cpp + orionldDeleteTemporalEntity.cpp + orionldPatchTemporalAttributeInstance.cpp + orionldPostTemporalAttributes.cpp ) # Include directories diff --git a/src/lib/orionld/serviceRoutines/orionldDeleteTemporalAttribute.cpp b/src/lib/orionld/serviceRoutines/orionldDeleteTemporalAttribute.cpp new file mode 100644 index 0000000000..e0c67c5f25 --- /dev/null +++ b/src/lib/orionld/serviceRoutines/orionldDeleteTemporalAttribute.cpp @@ -0,0 +1,43 @@ +/* +* +* Copyright 2023 FIWARE Foundation e.V. +* +* This file is part of Orion-LD Context Broker. +* +* Orion-LD 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-LD 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-LD Context Broker. If not, see http://www.gnu.org/licenses/. +* +* For those usages not covered by this license please contact with +* orionld at fiware dot org +* +* Author: Ken Zangelin +*/ +#include "logMsg/logMsg.h" + +#include "orionld/common/orionldState.h" // orionldState +#include "orionld/common/orionldError.h" // orionldError +#include "orionld/rest/OrionLdRestService.h" // OrionLdRestService +#include "orionld/serviceRoutines/orionldDeleteTemporalAttribute.h" // Own Interface + + + +// ---------------------------------------------------------------------------- +// +// orionldDeleteTemporalAttribute - +// +bool orionldDeleteTemporalAttribute(void) +{ + orionldError(OrionldOperationNotSupported, "Not Implemented", orionldState.serviceP->url, 501); + orionldState.noLinkHeader = true; // We don't want the Link header for non-implemented requests + return false; +} diff --git a/src/lib/orionld/serviceRoutines/orionldDeleteTemporalAttribute.h b/src/lib/orionld/serviceRoutines/orionldDeleteTemporalAttribute.h new file mode 100644 index 0000000000..08e475ee29 --- /dev/null +++ b/src/lib/orionld/serviceRoutines/orionldDeleteTemporalAttribute.h @@ -0,0 +1,37 @@ +#ifndef SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDDELETETEMPORALATTRIBUTE_H_ +#define SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDDELETETEMPORALATTRIBUTE_H_ + +/* +* +* Copyright 2023 FIWARE Foundation e.V. +* +* This file is part of Orion-LD Context Broker. +* +* Orion-LD 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-LD 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-LD Context Broker. If not, see http://www.gnu.org/licenses/. +* +* For those usages not covered by this license please contact with +* orionld at fiware dot org +* +* Author: Ken Zangelin +*/ + + + +// ---------------------------------------------------------------------------- +// +// orionldDeleteTemporalAttribute - +// +extern bool orionldDeleteTemporalAttribute(void); + +#endif // SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDDELETETEMPORALATTRIBUTE_H_ diff --git a/src/lib/orionld/serviceRoutines/orionldDeleteTemporalAttributeInstance.cpp b/src/lib/orionld/serviceRoutines/orionldDeleteTemporalAttributeInstance.cpp new file mode 100644 index 0000000000..e586049d2c --- /dev/null +++ b/src/lib/orionld/serviceRoutines/orionldDeleteTemporalAttributeInstance.cpp @@ -0,0 +1,43 @@ +/* +* +* Copyright 2023 FIWARE Foundation e.V. +* +* This file is part of Orion-LD Context Broker. +* +* Orion-LD 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-LD 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-LD Context Broker. If not, see http://www.gnu.org/licenses/. +* +* For those usages not covered by this license please contact with +* orionld at fiware dot org +* +* Author: Ken Zangelin +*/ +#include "logMsg/logMsg.h" + +#include "orionld/common/orionldState.h" // orionldState +#include "orionld/common/orionldError.h" // orionldError +#include "orionld/rest/OrionLdRestService.h" // OrionLdRestService +#include "orionld/serviceRoutines/orionldDeleteTemporalAttributeInstance.h" // Own Interface + + + +// ---------------------------------------------------------------------------- +// +// orionldDeleteTemporalAttributeInstance - +// +bool orionldDeleteTemporalAttributeInstance(void) +{ + orionldError(OrionldOperationNotSupported, "Not Implemented", orionldState.serviceP->url, 501); + orionldState.noLinkHeader = true; // We don't want the Link header for non-implemented requests + return false; +} diff --git a/src/lib/orionld/serviceRoutines/orionldDeleteTemporalAttributeInstance.h b/src/lib/orionld/serviceRoutines/orionldDeleteTemporalAttributeInstance.h new file mode 100644 index 0000000000..4c81de9e71 --- /dev/null +++ b/src/lib/orionld/serviceRoutines/orionldDeleteTemporalAttributeInstance.h @@ -0,0 +1,37 @@ +#ifndef SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDDELETETEMPORALATTRIBUTEINSTANCE_H_ +#define SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDDELETETEMPORALATTRIBUTEINSTANCE_H_ + +/* +* +* Copyright 2023 FIWARE Foundation e.V. +* +* This file is part of Orion-LD Context Broker. +* +* Orion-LD 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-LD 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-LD Context Broker. If not, see http://www.gnu.org/licenses/. +* +* For those usages not covered by this license please contact with +* orionld at fiware dot org +* +* Author: Ken Zangelin +*/ + + + +// ---------------------------------------------------------------------------- +// +// orionldDeleteTemporalAttributeInstance - +// +extern bool orionldDeleteTemporalAttributeInstance(void); + +#endif // SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDDELETETEMPORALATTRIBUTEINSTANCE_H_ diff --git a/src/lib/orionld/serviceRoutines/orionldDeleteTemporalEntity.cpp b/src/lib/orionld/serviceRoutines/orionldDeleteTemporalEntity.cpp new file mode 100644 index 0000000000..c76acdeecb --- /dev/null +++ b/src/lib/orionld/serviceRoutines/orionldDeleteTemporalEntity.cpp @@ -0,0 +1,43 @@ +/* +* +* Copyright 2023 FIWARE Foundation e.V. +* +* This file is part of Orion-LD Context Broker. +* +* Orion-LD 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-LD 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-LD Context Broker. If not, see http://www.gnu.org/licenses/. +* +* For those usages not covered by this license please contact with +* orionld at fiware dot org +* +* Author: Ken Zangelin +*/ +#include "logMsg/logMsg.h" + +#include "orionld/common/orionldState.h" // orionldState +#include "orionld/common/orionldError.h" // orionldError +#include "orionld/rest/OrionLdRestService.h" // OrionLdRestService +#include "orionld/serviceRoutines/orionldDeleteTemporalEntity.h" // Own Interface + + + +// ---------------------------------------------------------------------------- +// +// orionldDeleteTemporalEntity - +// +bool orionldDeleteTemporalEntity(void) +{ + orionldError(OrionldOperationNotSupported, "Not Implemented", orionldState.serviceP->url, 501); + orionldState.noLinkHeader = true; // We don't want the Link header for non-implemented requests + return false; +} diff --git a/src/lib/orionld/serviceRoutines/orionldDeleteTemporalEntity.h b/src/lib/orionld/serviceRoutines/orionldDeleteTemporalEntity.h new file mode 100644 index 0000000000..d56bb7dd45 --- /dev/null +++ b/src/lib/orionld/serviceRoutines/orionldDeleteTemporalEntity.h @@ -0,0 +1,37 @@ +#ifndef SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDDELETETEMPORALENTITY_H_ +#define SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDDELETETEMPORALENTITY_H_ + +/* +* +* Copyright 2023 FIWARE Foundation e.V. +* +* This file is part of Orion-LD Context Broker. +* +* Orion-LD 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-LD 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-LD Context Broker. If not, see http://www.gnu.org/licenses/. +* +* For those usages not covered by this license please contact with +* orionld at fiware dot org +* +* Author: Ken Zangelin +*/ + + + +// ---------------------------------------------------------------------------- +// +// orionldDeleteTemporalEntity - +// +extern bool orionldDeleteTemporalEntity(void); + +#endif // SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDDELETETEMPORALENTITY_H_ diff --git a/src/lib/orionld/serviceRoutines/orionldPatchTemporalAttributeInstance.cpp b/src/lib/orionld/serviceRoutines/orionldPatchTemporalAttributeInstance.cpp new file mode 100644 index 0000000000..66a2b710d7 --- /dev/null +++ b/src/lib/orionld/serviceRoutines/orionldPatchTemporalAttributeInstance.cpp @@ -0,0 +1,43 @@ +/* +* +* Copyright 2023 FIWARE Foundation e.V. +* +* This file is part of Orion-LD Context Broker. +* +* Orion-LD 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-LD 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-LD Context Broker. If not, see http://www.gnu.org/licenses/. +* +* For those usages not covered by this license please contact with +* orionld at fiware dot org +* +* Author: Ken Zangelin +*/ +#include "logMsg/logMsg.h" + +#include "orionld/common/orionldState.h" // orionldState +#include "orionld/common/orionldError.h" // orionldError +#include "orionld/rest/OrionLdRestService.h" // OrionLdRestService +#include "orionld/serviceRoutines/orionldPatchTemporalAttributeInstance.h" // Own Interface + + + +// ---------------------------------------------------------------------------- +// +// orionldPatchTemporalAttributeInstance - +// +bool orionldPatchTemporalAttributeInstance(void) +{ + orionldError(OrionldOperationNotSupported, "Not Implemented", orionldState.serviceP->url, 501); + orionldState.noLinkHeader = true; // We don't want the Link header for non-implemented requests + return false; +} diff --git a/src/lib/orionld/serviceRoutines/orionldPatchTemporalAttributeInstance.h b/src/lib/orionld/serviceRoutines/orionldPatchTemporalAttributeInstance.h new file mode 100644 index 0000000000..3d1301b102 --- /dev/null +++ b/src/lib/orionld/serviceRoutines/orionldPatchTemporalAttributeInstance.h @@ -0,0 +1,37 @@ +#ifndef SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDPATCHTEMPORALATTRIBUTEINSTANCE_H_ +#define SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDPATCHTEMPORALATTRIBUTEINSTANCE_H_ + +/* +* +* Copyright 2023 FIWARE Foundation e.V. +* +* This file is part of Orion-LD Context Broker. +* +* Orion-LD 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-LD 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-LD Context Broker. If not, see http://www.gnu.org/licenses/. +* +* For those usages not covered by this license please contact with +* orionld at fiware dot org +* +* Author: Ken Zangelin +*/ + + + +// ---------------------------------------------------------------------------- +// +// orionldPatchTemporalAttributeInstance - +// +extern bool orionldPatchTemporalAttributeInstance(void); + +#endif // SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDPATCHTEMPORALATTRIBUTEINSTANCE_H_ diff --git a/src/lib/orionld/serviceRoutines/orionldPostTemporalAttributes.cpp b/src/lib/orionld/serviceRoutines/orionldPostTemporalAttributes.cpp new file mode 100644 index 0000000000..91f536112e --- /dev/null +++ b/src/lib/orionld/serviceRoutines/orionldPostTemporalAttributes.cpp @@ -0,0 +1,43 @@ +/* +* +* Copyright 2023 FIWARE Foundation e.V. +* +* This file is part of Orion-LD Context Broker. +* +* Orion-LD 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-LD 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-LD Context Broker. If not, see http://www.gnu.org/licenses/. +* +* For those usages not covered by this license please contact with +* orionld at fiware dot org +* +* Author: Ken Zangelin +*/ +#include "logMsg/logMsg.h" + +#include "orionld/common/orionldState.h" // orionldState +#include "orionld/common/orionldError.h" // orionldError +#include "orionld/rest/OrionLdRestService.h" // OrionLdRestService +#include "orionld/serviceRoutines/orionldPostTemporalAttributes.h" // Own Interface + + + +// ---------------------------------------------------------------------------- +// +// orionldPostTemporalAttributes - +// +bool orionldPostTemporalAttributes(void) +{ + orionldError(OrionldOperationNotSupported, "Not Implemented", orionldState.serviceP->url, 501); + orionldState.noLinkHeader = true; // We don't want the Link header for non-implemented requests + return false; +} diff --git a/src/lib/orionld/serviceRoutines/orionldPostTemporalAttributes.h b/src/lib/orionld/serviceRoutines/orionldPostTemporalAttributes.h new file mode 100644 index 0000000000..e2a07441a0 --- /dev/null +++ b/src/lib/orionld/serviceRoutines/orionldPostTemporalAttributes.h @@ -0,0 +1,37 @@ +#ifndef SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDPOSTTEMPORALATTRIBUTES_H_ +#define SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDPOSTTEMPORALATTRIBUTES_H_ + +/* +* +* Copyright 2023 FIWARE Foundation e.V. +* +* This file is part of Orion-LD Context Broker. +* +* Orion-LD 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-LD 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-LD Context Broker. If not, see http://www.gnu.org/licenses/. +* +* For those usages not covered by this license please contact with +* orionld at fiware dot org +* +* Author: Ken Zangelin +*/ + + + +// ---------------------------------------------------------------------------- +// +// orionldPostTemporalAttributes - +// +extern bool orionldPostTemporalAttributes(void); + +#endif // SRC_LIB_ORIONLD_SERVICEROUTINES_ORIONLDPOSTTEMPORALATTRIBUTES_H_ diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_temporal_representation_501.test b/test/functionalTest/cases/0000_ngsild/ngsild_temporal_representation_501.test index 0554480e55..f758948b58 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_temporal_representation_501.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_temporal_representation_501.test @@ -35,27 +35,40 @@ orionldStart CB # Requests that still give 501: # 02. Get 501 for GET /ngsi-ld/v1/temporal/entities # 03. Get 501 for GET /ngsi-ld/v1/temporal/entities/ -# 04. Get 501 for DELETE /ngsi-ld/v1/temporal/entities/ -# 05. Get 501 for POST /ngsi-ld/v1/temporal/entities//attrs -# 06. Get 501 for DELETE /ngsi-ld/v1/temporal/entities//attrs/{attrId} -# 07. Get 501 for POST /ngsi-ld/v1/temporal/entityOperations/query +# 04. Get 501 for POST /ngsi-ld/v1/temporal/entityOperations/query +# +# 05. Get 501 for DELETE /ngsi-ld/v1/temporal/entities/ +# 06. Get 501 for POST /ngsi-ld/v1/temporal/entities//attrs +# 07. Get 501 for DELETE /ngsi-ld/v1/temporal/entities//attrs/{attrId} +# 08. Get 501 for DELETE /ngsi-ld/v1/temporal/entities//attrs/{attrId}/{instanceId} +# 09. Get 501 for PATCH /ngsi-ld/v1/temporal/entities//attrs/{attrId}/{instanceId} # echo "02. Get 501 for GET /ngsi-ld/v1/temporal/entities" echo "=================================================" -orionCurl --url /ngsi-ld/v1/temporal/entities +orionCurl --url /ngsi-ld/v1/temporal/entities?badParam=urn:S1 echo echo echo "03. Get 501 for GET /ngsi-ld/v1/temporal/entities/" echo "=======================================================" -orionCurl --url /ngsi-ld/v1/temporal/entities/urn:ngsi-ld:City:Madrid +orionCurl --url /ngsi-ld/v1/temporal/entities/urn:ngsi-ld:City:Madrid?badParam=urn:S1 echo echo -echo "04. Get 501 for DELETE /ngsi-ld/v1/temporal/entities/" +echo "04. Get 501 for POST /ngsi-ld/v1/temporal/entityOperations/query" +echo "================================================================" +payload='{ + "q": "A1>10" +}' +orionCurl --url /ngsi-ld/v1/temporal/entityOperations/query --payload "$payload" +echo +echo + + +echo "05. Get 501 for DELETE /ngsi-ld/v1/temporal/entities/" echo "==========================================================" orionCurl --url /ngsi-ld/v1/temporal/entities/urn:ngsi-ld:City:Madrid -X DELETE echo @@ -63,7 +76,7 @@ echo -echo "05. Get 501 for POST /ngsi-ld/v1/temporal/entities//attrs" +echo "06. Get 501 for POST /ngsi-ld/v1/temporal/entities//attrs" echo "==============================================================" payload='{ "attr1": { @@ -76,19 +89,36 @@ echo echo -echo "06. Get 501 for DELETE /ngsi-ld/v1/temporal/entities//attrs/{attrId}" +echo "07. Get 501 for DELETE /ngsi-ld/v1/temporal/entities//attrs/{attrId}" echo "=========================================================================" orionCurl --url /ngsi-ld/v1/temporal/entities/urn:ngsi-ld:City:Madrid/attrs/attr1 -X DELETE echo echo -echo "07. Get 501 for POST /ngsi-ld/v1/temporal/entityOperations/query" -echo "================================================================" +echo "08. Get 501 for DELETE /ngsi-ld/v1/temporal/entities//attrs/{attrId}/{instanceId}" +echo "======================================================================================" +orionCurl --url /ngsi-ld/v1/temporal/entities/urn:ngsi-ld:City:Madrid/attrs/attr1/instance1 -X DELETE +echo +echo + + +echo "09. Get 501 for PATCH /ngsi-ld/v1/temporal/entities//attrs/{attrId}/{instanceId}" +echo "=====================================================================================" payload='{ - "q": "A1>10" + "value": 1 }' -orionCurl --url /ngsi-ld/v1/temporal/entityOperations/query --payload "$payload" +orionCurl --url /ngsi-ld/v1/temporal/entities/urn:ngsi-ld:City:Madrid/attrs/attr1/instance1 -X PATCH --payload "$payload" +echo +echo + + +echo "10. Get 405 for POST /ngsi-ld/v1/temporal/entities//attrs/{attrId}/{instanceId}" +echo "====================================================================================" +payload='{ + "value": 1 +}' +orionCurl --url /ngsi-ld/v1/temporal/entities/urn:ngsi-ld:City:Madrid/attrs/attr1/instance1 --payload "$payload" echo echo @@ -122,7 +152,21 @@ Date: REGEX(.*) } -04. Get 501 for DELETE /ngsi-ld/v1/temporal/entities/ +04. Get 501 for POST /ngsi-ld/v1/temporal/entityOperations/query +================================================================ +HTTP/1.1 501 Not Implemented +Content-Length: 200 +Content-Type: application/json +Date: REGEX(.*) + +{ + "detail": "/ngsi-ld/v1/temporal/entityOperations/query", + "title": "Not Implemented in Orion-LD, please use Mintaka for this operation", + "type": "https://uri.etsi.org/ngsi-ld/errors/OperationNotSupported" +} + + +05. Get 501 for DELETE /ngsi-ld/v1/temporal/entities/ ========================================================== HTTP/1.1 501 Not Implemented Content-Length: 137 @@ -136,7 +180,7 @@ Date: REGEX(.*) } -05. Get 501 for POST /ngsi-ld/v1/temporal/entities//attrs +06. Get 501 for POST /ngsi-ld/v1/temporal/entities//attrs ============================================================== HTTP/1.1 501 Not Implemented Content-Length: 143 @@ -150,7 +194,7 @@ Date: REGEX(.*) } -06. Get 501 for DELETE /ngsi-ld/v1/temporal/entities//attrs/{attrId} +07. Get 501 for DELETE /ngsi-ld/v1/temporal/entities//attrs/{attrId} ========================================================================= HTTP/1.1 501 Not Implemented Content-Length: 145 @@ -164,20 +208,43 @@ Date: REGEX(.*) } -07. Get 501 for POST /ngsi-ld/v1/temporal/entityOperations/query -================================================================ +08. Get 501 for DELETE /ngsi-ld/v1/temporal/entities//attrs/{attrId}/{instanceId} +====================================================================================== HTTP/1.1 501 Not Implemented -Content-Length: 200 +Content-Length: 145 Content-Type: application/json Date: REGEX(.*) { - "detail": "/ngsi-ld/v1/temporal/entityOperations/query", - "title": "Not Implemented in Orion-LD, please use Mintaka for this operation", + "detail": "/ngsi-ld/v1/temporal/entities/*/attrs/*", + "title": "Not Implemented", "type": "https://uri.etsi.org/ngsi-ld/errors/OperationNotSupported" } +09. Get 501 for PATCH /ngsi-ld/v1/temporal/entities//attrs/{attrId}/{instanceId} +===================================================================================== +HTTP/1.1 501 Not Implemented +Content-Length: 147 +Content-Type: application/json +Date: REGEX(.*) + +{ + "detail": "/ngsi-ld/v1/temporal/entities/*/attrs/*/*", + "title": "Not Implemented", + "type": "https://uri.etsi.org/ngsi-ld/errors/OperationNotSupported" +} + + +10. Get 405 for POST /ngsi-ld/v1/temporal/entities//attrs/{attrId}/{instanceId} +==================================================================================== +HTTP/1.1 405 Method Not Allowed +Allow: GET,PATCH,DELETE +Content-Length: 0 +Date: REGEX(.*) + + + --TEARDOWN-- brokerStop CB dbDrop CB