[Opensrf-commits] r1009 - branches/new-json2/src/gateway

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Jul 6 17:12:44 EDT 2007


Author: erickson
Date: 2007-07-06 17:08:42 -0400 (Fri, 06 Jul 2007)
New Revision: 1009

Modified:
   branches/new-json2/src/gateway/osrf_json_gateway.c
Log:
made gateway config simpler for legacy json support.  assuming legacy json for now

Modified: branches/new-json2/src/gateway/osrf_json_gateway.c
===================================================================
--- branches/new-json2/src/gateway/osrf_json_gateway.c	2007-07-06 20:56:08 UTC (rev 1008)
+++ branches/new-json2/src/gateway/osrf_json_gateway.c	2007-07-06 21:08:42 UTC (rev 1009)
@@ -13,10 +13,10 @@
 #define MODULE_NAME "osrf_json_gateway_module"
 #define GATEWAY_CONFIG "OSRFGatewayConfig"
 #define CONFIG_CONTEXT "gateway"
-#define JSON_PROTOCOL "OSRFGatewayJSONProtocol"
+#define JSON_PROTOCOL "OSRFGatewayLegacyJSON"
+#define GATEWAY_USE_LEGACY_JSON 1
 
 #define GATEWAY_DEFAULT_CONFIG "/openils/conf/opensrf_core.xml"
-#define GATEWAY_DEFAULT_PROTOCOL "wrapper"  // other option is "classy"
 
 
 /* our config structure */
@@ -25,7 +25,7 @@
 } osrf_json_gateway_config;
 
 typedef struct { 
-	char* JSONProtocol;
+	int legacyJSON;
 } osrf_json_gateway_dir_config;
 
 
@@ -46,7 +46,7 @@
 
 static const char* osrf_json_gateway_set_json_proto(cmd_parms *parms, void *config, const char *arg) {
 	osrf_json_gateway_dir_config* cfg = (osrf_json_gateway_dir_config*) config;
-	cfg->JSONProtocol = (char*) arg;
+	cfg->legacyJSON = (!strcasecmp((char*) arg, "false")) ? 0 : 1;
 	return NULL;
 }
 
@@ -70,7 +70,7 @@
 static void* osrf_json_gateway_create_dir_config( apr_pool_t* p, char* dir) {
 	osrf_json_gateway_dir_config* cfg = (osrf_json_gateway_dir_config*) 
 			apr_palloc(p, sizeof(osrf_json_gateway_dir_config));
-	cfg->JSONProtocol = GATEWAY_DEFAULT_PROTOCOL;
+	cfg->legacyJSON = GATEWAY_USE_LEGACY_JSON;
 	return (void*) cfg;
 }
 
@@ -110,15 +110,16 @@
 	osrf_json_gateway_dir_config* dir_conf =  
 		ap_get_module_config(r->per_dir_config, &osrf_json_gateway_module);
 
-	ap_log_rerror( APLOG_MARK, APLOG_INFO, 0, r, "JSON protocol = %s", dir_conf->JSONProtocol);
 
 	/* provide 2 different JSON parsers and serializers to support legacy JSON */
 	jsonObject* (*parseJSONFunc) (char*) = legacy_jsonParseString;
 	char* (*jsonToStringFunc) (const jsonObject*) = legacy_jsonObjectToJSON;
 
-	if(dir_conf->JSONProtocol && !strcmp(dir_conf->JSONProtocol,"wrapper") ) {
-		/* if protocol is wrapper, use the new wrapper JSON code */
-		ap_log_rerror( APLOG_MARK, APLOG_INFO, 0, r, "Using wrapper JSON");
+	if(dir_conf->legacyJSON) {
+	    ap_log_rerror( APLOG_MARK, APLOG_INFO, 0, r, "Using legacy JSON");
+
+    } else {
+	    ap_log_rerror( APLOG_MARK, APLOG_INFO, 0, r, "Not using legacy JSON");
 		parseJSONFunc = jsonParseString;
 		jsonToStringFunc = jsonObjectToJSON;
 	}



More information about the opensrf-commits mailing list