Bug Fix for constructing RCSRepresentation from OCRepresentation.
authorAbhishek Pandey <abhi.siso@samsung.com>
Thu, 21 Jul 2016 09:19:45 +0000 (14:49 +0530)
committerAshok Babu Channa <ashok.channa@samsung.com>
Fri, 22 Jul 2016 04:44:30 +0000 (04:44 +0000)
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 <abhi.siso@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9547
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Junghyun Oh <junghyun.oh@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
service/resource-encapsulation/src/common/primitiveResource/src/RCSRepresentation.cpp

index 79db0bd9d01ca69b9145a79fb4bb987416d707e9..d0a1a9d66fa5ea5437c39c587242564ccaffa5fb 100644 (file)
@@ -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)