String Constant changes
authorChris Mitchell <chris.mitchell@intel.com>
Tue, 14 Oct 2014 23:46:57 +0000 (16:46 -0700)
committerChris Mitchell <chris.mitchell@intel.com>
Wed, 15 Oct 2014 23:03:21 +0000 (16:03 -0700)
Change-Id: Ib90cc60fdd5c2ee44a697249af448e07116d75e8

include/InitializeException.h
include/OCApi.h
include/OCResourceRequest.h
include/ResourceInitException.h
include/StringConstants.h [new file with mode: 0644]
include/WrapperFactory.h
src/InProcClientWrapper.cpp
src/InProcServerWrapper.cpp
src/OCException.cpp
src/OCResource.cpp

index d189f38..c6eed56 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <stdexcept>
 #include <ocstack.h>
+#include "StringConstants.h"
 
 namespace OC
 {
@@ -48,21 +49,21 @@ namespace OC
             switch(m_reason)
             {
             case OC_STACK_OK:
-                return "No Error";
+                return OC::InitException::NO_ERROR;
             case OC_STACK_INVALID_URI:
-                return "Invalid URI";
+                return OC::InitException::INVALID_URI;
             case OC_STACK_INVALID_IP:
-                return "Invalid IP";
+                return OC::InitException::INVALID_IP;
             case OC_STACK_INVALID_PORT:
-                return "Invalid Port";
+                return OC::InitException::INVALID_PORT;
             case OC_STACK_INVALID_CALLBACK:
-                return "Invalid Callback";
+                return OC::InitException::INVALID_CB;
             case OC_STACK_INVALID_METHOD:
-                return "Invalid Method";
+                return OC::InitException::INVALID_METHOD;
             case OC_STACK_ERROR:
-                return "General Fault";
+                return OC::InitException::GENERAL_FAULT;
             default:
-                return "Unknown Error";
+                return OC::InitException::UNKNOWN_ERROR;
             }
         }
 
@@ -72,4 +73,4 @@ namespace OC
     };
 }
 
-#endif
\ No newline at end of file
+#endif
index c041be6..30f9e4a 100644 (file)
@@ -35,7 +35,7 @@
 #include "ocstack.h"
 #include "OCHeaderOption.h"
 #include <OCException.h>
-
+#include "StringConstants.h"
 #include "oc_logger.hpp"
 
 namespace OC
@@ -531,7 +531,7 @@ namespace OC
                 }
                 else
                 {
-                    throw OCException("Array type should have at least []");
+                    throw OCException(OC::Exception::INVALID_ARRAY);
                 }
 
             }
@@ -553,7 +553,7 @@ namespace OC
                 }
                 else
                 {
-                    throw OCException("Array type should have at least []");
+                    throw OCException(OC::Exception::INVALID_ARRAY);
                 }
             }
 
@@ -575,7 +575,7 @@ namespace OC
                 }
                 else
                 {
-                    throw OCException("Array type should have at least []");
+                    throw OCException(OC::Exception::INVALID_ARRAY);
                 }
 
             }
@@ -598,7 +598,7 @@ namespace OC
                 }
                 else
                 {
-                    throw OCException("Array type should have at least []");
+                    throw OCException(OC::Exception::INVALID_ARRAY);
                 }
             }
 
@@ -620,7 +620,7 @@ namespace OC
                 }
                 else
                 {
-                    throw OCException("Array type should have at least []");
+                    throw OCException(OC::Exception::INVALID_ARRAY);
                 }
             }
 
index dffcfd0..890a4a7 100644 (file)
@@ -150,7 +150,7 @@ namespace OC
 
             // TODO this expects the representation oc:{} and not oc:[{}]
             //      this representation is fine when setting for simple resource.
