From: miker Date: Tue, 6 Jan 2009 02:20:31 +0000 (+0000) Subject: do not fetch from the db for retrieve-type methods (checks are done post-retrieve) X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5c76f98bde12f5c3812291e556b11d9726c3af43;p=Evergreen.git do not fetch from the db for retrieve-type methods (checks are done post-retrieve) git-svn-id: svn://svn.open-ils.org/ILS/trunk@11749 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/c-apps/oils_cstore.c b/Open-ILS/src/c-apps/oils_cstore.c index 4a6b8d614d..512badfd05 100644 --- a/Open-ILS/src/c-apps/oils_cstore.c +++ b/Open-ILS/src/c-apps/oils_cstore.c @@ -861,10 +861,12 @@ static int verifyObjectPCRUD ( osrfMethodContext* ctx, const jsonObject* obj ) osrfHash* meta = (osrfHash*) ctx->method->userData; osrfHash* class = osrfHashGet( meta, "class" ); char* method_type = strdup( osrfHashGet(meta, "methodtype") ); + int fetch = 1; if ( ( *method_type == 's' || *method_type == 'i' ) ) { free(method_type); method_type = strdup("retrieve"); + fetch = 0; // don't go to the db for the object for retrieve-type methods } osrfHash* pcrud = osrfHashGet( osrfHashGet(class, "permacrud"), method_type ); @@ -941,27 +943,32 @@ static int verifyObjectPCRUD ( osrfMethodContext* ctx, const jsonObject* obj ) } else { osrfLogDebug( OSRF_LOG_MARK, "global-level permissions not required, fetching context org ids" ); char* pkey = osrfHashGet(class, "primarykey"); + jsonObject *param = NULL; if (obj->classname) { pkey_value = oilsFMGetString( obj, pkey ); + if (!fetch) param = jsonObjectClone(obj); osrfLogDebug( OSRF_LOG_MARK, "Object supplied, using primary key value of %s", pkey_value ); } else { pkey_value = jsonObjectToSimpleString( obj ); + fetch = 1; osrfLogDebug( OSRF_LOG_MARK, "Object not supplied, using primary key value of %s and retrieving from the database", pkey_value ); } - jsonObject* _tmp_params = jsonParseStringFmt("[{\"%s\":\"%s\"}]", pkey, pkey_value); - jsonObject* _list = doFieldmapperSearch( - ctx, - class, - _tmp_params, - &err - ); + if (fetch) { + jsonObject* _tmp_params = jsonParseStringFmt("[{\"%s\":\"%s\"}]", pkey, pkey_value); + jsonObject* _list = doFieldmapperSearch( + ctx, + class, + _tmp_params, + &err + ); - jsonObject *param = jsonObjectClone(jsonObjectGetIndex(_list, 0)); + param = jsonObjectClone(jsonObjectGetIndex(_list, 0)); - jsonObjectFree(_tmp_params); - jsonObjectFree(_list); + jsonObjectFree(_tmp_params); + jsonObjectFree(_list); + } if (!param) { osrfLogDebug( OSRF_LOG_MARK, "Object not found in the database with primary key %s of %s", pkey, pkey_value );