Fix for SVACE and Klocwork issues.
authorHarish Kumara M <h.marappa@samsung.com>
Sat, 5 Mar 2016 06:49:09 +0000 (12:19 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Sat, 5 Mar 2016 14:38:04 +0000 (14:38 +0000)
1. Fix for SVACE reported issues.
2. Fix for Klocwork reported issues.
3. Fix the resource creation issue when "rt" property is having null value.
4. Added to code to check the uniqueness property of array for primitive types int,
    double, boolean and string.

Change-Id: Ib869361f0ffa1dac5d3f7b36ebf76754661e2a7f
Signed-off-by: Harish Kumara Marappa <h.marappa@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5369
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
22 files changed:
service/simulator/SConscript
service/simulator/examples/client/simulator_client.cpp
service/simulator/examples/server/simulator_server.cpp
service/simulator/inc/simulator_request_model.h
service/simulator/inc/simulator_resource_model.h
service/simulator/src/client/request_sender.cpp
service/simulator/src/client/simulator_remote_resource_impl.cpp
service/simulator/src/client/simulator_request_model.cpp
service/simulator/src/common/attribute_generator.cpp
service/simulator/src/common/attribute_value_generator.cpp
service/simulator/src/common/attribute_value_generator.h
service/simulator/src/common/resource_model_schema_builder.cpp
service/simulator/src/common/resource_model_schema_builder.h
service/simulator/src/common/simulator_resource_model_schema.cpp
service/simulator/src/common/simulator_utils.cpp
service/simulator/src/server/resource_update_automation.cpp
service/simulator/src/server/resource_update_automation_mngr.cpp
service/simulator/src/server/simulator_collection_resource_impl.cpp
service/simulator/src/server/simulator_resource_factory.cpp
service/simulator/src/server/simulator_resource_factory.h
service/simulator/src/server/simulator_single_resource_impl.cpp
tools/tizen/.gbs.conf

index 2f262a5..06c4639 100755 (executable)
@@ -67,6 +67,8 @@ java_headers.append(os.path.join(java_headers[0], 'linux'))
 java_headers.append(os.path.join(java_headers[0], 'solaris'))
 simulator_env.AppendUnique(CPPPATH = java_headers)
 
+simulator_env.Append( RPATH = env.Literal('\\$$ORIGIN'))
+
 simulator_env.AppendUnique(CPPPATH = ['../../extlibs/cjson'])
 simulator_env.PrependUnique(LIBS = ['octbstack', 'oc', 'RamlParser'])
 simulator_env.AppendUnique(LIBS = ['pthread'])
index 81bae25..a8f9f8f 100644 (file)
@@ -115,7 +115,7 @@ class ClientController
 
             int index = 1;
             std::vector<std::string> ids;
-            for (auto & resourceEntry : m_resList)
+            for (auto &resourceEntry : m_resList)
             {
                 std::cout << index++ << ": " << (resourceEntry.second)->getURI() << "[" <<
                           (resourceEntry.second)->getHost()  << "]" << std::endl;
@@ -187,13 +187,13 @@ class ClientController
             std::cout << "Host: " << resource->getHost().c_str() << std::endl;
             std::cout << "ID: " << resource->getID().c_str() << std::endl;
             std::cout << "Resource Types: ";
-            for (auto & type : resource->getResourceTypes())
+            for (auto &type : resource->getResourceTypes())
                 std::cout << type << " ";
             std::cout << "\nInterface Types: ";
-            for (auto & type : resource->getInterface())
+            for (auto &type : resource->getInterface())
                 std::cout << type << " ";
             std::cout << std::boolalpha << "\nisObservable : " << resource->isObservable()
-                    << std::noboolalpha << std::endl;
+                      << std::noboolalpha << std::endl;
             std::cout << "#############################" << std::endl;
         }
 
@@ -204,11 +204,11 @@ class ClientController
 
             // callback implementaion
             SimulatorRemoteResource::ObserveNotificationCallback callback =
-                [](const std::string &uid, SimulatorResult result,
-                    const SimulatorResourceModel &rep, int seq)
+                [](const std::string & uid, SimulatorResult result,
+                   const SimulatorResourceModel & rep, int seq)
             {
                 std::cout << "\nObserve notification received ###[errorcode:  " << result <<
-                    " seq:  " << seq << "UID: " << uid << "]" << std::endl;
+                          " seq:  " << seq << "UID: " << uid << "]" << std::endl;
 
                 std::cout << "Representation is: " << std::endl;
                 std::cout << rep.asString() << std::endl;
@@ -222,12 +222,12 @@ class ClientController
             catch (InvalidArgsException &e)
             {
                 std::cout << "InvalidArgsException occured [code : " << e.code() << " Detail: "
-                        << e.what() << "]" << std::endl;
+                          << e.what() << "]" << std::endl;
             }
             catch (SimulatorException &e)
             {
                 std::cout << "SimulatorException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
         }
 
@@ -244,7 +244,7 @@ class ClientController
             catch (SimulatorException &e)
             {
                 std::cout << "SimulatorException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
         }
 
@@ -255,10 +255,10 @@ class ClientController
 
             // callback implementaion
             SimulatorRemoteResource::ResponseCallback callback =
-                [](const std::string &uid, SimulatorResult result, const SimulatorResourceModel &rep)
+                [](const std::string & uid, SimulatorResult result, const SimulatorResourceModel & rep)
             {
                 std::cout << "\nGET Response received ### [errorcode:  " << result << "]"
-                        << std::endl;
+                          << std::endl;
                 std::cout << "UID is: " << uid << std::endl;
                 std::cout << "Representation is: " << std::endl;
                 std::cout << rep.asString() << std::endl;
@@ -272,17 +272,17 @@ class ClientController
             catch (InvalidArgsException &e)
             {
                 std::cout << "InvalidArgsException occured [code : " << e.code() << " Detail: "
-                        << e.what() << "]" << std::endl;
+                          << e.what() << "]" << std::endl;
             }
             catch (NoSupportException &e)
             {
                 std::cout << "NoSupportException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
             catch (SimulatorException &e)
             {
                 std::cout << "SimulatorException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
         }
 
@@ -293,10 +293,10 @@ class ClientController
 
             // callback implementaion
             SimulatorRemoteResource::ResponseCallback callback =
-                [](const std::string &uid, SimulatorResult result, const SimulatorResourceModel &rep)
+                [](const std::string & uid, SimulatorResult result, const SimulatorResourceModel & rep)
             {
                 std::cout << "\nPUT Response received ![errorcode:  " << result << "]"
-                        << std::endl;
+                          << std::endl;
                 std::cout << "UID is: " << uid << std::endl;
                 std::cout << "Representation is: " << std::endl;
                 std::cout << rep.asString() << std::endl;
@@ -314,17 +314,17 @@ class ClientController
             catch (InvalidArgsException &e)
             {
                 std::cout << "InvalidArgsException occured [code : " << e.code() << " Detail: "
-                        << e.what() << "]" << std::endl;
+                          << e.what() << "]" << std::endl;
             }
             catch (NoSupportException &e)
             {
                 std::cout << "NoSupportException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
             catch (SimulatorException &e)
             {
                 std::cout << "SimulatorException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
         }
 
@@ -335,10 +335,10 @@ class ClientController
 
             // callback implementaion
             SimulatorRemoteResource::ResponseCallback callback =
-                [](const std::string &uid, SimulatorResult result, const SimulatorResourceModel &rep)
+                [](const std::string & uid, SimulatorResult result, const SimulatorResourceModel & rep)
             {
                 std::cout << "\nPOST Response received ![errorcode:  " << result << "]"
-                        << std::endl;
+                          << std::endl;
                 std::cout << "UID is: " << uid << std::endl;
                 std::cout << "Representation is: " << std::endl;
                 std::cout << rep.asString() << std::endl;
@@ -356,17 +356,17 @@ class ClientController
             catch (InvalidArgsException &e)
             {
                 std::cout << "InvalidArgsException occured [code : " << e.code() << " Detail: "
-                        << e.what() << "]" << std::endl;
+                          << e.what() << "]" << std::endl;
             }
             catch (NoSupportException &e)
             {
                 std::cout << "NoSupportException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
             catch (SimulatorException &e)
             {
                 std::cout << "SimulatorException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
         }
 
@@ -376,11 +376,11 @@ class ClientController
             if (!resource) return;
 
             SimulatorRemoteResource::AutoRequestGenerationCallback callback =
-                [] (const std::string &uid, int sessionId, OperationState state)
+                [] (const std::string & uid, int sessionId, OperationState state)
             {
                 std::cout << "\nResource verification status received ![id:  " << sessionId <<
-                        "  State: " << getOperationStateString(state) << " UID: " << uid << "]" <<
-                        std::endl;
+                          "  State: " << getOperationStateString(state) << " UID: " << uid << "]" <<
+                          std::endl;
             };
 
             try
@@ -391,17 +391,17 @@ class ClientController
             catch (InvalidArgsException &e)
             {
                 std::cout << "InvalidArgsException occured [code : " << e.code() << " Detail: "
-                        << e.what() << "]" << std::endl;
+                          << e.what() << "]" << std::endl;
             }
             catch (NoSupportException &e)
             {
                 std::cout << "NoSupportException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
             catch (SimulatorException &e)
             {
                 std::cout << "SimulatorException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
         }
 
@@ -411,11 +411,11 @@ class ClientController
             if (!resource) return;
 
             SimulatorRemoteResource::AutoRequestGenerationCallback callback =
-                [] (const std::string &uid, int sessionId, OperationState state)
+                [] (const std::string & uid, int sessionId, OperationState state)
             {
                 std::cout << "\nResource verification status received ![id:  " << sessionId <<
-                        "  State: " << getOperationStateString(state) << " UID: " << uid << "]" <<
-                        std::endl;
+                          "  State: " << getOperationStateString(state) << " UID: " << uid << "]" <<
+                          std::endl;
             };
 
             try
@@ -426,17 +426,17 @@ class ClientController
             catch (InvalidArgsException &e)
             {
                 std::cout << "InvalidArgsException occured [code : " << e.code() << " Detail: "
-                        << e.what() << "]" << std::endl;
+                          << e.what() << "]" << std::endl;
             }
             catch (NoSupportException &e)
             {
                 std::cout << "NoSupportException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
             catch (SimulatorException &e)
             {
                 std::cout << "SimulatorException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
         }
 
@@ -446,11 +446,11 @@ class ClientController
             if (!resource) return;
 
             SimulatorRemoteResource::AutoRequestGenerationCallback callback =
-                [] (const std::string &uid, int sessionId, OperationState state)
+                [] (const std::string & uid, int sessionId, OperationState state)
             {
                 std::cout << "\nResource verification status received ![id:  " << sessionId <<
-                        "  State: " << getOperationStateString(state) << " UID: " << uid << "]"
-                        << std::endl;
+                          "  State: " << getOperationStateString(state) << " UID: " << uid << "]"
+                          << std::endl;
             };
 
             try
@@ -461,17 +461,17 @@ class ClientController
             catch (InvalidArgsException &e)
             {
                 std::cout << "InvalidArgsException occured [code : " << e.code() << " Detail: "
-                        << e.what() << "]" << std::endl;
+                          << e.what() << "]" << std::endl;
             }
             catch (NoSupportException &e)
             {
                 std::cout << "NoSupportException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
             catch (SimulatorException &e)
             {
                 std::cout << "SimulatorException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
         }
 
@@ -492,12 +492,12 @@ class ClientController
             catch (InvalidArgsException &e)
             {
                 std::cout << "InvalidArgsException occured [code : " << e.code() << " Detail: "
-                        << e.what() << "]" << std::endl;
+                          << e.what() << "]" << std::endl;
             }
             catch (SimulatorException &e)
             {
                 std::cout << "SimulatorException occured [code : " << e.code() << " Detail: " <<
-                        e.what() << "]" << std::endl;
+                          e.what() << "]" << std::endl;
             }
         }
 
@@ -510,7 +510,7 @@ class ClientController
             try
             {
                 SimulatorManager::getInstance()->getDeviceInfo(resource->getHost(),
-                    std::bind([](const std::string & host, DeviceInfo & deviceInfo)
+                        std::bind([](const std::string & host, DeviceInfo & deviceInfo)
                 {
                     std::cout << "###Device Information received...." << std::endl;
                     std::ostringstream out;
@@ -544,7 +544,7 @@ class ClientController
             try
             {
                 SimulatorManager::getInstance()->getPlatformInfo(resource->getHost(),
-                    std::bind([](const std::string & host, PlatformInfo & platformInfo)
+                        std::bind([](const std::string & host, PlatformInfo & platformInfo)
                 {
                     std::cout << "###Platform Information received...." << std::endl;
                     std::ostringstream out;
@@ -567,12 +567,12 @@ class ClientController
             catch (InvalidArgsException &e)
             {
                 std::cout << "InvalidArgsException occured [code : " << e.code()
-                        << " Detail: " << e.what() << "]" << std::endl;
+                          << " Detail: " << e.what() << "]" << std::endl;
             }
             catch (SimulatorException &e)
             {
                 std::cout << "SimulatorException occured [code : " << e.code()
-                        << " Detail: " << e.what() << "]" << std::endl;
+                          << " Detail: " << e.what() << "]" << std::endl;
             }
         }
 
index 147ba5e..776fc21 100644 (file)
@@ -43,7 +43,7 @@ int selectResource()
     }
 
     int index = 1;
-    for (auto & resource : g_singleResources)
+    for (auto &resource : g_singleResources)
     {
         std::cout << index++ << ": " << resource->getURI().c_str() << std::endl;
     }
@@ -67,7 +67,7 @@ void simulateResource()
     {
         // Resource model change callback
         SimulatorResource::ResourceModelUpdateCallback modelChangeCB =
-        [](const std::string &uri, const SimulatorResourceModel &resModel)
+            [](const std::string & uri, const SimulatorResourceModel & resModel)
         {
             std::cout << "[callback] Resource model is changed URI: " << uri.c_str() << std::endl;
             std::cout << "#### Modified attributes are ####" << std::endl;
@@ -78,7 +78,7 @@ void simulateResource()
 
         // Observer added/removed callback
         SimulatorResource::ObserverCallback observerCB =
-        [] (const std::string &uri, ObservationStatus state, const ObserverInfo &observerInfo)
+            [] (const std::string & uri, ObservationStatus state, const ObserverInfo & observerInfo)
         {
             std::cout << "[callback] Observer notification received..." << uri << std::endl;
 
@@ -86,14 +86,15 @@ void simulateResource()
             out << "ID:  " << (int) observerInfo.id << std::endl;
             out << " [address: " << observerInfo.address << " port: " << observerInfo.port
                 << "]" << std::endl;
-            out << "State: " << ((state == ObservationStatus::REGISTER)? "REGISTER" : "UNREGISTER") << std::endl;
+            out << "State: " << ((state == ObservationStatus::REGISTER) ? "REGISTER" : "UNREGISTER") <<
+                std::endl;
             std::cout << out.str();
         };
 
         // Get the RAML file path from user
         std::string configPath;
         std::cout << "Enter RAML path: ";
-        std::cin>>configPath;
+        std::cin >> configPath;
 
         SimulatorResourceSP resource =
             SimulatorManager::getInstance()->createResource(configPath);
@@ -176,10 +177,11 @@ void stopResource()
 void automateResourceUpdate()
 {
     SimulatorSingleResource::AutoUpdateCompleteCallback callback =
-        [](const std::string &uri, const int id) {
-            std::cout << "Update automation is completed [URI: " << uri
-                      << "  AutomationID: " << id << "] ###" << std::endl;
-        };
+        [](const std::string & uri, const int id)
+    {
+        std::cout << "Update automation is completed [URI: " << uri
+                  << "  AutomationID: " << id << "] ###" << std::endl;
+    };
 
     int index = selectResource();
     if (-1 == index)
@@ -208,10 +210,11 @@ void automateResourceUpdate()
 void automateAttributeUpdate()
 {
     SimulatorSingleResource::AutoUpdateCompleteCallback callback =
-        [](const std::string &uri, const int id) {
-            std::cout << "Update automation is completed [URI: " << uri
-                      << "  AutomationID: " << id << "] ###" << std::endl;
-        };
+        [](const std::string & uri, const int id)
+    {
+        std::cout << "Update automation is completed [URI: " << uri
+                  << "  AutomationID: " << id << "] ###" << std::endl;
+    };
 
     int index = selectResource();
     if (-1 == index)
@@ -221,7 +224,7 @@ void automateAttributeUpdate()
     std::map<std::string, SimulatorResourceAttribute> attributes =
         resource->getAttributes();
     int size = 0;
-    for (auto & attributeEntry : attributes)
+    for (auto &attributeEntry : attributes)
     {
         std::cout << ++size << ": " << attributeEntry.first << std::endl;
     }
@@ -234,7 +237,7 @@ void automateAttributeUpdate()
 
     int choice = -1;
     std::cout << "Select the attribute which you want to automate for updation: " <<
-        std::endl;
+              std::endl;
     std::cin >> choice;
     if (choice < 0 || choice > size)
     {
@@ -244,7 +247,7 @@ void automateAttributeUpdate()
 
     int count = 0;
     std::string attributeName;
-    for (auto & attributeEntry : attributes)
+    for (auto &attributeEntry : attributes)
     {
         if (count == choice - 1)
         {
@@ -262,7 +265,7 @@ void automateAttributeUpdate()
         type = AutoUpdateType::REPEAT;
 
     std::cout << "Requesting attribute automation for " << attributeName <<
-        std::endl;
+              std::endl;
 
     try
     {
@@ -300,7 +303,7 @@ void stopAutomation()
         return;
     }
 
-    for (auto & id : ids)
+    for (auto &id : ids)
     {
         std::cout <<  id  << " ";
         resource->stopUpdation(id);
@@ -318,7 +321,7 @@ void getObservers()
     std::vector<ObserverInfo> observersList = resource->getObservers();
 
     std::cout << "##### Number of Observers [" << observersList.size() << "]" << std::endl;
-    for (auto & observerInfo : observersList)
+    for (auto &observerInfo : observersList)
     {
         std::cout << " ID :  " << (int) observerInfo.id << " [address: " <<
                   observerInfo.address << " port: " << observerInfo.port << "]" << std::endl;
@@ -381,8 +384,21 @@ void setLogger()
 
 void setDeviceInfo()
 {
-    SimulatorManager::getInstance()->setDeviceInfo("IoTivity Simulator Linux Sample");
-    std::cout << "Setting Device Info is successful" << std::endl;
+    try
+    {
+        SimulatorManager::getInstance()->setDeviceInfo("IoTivity Simulator Linux Sample");
+        std::cout << "Setting Device Info is successful" << std::endl;
+    }
+    catch (InvalidArgsException &e)
+    {
+        std::cout << "InvalidArgsException occured [code : " << e.code() << " Details: "
+                  << e.what() << "]" << std::endl;
+    }
+    catch (SimulatorException &e)
+    {
+        std::cout << "SimulatorException occured [code : " << e.code() << " Details: "
+                  << e.what() << "]" << std::endl;
+    }
 }
 
 void setPlatformInfo()
@@ -400,12 +416,21 @@ void setPlatformInfo()
     pInfo.setSystemTime("2015-09-10T11:10:30Z");
     pInfo.setDateOfManfacture("2015-09-10T11:10:30Z");
 
-    SimulatorManager::getInstance()->setPlatformInfo(pInfo);
-    std::cout << "Setting Platform Info is successful" << std::endl;
+    try
+    {
+        SimulatorManager::getInstance()->setPlatformInfo(pInfo);
+        std::cout << "Setting Platform Info is successful" << std::endl;
+    }
+    catch (SimulatorException &e)
+    {
+        std::cout << "SimulatorException occured [code : " << e.code() << " Details: "
+                  << e.what() << "]" << std::endl;
+    }
 }
 
 void addInterface()
 {
+
     int index = selectResource();
     if (-1 == index)
         return;
index e12ed04..eb3b2a6 100644 (file)
@@ -27,7 +27,7 @@
 class SimulatorRequestModel
 {
     public:
-        SimulatorRequestModel() = default;
+        SimulatorRequestModel();
         SimulatorRequestModel(RequestType type);
 
         RequestType getType() const;
index 973ddb8..a83028f 100644 (file)
@@ -120,7 +120,14 @@ class SimulatorResourceModel
             auto x = m_attributes.find(name);
             if (x != m_attributes.end())
             {
-                val = boost::get<T>(x->second);
+                try
+                {
+                    val = boost::get<T>(x->second);
+                }
+                catch (boost::bad_get &e)
+                {
+                    return val;
+                }
             }
             return val;
         }
index 7e0be03..4337a8d 100644 (file)
@@ -42,8 +42,7 @@ SimulatorResult GETRequestSender::send(const std::map<std::string, std::string>
     requestInfo.type = RequestType::RQ_TYPE_GET;
     requestInfo.queryParams = queryParams;
 
-    SIM_LOG(ILogger::INFO, "Sending GET request..." << "\n**Payload Details**\n" << getRequestString(
-                queryParams));
+    SIM_LOG(ILogger::INFO, "Sending GET request." << "\n" << getRequestString(queryParams))
 
     OCStackResult ocResult =  m_ocResource->get(queryParams,
                               std::bind(&GETRequestSender::onResponseReceived, this, std::placeholders::_1,
@@ -55,7 +54,7 @@ void GETRequestSender::onResponseReceived(const OC::HeaderOptions &headerOptions
         const OC::OCRepresentation &rep, const int errorCode, RequestInfo &requestInfo,
         ResponseCallback callback)
 {
-    SIM_LOG(ILogger::INFO, "Response received for GET..." << "\n" << getPayloadString(rep));
+    SIM_LOG(ILogger::INFO, "Response received for GET." << "\n" << getPayloadString(rep));
     SimulatorResourceModel resourceModel = SimulatorResourceModel::build(rep);
     callback(static_cast<SimulatorResult>(errorCode), resourceModel, requestInfo);
 }
@@ -79,10 +78,11 @@ SimulatorResult PUTRequestSender::send(const std::map<std::string, std::string>
     requestInfo.queryParams = queryParams;
     requestInfo.payLoad = representation;
 
-    SIM_LOG(ILogger::INFO, "Sending PUT request..." << "\n**Payload Details**\n" << getRequestString(
-                queryParams));
+    OC::OCRepresentation ocRep = representation.asOCRepresentation();
+    SIM_LOG(ILogger::INFO, "Sending PUT request." << "\n**Payload Details**\n" << getRequestString(
+                queryParams, ocRep));
 
-    OCStackResult ocResult =  m_ocResource->put(representation.asOCRepresentation(), queryParams,
+    OCStackResult ocResult =  m_ocResource->put(ocRep, queryParams,
                               std::bind(&PUTRequestSender::onResponseReceived, this, std::placeholders::_1,
                                         std::placeholders::_2, std::placeholders::_3, requestInfo, callback));
     return static_cast<SimulatorResult>(ocResult);
@@ -92,7 +92,7 @@ void PUTRequestSender::onResponseReceived(const OC::HeaderOptions &headerOptions
         const OC::OCRepresentation &rep, const int errorCode, RequestInfo &requestInfo,
         ResponseCallback callback)
 {
-    SIM_LOG(ILogger::INFO, "Response received for PUT..." << "\n" << getPayloadString(rep));
+    SIM_LOG(ILogger::INFO, "Response received for PUT." << "\n" << getPayloadString(rep));
     SimulatorResourceModel resourceModel = SimulatorResourceModel::build(rep);
     callback(static_cast<SimulatorResult>(errorCode), resourceModel, requestInfo);
 }
@@ -116,10 +116,11 @@ SimulatorResult POSTRequestSender::send(const std::map<std::string, std::string>
     requestInfo.queryParams = queryParams;
     requestInfo.payLoad = representation;
 
-    SIM_LOG(ILogger::INFO, "Sending POST request..." << "\n**Payload Details**\n" << getRequestString(
-                queryParams));
+    OC::OCRepresentation ocRep = representation.asOCRepresentation();
+    SIM_LOG(ILogger::INFO, "Sending POST request." << "\n**Payload Details**\n" << getRequestString(
+                queryParams, ocRep));
 
-    OCStackResult ocResult =  m_ocResource->post(representation.asOCRepresentation(), queryParams,
+    OCStackResult ocResult =  m_ocResource->post(ocRep, queryParams,
                               std::bind(&POSTRequestSender::onResponseReceived, this, std::placeholders::_1,
                                         std::placeholders::_2, std::placeholders::_3, requestInfo, callback));
     return static_cast<SimulatorResult>(ocResult);
@@ -129,7 +130,7 @@ void POSTRequestSender::onResponseReceived(const OC::HeaderOptions &headerOption
         const OC::OCRepresentation &rep, const int errorCode, RequestInfo &requestInfo,
         ResponseCallback callback)
 {
-    SIM_LOG(ILogger::INFO, "Response received for POST..." << "\n" << getPayloadString(rep));
+    SIM_LOG(ILogger::INFO, "Response received for POST." << "\n" << getPayloadString(rep));
     SimulatorResourceModel resourceModel = SimulatorResourceModel::build(rep);
     callback(static_cast<SimulatorResult>(errorCode), resourceModel, requestInfo);
 }
index 7c057f0..d6234b9 100644 (file)
@@ -124,6 +124,8 @@ void SimulatorRemoteResourceImpl::observe(ObserveType type,
     if (m_observeState)
     {
         OC_LOG(ERROR, TAG, "Resource is already being observed!");
+        SIM_LOG(ILogger::ERROR, "[URI: " << getURI() << "] Resource is already being observed!")
+
         throw SimulatorException(SIMULATOR_ERROR, "Resource is already being observed!");
     }
 
@@ -131,7 +133,8 @@ void SimulatorRemoteResourceImpl::observe(ObserveType type,
             [](const OC::HeaderOptions & headerOptions, const OC::OCRepresentation & ocRep,
                const int errorCode, const int sqNum, std::string id, ObserveNotificationCallback callback)
     {
-        SIM_LOG(ILogger::INFO, "Observe response received..." << "\n" << getPayloadString(ocRep));
+        SIM_LOG(ILogger::INFO, "Response received for OBSERVE request."
+                << "\n" << getPayloadString(ocRep))
 
         SimulatorResourceModel resourceModel = SimulatorResourceModel::build(ocRep);
         callback(id, static_cast<SimulatorResult>(errorCode), resourceModel, sqNum);
@@ -148,7 +151,7 @@ void SimulatorRemoteResourceImpl::observe(ObserveType type,
         if (OC_STACK_OK != ocResult)
             throw SimulatorException(static_cast<SimulatorResult>(ocResult), OC::OCException::reason(ocResult));
 
-        SIM_LOG(ILogger::INFO, "OBSERVE request sent");
+        SIM_LOG(ILogger::INFO, "[URI: " << getURI() << "] Sent OBSERVE request.")
     }
     catch (OC::OCException &e)
     {
@@ -166,11 +169,13 @@ void SimulatorRemoteResourceImpl::cancelObserve()
         if (OC_STACK_OK != ocResult)
         {
             OC_LOG(ERROR, TAG, "Cancelling observe failed!");
+            SIM_LOG(ILogger::INFO, "[URI: " << getURI() << "] Sending OBSERVE cancel request failed!")
+
             throw SimulatorException(static_cast<SimulatorResult>(ocResult),
                                      OC::OCException::reason(ocResult));
         }
 
-        SIM_LOG(ILogger::INFO, "OBSERVE CANCEL request sent");
+        SIM_LOG(ILogger::INFO, "[URI: " << getURI() << "] Sent OBSERVE cancel request.")
     }
     catch (OC::OCException &e)
     {
@@ -192,6 +197,8 @@ void SimulatorRemoteResourceImpl::get(const GetResponseCallback &callback)
     if (SIMULATOR_OK != result)
     {
         OC_LOG(ERROR, TAG, "Failed to send GET request!");
+        SIM_LOG(ILogger::ERROR, "[URI: " << getURI() << "] Failed to send GET request!")
+
         throw SimulatorException(result, "Failed to send GET request!");
     }
 }
@@ -208,6 +215,8 @@ void SimulatorRemoteResourceImpl::get(const std::map<std::string, std::string> &
     if (SIMULATOR_OK != result)
     {
         OC_LOG(ERROR, TAG, "Failed to send GET request!");
+        SIM_LOG(ILogger::ERROR, "[URI: " << getURI() << "] Failed to send GET request!")
+
         throw SimulatorException(result, "Failed to send GET request!");
     }
 }
@@ -231,6 +240,8 @@ void SimulatorRemoteResourceImpl::get(const std::string &interfaceType,
     if (SIMULATOR_OK != result)
     {
         OC_LOG(ERROR, TAG, "Failed to send GET request!");
+        SIM_LOG(ILogger::ERROR, "[URI: " << getURI() << "] Failed to send GET request!")
+
         throw SimulatorException(result, "Failed to send GET request!");
     }
 }
@@ -247,6 +258,8 @@ void SimulatorRemoteResourceImpl::put(const SimulatorResourceModel &representati
     if (SIMULATOR_OK != result)
     {
         OC_LOG(ERROR, TAG, "Failed to send PUT request!");
+        SIM_LOG(ILogger::ERROR, "[URI: " << getURI() << "] Failed to send PUT request!")
+
         throw SimulatorException(result, "Failed to send PUT request!");
     }
 }
@@ -264,6 +277,8 @@ void SimulatorRemoteResourceImpl::put(const std::map<std::string, std::string> &
     if (SIMULATOR_OK != result)
     {
         OC_LOG(ERROR, TAG, "Failed to send PUT request!");
+        SIM_LOG(ILogger::ERROR, "[URI: " << getURI() << "] Failed to send PUT request!")
+
         throw SimulatorException(result, "Failed to send PUT request!");
     }
 }
@@ -288,6 +303,8 @@ void SimulatorRemoteResourceImpl::put(const std::string &interfaceType,
     if (SIMULATOR_OK != result)
     {
         OC_LOG(ERROR, TAG, "Failed to send PUT request!");
+        SIM_LOG(ILogger::ERROR, "[URI: " << getURI() << "] Failed to send PUT request!")
+
         throw SimulatorException(result, "Failed to send PUT request!");
     }
 }
@@ -304,6 +321,8 @@ void SimulatorRemoteResourceImpl::post(const SimulatorResourceModel &representat
     if (SIMULATOR_OK != result)
     {
         OC_LOG(ERROR, TAG, "Failed to send POST request!");
+        SIM_LOG(ILogger::ERROR, "[URI: " << getURI() << "] Failed to send POST request!")
+
         throw SimulatorException(result, "Failed to send POST request!");
     }
 }
@@ -321,6 +340,8 @@ void SimulatorRemoteResourceImpl::post(const std::map<std::string, std::string>
     if (SIMULATOR_OK != result)
     {
         OC_LOG(ERROR, TAG, "Failed to send POST request!");
+        SIM_LOG(ILogger::ERROR, "[URI: " << getURI() << "] Failed to send POST request!")
+
         throw SimulatorException(result, "Failed to send POST request!");
     }
 }
@@ -345,6 +366,8 @@ void SimulatorRemoteResourceImpl::post(const std::string &interfaceType,
     if (SIMULATOR_OK != result)
     {
         OC_LOG(ERROR, TAG, "Failed to send POST request!");
+        SIM_LOG(ILogger::ERROR, "[URI: " << getURI() << "] Failed to send POST request!")
+
         throw SimulatorException(result, "Failed to send POST request!");
     }
 }
index f937601..ebc56c6 100644 (file)
  ******************************************************************/
 #include "simulator_request_model.h"
 
+SimulatorRequestModel::SimulatorRequestModel()
+    : m_type(RequestType::RQ_TYPE_UNKNOWN),
+        m_reqBodySchema(nullptr) {}
+
 SimulatorRequestModel::SimulatorRequestModel(RequestType type)
     : m_type(type) {}
 
index 6c29bca..50a18ca 100644 (file)
@@ -118,7 +118,6 @@ bool AttributeCombinationGen::next(SimulatorResourceModel &resModel)
     {
         updateAttributeInModel(m_index);
         resModel = m_resModel;
-        return true;
     }
     else
     {
@@ -140,10 +139,9 @@ bool AttributeCombinationGen::next(SimulatorResourceModel &resModel)
         }
 
         resModel = m_resModel;
-        return true;
     }
 
-    return false;
+    return true;
 }
 
 void AttributeCombinationGen::updateAttributeInModel(int index)
index 992b4eb..188b615 100644 (file)
@@ -31,7 +31,8 @@ std::unique_ptr<AttributeValueGen> AttributeValueGenFactory::create(
         std::shared_ptr<IntegerProperty> intProperty = property->asInteger();
         if (intProperty->hasRange())
         {
-            int min, max;
+            int min = 0;
+            int max = 0;
             intProperty->getRange(min, max);
             return std::unique_ptr<AttributeValueGen>(
                        new RangeValueGen<int>(min, max));
@@ -49,7 +50,8 @@ std::unique_ptr<AttributeValueGen> AttributeValueGenFactory::create(
         std::shared_ptr<DoubleProperty> doubleProperty = property->asDouble();
         if (doubleProperty->hasRange())
         {
-            double min, max;
+            double min = 0.0;
+            double max = 0.0;
             doubleProperty->getRange(min, max);
             return std::unique_ptr<AttributeValueGen>(
                        new RangeValueGen<double>(min, max));
index e7a6bf1..e55af62 100644 (file)
@@ -41,7 +41,7 @@ class RangeValueGen : public AttributeValueGen
         TYPE m_cur;
 
     public:
-        RangeValueGen(TYPE min, TYPE max) : m_min(min), m_max(max), m_cur(m_min) {}
+        RangeValueGen(TYPE min, TYPE max) : m_min(min), m_max(max), m_cur(min) {}
 
         bool hasNext()
         {
index 3ddc1c7..5ddf5ba 100644 (file)
@@ -216,12 +216,7 @@ std::shared_ptr<ArrayProperty> ResourceModelSchemaBuilder::buildArrayAttribute(
                 std::shared_ptr<IntegerProperty> elementProperty =
                     buildIntegerAttribute(elementAttribute);
 
-                if (arrayAttribute.isDefaultValue())
-                {
-                    auto defaultValue = boost::get<int>(arrayAttribute.getValue());
-                    elementProperty->setDefaultValue(defaultValue);
-                }
-
+                setArrayProperties(property, arrayProperty);
                 arrayProperty->setElementProperty(elementProperty);
             }
             break;
@@ -234,12 +229,7 @@ std::shared_ptr<ArrayProperty> ResourceModelSchemaBuilder::buildArrayAttribute(
                 std::shared_ptr<DoubleProperty> elementProperty =
                     buildDoubleAttribute(elementAttribute);
 
-                if (arrayAttribute.isDefaultValue())
-                {
-                    auto defaultValue = boost::get<double>(arrayAttribute.getValue());
-                    elementProperty->setDefaultValue(defaultValue);
-                }
-
+                setArrayProperties(property, arrayProperty);
                 arrayProperty->setElementProperty(elementProperty);
             }
             break;
@@ -252,12 +242,7 @@ std::shared_ptr<ArrayProperty> ResourceModelSchemaBuilder::buildArrayAttribute(
                 std::shared_ptr<BooleanProperty> elementProperty =
                     buildBooleanAttribute(elementAttribute);
 
-                if (arrayAttribute.isDefaultValue())
-                {
-                    auto defaultValue = boost::get<bool>(arrayAttribute.getValue());
-                    elementProperty->setDefaultValue(defaultValue);
-                }
-
+                setArrayProperties(property, arrayProperty);
                 arrayProperty->setElementProperty(elementProperty);
             }
             break;
@@ -270,12 +255,7 @@ std::shared_ptr<ArrayProperty> ResourceModelSchemaBuilder::buildArrayAttribute(
                 std::shared_ptr<StringProperty> elementProperty =
                     buildStringAttribute(elementAttribute);
 
-                if (arrayAttribute.isDefaultValue())
-                {
-                    auto defaultValue = boost::get<std::string>(arrayAttribute.getValue());
-                    elementProperty->setDefaultValue(defaultValue);
-                }
-
+                setArrayProperties(property, arrayProperty);
                 arrayProperty->setElementProperty(elementProperty);
             }
             break;
@@ -303,6 +283,7 @@ std::shared_ptr<ArrayProperty> ResourceModelSchemaBuilder::buildModelArrayAttrib
     }
 
     std::shared_ptr<ArrayProperty> arrayProperty = ArrayProperty::build();
+    setArrayProperties(property, arrayProperty);
     arrayProperty->setElementProperty(modelProperty);
 
     return arrayProperty;
@@ -323,4 +304,26 @@ std::shared_ptr<ModelProperty> ResourceModelSchemaBuilder::buildModelAttribute(
     }
 
     return modelProperty;
+}
+
+void ResourceModelSchemaBuilder::setArrayProperties(
+    const std::shared_ptr<RAML::Properties> &property,
+    const std::shared_ptr<ArrayProperty> &arrayProperty)
+{
+    for (auto &valueProperty : property->getValueProperties())
+    {
+        if (RAML::ValueProperty::Type::ARRAY == valueProperty->type())
+        {
+            int minItems = 0;
+            int maxItems = 0;
+            bool unique = false;
+            bool additionalItems = false;
+
+            valueProperty->valueArray(minItems, maxItems, unique, additionalItems);
+            arrayProperty->setRange(minItems, maxItems);
+            arrayProperty->setUnique(unique);
+            arrayProperty->setVariable(additionalItems);
+            break;
+        }
+    }
 }
\ No newline at end of file
index c7a0159..fee7751 100644 (file)
@@ -62,6 +62,10 @@ class ResourceModelSchemaBuilder
         std::shared_ptr<ModelProperty> buildModelAttribute(
             const std::shared_ptr<RAML::Properties> &property);
 
+        void setArrayProperties(
+            const std::shared_ptr<RAML::Properties> &property,
+            const std::shared_ptr<ArrayProperty> &arrayProperty);
+
         std::shared_ptr<RAML::RequestResponseBody> m_ramlSchema;
 };
 
index 581e47c..f17a22b 100644 (file)
@@ -42,6 +42,33 @@ static AttributeValueVariant buildArrayValue(int depth, AttributeValueVariant &c
     return arrayValue;
 }
 
+template <typename T, typename=void>
+struct UniquenessChecker
+{
+    static bool get(const std::vector<T> &/*value*/)
+    {
+        return true;
+    }
+};
+
+template <typename T>
+struct UniquenessChecker<T, typename std::enable_if<
+    std::is_same<T, int>::value
+    || std::is_same<T, double>::value
+    || std::is_same<T, bool>::value
+    || std::is_same<T, std::string>::value
+    >::type >
+{
+    static bool get(const std::vector<T> &value)
+    {
+        std::vector<T> valueCopy = value;
+        std::sort(valueCopy.begin(), valueCopy.end());
+        if(valueCopy.end() != std::unique(valueCopy.begin(), valueCopy.end()))
+            return false;
+        return true;
+    }
+};
+
 class IntegerValidator : public boost::static_visitor<bool>
 {
     public:
@@ -121,13 +148,15 @@ class ArrayValidator : public boost::static_visitor<bool>
         bool operator ()(const std::vector<T> &value)
         {
             // Validating length of array
-            if (m_property->hasRange())
+            if (!checkLength(value))
             {
-                if (value.size() < m_property->getMinItems()
-                    || (value.size() > m_property->getMaxItems() && !m_property->isVariable()))
-                {
-                    return false;
-                }
+                return false;
+            }
+
+            // Validate the uniqueness of elements of array
+            if (!checkUniqueness(value))
+            {
+                return false;
             }
 
             // Validating elements of array
@@ -147,6 +176,32 @@ class ArrayValidator : public boost::static_visitor<bool>
         }
 
     private:
+        template <typename T>
+        bool checkLength(const std::vector<T> &value)
+        {
+            if (m_property->hasRange())
+            {
+                if (value.size() < m_property->getMinItems()
+                    || (value.size() > m_property->getMaxItems() && !m_property->isVariable()))
+                {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        template <typename T>
+        bool checkUniqueness(const std::vector<T> &value)
+        {
+            if (m_property->isUnique())
+            {
+                return UniquenessChecker<T>::get(value);
+            }
+
+            return true;
+        }
+
         std::shared_ptr<ArrayProperty> m_property;
 };
 
@@ -181,6 +236,8 @@ AttributeProperty::Type AttributeProperty::getType() const
 IntegerProperty::IntegerProperty(int defaultValue)
     : AttributeProperty(AttributeProperty::Type::INTEGER),
       m_defaultValue(defaultValue),
+      m_min(0),
+      m_max(0),
       m_hasRange(false) {}
 
 std::shared_ptr<IntegerProperty> IntegerProperty::build(int defaultValue)
@@ -290,6 +347,8 @@ AttributeValueVariant IntegerProperty::buildValue()
 DoubleProperty::DoubleProperty(double defaultValue)
     : AttributeProperty(AttributeProperty::Type::DOUBLE),
       m_defaultValue(defaultValue),
+      m_min(0),
+      m_max(0),
       m_hasRange(false) {}
 
 std::shared_ptr<DoubleProperty> DoubleProperty::build(double defaultValue)
@@ -438,6 +497,8 @@ AttributeValueVariant BooleanProperty::buildValue()
 StringProperty::StringProperty(const std::string &defaultValue)
     : AttributeProperty(AttributeProperty::Type::STRING),
       m_defaultValue(defaultValue),
+      m_min(0),
+      m_max(0),
       m_hasRange(false) {}
 
 std::shared_ptr<StringProperty> StringProperty::build(const std::string &defaultValue)
@@ -552,6 +613,8 @@ AttributeValueVariant StringProperty::buildValue()
 
 ArrayProperty::ArrayProperty()
     :   AttributeProperty(AttributeProperty::Type::ARRAY),
+        m_min(0),
+        m_max(0),
         m_isVariableSize(false),
         m_isUnique(false),
         m_hasRange(false) {}
index bbc2af1..b512d22 100644 (file)
@@ -163,6 +163,5 @@ std::string getRequestString(const std::map<std::string, std::string> &queryPara
     }
 
     requestString << std::endl;
-    requestString << "Payload:  No payload";
     return requestString.str();
 }
index 3dfd496..ad2f997 100644 (file)
@@ -111,7 +111,13 @@ void AttributeUpdateAutomation::updateAttribute(SimulatorResourceAttribute attri
     if (!m_stopRequested)
     {
         OC_LOG_V(DEBUG, ATAG, "Attribute:%s automation is completed!", m_attrName.c_str());
-        SIM_LOG(ILogger::INFO, "Automation of " << m_attrName << " attribute is completed.");
+        SIM_LOG(ILogger::INFO, "Attribute automation completed [Name: \"" << m_attrName
+                    << "\", id: " << m_id <<"].");
+    }
+    else
+    {
+        SIM_LOG(ILogger::INFO, "Attribute automation stopped [Name: \"" << m_attrName
+                    << "\", id: " << m_id <<"].");
     }
 
     // Notify application through callback
@@ -203,7 +209,13 @@ void ResourceUpdateAutomation::updateAttributes(
     if (!m_stopRequested)
     {
         OC_LOG_V(DEBUG, ATAG, "Resource update automation complete [id: %d]!", m_id);
-        SIM_LOG(ILogger::INFO, "Resource update automation complete [id: " << m_id << "]");
+        SIM_LOG(ILogger::INFO, "Resource automation completed [URI: \"" << m_resource->getURI()
+                << "\", id: " << m_id << "].");
+    }
+    else
+    {
+        SIM_LOG(ILogger::INFO, "Resource automation stopped [URI: \"" << m_resource->getURI()
+                << "\", id: " << m_id <<"].");
     }
 
     // Notify application
index d6351b6..98aa30e 100644 (file)
@@ -38,7 +38,8 @@ int UpdateAutomationMngr::startResourceAutomation(
     std::lock_guard<std::mutex> lock(m_lock);
     resourceAutomation->start();
 
-    SIM_LOG(ILogger::INFO, "Resource automation successfully started [ id: " << m_id << " ]");
+    SIM_LOG(ILogger::INFO, "Resource automation started [URI: \"" << resource->getURI()
+            << "\", id: " << m_id << "].");
 
     m_resourceUpdationList[m_id] = resourceAutomation;
     return m_id++;
@@ -56,8 +57,8 @@ int UpdateAutomationMngr::startAttributeAutomation(
     std::lock_guard<std::mutex> lock(m_lock);
     attributeAutomation->start();
 
-    SIM_LOG(ILogger::INFO, "Automation for " << attrName << " attribute has successfully started [ id: "
-            << m_id << " ]");
+    SIM_LOG(ILogger::INFO, "Attribute automation started [Name: \"" << attrName << "\", id: "
+            << m_id << "].");
 
     m_attrUpdationList[m_id] = attributeAutomation;
     return m_id++;
index 7293678..64b5ac3 100755 (executable)
@@ -27,7 +27,6 @@
 #define TAG "SIMULATOR_COLLECTION_RESOURCE"
 
 SimulatorCollectionResourceImpl::SimulatorCollectionResourceImpl()
-    :   m_resourceHandle(nullptr)
 {
     m_type = SimulatorResource::Type::COLLECTION_RESOURCE;
     m_interfaces.push_back(OC::LINK_INTERFACE);
@@ -36,6 +35,8 @@ SimulatorCollectionResourceImpl::SimulatorCollectionResourceImpl()
     // Add empty vector of OIC Links
     std::vector<SimulatorResourceModel> links;
     m_resModel.add("links", links);
+
+    m_resourceHandle = nullptr;
 }
 
 bool SimulatorCollectionResourceImpl::isCollection() const
@@ -181,12 +182,12 @@ void SimulatorCollectionResourceImpl::setModelChangeCallback(ResourceModelUpdate
 
 bool SimulatorCollectionResourceImpl::isObservable() const
 {
-    return (m_property & OC_OBSERVABLE);
+    return ((m_property & OC_OBSERVABLE) == OC_OBSERVABLE);
 }
 
 bool SimulatorCollectionResourceImpl::isDiscoverable() const
 {
-    return (m_property & OC_DISCOVERABLE);
+    return ((m_property & OC_DISCOVERABLE) == OC_DISCOVERABLE);
 }
 
 bool SimulatorCollectionResourceImpl::isStarted() const
@@ -596,8 +597,8 @@ void SimulatorCollectionResourceImpl::addLink(const SimulatorResourceSP &resourc
         std::string linkURI = link.get<std::string>("href");
         if (linkURI == resource->getURI())
         {
-            break;
             found = true;
+            break;
         }
     }
 
index eae3066..fb73db7 100755 (executable)
@@ -142,18 +142,36 @@ std::shared_ptr<SimulatorResource> SimulatorResourceFactory::buildResource(
     std::string resourceURI = ramlResource->getResourceUri();\r
     std::string resourceName = ramlResource->getDisplayName();\r
     std::string resourceType;\r
+\r
+    // Extracting resource type.\r
     if (resourceModel.contains("rt"))\r
     {\r
         resourceType = resourceModel.get<std::string>("rt");\r
         resourceModel.remove("rt");\r
     }\r
-\r
-    if (resourceModel.contains("resourceType"))\r
+    else if (resourceModel.contains("resourceType"))\r
     {\r
         resourceType = resourceModel.get<std::string>("resourceType");\r
         resourceModel.remove("resourceType");\r
     }\r
 \r
+    // Construct resource type from uri\r
+    if(resourceType.empty())\r
+    {\r
+        std::ostringstream rtString;\r
+        rtString << "oic.r.";\r
+\r
+        size_t pos = resourceURI.rfind("/");\r
+        if (pos == std::string::npos)\r
+            pos = -1;\r
+\r
+        std::string rtName = resourceURI.substr(pos+1);\r
+        std::transform(rtName.begin(), rtName.end(), rtName.begin(), ::tolower);\r
+        rtString << rtName;\r
+        resourceType = rtString.str();\r
+    }\r
+\r
+    // Extracting interface type.\r
     std::vector<std::string> interfaceTypes;\r
     if (resourceModel.contains("if"))\r
     {\r
@@ -162,19 +180,28 @@ std::shared_ptr<SimulatorResource> SimulatorResourceFactory::buildResource(
         {\r
             interfaceTypes.push_back(resourceModel.get<std::string>("if"));\r
         }\r
-        else if(AttributeValueType::STRING == typeInfo.baseType()\r
-            && AttributeValueType::VECTOR == typeInfo.type()\r
+        else if(AttributeValueType::VECTOR == typeInfo.type()\r
+            && AttributeValueType::STRING == typeInfo.baseType()\r
             && typeInfo.depth() == 1)\r
         {\r
             interfaceTypes = resourceModel.get<std::vector<std::string>>("if");\r
+            if (interfaceTypes.size() > 1)\r
+                interfaceTypes.erase(interfaceTypes.begin()+1, interfaceTypes.end());\r
         }\r
-        else\r
+\r
+        resourceModel.remove("if");\r
+    }\r
+\r
+    for (auto &requestModel : requestModels)\r
+    {\r
+        if (requestModel.second)\r
         {\r
-            return nullptr;\r
+            addInterfaceFromQueryParameter((requestModel.second)->getQueryParams("if"),\r
+                interfaceTypes);\r
         }\r
-        resourceModel.remove("if");\r
     }\r
 \r
+    // Remove properties which are not part of resource representation\r
     resourceModel.remove("p");\r
     resourceModel.remove("n");\r
     resourceModel.remove("id");\r
@@ -188,7 +215,8 @@ std::shared_ptr<SimulatorResource> SimulatorResourceFactory::buildResource(
 \r
         collectionRes->setName(resourceName);\r
         collectionRes->setResourceType(resourceType);\r
-        collectionRes->setInterface(interfaceTypes);\r
+        if (interfaceTypes.size() > 0)\r
+            collectionRes->setInterface(interfaceTypes);\r
         collectionRes->setURI(ResourceURIFactory::getInstance()->makeUniqueURI(resourceURI));\r
 \r
         // Set the resource model and its schema to simulated resource\r
@@ -205,7 +233,8 @@ std::shared_ptr<SimulatorResource> SimulatorResourceFactory::buildResource(
 \r
         singleRes->setName(resourceName);\r
         singleRes->setResourceType(resourceType);\r
-        singleRes->setInterface(interfaceTypes);\r
+        if (interfaceTypes.size() > 0)\r
+            singleRes->setInterface(interfaceTypes);\r
         singleRes->setURI(ResourceURIFactory::getInstance()->makeUniqueURI(resourceURI));\r
 \r
         // Set the resource model and its schema to simulated resource\r
@@ -219,6 +248,19 @@ std::shared_ptr<SimulatorResource> SimulatorResourceFactory::buildResource(
     return simResource;\r
 }\r
 \r
+void SimulatorResourceFactory::addInterfaceFromQueryParameter(\r
+    std::vector<std::string> queryParamValue, std::vector<std::string> &interfaceTypes)\r
+{\r
+    for (auto &interfaceType : queryParamValue)\r
+    {\r
+        if (interfaceTypes.end() ==\r
+            std::find(interfaceTypes.begin(), interfaceTypes.end(), interfaceType))\r
+        {\r
+            interfaceTypes.push_back(interfaceType);\r
+        }\r
+    }\r
+}\r
+\r
 ResourceURIFactory *ResourceURIFactory::getInstance()\r
 {\r
     static ResourceURIFactory s_instance;\r
index eef0b4f..7e489e3 100755 (executable)
@@ -91,6 +91,9 @@ class SimulatorResourceFactory
         std::shared_ptr<SimulatorResource> buildResource(
             const std::shared_ptr<RAML::RamlResource> &ramlResource);
 
+        void addInterfaceFromQueryParameter(
+            std::vector<std::string> queryParamValue, std::vector<std::string> &interfaceTypes);
+
         SimulatorResourceFactory() = default;
         SimulatorResourceFactory(const SimulatorResourceFactory &) = delete;
         SimulatorResourceFactory &operator=(const SimulatorResourceFactory &) = delete;
index 3b04d8c..f33a225 100755 (executable)
 #define TAG "SIMULATOR_SINGLE_RESOURCE"
 
 SimulatorSingleResourceImpl::SimulatorSingleResourceImpl()
-    :   m_resourceHandle(nullptr)
 {
     m_type = SimulatorResource::Type::SINGLE_RESOURCE;
     m_interfaces.push_back(OC::DEFAULT_INTERFACE);
     m_property = static_cast<OCResourceProperty>(OC_DISCOVERABLE | OC_OBSERVABLE);
     m_resModelSchema = SimulatorResourceModelSchema::build();
+
+    // Set resource supports GET, PUT and POST by default
+    m_requestModels["GET"] = nullptr;
+    m_requestModels["POST"] = nullptr;
+    m_requestModels["PUT"] = nullptr;
+
+    m_resourceHandle = nullptr;
 }
 
 void SimulatorSingleResourceImpl::setName(const std::string &name)
@@ -55,7 +61,6 @@ void SimulatorSingleResourceImpl::setURI(const std::string &uri)
     m_uri = uri;
 }
 
-// TODO: Support adding multiple resource types for a resource
 void SimulatorSingleResourceImpl::setResourceType(const std::string &resourceType)
 {
     VALIDATE_INPUT(resourceType.empty(), "Resource type is empty!")
@@ -70,7 +75,6 @@ void SimulatorSingleResourceImpl::setResourceType(const std::string &resourceTyp
     m_resourceType = resourceType;
 }
 
-// TODO:  Assuming baseline is not mandatory to be present always.
 void SimulatorSingleResourceImpl::setInterface(const std::string &interfaceType)
 {
     VALIDATE_INPUT(interfaceType.empty(), "Interface type list is empty!")
@@ -85,7 +89,6 @@ void SimulatorSingleResourceImpl::setInterface(const std::string &interfaceType)
     m_interfaces = {interfaceType};
 }
 
-// TODO:  Assuming baseline is not mandatory to be present always.
 void SimulatorSingleResourceImpl::setInterface(const std::vector<std::string> &interfaceTypes)
 {
     VALIDATE_INPUT(interfaceTypes.empty(), "Interface type list is empty!")
@@ -97,9 +100,15 @@ void SimulatorSingleResourceImpl::setInterface(const std::vector<std::string> &i
                                  "Resource interface can not be reset when resource is started!");
     }
 
-    m_interfaces = interfaceTypes;
-    auto lastElement = std::unique(m_interfaces.begin(), m_interfaces.end());
-    m_interfaces.erase(lastElement, m_interfaces.end());
+    m_interfaces.clear();
+    for (auto &interfaceType : interfaceTypes)
+    {
+        if (m_interfaces.end() ==
+            std::find(m_interfaces.begin(), m_interfaces.end(), interfaceType))
+        {
+            m_interfaces.push_back(interfaceType);
+        }
+    }
 }
 
 void SimulatorSingleResourceImpl::addInterface(const std::string &interfaceType)
@@ -108,7 +117,8 @@ void SimulatorSingleResourceImpl::addInterface(const std::string &interfaceType)
 
     if (m_interfaces.end() != std::find(m_interfaces.begin(), m_interfaces.end(), interfaceType))
     {
-        SIM_LOG(ILogger::ERROR, "Resource already supporting this Interface: " << interfaceType);
+        SIM_LOG(ILogger::ERROR, "[" << m_uri << "] "
+                << "Resource already supporting this Interface: " << interfaceType)
         return;
     }
 
@@ -170,12 +180,12 @@ void SimulatorSingleResourceImpl::setModelChangeCallback(ResourceModelUpdateCall
 
 bool SimulatorSingleResourceImpl::isObservable() const
 {
-    return (m_property & OC_OBSERVABLE);
+    return ((m_property & OC_OBSERVABLE) == OC_OBSERVABLE);
 }
 
 bool SimulatorSingleResourceImpl::isDiscoverable() const
 {
-    return (m_property & OC_DISCOVERABLE);
+    return ((m_property & OC_DISCOVERABLE) == OC_DISCOVERABLE);
 }
 
 bool SimulatorSingleResourceImpl::isStarted() const
@@ -188,7 +198,7 @@ void SimulatorSingleResourceImpl::start()
     std::lock_guard<std::recursive_mutex> lock(m_objectLock);
     if (m_resourceHandle)
     {
-        SIM_LOG(ILogger::INFO, "[" << m_name << "] " << "Resource already started!")
+        SIM_LOG(ILogger::ERROR, "[" << m_uri << "] " << "Resource already started!")
         return;
     }
 
@@ -229,7 +239,7 @@ void SimulatorSingleResourceImpl::stop()
     std::lock_guard<std::recursive_mutex> lock(m_objectLock);
     if (!m_resourceHandle)
     {
-        SIM_LOG(ILogger::INFO, "[" << m_name << "] " << "Resource is not started yet!")
+        SIM_LOG(ILogger::ERROR, "[" << m_uri << "] " << "Resource is not started yet!")
         return;
     }
 
@@ -325,17 +335,31 @@ bool SimulatorSingleResourceImpl::addAttribute(
         return false;
     }
 
+    // Add attribute to resource representation and its schema
     std::lock_guard<std::recursive_mutex> modelLock(m_modelLock);
     std::lock_guard<std::mutex> schemaLock(m_modelSchemaLock);
 
-    if (!m_resModel.contains(attribute.getName()))
+    if (!m_resModel.add(attribute.getName(), attribute.getValue()))
     {
-        m_resModel.add(attribute.getName(), attribute.getValue());
-        m_resModelSchema->add(attribute.getName(), attribute.getProperty());
-        return true;
+        return false;
     }
 
-    return false;
+    m_resModelSchema->add(attribute.getName(), attribute.getProperty());
+
+    if (notify && isStarted())
+    {
+        try
+        {
+            notifyAll();
+        }
+        catch (SimulatorException &e)
+        {
+            SIM_LOG(ILogger::ERROR, "[" << m_uri << "] " << "Error when notifying the observers!")
+        }
+        notifyApp();
+    }
+
+    return true;
 }
 
 bool SimulatorSingleResourceImpl::updateAttributeValue(
@@ -346,25 +370,35 @@ bool SimulatorSingleResourceImpl::updateAttributeValue(
         return false;
     }
 
+    // Validate the new value against attribute schema property
+    std::lock_guard<std::mutex> schemaLock(m_modelSchemaLock);
+    auto property = m_resModelSchema->get(attribute.getName());
+    if (!(property->validate(attribute.getValue())))
+    {
+        return false;
+    }
+
+    // Update the attribute value
     std::lock_guard<std::recursive_mutex> modelLock(m_modelLock);
-    if (m_resModel.update(attribute.getName(), attribute.getValue()))
+    if (!m_resModel.update(attribute.getName(), attribute.getValue()))
     {
-        if (notify && isStarted())
+        return false;
+    }
+
+    if (notify && isStarted())
+    {
+        try
         {
-            try
-            {
-                notifyAll();
-            }
-            catch (SimulatorException &e)
-            {
-                SIM_LOG(ILogger::ERROR, "Error when notifying the observers.")
-            }
-            notifyApp();
+            notifyAll();
         }
-        return true;
+        catch (SimulatorException &e)
+        {
+            SIM_LOG(ILogger::ERROR, "[" << m_uri << "] " << "Error when notifying the observers!")
+        }
+        notifyApp();
     }
 
-    return false;
+    return true;
 }
 
 bool SimulatorSingleResourceImpl::removeAttribute(
@@ -375,10 +409,28 @@ bool SimulatorSingleResourceImpl::removeAttribute(
         return false;
     }
 
+    // Remove attribute from resource representation and its schema
     std::lock_guard<std::recursive_mutex> modelLock(m_modelLock);
     std::lock_guard<std::mutex> schemaLock(m_modelSchemaLock);
-    m_resModel.remove(attrName);
+
     m_resModelSchema->remove(attrName);
+    if (!m_resModel.remove(attrName))
+    {
+        return false;
+    }
+
+    if (notify && isStarted())
+    {
+        try
+        {
+            notifyAll();
+        }
+        catch (SimulatorException &e)
+        {
+            SIM_LOG(ILogger::ERROR, "[" << m_uri << "] " << "Error when notifying the observers!")
+        }
+        notifyApp();
+    }
 
     return true;
 }
@@ -522,7 +574,7 @@ bool SimulatorSingleResourceImpl::updateResourceModel(const SimulatorResourceMod
         }
         catch (SimulatorException &e)
         {
-            SIM_LOG(ILogger::ERROR, "Error when notifying the observers.")
+            SIM_LOG(ILogger::ERROR, "[" << m_uri << "] " << "Error when notifying the observers!")
         }
         notifyApp();
     }
@@ -581,7 +633,6 @@ void SimulatorSingleResourceImpl::setCommonProperties(OC::OCRepresentation &ocRe
     std::lock_guard<std::recursive_mutex> lock(m_objectLock);
     ocResRep.setValue("rt", m_resourceType);
     ocResRep.setValue("if", m_interfaces);
-    // TODO: How to set property "p" ????
     ocResRep.setValue("n", m_name);
 }
 
@@ -602,7 +653,7 @@ OCEntityHandlerResult SimulatorSingleResourceImpl::handleRequests(
         {
             OC::OCRepresentation rep = request->getResourceRepresentation();
             std::string payload = getPayloadString(rep);
-            SIM_LOG(ILogger::INFO, "[" << m_name << "] " << request->getRequestType()
+            SIM_LOG(ILogger::INFO, "[" << m_uri << "] " << request->getRequestType()
                     << " request received. \n**Payload details**\n" << payload)
         }
 
@@ -632,14 +683,16 @@ OCEntityHandlerResult SimulatorSingleResourceImpl::handleRequests(
         if (OC::ObserveAction::ObserveRegister == observationInfo.action)
         {
             addObserver(observationInfo);
-            SIM_LOG(ILogger::INFO, "[" << m_uri << "] Observer added [id: " << observationInfo.obsId <<
-                    ", address: " << observationInfo.address << "port: " << observationInfo.port << "]");
+            SIM_LOG(ILogger::INFO, "[" << m_uri << "] Observer added [id: "
+                    << (int)observationInfo.obsId << ", address: " << observationInfo.address
+                    << ", port: " << observationInfo.port << "].");
         }
         else if (OC::ObserveAction::ObserveUnregister == observationInfo.action)
         {
             removeObserver(observationInfo);
-            SIM_LOG(ILogger::INFO, "[" << m_uri << "] Observer removed [id: " << observationInfo.obsId <<
-                    ", address: " << observationInfo.address << "port: " << observationInfo.port << "]");
+            SIM_LOG(ILogger::INFO, "[" << m_uri << "] Observer removed [id: "
+                    << (int)observationInfo.obsId << ", address: " << observationInfo.address
+                    << ", port: " << observationInfo.port << "].");
         }
     }
 
@@ -691,12 +744,11 @@ OCEntityHandlerResult SimulatorSingleResourceImpl::handleGET(
     // Check if resource support GET request
     if (m_requestModels.end() == m_requestModels.find("GET"))
     {
-        SIM_LOG(ILogger::INFO, "Resource does not support GET request!")
+        SIM_LOG(ILogger::ERROR, "[" << m_uri << "] "
+                << "Resource does not support GET request!")
         return sendResponse(request, 405, OC_EH_ERROR);
     }
 
-    RequestModelSP requestModel = m_requestModels["GET"];
-
     // Handling interface query parameter "if"
     auto interfaceType = m_interfaces[0];
     auto requestQueryParams = request->getQueryParameters();
@@ -707,7 +759,8 @@ OCEntityHandlerResult SimulatorSingleResourceImpl::handleGET(
 
     if (!isValidInterface(interfaceType, "GET"))
     {
-        SIM_LOG(ILogger::INFO, "Invalid interface type: " << interfaceType)
+        SIM_LOG(ILogger::ERROR, "[" << m_uri << "] "
+                << "GET request received on invalid interface : " << interfaceType)
         return OC_EH_ERROR;
     }
 
@@ -721,16 +774,7 @@ OCEntityHandlerResult SimulatorSingleResourceImpl::handleGET(
         setCommonProperties(resourceRep);
     }
 
-    if (OC_EH_OK == sendResponse(request, 200, OC_EH_OK, resourceRep, interfaceType))
-    {
-        SIM_LOG(ILogger::INFO, "[" << m_uri <<
-                "] Sent response for GET request \n**Payload details**" <<
-                getPayloadString(resourceRep))
-        return OC_EH_OK;
-    }
-
-    SIM_LOG(ILogger::INFO, "[" << m_uri << "] Failed to send response for GET request!")
-    return OC_EH_ERROR;
+    return sendResponse(request, 200, OC_EH_OK, resourceRep, interfaceType);
 }
 
 OCEntityHandlerResult SimulatorSingleResourceImpl::handlePUT(
@@ -739,12 +783,11 @@ OCEntityHandlerResult SimulatorSingleResourceImpl::handlePUT(
     // Check if resource support PUT request
     if (m_requestModels.end() == m_requestModels.find("PUT"))
     {
-        SIM_LOG(ILogger::INFO, "Resource does not support PUT request!")
+        SIM_LOG(ILogger::ERROR, "[" << m_uri << "] "
+                << "Resource does not support PUT request!")
         return sendResponse(request, 405, OC_EH_ERROR);
     }
 
-    RequestModelSP requestModel = m_requestModels["PUT"];
-
     // Handling interface query parameter "if"
     auto interfaceType = m_interfaces[0];
     auto requestQueryParams = request->getQueryParameters();
@@ -755,24 +798,34 @@ OCEntityHandlerResult SimulatorSingleResourceImpl::handlePUT(
 
     if (!isValidInterface(interfaceType, "PUT"))
     {
-        SIM_LOG(ILogger::INFO, "Invalid interface type: " << interfaceType)
+        SIM_LOG(ILogger::ERROR, "[" << m_uri << "] "
+                << "PUT request received on invalid interface : " << interfaceType)
         return OC_EH_ERROR;
     }
 
     OC::OCRepresentation reqOcRep = request->getResourceRepresentation();
     SimulatorResourceModel reqResModel = SimulatorResourceModel::build(reqOcRep);
     SimulatorResourceModel updatedResModel;
-    if (true == updateResourceModel(reqResModel, updatedResModel, true))
+    if (true == updateResourceModel(reqResModel, updatedResModel, true, false))
     {
         auto ocRep = updatedResModel.asOCRepresentation();
         auto result = sendResponse(request, 200, OC_EH_OK,
                                    ocRep, m_interfaces[0]);
         notifyApp(updatedResModel);
-        notifyAll();
+        try
+        {
+            notifyAll();
+        }
+        catch (SimulatorException &e)
+        {
+            SIM_LOG(ILogger::ERROR, "[" << m_uri << "] "
+                    << "Error when notifying the observers!")
+        }
+
         return result;
     }
 
-    SIM_LOG(ILogger::ERROR, "Updating resource representation failed!");
+    SIM_LOG(ILogger::ERROR, "[" << m_uri << "] " << "Updating resource representation failed!")
     return sendResponse(request, 400, OC_EH_ERROR);
 }
 
@@ -782,12 +835,11 @@ OCEntityHandlerResult SimulatorSingleResourceImpl::handlePOST(
     // Check if resource support PUT request
     if (m_requestModels.end() == m_requestModels.find("POST"))
     {
-        SIM_LOG(ILogger::INFO, "Resource does not support POST request!")
+        SIM_LOG(ILogger::ERROR, "[" << m_uri << "] "
+                << "Resource does not support POST request!")
         return sendResponse(request, 405, OC_EH_ERROR);
     }
 
-    RequestModelSP requestModel = m_requestModels["POST"];
-
     // Handling interface query parameter "if"
     auto interfaceType = m_interfaces[0];
     auto requestQueryParams = request->getQueryParameters();
@@ -798,31 +850,43 @@ OCEntityHandlerResult SimulatorSingleResourceImpl::handlePOST(
 
     if (!isValidInterface(interfaceType, "POST"))
     {
-        SIM_LOG(ILogger::INFO, "Invalid interface type: " << interfaceType)
+        SIM_LOG(ILogger::ERROR, "[" << m_uri << "] "
+                << "POST request received on invalid interface : " << interfaceType)
         return OC_EH_ERROR;
     }
 
     OC::OCRepresentation reqOcRep = request->getResourceRepresentation();
     SimulatorResourceModel reqResModel = SimulatorResourceModel::build(reqOcRep);
     SimulatorResourceModel updatedResModel;
-    if (true == updateResourceModel(reqResModel, updatedResModel))
+    if (true == updateResourceModel(reqResModel, updatedResModel, false, false))
     {
         auto ocRep = updatedResModel.asOCRepresentation();
         auto result = sendResponse(request, 200, OC_EH_OK,
                                    ocRep, m_interfaces[0]);
         notifyApp(updatedResModel);
-        notifyAll();
+        try
+        {
+            notifyAll();
+        }
+        catch (SimulatorException &e)
+        {
+            SIM_LOG(ILogger::ERROR, "[" << m_uri << "] "
+                    << "Error when notifying the observers!")
+        }
+
         return result;
     }
 
-    SIM_LOG(ILogger::ERROR, "Updating resource representation failed!");
+    SIM_LOG(ILogger::ERROR, "[" << m_uri << "] " << "Updating resource representation failed!")
     return sendResponse(request, 400, OC_EH_ERROR);
 }
 
 OCEntityHandlerResult SimulatorSingleResourceImpl::handleDELETE(
     const std::shared_ptr<OC::OCResourceRequest> &request)
 {
-    return OC_EH_ERROR;
+    SIM_LOG(ILogger::ERROR, "[" << m_uri << "] "
+            << "Resource does not support DELETE request!")
+    return sendResponse(request, 405, OC_EH_ERROR);;
 }
 
 bool SimulatorSingleResourceImpl::isValidInterface(const std::string &interfaceType,
@@ -857,15 +921,20 @@ OCEntityHandlerResult SimulatorSingleResourceImpl::sendResponse(
     response->setResponseResult(responseResult);
     if (OC_STACK_OK != OC::OCPlatform::sendResponse(response))
     {
+        SIM_LOG(ILogger::ERROR, "[" << m_uri << "] Failed to send response for " <<
+            request->getRequestType() <<" request!")
         return OC_EH_ERROR;
     }
 
+    SIM_LOG(ILogger::INFO, "[" << m_uri << "] Sent response for " <<
+        request->getRequestType() << " request.")
+
     return OC_EH_OK;
 }
 
 OCEntityHandlerResult SimulatorSingleResourceImpl::sendResponse(
     const std::shared_ptr<OC::OCResourceRequest> &request, const int errorCode,
-    OCEntityHandlerResult responseResult, OC::OCRepresentation &Payload,
+    OCEntityHandlerResult responseResult, OC::OCRepresentation &payload,
     const std::string &interfaceType)
 {
     std::shared_ptr<OC::OCResourceResponse> response(new OC::OCResourceResponse());
@@ -873,11 +942,17 @@ OCEntityHandlerResult SimulatorSingleResourceImpl::sendResponse(
     response->setResourceHandle(request->getResourceHandle());
     response->setErrorCode(errorCode);
     response->setResponseResult(responseResult);
-    response->setResourceRepresentation(Payload, interfaceType);
+    response->setResourceRepresentation(payload, interfaceType);
     if (OC_STACK_OK != OC::OCPlatform::sendResponse(response))
     {
+        SIM_LOG(ILogger::ERROR, "[" << m_uri << "] Failed to send response for " <<
+            request->getRequestType() <<" request!")
         return OC_EH_ERROR;
     }
 
+    SIM_LOG(ILogger::INFO, "[" << m_uri << "] Sent response for " <<
+        request->getRequestType() << " request \n\n" <<
+        "**Payload details**" << getPayloadString(payload))
+
     return OC_EH_OK;
 }
index 37128eb..88e8cf9 100644 (file)
@@ -9,7 +9,7 @@ profile = profile.tizen
 #passwd =
 obs = obs.tizen
 #Comma separated list of repositories
-repos = repo.tizen_latest
+repos = repo.public_latest, repo.devel-gcc49-base, 
 #repos = repo.tizen_main, repo.tizen_base
 #Build config for gbs build
 #buildconf = <patch/to/build-config-file>
@@ -25,15 +25,12 @@ url = https://api.tizen.org
 #passwd =
 
 #Repo section example
-[repo.tizen_latest]
+[repo.public_latest]
 #Build against repo's URL
-url = http://download.tizen.org/releases/2.3/2.3-mobile/tizen-2.3-mobile_20150206.1/repos/target/packages/
+url = http://download.tizen.org/snapshots/2.4-mobile/common/latest/repos/target-TM1/packages/
 #Optional user and password, set if differ from profile's user and password
 #user =
 #passwd =
 
-#Individual repo is also supported
-#[repo.tizen_base]
-#url = http://download.tizen.org/releases/daily/trunk/ivi/latest/repos/base/ia32/packages/
-#[repo.tizen_main]
-#url = http://download.tizen.org/releases/daily/trunk/ivi/latest/repos/ivi/ia32/packages/
+[repo.devel-gcc49-base]
+url = http://download.tizen.org/releases/2.4/2.4-base/tizen-2.4-base_20151027.1/repos/standard/packages/