Skip to content

Commit

Permalink
Remove use of href for domain retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Jan 23, 2024
1 parent 6d2f3c7 commit df0d22b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 34 deletions.
3 changes: 3 additions & 0 deletions src/rest_vol.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ extern const char *link_collection_keys2[];
/* JSON keys to retrieve objects accessed through path(s) */
extern const char *h5paths_keys[];

/* JSON keys to retrieve the path to a domain in HSDS */
extern const char *domain_keys[];

/* A global struct containing the buffer which cURL will write its
* responses out to after making a call to the server. The buffer
* in this struct is allocated upon connector initialization and is
Expand Down
40 changes: 6 additions & 34 deletions src/rest_vol_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ static void RV_free_object_table(object_table_entry *object_table, size_t num_en

/* JSON keys to retrieve relevant information for H5Oget_info */
const char *attribute_count_keys[] = {"attributeCount", (const char *)0};
const char *hrefs_keys[] = {"hrefs", (const char *)0};

/*-------------------------------------------------------------------------
* Function: RV_object_open
Expand Down Expand Up @@ -1336,41 +1335,14 @@ RV_get_object_info_callback(char *HTTP_response, void *callback_data_in, void *c
* and converted to an unsigned long for the fileno field and the object's UUID string
* is hashed to an haddr_t for the addr field.
*/
if (NULL == (key_obj = yajl_tree_get(target_tree, domain_keys, yajl_t_string)))
FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "can't get domain from response");

if (NULL == (key_obj = yajl_tree_get(target_tree, hrefs_keys, yajl_t_array)))
FUNC_GOTO_ERROR(H5E_OBJECT, H5E_CANTGET, FAIL, "retrieval of object HREFs failed");
if (!YAJL_IS_STRING(key_obj))
FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "retrieved domain was not a valid string");

/* Find the "home" href that corresponds to the object's domain path */
for (i = 0; i < YAJL_GET_ARRAY(key_obj)->len; i++) {
yajl_val href_obj = YAJL_GET_ARRAY(key_obj)->values[i];
size_t j;

if (!YAJL_IS_OBJECT(href_obj))
FUNC_GOTO_ERROR(H5E_OBJECT, H5E_BADVALUE, FAIL, "HREFs array value is not an object");

for (j = 0; j < YAJL_GET_OBJECT(href_obj)->len; j++) {
char *key_val;

if (NULL == (key_val = YAJL_GET_STRING(YAJL_GET_OBJECT(href_obj)->values[j])))
FUNC_GOTO_ERROR(H5E_OBJECT, H5E_BADVALUE, FAIL, "HREF object key value was NULL");

/* If this object's "rel" key does not have the value "home", skip this object */
if (!strcmp(YAJL_GET_OBJECT(href_obj)->keys[j], "rel") && strcmp(key_val, "home")) {
domain_path = NULL;
break;
} /* end if */

if (!strcmp(YAJL_GET_OBJECT(href_obj)->keys[j], "href"))
domain_path = key_val;
} /* end for */

if (domain_path)
break;
} /* end for */

if (!domain_path)
FUNC_GOTO_ERROR(H5E_OBJECT, H5E_CANTGET, FAIL,
"unable to determine a value for object info file number field");
if (NULL == (domain_path = YAJL_GET_STRING(key_obj)))
FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "retrieved domain was NULL");

obj_info->fileno = (unsigned long)rv_hash_string(domain_path);

Expand Down

0 comments on commit df0d22b

Please sign in to comment.