Fix for the issue of factory reset feature of things-manager not working. 41/841/2
authorHarish Kumara Marappa <h.marappa@samsung.com>
Mon, 27 Apr 2015 14:45:31 +0000 (20:15 +0530)
committerUze Choi <uzchoi@samsung.com>
Tue, 28 Apr 2015 01:14:34 +0000 (01:14 +0000)
Things-manager service sends factory reset request to collection using
ActionSet structure. When user calls factory reset second time it was not
working as the ActionSet executed for first request had not been deleted.
Modified the thingsDiagnostic class for deleting the factoryReset
actionset everytime after its execution.

Change-Id: I312a0126a48ebd6dda6e5e887daed6f2a797de67
Signed-off-by: Harish Kumara Marappa <h.marappa@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/841
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/things-manager/sdk/src/ThingsDiagnostics.cpp
service/things-manager/sdk/src/ThingsDiagnostics.h

index 524c197..03ca932 100755 (executable)
@@ -299,8 +299,32 @@ namespace OIC
         }
 
         std::cout << "PUT request was successful" << std::endl;
-
         getCallback(diag)(headerOptions, rep, eCode);
+
+        // Delete the created actionset
+        std::shared_ptr < OCResource > resource = getResource(diag);
+        if (resource)
+        {
+            g_groupmanager->deleteActionSet(resource, diag,
+                    std::function<
+                            void(const HeaderOptions& headerOptions,
+                                    const OCRepresentation& rep, const int eCode) >(
+                            std::bind(&ThingsDiagnostics::onDeleteGroupAction, this,
+                                    std::placeholders::_1, std::placeholders::_2,
+                                    std::placeholders::_3, diag)));
+        }
+    }
+
+    void ThingsDiagnostics::onDeleteGroupAction(const HeaderOptions& headerOptions,
+            const OCRepresentation& rep, const int eCode, std::string diag)
+    {
+        if (eCode != OC_STACK_OK)
+        {
+            std::cout << "Delete actionset returned with error: " << eCode << diag << std::endl;
+            return;
+        }
+
+        std::cout << "Deleted the actionset created!" << diag<< std::endl;
     }
 
     void ThingsDiagnostics::onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep,
index 024a2d9..a144470 100755 (executable)
@@ -162,6 +162,8 @@ namespace OIC
 
         void onExecuteForGroupAction(const HeaderOptions& headerOptions,
                 const OCRepresentation& rep, const int eCode, std::string conf);
+        void onDeleteGroupAction(const HeaderOptions& headerOptions,
+                const OCRepresentation& rep, const int eCode, std::string conf);
         void onGetChildInfoForUpdate(const HeaderOptions& headerOptions,
                 const OCRepresentation& rep, const int eCode, std::string conf);
         void onCreateActionSet(const HeaderOptions& headerOptions, const OCRepresentation& rep,