[open-ils-commits] r11571 - trunk/Open-ILS/src/c-apps
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Dec 15 10:00:44 EST 2008
Author: miker
Date: 2008-12-15 10:00:43 -0500 (Mon, 15 Dec 2008)
New Revision: 11571
Modified:
trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
variable cleanup; more error reporting to the client; free() reordering for safe object use
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2008-12-15 14:36:39 UTC (rev 11570)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2008-12-15 15:00:43 UTC (rev 11571)
@@ -968,10 +968,13 @@
osrfLogDebug( OSRF_LOG_MARK, "%d foreign context fields(s) specified for class %s", ((osrfStringArray*)osrfHashGet(fcontext,"context"))->size, class_name);
+ char* foreign_pkey = osrfHashGet(fcontext, "field");
+ char* foreign_pkey_value = oilsFMGetString(param, osrfHashGet(fcontext, "fkey"));
+
jsonObject* _tmp_params = jsonParseStringFmt(
"[{\"%s\":\"%s\"}]",
- osrfHashGet(fcontext, "field"),
- oilsFMGetString(param, osrfHashGet(fcontext, "fkey"))
+ foreign_pkey,
+ foreign_pkey_value
);
jsonObject* _list = doFieldmapperSearch(
@@ -980,18 +983,37 @@
_tmp_params,
&err
);
-
-
+
jsonObject* _fparam = jsonObjectGetIndex(_list, 0);
if (!_fparam) {
jsonObjectFree(_tmp_params);
jsonObjectFree(_list);
+
+ growing_buffer* msg = buffer_init(128);
+ buffer_fadd(
+ msg,
+ "%s: no object found with primary key %s of %s",
+ MODULENAME,
+ foreign_pkey,
+ foreign_pkey_value
+ );
+
+ char* m = buffer_release(msg);
+ osrfAppSessionStatus( ctx->session, OSRF_STATUS_BADREQUEST, "osrfMethodException", ctx->request, m );
+ free(m);
+
+ osrfStringArrayFree(class_list);
+ free(foreign_pkey_value);
+ free(foreign_pkey);
+ jsonObjectFree(param);
+
return 0;
}
jsonObjectFree(_tmp_params);
- jsonObjectFree(_list);
+ free(foreign_pkey_value);
+ free(foreign_pkey);
char* foreign_field = NULL;
while ( (foreign_field = osrfStringArrayGetString(osrfHashGet(fcontext,"context"), i++)) ) {
@@ -1005,7 +1027,7 @@
);
}
- jsonObjectFree(_fparam);
+ jsonObjectFree(_list);
}
osrfStringArrayFree(class_list);
More information about the open-ils-commits
mailing list