[open-ils-commits] r16291 - trunk/Open-ILS/src/c-apps (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Apr 25 10:44:41 EDT 2010


Author: scottmk
Date: 2010-04-25 10:44:38 -0400 (Sun, 25 Apr 2010)
New Revision: 16291

Modified:
   trunk/Open-ILS/src/c-apps/oils_qstore.c
Log:
Implement the .finish method for the qstore server.

M    Open-ILS/src/c-apps/oils_qstore.c


Modified: trunk/Open-ILS/src/c-apps/oils_qstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_qstore.c	2010-04-23 20:53:11 UTC (rev 16290)
+++ trunk/Open-ILS/src/c-apps/oils_qstore.c	2010-04-25 14:44:38 UTC (rev 16291)
@@ -102,6 +102,12 @@
 	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 @@
 	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.



More information about the open-ils-commits mailing list