fix configuration parsing problem in Resource Container
authorMinji Park <minjii.park@samsung.com>
Wed, 23 Mar 2016 07:56:01 +0000 (16:56 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 25 Mar 2016 04:44:40 +0000 (04:44 +0000)
- fix configuration parsing for input information with bundle resource uri

Change-Id: I8a45b7a00179ab11a018ef1c3030df0233339090
Signed-off-by: Minji Park <minjii.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/6217
Reviewed-by: Markus Jung <markus.jung85@gmail.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/resource-container/examples/BMISensorBundle/src/BMISensorResource.cpp
service/resource-container/src/Configuration.cpp
service/resource-container/src/ResourceContainerImpl.cpp

index 899def0..a9ae815 100644 (file)
@@ -57,10 +57,10 @@ void BMISensorResource::onUpdatedInputResource(const std::string attributeName,
     m_mapInputData.clear();
 
     if (!attributeName.compare("weight"))
-        m_mapInputData.insert(std::make_pair("weight", values.back().toString()));
+        m_mapInputData.insert(std::make_pair("weight", values.back().get< std::string >()));
 
     if (!attributeName.compare("height"))
-        m_mapInputData.insert(std::make_pair("height", values.back().toString()));
+        m_mapInputData.insert(std::make_pair("height", values.back().get< std::string >()));
 
     executeLogic();
 }
index 82a58a2..96f9526 100644 (file)
@@ -191,7 +191,7 @@ namespace OIC
             }
         }
 
-        void Configuration::getResourceConfiguration(std::string bundleId, std::string resourceName,
+        void Configuration::getResourceConfiguration(std::string bundleId, std::string resourceUri,
                         resourceInfo *resourceInfoOut){
             rapidxml::xml_node< char > *bundle;
             rapidxml::xml_node< char > *resource;
@@ -200,7 +200,7 @@ namespace OIC
             string strBundleId;
             string strKey, strValue;
             OIC_LOG_V(INFO, CONTAINER_TAG, "Loading resource configuration for %s %s!",
-                    bundleId.c_str(), resourceName.c_str());
+                bundleId.c_str(), resourceUri.c_str());
 
             if (m_loaded)
             {
@@ -209,8 +209,8 @@ namespace OIC
                     // <bundle>
                     if (m_xmlDoc.first_node())
                     {
-                        for (bundle = m_xmlDoc.first_node()->first_node(BUNDLE_TAG); bundle; bundle =
-                                 bundle->next_sibling())
+                        for (bundle = m_xmlDoc.first_node()->first_node(BUNDLE_TAG); bundle;
+                            bundle = bundle->next_sibling())
                         {
                             // <id>
                             strBundleId = bundle->first_node(BUNDLE_ID)->value();
@@ -236,12 +236,18 @@ namespace OIC
 
                                             if (!strKey.compare(OUTPUT_RESOURCE_NAME))
                                             {
-                                                if (trim_both(strValue).compare(resourceName) != 0) break;
+                                                
                                                 resourceInfoOut->name = trim_both(strValue);
                                             }
 
                                             else if (!strKey.compare(OUTPUT_RESOURCE_URI))
+                                            {
+                                                if (trim_both(strValue).compare(resourceUri) != 0)
+                                                {
+                                                    break;
+                                                }
                                                 resourceInfoOut->uri = trim_both(strValue);
+                                            }
 
                                             else if (!strKey.compare(OUTPUT_RESOURCE_ADDR))
                                                 resourceInfoOut->address = trim_both(strValue);
index 0217199..b8dfd46 100644 (file)
@@ -817,11 +817,10 @@ namespace OIC
         {
             OIC_LOG_V(DEBUG, CONTAINER_TAG, "Discover input resource %s", outputResourceUri.c_str());
             auto foundOutputResource = m_mapResources.find(outputResourceUri);
-           // auto resourceProperty = foundOutputResource->second->m_mapResourceProperty;
 
             resourceInfo info;
             m_config->getResourceConfiguration(foundOutputResource->second->m_bundleId,
-                    foundOutputResource->second->m_name, &info);
+                outputResourceUri, &info);
             map< string, vector< map< string, string > > > resourceProperty = info.resourceProperty;
 
             try