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>
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)