From: jaesick.shin Date: Wed, 23 Nov 2016 09:12:48 +0000 (+0900) Subject: [IoT-1590] Modify attribute key name followed by OCF property naming convention. X-Git-Tag: 1.3.0~1050^2~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a7e5d5b8568b641b0f9a4bd8c9e3a42eb4f685a;p=platform%2Fupstream%2Fiotivity.git [IoT-1590] Modify attribute key name followed by OCF property naming convention. All the OCF property should be written as lower case. So, change the key name of attributes. second patch include, removed duplicated NS_QUERY_CONSUMERID. Change-Id: I2fcc76fac003e805ad19edb0d7ee10c659218b5f Signed-off-by: jaesick.shin Reviewed-on: https://gerrit.iotivity.org/gerrit/14657 Reviewed-by: Uze Choi Tested-by: Uze Choi (cherry picked from commit 421ca0f436ae959caba272030df9b10d3024f788) Reviewed-on: https://gerrit.iotivity.org/gerrit/15131 Tested-by: jenkins-iotivity --- diff --git a/service/notification/cpp-wrapper/unittest/NSConsumerServiceSimulator.h b/service/notification/cpp-wrapper/unittest/NSConsumerServiceSimulator.h index 6d05f00..054f76c 100755 --- a/service/notification/cpp-wrapper/unittest/NSConsumerServiceSimulator.h +++ b/service/notification/cpp-wrapper/unittest/NSConsumerServiceSimulator.h @@ -67,8 +67,8 @@ class NSConsumerSimulator } OC::OCRepresentation rep; - rep.setValue("providerId", providerID); - rep.setValue("messageId", id); + rep.setValue("providerid", providerID); + rep.setValue("messageid", id); rep.setValue("state", type); m_syncResource->post(rep, OC::QueryParamsMap(), &onPost, OC::QualityOfService::LowQos); @@ -115,7 +115,7 @@ class NSConsumerSimulator { OC::QueryParamsMap map; - map.insert(std::pair(std::string("consumerId"), + map.insert(std::pair(std::string("consumerid"), std::string("123456789012345678901234567890123456"))); try @@ -160,14 +160,14 @@ class NSConsumerSimulator std::shared_ptr ) { - if (rep.getUri() == "/notification/message" && rep.hasAttribute("messageId") - && rep.getValue("messageId") != 1) + if (rep.getUri() == "/notification/message" && rep.hasAttribute("messageid") + && rep.getValue("messageid") != 1) { - m_messageFunc(int(rep.getValue("messageId")), + m_messageFunc(int(rep.getValue("messageid")), std::string(rep.getValueToString("title")), - std::string(rep.getValueToString("contentText")), + std::string(rep.getValueToString("contenttext")), std::string(rep.getValueToString("source"))); - if (rep.getValue("messageId") == 3) + if (rep.getValue("messageid") == 3) { m_topicResource->get(OC::QueryParamsMap(), std::bind(&NSConsumerSimulator::onTopicGet, this, std::placeholders::_1, @@ -177,7 +177,7 @@ class NSConsumerSimulator } else if (rep.getUri() == "/notification/sync") { - m_syncFunc(int(rep.getValue("state")), int(rep.getValue("messageId"))); + m_syncFunc(int(rep.getValue("state")), int(rep.getValue("messageid"))); } } void onTopicGet(const OC::HeaderOptions &/*headerOption*/, diff --git a/service/notification/cpp-wrapper/unittest/NSProviderServiceSimulator.h b/service/notification/cpp-wrapper/unittest/NSProviderServiceSimulator.h index f821496..4a7488c 100755 --- a/service/notification/cpp-wrapper/unittest/NSProviderServiceSimulator.h +++ b/service/notification/cpp-wrapper/unittest/NSProviderServiceSimulator.h @@ -123,11 +123,11 @@ class NSProviderSimulator std::string syncUri = m_notificationUri + m_syncUri; std::string topicUri = m_notificationUri + m_topicUri; std::string providerId = "123456789012345678901234567890123456"; - rep.setValue("subControllability", m_accepter); - rep.setValue("messageUri", msgUri); - rep.setValue("syncUri", syncUri); - rep.setValue("topicUri", topicUri); - rep.setValue("providerId", providerId); + rep.setValue("subcontrollability", m_accepter); + rep.setValue("messageuri", msgUri); + rep.setValue("syncuri", syncUri); + rep.setValue("topicuri", topicUri); + rep.setValue("providerid", providerId); } else if (type == requestType::NS_SYNC) { @@ -157,14 +157,14 @@ class NSProviderSimulator [& topicArr](const NS_TopicState & topicState) { OC::OCRepresentation topic; - topic.setValue("topicName", topicState.first); - topic.setValue("topicState", (int) topicState.second); + topic.setValue("topicname", topicState.first); + topic.setValue("topicstate", (int) topicState.second); topicArr.push_back(topic); } ); rep.setValue> - ("topicList", topicArr); + ("topiclist", topicArr); } else { @@ -182,7 +182,7 @@ class NSProviderSimulator m_syncRep = requests->getResourceRepresentation(); std::cout << "Receive POST for Sync" << std::endl; - std::cout << "provider Id : " << m_syncRep.getValueToString("providerId") << std::endl; + std::cout << "provider Id : " << m_syncRep.getValueToString("providerid") << std::endl; std::cout << "Sync State : " << m_syncRep.getValueToString("state") << std::endl; response->setResourceRepresentation(m_syncRep); @@ -195,15 +195,15 @@ class NSProviderSimulator { auto receivePayload = requests->getResourceRepresentation() - .getValue>("topicList"); + .getValue>("topiclist"); std::for_each (receivePayload.begin(), receivePayload.end(), [this](const OC::OCRepresentation & rep) { - auto tmp = m_allowedTopicList.find(rep.getValueToString("topicName")); + auto tmp = m_allowedTopicList.find(rep.getValueToString("topicname")); if (tmp != m_allowedTopicList.end()) { - tmp->second = (TopicAllowState) rep.getValue("topicState"); + tmp->second = (TopicAllowState) rep.getValue("topicstate"); } } ); @@ -234,8 +234,8 @@ class NSProviderSimulator { OC::OCRepresentation rep; std::string providerId = "123456789012345678901234567890123456"; - rep.setValue("messageId", (int)messageType::NS_ALLOW); - rep.setValue("providerId", providerId); + rep.setValue("messageid", (int)messageType::NS_ALLOW); + rep.setValue("providerid", providerId); auto response = std::make_shared(); response->setRequestHandle(requests->getRequestHandle()); @@ -306,27 +306,27 @@ class NSProviderSimulator void sendRead(const uint64_t &id) { std::string providerId = "123456789012345678901234567890123456"; - m_syncRep.setValue("messageId", id); + m_syncRep.setValue("messageid", id); m_syncRep.setValue("state", (int)1); - m_syncRep.setValue("providerId", providerId); + m_syncRep.setValue("providerid", providerId); OC::OCPlatform::notifyAllObservers(m_syncHandle); } void sendDismiss(const uint64_t &id) { std::string providerId = "123456789012345678901234567890123456"; - m_syncRep.setValue("messageId", id); + m_syncRep.setValue("messageid", id); m_syncRep.setValue("state", (int)2); - m_syncRep.setValue("providerId", providerId); + m_syncRep.setValue("providerid", providerId); OC::OCPlatform::notifyAllObservers(m_syncHandle); } void setMessage(const uint64_t &id, const std::string &title, const std::string &content) { std::string providerId = "123456789012345678901234567890123456"; - m_messageRep.setValue("messageId", id); + m_messageRep.setValue("messageid", id); m_messageRep.setValue("title", title); - m_messageRep.setValue("contentText", content); - m_messageRep.setValue("providerId", providerId); + m_messageRep.setValue("contenttext", content); + m_messageRep.setValue("providerid", providerId); } void setTopics(const NS_TopicList &topics) diff --git a/service/notification/src/common/NSConstants.h b/service/notification/src/common/NSConstants.h index e83ed34..d22f45c 100644 --- a/service/notification/src/common/NSConstants.h +++ b/service/notification/src/common/NSConstants.h @@ -78,7 +78,7 @@ // NOTIOBJ // #define NOTIOBJ_TITLE_KEY "title" #define NOTIOBJ_ID_KEY "id" -#define NOTOOBJ_CONTENT_KEY "contentText" +#define NOTOOBJ_CONTENT_KEY "contenttext" #define DISCOVERY_TAG "NS_PROVIDER_DISCOVERY" #define SUBSCRIPTION_TAG "NS_PROVIDER_SUBSCRIPTION" @@ -106,8 +106,8 @@ #define NS_QUERY_SEPARATOR "&;" #define NS_KEY_VALUE_DELIMITER "=" -#define NS_QUERY_CONSUMER_ID "consumerId" -#define NS_QUERY_PROVIDER_ID "providerId" +#define NS_QUERY_CONSUMER_ID "consumerid" +#define NS_QUERY_PROVIDER_ID "providerid" #define NS_QUERY_INTERFACE "if" #define NS_QUERY_ID_SIZE 10 @@ -201,25 +201,25 @@ #define VERSION "1.2.0" #define NS_ATTRIBUTE_VERSION "version" -#define NS_ATTRIBUTE_POLICY "subControllability" -#define NS_ATTRIBUTE_MESSAGE "messageUri" -#define NS_ATTRIBUTE_SYNC "syncUri" -#define NS_ATTRIBUTE_TOPIC "topicUri" -#define NS_ATTRIBUTE_MESSAGE_ID "messageId" -#define NS_ATTRIBUTE_PROVIDER_ID "providerId" -#define NS_ATTRIBUTE_CONSUMER_ID "consumerId" -#define NS_ATTRIBUTE_TOPIC_LIST "topicList" -#define NS_ATTRIBUTE_TOPIC_NAME "topicName" -#define NS_ATTRIBUTE_TOPIC_SELECTION "topicState" +#define NS_ATTRIBUTE_POLICY "subcontrollability" +#define NS_ATTRIBUTE_MESSAGE "messageuri" +#define NS_ATTRIBUTE_SYNC "syncuri" +#define NS_ATTRIBUTE_TOPIC "topicuri" +#define NS_ATTRIBUTE_MESSAGE_ID "messageid" +#define NS_ATTRIBUTE_PROVIDER_ID "providerid" +#define NS_ATTRIBUTE_CONSUMER_ID "consumerid" +#define NS_ATTRIBUTE_TOPIC_LIST "topiclist" +#define NS_ATTRIBUTE_TOPIC_NAME "topicname" +#define NS_ATTRIBUTE_TOPIC_SELECTION "topicstate" #define NS_ATTRIBUTE_TITLE "title" -#define NS_ATTRIBUTE_TEXT "contentText" +#define NS_ATTRIBUTE_TEXT "contenttext" #define NS_ATTRIBUTE_SOURCE "source" #define NS_ATTRIBUTE_STATE "state" #define NS_ATTRIBUTE_DEVICE "device" #define NS_ATTRIBUTE_TYPE "type" -#define NS_ATTRIBUTE_DATETIME "dateTime" +#define NS_ATTRIBUTE_DATETIME "datetime" #define NS_ATTRIBUTE_TTL "ttl" -#define NS_ATTRIBUTE_ICON_IMAGE "iconImage" +#define NS_ATTRIBUTE_ICON_IMAGE "iconimage" typedef enum eConnectionState { diff --git a/service/notification/src/common/NSStructs.h b/service/notification/src/common/NSStructs.h index ceb84a3..4cd67b1 100644 --- a/service/notification/src/common/NSStructs.h +++ b/service/notification/src/common/NSStructs.h @@ -133,7 +133,7 @@ typedef struct typedef struct { OCResourceHandle handle; - char * id; + uint64_t messageId; char providerId[NS_UUID_STRING_SIZE]; char * state; diff --git a/service/notification/src/provider/NSProviderResource.c b/service/notification/src/provider/NSProviderResource.c index 7d0c979..25f0bca 100644 --- a/service/notification/src/provider/NSProviderResource.c +++ b/service/notification/src/provider/NSProviderResource.c @@ -158,7 +158,7 @@ NSResult NSCreateResource(char *uri) } else if (strcmp(uri, NS_COLLECTION_SYNC_URI) == 0) { - NotificationSyncResource.id = NULL; + NotificationSyncResource.messageId = 0; (NotificationSyncResource.providerId)[0] = '\0'; NotificationSyncResource.state = NULL; NotificationSyncResource.handle = NULL; diff --git a/service/notification/unittest/NSConsumerSimulator.h b/service/notification/unittest/NSConsumerSimulator.h index f3183a9..1a7a8ff 100644 --- a/service/notification/unittest/NSConsumerSimulator.h +++ b/service/notification/unittest/NSConsumerSimulator.h @@ -67,8 +67,8 @@ public: } OC::OCRepresentation rep; - rep.setValue("providerId", providerID); - rep.setValue("messageId", id); + rep.setValue("providerid", providerID); + rep.setValue("messageid", id); rep.setValue("state", type); m_syncResource->post(rep, OC::QueryParamsMap(), &onPost, OC::QualityOfService::LowQos); @@ -110,7 +110,7 @@ private: std::shared_ptr resource) { OC::QueryParamsMap map; - map.insert(std::pair(std::string("consumerId"), + map.insert(std::pair(std::string("consumerid"), std::string("123456789012345678901234567890123456"))); try @@ -155,15 +155,15 @@ private: const OC::OCRepresentation &rep , const int & /*eCode*/, const int &, std::shared_ptr ) { - if (rep.getUri() == "/notification/message" && rep.hasAttribute("messageId") - && rep.getValue("messageId") != 1) + if (rep.getUri() == "/notification/message" && rep.hasAttribute("messageid") + && rep.getValue("messageid") != 1) { - m_messageFunc(int(rep.getValue("messageId")), + m_messageFunc(int(rep.getValue("messageid")), std::string(rep.getValueToString("title")), - std::string(rep.getValueToString("contentText")), + std::string(rep.getValueToString("contenttext")), std::string(rep.getValueToString("source"))); - if(rep.getValue("messageId") == 3) + if(rep.getValue("messageid") == 3) { m_topicResource->get(std::string("oic.wk.notification"), std::string("oic.if.baseline"), OC::QueryParamsMap(), @@ -174,7 +174,7 @@ private: } else if (rep.getUri() == "/notification/sync") { - m_syncFunc(int(rep.getValue("state")), int(rep.getValue("messageId"))); + m_syncFunc(int(rep.getValue("state")), int(rep.getValue("messageid"))); } } @@ -189,7 +189,7 @@ private: OC::OCRepresentation postRep; std::vector topicArr = - rep.getValue>("topicList"); + rep.getValue>("topiclist"); std::vector postTopicArr; @@ -200,8 +200,8 @@ private: OC::OCRepresentation topic = *it; OC::OCRepresentation postTopic; - postTopic.setValue("topicName", topic.getValueToString("topicName")); - postTopic.setValue("topicState", (int) topic.getValue("topicState")); + postTopic.setValue("topicname", topic.getValueToString("topicname")); + postTopic.setValue("topicstate", (int) topic.getValue("topicstate")); postTopicArr.push_back(topic); @@ -210,10 +210,10 @@ private: } postRep.setValue> - ("topicList", postTopicArr); + ("topiclist", postTopicArr); OC::QueryParamsMap map; - map.insert(std::pair(std::string("consumerId"), + map.insert(std::pair(std::string("consumerid"), std::string("123456789012345678901234567890123456"))); m_topicResource->post(postRep, map, &onPost, OC::QualityOfService::LowQos); } diff --git a/service/notification/unittest/NSProviderSimulator.h b/service/notification/unittest/NSProviderSimulator.h index e864abc..8874733 100644 --- a/service/notification/unittest/NSProviderSimulator.h +++ b/service/notification/unittest/NSProviderSimulator.h @@ -123,11 +123,11 @@ private: std::string syncUri = m_notificationUri + m_syncUri; std::string topicUri = m_notificationUri + m_topicUri; std::string providerId = "123456789012345678901234567890123456"; - rep.setValue("subControllability", m_accepter); - rep.setValue("messageUri", msgUri); - rep.setValue("syncUri", syncUri); - rep.setValue("topicUri", topicUri); - rep.setValue("providerId", providerId); + rep.setValue("subcontrollability", m_accepter); + rep.setValue("messageuri", msgUri); + rep.setValue("syncuri", syncUri); + rep.setValue("topicuri", topicUri); + rep.setValue("providerid", providerId); } else if (type == requestType::NS_SYNC) { @@ -157,14 +157,14 @@ private: [& topicArr](const NS_TopicState & topicState) { OC::OCRepresentation topic; - topic.setValue("topicName", topicState.first); - topic.setValue("topicState", (int) topicState.second); + topic.setValue("topicname", topicState.first); + topic.setValue("topicstate", (int) topicState.second); topicArr.push_back(topic); } ); rep.setValue> - ("topicList", topicArr); + ("topiclist", topicArr); } else { @@ -182,7 +182,7 @@ private: m_syncRep = requests->getResourceRepresentation(); std::cout << "Receive POST for Sync" << std::endl; - std::cout << "provider Id : " << m_syncRep.getValueToString("providerId") << std::endl; + std::cout << "provider Id : " << m_syncRep.getValueToString("providerid") << std::endl; std::cout << "Sync State : " << m_syncRep.getValueToString("state") << std::endl; response->setResourceRepresentation(m_syncRep); @@ -195,15 +195,15 @@ private: { auto receivePayload = requests->getResourceRepresentation() - .getValue>("topicList"); + .getValue>("topiclist"); std::for_each (receivePayload.begin(), receivePayload.end(), [this](const OC::OCRepresentation & rep) { - auto tmp = m_allowedTopicList.find(rep.getValueToString("topicName")); + auto tmp = m_allowedTopicList.find(rep.getValueToString("topicname")); if (tmp != m_allowedTopicList.end()) { - tmp->second = (TopicAllowState) rep.getValue("topicState"); + tmp->second = (TopicAllowState) rep.getValue("topicstate"); } } ); @@ -234,8 +234,8 @@ private: { OC::OCRepresentation rep; std::string providerId = "123456789012345678901234567890123456"; - rep.setValue("messageId", (int)messageType::NS_ALLOW); - rep.setValue("providerId", providerId); + rep.setValue("messageid", (int)messageType::NS_ALLOW); + rep.setValue("providerid", providerId); auto response = std::make_shared(); response->setRequestHandle(requests->getRequestHandle()); @@ -306,27 +306,27 @@ public: void sendRead(const uint64_t & id) { std::string providerId = "123456789012345678901234567890123456"; - m_syncRep.setValue("messageId", id); + m_syncRep.setValue("messageid", id); m_syncRep.setValue("state", (int)1); - m_syncRep.setValue("providerId", providerId); + m_syncRep.setValue("providerid", providerId); OC::OCPlatform::notifyAllObservers(m_syncHandle); } void sendDismiss(const uint64_t & id) { std::string providerId = "123456789012345678901234567890123456"; - m_syncRep.setValue("messageId", id); + m_syncRep.setValue("messageid", id); m_syncRep.setValue("state", (int)2); - m_syncRep.setValue("providerId", providerId); + m_syncRep.setValue("providerid", providerId); OC::OCPlatform::notifyAllObservers(m_syncHandle); } void setMessage(const uint64_t & id, const std::string & title, const std::string & content) { std::string providerId = "123456789012345678901234567890123456"; - m_messageRep.setValue("messageId", id); + m_messageRep.setValue("messageid", id); m_messageRep.setValue("title", title); - m_messageRep.setValue("contentText", content); - m_messageRep.setValue("providerId", providerId); + m_messageRep.setValue("contenttext", content); + m_messageRep.setValue("providerid", providerId); } void setTopics(const NS_TopicList & topics)