diff --git a/src/lib/ngsi10/SubscribeContextRequest.cpp b/src/lib/ngsi10/SubscribeContextRequest.cpp index a0e2b19022..e36fa0f55b 100644 --- a/src/lib/ngsi10/SubscribeContextRequest.cpp +++ b/src/lib/ngsi10/SubscribeContextRequest.cpp @@ -73,20 +73,10 @@ std::string SubscribeContextRequest::check(const std::string& predetectedError, * * SubscribeContextRequest::release - * -* Old versions of this method also include a 'restriction.release()' call. However, now each time -* a SubscribeContextRequest is created, the method toNgsiv2Subscription() is used on it and the -* 'ownership' of the Restriction is transferred to the corresponding NGSIv2 class. Thus, leaving -* that 'restriction.release()' would cause double-free problems. -* -* What causes the problem is the following line in SubscribeContextRequest::toNgsiv2Subscription: -* -* sub->restriction = restriction; -* -* After doing this, we have TWO vectors pointing to the same scopes. -* */ void SubscribeContextRequest::release(void) { + restriction.release(); entityIdVector.release(); attributeList.release(); notifyConditionVector.release(); @@ -109,80 +99,3 @@ void SubscribeContextRequest::fill(EntityTypeInfo typeInfo) restriction.scopeVector.push_back(scopeP); } } - - -/* **************************************************************************** -* -* SubscribeContextRequest::toNgsiv2Subscription - -*/ -void SubscribeContextRequest::toNgsiv2Subscription(Subscription* sub) -{ - // Convert entityIdVector - for (unsigned int ix = 0; ix < entityIdVector.size(); ++ix) - { - EntityId* enP = entityIdVector[ix]; - EntID en; - - if (enP->isPatternIsTrue()) - { - en.idPattern = enP->id; - } - else - { - en.id = enP->id; - } - en.type = enP->type; - - sub->subject.entities.push_back(en); - } - - // Convert attributeList - for (unsigned int ix = 0; ix < attributeList.size(); ++ix) - { - sub->notification.attributes.push_back(attributeList[ix]); - } - - // Convert reference - sub->notification.httpInfo.url = reference.get(); - - // Convert duration - if (duration.isEmpty()) - { - sub->expires = DEFAULT_DURATION_IN_SECONDS + getCurrentTime(); - } - else - { - sub->expires = duration.parse() + getCurrentTime(); - } - - // Convert restriction - sub->restriction = restriction; - - // Convert notifyConditionVector - for (unsigned int ix = 0; ix < notifyConditionVector.size(); ++ix) - { - NotifyCondition* ncP = notifyConditionVector[ix]; - if (ncP->type == ON_CHANGE_CONDITION) // this is just a sanity measure: all types should be ONCHANGE - { - for (unsigned int jx = 0; jx < ncP->condValueList.size(); ++jx) - { - sub->subject.condition.attributes.push_back(ncP->condValueList[jx]); - } - } - } - - // Convert throttling - sub->throttling = throttling.parse(); - - // Note that we don't do anything with 'restrictions': it is not needed by the NGSIv2 logic - - // Fill NGSIv2 fields not used in NGSIv1 with default values - // description and expression are not touched, so default empty string provided by constructor will be used - sub->status = STATUS_ACTIVE; - sub->descriptionProvided = false; - sub->attrsFormat = NGSI_V2_NORMALIZED; - sub->notification.blacklist = false; - sub->notification.httpInfo.custom = false; - - sub->notification.metadata.clear(); -} diff --git a/src/lib/ngsi10/SubscribeContextRequest.h b/src/lib/ngsi10/SubscribeContextRequest.h index edd7abe476..ed3abd4346 100644 --- a/src/lib/ngsi10/SubscribeContextRequest.h +++ b/src/lib/ngsi10/SubscribeContextRequest.h @@ -62,7 +62,6 @@ typedef struct SubscribeContextRequest std::string check(const std::string& predetectedError, int counter); void release(void); - void toNgsiv2Subscription(ngsiv2::Subscription* sub); void fill(EntityTypeInfo typeInfo); } SubscribeContextRequest; diff --git a/src/lib/ngsi10/UpdateContextSubscriptionRequest.cpp b/src/lib/ngsi10/UpdateContextSubscriptionRequest.cpp index c888956db3..721eaabdfe 100644 --- a/src/lib/ngsi10/UpdateContextSubscriptionRequest.cpp +++ b/src/lib/ngsi10/UpdateContextSubscriptionRequest.cpp @@ -87,42 +87,6 @@ std::string UpdateContextSubscriptionRequest::check(const std::string& predetect */ void UpdateContextSubscriptionRequest::release(void) { - // Old versions of this method also include a 'restriction.release()' call. However, now each time - // a UpdateContextSubscriptionRequest is created, the method toNgsiv2Subscription() is used on it and the - // 'ownership' of the Restriction is transferred to the corresponding NGSIv2 class. Thus, leaving - // that 'restriction.release()' would cause double-free problems - + restriction.release(); notifyConditionVector.release(); -} - - - -/* **************************************************************************** -* -* UpdateContextSubscriptionRequest::toNgsiv2Subscription - -*/ -void UpdateContextSubscriptionRequest::toNgsiv2Subscription(SubscriptionUpdate* subUp) -{ - // Parent method will do most of the work - SubscribeContextRequest::toNgsiv2Subscription(subUp); - - // Fill remaining fields in SubscriptionUpdate - subUp->id = subscriptionId.get(); - subUp->fromNgsiv1 = true; - - // Fields that can be modified in a NGSIv1 subscription - // (See https://fiware-orion.readthedocs.io/en/master/user/updating_regs_and_subs/index.html) - // - // * notifyConditions (within subject in NGSIv2) - // * throttling (root field in NGSIv2) - // * duration (root field -as 'expires'- in NGSIv2) - // * restriction (already processed in the parent method) - - subUp->subjectProvided = (notifyConditionVector.size() > 0); - subUp->expiresProvided = !duration.isEmpty(); - subUp->statusProvided = false; // not supported in NGSIv1 - subUp->notificationProvided = false; // NGSIv1 doesn's allow changes in that part - subUp->attrsFormatProvided = true; // updating in NGSIv1 involves and implicit change to NGSIv1 legacy format - subUp->throttlingProvided = !throttling.isEmpty(); - -} +} \ No newline at end of file diff --git a/src/lib/ngsi10/UpdateContextSubscriptionRequest.h b/src/lib/ngsi10/UpdateContextSubscriptionRequest.h index e96d8e435d..a0d3ecf9d3 100644 --- a/src/lib/ngsi10/UpdateContextSubscriptionRequest.h +++ b/src/lib/ngsi10/UpdateContextSubscriptionRequest.h @@ -50,7 +50,6 @@ struct UpdateContextSubscriptionRequest : public SubscribeContextRequest UpdateContextSubscriptionRequest(); std::string check(const std::string& predetectedError, int counter); void release(void); - void toNgsiv2Subscription(ngsiv2::SubscriptionUpdate* subUp); }; #endif // SRC_LIB_NGSI10_UPDATECONTEXTSUBSCRIPTIONREQUEST_H_