-            boost::property_tree::ptree payload = root.get_child("oc", boost::property_tree::ptree());
+            boost::property_tree::ptree payload = root.get_child(OC::Key::OCKEY, boost::property_tree::ptree());
 
             for(auto& item: payload)
             {
index 8cca8c2..a3ebea6 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <stdexcept>
 #include <ocstack.h>
+#include "StringConstants.h"
 
 namespace OC
 {
@@ -60,22 +61,22 @@ namespace OC
 
             if(isUriMissing())
             {
-                ret += "Missing URI;";
+                ret += OC::InitException::MISSING_URI;
             }
 
             if(isTypeMissing())
             {
-                ret += "Missing Resource Type;";
+                ret += OC::InitException::MISSING_TYPE;
             }
 
             if(isInterfaceMissing())
             {
-                ret += "Missing Interface;";
+                ret += OC::InitException::MISSING_INTERFACE;
             }
 
             if(isClientWrapperMissing())
             {
-                ret += "Missing ClientWrapper;";
+                ret += OC::InitException::MISSING_CLIENT_WRAPPER;
             }
 
             return ret.c_str();
diff --git a/include/StringConstants.h b/include/StringConstants.h
new file mode 100644 (file)
index 0000000..24c985f
--- /dev/null
@@ -0,0 +1,119 @@
+//******************************************************************
+//
+// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef _STRING_CONSTANTS_H_
+#define _STRING_CONSTANTS_H_
+
+#include <string>
+
+using namespace std;
+
+namespace OC
+{
+    namespace InitException
+    {
+        static const std::string NO_ERROR                   = "No Error";
+        static const std::string INVALID_URI                = "Invalid URI";
+        static const std::string INVALID_PORT               = "Invalid Port";
+        static const std::string INVALID_IP                 = "Invalid IP";
+        static const std::string INVALID_CB                 = "Invalid Callback";
+        static const std::string INVALID_METHOD             = "Invalid Method";
+        static const std::string GENERAL_FAULT              = "General Fault";
+        static const std::string UNKNOWN_ERROR              = "Unknown Error";
+
+        static const std::string STACK_INIT_ERROR           = "Error Initializing Stack";
+        static const std::string NOT_CONFIGURED_AS_SERVER   =
+                          "Cannot static construct a Server when configured as a client";
+        static const std::string INVALID_PARAM              = "Invalid Param";
+        static const std::string MISSING_URI                = "Missing URI;";
+        static const std::string MISSING_TYPE               = "Missing Resource Type;";
+        static const std::string MISSING_INTERFACE          = "Missing Interface;";
+        static const std::string MISSING_CLIENT_WRAPPER     = "Missing ClientWrapper;";
+    }
+
+    namespace Exception // Not To Be Confused With 'InitException'
+    {
+        static const std::string SVCTYPE_OUTOFPROC          = "ServiceType::OutOfProc";
+        static const std::string BIND_TYPE_FAILED           = "Bind Type to resource failed";
+        static const std::string BIND_INTERFACE_FAILED      = "Bind Interface to resource failed";
+        static const std::string START_PRESENCE_FAILED      = "startPresence failed";
+        static const std::string END_PRESENCE_FAILED        = "stopPresence failed";
+        static const std::string INVALID_ARRAY              = "Array type should have at least []";
+        static const std::string STR_NULL_RESPONSE          = "Response is NULL";
+        static const std::string STR_PAYLOAD_OVERFLOW       = "Payload overflow";
+
+
+        static const std::string NO_ERROR                   = "No Error";
+        static const std::string RESOURCE_CREATED           = "Resource Created";
+        static const std::string RESOURCE_DELETED           = "Resource Deleted";
+        static const std::string INVALID_URI                = "Invalid URI";
+        static const std::string INVALID_IP                 = "Invalid IP";
+        static const std::string INVALID_PORT               = "Invalid Port";
+        static const std::string INVALID_CB                 = "Invalid Callback";
+        static const std::string INVALID_METHOD             = "Invalid Method";
+        static const std::string INVALID_QUERY              = "Invalid Query";
+        static const std::string INVALID_PARAM              = "Invalid Param";
+        static const std::string INVALID_OBESERVE           = "Invalid Observe Param";
+        static const std::string NO_MEMORY                  = "No Memory";
+        static const std::string COMM_ERROR                 = "Communication Error";
+        static const std::string NOT_IMPL                   = "Not Implemented";
+        static const std::string NOT_FOUND                  = "Resource Not Found";
+        static const std::string RESOURCE_ERROR             = "Resource Error";
+        static const std::string SLOW_RESOURCE              = "Slow Resource";
+        static const std::string NO_OBSERVERS               = "No Observers";
+        static const std::string OBSV_NO_FOUND              = "Stack observer not found";
+        static const std::string OBSV_NOT_ADDED             = "Stack observer not added";
+        static const std::string OBSV_NOT_REMOVED           = "Stack observer not removed";
+        static const std::string STACK_RESOURCE_DELETED     = "The specified resource has been deleted";
+        static const std::string PRESENCE_STOPPED           = "Stack presence stopped";
+        static const std::string PRESENCE_NOT_HANDLED       = "Stack presence should not be handled";
+        static const std::string INVALID_OPTION             = "Invalid option";
+        static const std::string GENERAL_FAULT              = "General Fault";
+        static const std::string MALFORMED_STACK_RESPONSE   = "Response from OC_STACK is malformed";
+        static const std::string UNKNOWN_ERROR              = "Unknown Error";
+    }
+
+    namespace Error
+    {
+        static const std::string INVALID_IP                 = "Invalid IP";
+    }
+
+    namespace PlatformCommands
+    {
+        static const std::string GET                        = "GET";
+        static const std::string PUT                        = "PUT";
+        static const std::string POST                       = "POST";
+        static const std::string DELETE                     = "DELETE";
+    }
+
+    namespace Key
+    {
+        static const std::string OCKEY                      = "oc";
+        static const std::string URIKEY                     = "href";
+        static const std::string OBSERVABLEKEY              = "obs";
+        static const std::string RESOURCETYPESKEY           = "rt";
+        static const std::string INTERFACESKEY              = "if";
+        static const std::string PROPERTYKEY                = "prop";
+        static const std::string REPKEY                     = "rep";
+    }
+
+}
+
+#endif // _STRING_CONSTANTS_H_
index 45e349c..c4923e4 100644 (file)
@@ -29,6 +29,7 @@
 #include <InProcClientWrapper.h>
 #include <OutOfProcServerWrapper.h>
 #include <InProcServerWrapper.h>
+#include "StringConstants.h"
 
 namespace OC
 {
@@ -75,7 +76,7 @@ namespace OC
                 return std::make_shared<InProcServerWrapper>(owner, csdkLock, cfg);
                 break;
             case ServiceType::OutOfProc:
-                throw OC::OCException("ServiceType::OutOfProc", OC_STACK_NOTIMPL);
+                throw OC::OCException(OC::Exception::SVCTYPE_OUTOFPROC, OC_STACK_NOTIMPL);
                 break;
             }
                        return nullptr;
index c875f63..e8a41f3 100644 (file)
@@ -45,7 +45,7 @@ namespace OC
 
             if(OC_STACK_OK != result)
             {
-                throw InitializeException("Error Initializing Stack", result);
+                throw InitializeException(OC::InitException::STACK_INIT_ERROR, result);
             }
 
             m_threadRun = true;
@@ -107,7 +107,7 @@ namespace OC
         }
         else
         {
-            return "INVALID IP";
+            return OC::Error::INVALID_IP;
         }
     }
 
