Fix minor issue for Group Action of ThingsManager.
authorHyunJun Kim <hyunjun2.kim@samsung.com>
Thu, 2 Apr 2015 07:07:55 +0000 (16:07 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 3 Apr 2015 01:44:50 +0000 (01:44 +0000)
addActionSet and executeActionSet do not return error message when entered invalid parameters.
In this case, we return 'OC_STACK_INVALID_PARAM'.

getActionSetfromString didn't return when entered malformed string.
It will be returned NULL in this case.

Change-Id: Ifd28640d6aca6714646b33ea8fb69c55f8ca36f7
Signed-off-by: HyunJun Kim <hyunjun2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/631
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/things-manager/sdk/src/GroupManager.cpp

index 40f7b45..e418b87 100755 (executable)
@@ -502,6 +502,13 @@ ActionSet* GroupManager::getActionSetfromString(std::string description)
 
     Capability *capa = NULL;
     ActionSet *actionset = new ActionSet();
+
+
+    if( description.at(0) == '*')
+    {
+        goto exit;
+    }
+
     plainText = new char[(description.length() + 1)];
     strcpy(plainText, description.c_str());
 
@@ -629,6 +636,11 @@ OCStackResult GroupManager::addActionSet(std::shared_ptr< OCResource > resource,
     // BUILD message of ActionSet which it is included delimiter.
     if ((resource != NULL) && (newActionSet != NULL))
     {
+        if(newActionSet->mDelay < 0)
+        {
+            return OC_STACK_INVALID_PARAM; 
+        }
+
         std::string message = getStringFromActionSet(newActionSet);
 
         OCRepresentation rep;
@@ -662,7 +674,7 @@ OCStackResult GroupManager::executeActionSet(std::shared_ptr< OCResource > resou
 OCStackResult GroupManager::executeActionSet(std::shared_ptr< OCResource > resource,
         std::string actionsetName, long int delay, PostCallback cb)
 {
-    if(delay == 0 )
+    if(delay <= 0 )
     {
         return OC_STACK_INVALID_PARAM;
     }