From 7b16d80e7e187b9e8501ccd095ff661f3e3aba60 Mon Sep 17 00:00:00 2001 From: Abhishek Pandey Date: Thu, 21 Jul 2016 14:49:45 +0530 Subject: [PATCH] Bug Fix for constructing RCSRepresentation from OCRepresentation. When constructing RCSRepresentation object from OCRepresentation object received from base layer, fromOCRepresentation() function does not attempt to convert child representation objects in OCRepresentation object it receives as input parameter. This patch fixes this issue by adding code to iterate over child objects in OCRepresentation and constructing an equivalent RCSRepresentation for them recursively. Change-Id: Ie9c3f6cfaebeb4ceb1c23a07647458414fef3afc Signed-off-by: Abhishek Pandey Reviewed-on: https://gerrit.iotivity.org/gerrit/9547 Tested-by: jenkins-iotivity Reviewed-by: Junghyun Oh Reviewed-by: Ashok Babu Channa --- .../src/common/primitiveResource/src/RCSRepresentation.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/service/resource-encapsulation/src/common/primitiveResource/src/RCSRepresentation.cpp b/service/resource-encapsulation/src/common/primitiveResource/src/RCSRepresentation.cpp index 79db0bd..d0a1a9d 100644 --- a/service/resource-encapsulation/src/common/primitiveResource/src/RCSRepresentation.cpp +++ b/service/resource-encapsulation/src/common/primitiveResource/src/RCSRepresentation.cpp @@ -147,9 +147,17 @@ namespace OIC RCSRepresentation RCSRepresentation::fromOCRepresentation(const OC::OCRepresentation& ocRep) { - return RCSRepresentation(ocRep.getUri(), ocRep.getResourceInterfaces(), + RCSRepresentation rcsRep(ocRep.getUri(), ocRep.getResourceInterfaces(), ocRep.getResourceTypes(), ResourceAttributesConverter::fromOCRepresentation(ocRep)); + + // Convert child representations + for (auto &childOCRep : ocRep.getChildren()) + { + rcsRep.addChild(fromOCRepresentation(childOCRep)); + } + + return rcsRep; } OC::OCRepresentation RCSRepresentation::toOCRepresentation(const RCSRepresentation& rcsRep) -- 2.7.4