@@ -119,34 +119,27 @@ namespace OC
     };
 
 
-    const std::string URIKEY = "href";
-    const std::string OBSERVABLEKEY = "obs";
-    const std::string RESOURCETYPESKEY= "rt";
-    const std::string INTERFACESKEY = "if";
-    const std::string PROPERTYKEY = "prop";
-    const std::string REPKEY = "rep";
-
     std::shared_ptr<OCResource> InProcClientWrapper::parseOCResource(
         IClientWrapper::Ptr clientWrapper, const std::string& host,
         const boost::property_tree::ptree resourceNode)
     {
-        std::string uri = resourceNode.get<std::string>(URIKEY, "");
-        bool obs = resourceNode.get<int>(OBSERVABLEKEY,0) == 1;
+        std::string uri = resourceNode.get<std::string>(OC::Key::URIKEY, "");
+        bool obs = resourceNode.get<int>(OC::Key::OBSERVABLEKEY,0) == 1;
         std::vector<std::string> rTs;
         std::vector<std::string> ifaces;
 
         boost::property_tree::ptree properties =
-            resourceNode.get_child(PROPERTYKEY, boost::property_tree::ptree());
+            resourceNode.get_child(OC::Key::INTERFACESKEY, boost::property_tree::ptree());
 
         boost::property_tree::ptree rT =
-            properties.get_child(RESOURCETYPESKEY, boost::property_tree::ptree());
+            properties.get_child(OC::Key::RESOURCETYPESKEY, boost::property_tree::ptree());
         for(auto itr : rT)
         {
             rTs.push_back(itr.second.data());
         }
 
         boost::property_tree::ptree iF =
-            properties.get_child(INTERFACESKEY, boost::property_tree::ptree());
+            properties.get_child(OC::Key::INTERFACESKEY, boost::property_tree::ptree());
         for(auto itr : iF)
         {
             ifaces.push_back(itr.second.data());
@@ -281,7 +274,7 @@ namespace OC
         {
             return OCRepresentation();
         }
-        boost::property_tree::ptree payload = root.get_child("oc", boost::property_tree::ptree());
+        boost::property_tree::ptree payload = root.get_child(OC::Key::OCKEY, boost::property_tree::ptree());
         OCRepresentation root_resource;
         std::vector<OCRepresentation> children;
         bool isRoot = true;
@@ -291,7 +284,7 @@ namespace OC
             try
             {
                 auto resourceNode = payloadItr.second;
-                std::string uri = resourceNode.get<std::string>(URIKEY, "");
+                std::string uri = resourceNode.get<std::string>(OC::Key::URIKEY, "");
 
                 if (isRoot)
                 {
@@ -302,22 +295,22 @@ namespace OC
                     child.setUri(uri);
                 }
 
-                if( resourceNode.count(PROPERTYKEY) != 0 )
+                if( resourceNode.count(OC::Key::INTERFACESKEY) != 0 )
                 {
                     std::vector<std::string> rTs;
                     std::vector<std::string> ifaces;
                     boost::property_tree::ptree properties =
-                        resourceNode.get_child(PROPERTYKEY, boost::property_tree::ptree());
+                        resourceNode.get_child(OC::Key::INTERFACESKEY, boost::property_tree::ptree());
 
                     boost::property_tree::ptree rT =
-                        properties.get_child(RESOURCETYPESKEY, boost::property_tree::ptree());
+                        properties.get_child(OC::Key::RESOURCETYPESKEY, boost::property_tree::ptree());
                     for(auto itr : rT)
                     {
                         rTs.push_back(itr.second.data());
                     }
 
                     boost::property_tree::ptree iF =
-                        properties.get_child(INTERFACESKEY, boost::property_tree::ptree());
+                        properties.get_child(OC::Key::INTERFACESKEY, boost::property_tree::ptree());
                     for(auto itr : iF)
                     {
                         ifaces.push_back(itr.second.data());
@@ -334,10 +327,10 @@ namespace OC
                     }
                 }
 
-                if( resourceNode.count(REPKEY) != 0 )
+                if( resourceNode.count(OC::Key::INTERFACESKEY) != 0 )
                 {
                     boost::property_tree::ptree rep =
-                        resourceNode.get_child(REPKEY, boost::property_tree::ptree());
+                        resourceNode.get_child(OC::Key::INTERFACESKEY, boost::property_tree::ptree());
                     AttributeMap attrs;
                     for( auto item : rep)
                     {
index 4af539d..43c9a77 100644 (file)
@@ -90,17 +90,17 @@ void formResourceRequest(OCEntityHandlerFlag flag,
             if(OC_REST_GET == entityHandlerRequest->method)
             {
                 // TODO Why strings : "GET"??
-                pRequest->setRequestType("GET");
+                pRequest->setRequestType(OC::PlatformCommands::GET);
             }
             else if(OC_REST_PUT == entityHandlerRequest->method)
             {
-                pRequest->setRequestType("PUT");
+                pRequest->setRequestType(OC::PlatformCommands::PUT);
                 pRequest->setPayload(std::string(reinterpret_cast<const char*>
                                             (entityHandlerRequest->reqJSONPayload)));
             }
             else if(OC_REST_POST == entityHandlerRequest->method)
             {
-                pRequest->setRequestType("POST");
+                pRequest->setRequestType(OC::PlatformCommands::POST);
                 pRequest->setPayload(std::string(reinterpret_cast<const char*>
                                             (entityHandlerRequest->reqJSONPayload)));
             }
@@ -142,7 +142,7 @@ void processResourceResponse(OCEntityHandlerFlag flag,
         }
         else
         {
-            throw OCException("Response is NULL", OC_STACK_MALFORMED_RESPONSE);
+            throw OCException(OC::Exception::STR_NULL_RESPONSE, OC_STACK_MALFORMED_RESPONSE);
         }
 
         if (payLoad.size() < entityHandlerRequest->resJSONPayloadLen)
@@ -169,7 +169,7 @@ void processResourceResponse(OCEntityHandlerFlag flag,
         }
         else
         {
-            throw OCException("Payload overflow", OC_STACK_MALFORMED_RESPONSE);
+            throw OCException(OC::Exception::STR_PAYLOAD_OVERFLOW, OC_STACK_MALFORMED_RESPONSE);
         }
     }
 
@@ -296,7 +296,7 @@ namespace OC
         }
         else
         {
-            throw InitializeException("Cannot construct a Server when configured as a client",
+            throw InitializeException(OC::InitException::NOT_CONFIGURED_AS_SERVER,
                                       OC_STACK_INVALID_PARAM);
         }
 
@@ -304,7 +304,7 @@ namespace OC
 
         if(OC_STACK_OK != result)
         {
-            throw InitializeException("Error Initializing Stack", result);
+            throw InitializeException(OC::InitException::STACK_INIT_ERROR, result);
         }
 
         m_threadRun = true;
@@ -451,7 +451,7 @@ namespace OC
 
         if (result != OC_STACK_OK)
         {
-            throw OCException("Bind Type to resource failed", result);
+            throw OCException(OC::Exception::BIND_TYPE_FAILED, result);
         }
         return result;
     }
@@ -475,7 +475,7 @@ namespace OC
 
         if (result != OC_STACK_OK)
         {
-            throw OCException("Bind Interface to resource failed", result);
+            throw OCException(OC::Exception::BIND_INTERFACE_FAILED, result);
         }
         return result;
     }
@@ -492,7 +492,7 @@ namespace OC
 
         if(result != OC_STACK_OK)
         {
-            throw OCException("startPresence failed", result);
+            throw OCException(OC::Exception::START_PRESENCE_FAILED, result);
         }
         return result;
     }
@@ -509,7 +509,7 @@ namespace OC
 
         if(result != OC_STACK_OK)
         {
-            throw OCException("stopPresence failed", result);
+            throw OCException(OC::Exception::END_PRESENCE_FAILED, result);
         }
         return result;
     }
index f50fa59..612dc1d 100644 (file)
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 #include "OCException.h"
+#include "StringConstants.h"
 
 std::string OC::OCException::reason(const OCStackResult sr)
 {
     switch(sr)
     {
         case OC_STACK_OK:
-             return "No Error";
+             return OC::Exception::NO_ERROR;
         case OC_STACK_RESOURCE_CREATED:
-             return "Resource Created";
+             return OC::Exception::RESOURCE_CREATED;
         case OC_STACK_RESOURCE_DELETED:
-             return "Resource Deleted";
+             return OC::Exception::RESOURCE_DELETED;
         case OC_STACK_INVALID_URI:
-            return "Invalid URI";
+            return OC::Exception::INVALID_URI;
         case OC_STACK_INVALID_IP:
-            return "Invalid IP";
+            return OC::Exception::INVALID_IP;
         case OC_STACK_INVALID_PORT:
-            return "Invalid Port";
+            return OC::Exception::INVALID_PORT;
         case OC_STACK_INVALID_CALLBACK:
-            return "Invalid Callback";
+            return OC::Exception::INVALID_CB;
         case OC_STACK_INVALID_METHOD:
-            return "Invalid Method";
+            return OC::Exception::INVALID_METHOD;
         case OC_STACK_INVALID_QUERY:
-            return "Invalid Query";
+            return OC::Exception::INVALID_QUERY;
         case OC_STACK_INVALID_PARAM:
-            return "Invalid Parameter";
+            return OC::Exception::INVALID_PARAM;
         case OC_STACK_INVALID_OBSERVE_PARAM:
-            return "Invalid Observe Parameter";
+            return OC::Exception::INVALID_OBESERVE;
         case OC_STACK_NO_MEMORY:
-            return "No Memory";
+            return OC::Exception::NO_MEMORY;
         case OC_STACK_COMM_ERROR:
-            return "Communication Error";
+            return OC::Exception::COMM_ERROR;
         case OC_STACK_NOTIMPL:
-            return "Not Implemented";
+            return OC::Exception::NOT_IMPL;
         case OC_STACK_NO_RESOURCE:
-            return "Resource Not Found";
+            return OC::Exception::NOT_FOUND;
         case OC_STACK_RESOURCE_ERROR:
-            return "Resource Error";
+            return OC::Exception::RESOURCE_ERROR;
         case OC_STACK_SLOW_RESOURCE:
-            return "Slow Resource";
+            return OC::Exception::SLOW_RESOURCE;
         case OC_STACK_NO_OBSERVERS:
-            return "No Observers";
-       case OC_STACK_OBSERVER_NOT_FOUND:
-            return "Stack observer not found";
-       case OC_STACK_OBSERVER_NOT_ADDED:
-            return "Stack observer not added";
-       case OC_STACK_OBSERVER_NOT_REMOVED:
-            return "Stack observer not removed";
+            return OC::Exception::NO_OBSERVERS;
+        case OC_STACK_OBSERVER_NOT_FOUND:
+            return OC::Exception::OBSV_NO_FOUND;
+        case OC_STACK_OBSERVER_NOT_ADDED:
+            return OC::Exception::OBSV_NOT_ADDED;
+        case OC_STACK_OBSERVER_NOT_REMOVED:
+            return OC::Exception::OBSV_NOT_REMOVED;
 #ifdef WITH_PRESENCE
-       case OC_STACK_PRESENCE_STOPPED:
-            return "Stack presence stopped";
-       case OC_STACK_PRESENCE_DO_NOT_HANDLE:
-            return "Stack presence should not be handled";
+        case OC_STACK_PRESENCE_STOPPED:
+            return OC::Exception::PRESENCE_STOPPED;
+        case OC_STACK_PRESENCE_DO_NOT_HANDLE:
+            return OC::Exception::PRESENCE_NOT_HANDLED;
 #endif
-       case OC_STACK_INVALID_OPTION:
-            return "Invalid option";
-       case OC_STACK_MALFORMED_RESPONSE:
-            return "Malformed response";
-       case OC_STACK_ERROR:
-            return "General Fault";
+        case OC_STACK_INVALID_OPTION:
+            return OC::Exception::INVALID_OPTION;
+        case OC_STACK_MALFORMED_RESPONSE:
+            return OC::Exception::MALFORMED_STACK_RESPONSE;
+        case OC_STACK_ERROR:
+            return OC::Exception::GENERAL_FAULT;
     }
 
-    return "Unknown Error";
+    return OC::Exception::UNKNOWN_ERROR;
 }
 
index ee9cca7..b3062e9 100644 (file)
@@ -83,12 +83,12 @@ OCStackResult OCResource::get(const std::string& resourceType, const std::string
 
     if(!resourceType.empty())
     {
-        mapCpy["rt"]=resourceType;
+        mapCpy[OC::Key::RESOURCETYPESKEY]=resourceType;
     }
 
     if(!resourceInterface.empty())
     {
-        mapCpy["if"]= resourceInterface;
+        mapCpy[OC::Key::INTERFACESKEY]= resourceInterface;
     }
 
     return result_guard(get(mapCpy, attributeHandler, QoS));
@@ -132,12 +132,12 @@ OCStackResult OCResource::put(const std::string& resourceType,
 
     if(!resourceType.empty())
     {
-        mapCpy["rt"]=resourceType;
+        mapCpy[OC::Key::RESOURCETYPESKEY]=resourceType;
     }
 
     if(!resourceInterface.empty())
     {
-        mapCpy["if"]=resourceInterface;
+        mapCpy[OC::Key::INTERFACESKEY]=resourceInterface;
     }
 
     return result_guard(put(rep, mapCpy, attributeHandler, QoS));
@@ -181,12 +181,12 @@ OCStackResult OCResource::post(const std::string& resourceType,
 
     if(!resourceType.empty())
     {
-        mapCpy["rt"]=resourceType;
+        mapCpy[OC::Key::RESOURCETYPESKEY]=resourceType;
     }
 
     if(!resourceInterface.empty())
     {
-        mapCpy["if"]=resourceInterface;
+        mapCpy[OC::Key::INTERFACESKEY]=resourceInterface;
     }
 
     return result_guard(post(rep, mapCpy, attributeHandler, QoS));