Update RD DB link parsing. 91/21991/2
authorTodd Malsbary <todd.malsbary@intel.com>
Thu, 17 Aug 2017 22:30:56 +0000 (15:30 -0700)
committerJee Hyeok Kim <jihyeok13.kim@samsung.com>
Thu, 24 Aug 2017 01:25:00 +0000 (01:25 +0000)
- "lt" in RD publish is now "ttl".
- "pri" defaults to 1 in links where it is not present.
- Remove all references to oic.wk.rdpub (except definition in header
  files).

Bug: https://jira.iotivity.org/browse/IOT-2616
Change-Id: I7a55398ab1c8b60166730f33cbce83e0bf193999
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21991
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Habib Virji <habib.virji@samsung.com>
Reviewed-by: George Nash <george.nash@intel.com>
Reviewed-by: Jee Hyeok Kim <jihyeok13.kim@samsung.com>
cloud/resourcedirectory/src/main/java/org/iotivity/cloud/rdserver/resources/directory/rd/ResourceDirectoryResource.java
cloud/resourcedirectory/src/test/java/org/iotivity/cloud/testrdserver/RDServerTestUtils.java
resource/csdk/include/octypes.h
resource/csdk/resource-directory/src/internal/rd_database.c
resource/csdk/resource-directory/src/rd_client.c
resource/csdk/stack/src/ocstack.c

index f56f29d..ce4877a 100644 (file)
@@ -101,17 +101,6 @@ public class ResourceDirectoryResource extends Resource {
     private IResponse handlePostRequest(IRequest request)
             throws ServerException {
 
-        HashMap<String, List<String>> queryMap = request.getUriQueryMap();
-
-        checkQueryException(Arrays.asList(Constants.RESOURCE_TYPE), queryMap);
-
-        List<String> listRT = queryMap.get(Constants.RESOURCE_TYPE);
-
-        // check query "rt=oic.rd.pub"
-        if (!listRT.get(0).equals(Constants.RESOURCE_TYPE_RDPUBLISH)) {
-            throw new PreconditionFailedException("rt property is not correct");
-        }
-
         HashMap<String, Object> payload = mCbor
                 .parsePayloadFromCbor(request.getPayload(), HashMap.class);
 
index 78e08fa..efbc44e 100644 (file)
@@ -41,8 +41,7 @@ public class RDServerTestUtils {
         Cbor<HashMap<Object, Object>> cbor = new Cbor<>();
         IRequest request = MessageBuilder.createRequest(RequestMethod.POST,
                 Constants.RD_URI,
-                Constants.RESOURCE_TYPE + "="
-                        + Constants.RESOURCE_TYPE_RDPUBLISH,
+                null,
                 ContentFormat.APPLICATION_CBOR,
                 cbor.encodingPayloadToCbor(payload));
         return request;
@@ -53,4 +52,4 @@ public class RDServerTestUtils {
         mongoDB.createTable(Constants.RD_TABLE);
         mongoDB.createTable(Constants.PRESENCE_TABLE);
     }
-}
\ No newline at end of file
+}
index 61978b4..8e22000 100644 (file)
@@ -183,12 +183,12 @@ extern "C" {
 /** To represent interface.*/
 #define OC_RSRVD_INTERFACE              "if"
 
-/** To indicate how long RD should publish this item.*/
-#define OC_RSRVD_DEVICE_TTL             "lt"
-
 /** To represent time to live.*/
 #define OC_RSRVD_TTL                    "ttl"
 
+/** To indicate how long RD should publish this item.*/
+#define OC_RSRVD_DEVICE_TTL             OC_RSRVD_TTL
+
 /** To represent non*/
 #define OC_RSRVD_NONCE                  "non"
 
index d54a859..562681d 100644 (file)
@@ -238,7 +238,6 @@ static int storeEndpoints(OCRepPayload **eps, size_t size, sqlite3_int64 rowid)
     int deleteEpLength = (int)sizeof(deleteEp);
     int insertEpLength = (int)sizeof(insertEp);
 
-
     VERIFY_SQLITE(sqlite3_prepare_v2(gRDDB, deleteEp, deleteEpLength, &stmt, NULL));
     VERIFY_SQLITE(sqlite3_bind_int64(stmt, sqlite3_bind_parameter_index(stmt, "@id"), rowid));
     res = sqlite3_step(stmt);
@@ -261,11 +260,9 @@ static int storeEndpoints(OCRepPayload **eps, size_t size, sqlite3_int64 rowid)
             VERIFY_SQLITE(sqlite3_bind_text(stmt, sqlite3_bind_parameter_index(stmt, "@ep"),
                             ep, (int)strlen(ep), SQLITE_STATIC));
         }
-        sqlite3_int64 pri;
-        if (OCRepPayloadGetPropInt(eps[i], OC_RSRVD_PRIORITY, (int64_t *) &pri))
-        {
-            VERIFY_SQLITE(sqlite3_bind_int64(stmt, sqlite3_bind_parameter_index(stmt, "@pri"), pri));
-        }
+        sqlite3_int64 pri = 1;
+        OCRepPayloadGetPropInt(eps[i], OC_RSRVD_PRIORITY, (int64_t *) &pri);
+        VERIFY_SQLITE(sqlite3_bind_int64(stmt, sqlite3_bind_parameter_index(stmt, "@pri"), pri));
         VERIFY_SQLITE(sqlite3_bind_int64(stmt, sqlite3_bind_parameter_index(stmt, "@id"), rowid));
         res = sqlite3_step(stmt);
         if (SQLITE_DONE != res)
index 5df7c7c..0a60445 100644 (file)
@@ -376,8 +376,7 @@ OCStackResult OC_CALL OCRDPublishWithDeviceId(OCDoHandle *handle, const char *ho
     }
 
     char targetUri[MAX_URI_LENGTH] = { 0 };
-    snprintf(targetUri, MAX_URI_LENGTH, "%s%s?rt=%s", host,
-             OC_RSRVD_RD_URI, OC_RSRVD_RESOURCE_TYPE_RDPUBLISH);
+    snprintf(targetUri, MAX_URI_LENGTH, "%s%s", host, OC_RSRVD_RD_URI);
     OIC_LOG_V(DEBUG, TAG, "Target URI: %s", targetUri);
 
     OCRepPayload *rdPayload = RDPublishPayloadCreate(id, pubResHandle, nPubResHandles);
index 2fabe85..483d737 100644 (file)
@@ -5928,11 +5928,7 @@ OCStackResult OCUpdateResourceInsWithResponse(const char *requestUri,
     {
         OIC_LOG(DEBUG, TAG, "update the ins of published resource");
 
-        char rdPubUri[MAX_URI_LENGTH] = { 0 };
-        snprintf(rdPubUri, MAX_URI_LENGTH, "%s?rt=%s", OC_RSRVD_RD_URI,
-                 OC_RSRVD_RESOURCE_TYPE_RDPUBLISH);
-
-        if (strcmp(rdPubUri, targetUri) == 0)
+        if (strcmp(OC_RSRVD_RD_URI, targetUri) == 0)
         {
             // Update resource unique id in stack.
             if (response)