From: scottmk Date: Sun, 25 Apr 2010 14:44:38 +0000 (+0000) Subject: Implement the .finish method for the qstore server. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=731872e4307b8e88d65ea2ba03f5e4845c919943;p=evergreen%2Fmasslnc.git Implement the .finish method for the qstore server. M Open-ILS/src/c-apps/oils_qstore.c git-svn-id: svn://svn.open-ils.org/ILS/trunk@16291 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/c-apps/oils_qstore.c b/Open-ILS/src/c-apps/oils_qstore.c index 3438a3ceb8..a141741c9d 100644 --- a/Open-ILS/src/c-apps/oils_qstore.c +++ b/Open-ILS/src/c-apps/oils_qstore.c @@ -102,6 +102,12 @@ int osrfAppInitialize() { osrfAppRegisterMethod( modulename, OSRF_BUFFER_C_STR( method_name ), "doSql", "", 1, OSRF_METHOD_STREAMING ); + buffer_reset( method_name ); + OSRF_BUFFER_ADD( method_name, modulename ); + OSRF_BUFFER_ADD( method_name, ".finish" ); + osrfAppRegisterMethod( modulename, OSRF_BUFFER_C_STR( method_name ), + "doFinish", "", 1, 0 ); + return 0; } @@ -326,6 +332,31 @@ int doSql( osrfMethodContext* ctx ) { return 0; } +int doFinish( osrfMethodContext* ctx ) { + if(osrfMethodVerifyContext( ctx )) { + osrfLogError( OSRF_LOG_MARK, "Invalid method context" ); + return -1; + } + + // Get the query token. + const jsonObject* token_obj = jsonObjectGetIndex( ctx->params, 0 ); + if( token_obj->type != JSON_STRING ) { + osrfAppSessionStatus( ctx->session, OSRF_STATUS_BADREQUEST, "osrfMethodException", + ctx->request, "Invalid parameter; query token must be a string" ); + return -1; + } + const char* token = jsonObjectGetString( token_obj ); + + // Delete the corresponding entry from the cache. If there is no cache, or no such entry, + // just ignore the problem and report success. + osrfHash* cache = ctx->session->userData; + if( cache ) + osrfHashRemove( cache, token ); + + osrfAppRespondComplete( ctx, NULL ); + return 0; +} + /** @brief Save a query in session-level userData for reference in future method calls. @param ctx Pointer to the current method context.