Removing some dead code
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 19 Feb 2008 13:54:39 +0000 (13:54 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 19 Feb 2008 13:54:39 +0000 (13:54 +0000)
changed (wherever possible) references from objson to the new opensrf/osrf_json.h
cstore is the last remaining legacy json (objson) client that needs updating

git-svn-id: svn://svn.open-ils.org/ILS/trunk@8772 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/apachemods/json_xml.h
Open-ILS/src/apachemods/mod_rest_gateway.c [deleted file]
Open-ILS/src/apachemods/mod_rest_gateway.h [deleted file]
Open-ILS/src/c-apps/Makefile
Open-ILS/src/c-apps/oils_auth.c
Open-ILS/src/c-apps/oils_cstore.c
Open-ILS/src/c-apps/oils_fetch.c [deleted file]

index 2752fd0..e59996b 100644 (file)
@@ -3,8 +3,7 @@
 #include <stdio.h>
 
 /* the JSON parser, so we can read the response we're XMLizing */
-#include "objson/object.h"
-#include "objson/json_parser.h"
-#include "utils.h"
+#include <opensrf/osrf_json.h>
+#include <opensrf/utils.h>
 
 char* json_string_to_xml(char*);
diff --git a/Open-ILS/src/apachemods/mod_rest_gateway.c b/Open-ILS/src/apachemods/mod_rest_gateway.c
deleted file mode 100644 (file)
index 8adff62..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-#include "mod_rest_gateway.h"
-#include "http_log.h"
-
-char* ils_rest_gateway_config_file;
-
-static const char* ils_gateway_set_config(cmd_parms *parms, void *config, const char *arg) {
-       ils_gateway_config  *cfg;
-
-       cfg = ap_get_module_config(parms->server->module_config, &ils_rest_gateway_module);
-
-       cfg->configfile = (char*) arg;
-       ils_rest_gateway_config_file = (char*) arg;
-
-       return NULL;
-}
-
-/* tell apache about our commands */
-static const command_rec ils_gateway_cmds[] = {
-       AP_INIT_TAKE1( GATEWAY_CONFIG, ils_gateway_set_config, NULL, RSRC_CONF, "gateway config file"),
-       {NULL}
-};
-
-/* build the config object */
-static void* ils_gateway_create_config( apr_pool_t* p, server_rec* s) {
-       ils_gateway_config* cfg = (ils_gateway_config*) apr_palloc(p, sizeof(ils_gateway_config));
-       cfg->configfile = GATEWAY_DEFAULT_CONFIG;
-       return (void*) cfg;
-}
-
-
-static void mod_ils_gateway_child_init(apr_pool_t *p, server_rec *s) {
-
-       char* cfg = ils_rest_gateway_config_file;
-
-       if( ! osrf_system_bootstrap_client( cfg, CONFIG_CONTEXT) ) {
-               osrfLogError( OSRF_LOG_MARK, "Unable to load gateway config file...");
-               return;
-       }
-       fprintf(stderr, "Bootstrapping %ld\n", (long) getpid() );
-       fflush(stderr);
-}
-
-static int mod_ils_gateway_method_handler (request_rec *r) {
-
-       /* make sure we're needed first thing*/
-       if (strcmp(r->handler, MODULE_NAME )) 
-               return DECLINED;
-
-       osrfLogSetAppname("oils_rest_gw");
-
-       apr_pool_t *p = r->pool;        /* memory pool */
-       char* arg = r->args;                    /* url query string */
-
-       char* service                                   = NULL; /* service to connect to */
-       char* method                                    = NULL; /* method to perform */
-
-       //json* exception                               = NULL; /* returned in error conditions */
-       //jsonObject* exception                         = NULL; /* returned in error conditions */
-       string_array* sarray                    = init_string_array(12); /* method parameters */
-
-       growing_buffer* buffer          = NULL; /* POST data */
-       growing_buffer* tmp_buf         = NULL; /* temp buffer */
-
-       char* key                                               = NULL; /* query item name */
-       char* val                                               = NULL; /* query item value */
-
-        jsonObject* response                    = jsonParseString("{\"status\":0,\"debug\":\"\"}");
-        jsonObject* payload                     = jsonParseString("[]");
-        jsonObjectSetKey(response, "payload", payload );
-
-       /* verify we are connected */
-               if(!osrfSystemGetTransportClient()) {
-               osrfLogError( OSRF_LOG_MARK, "Bootstrap Failed, no transport client");
-               return HTTP_INTERNAL_SERVER_ERROR;
-       }
-
-
-       /* gather the post args and append them to the url query string */
-       if( !strcmp(r->method,"POST") ) {
-
-               ap_setup_client_block(r,REQUEST_CHUNKED_DECHUNK);
-
-               if(! ap_should_client_block(r)) {
-                       osrfLogWarning( OSRF_LOG_MARK, "No Post Body");
-               }
-
-               char body[1025];
-               memset(body, '\0', sizeof(body));
-               buffer = buffer_init(1025);
-
-               while(ap_get_client_block(r, body, 1024)) {
-                       buffer_add( buffer, body );
-                       memset(body, '\0', sizeof(body));
-               }
-
-               if(arg && arg[0]) {
-                       tmp_buf = buffer_init(1024);
-                       buffer_add(tmp_buf,arg);
-                       buffer_add(tmp_buf,buffer->buf);
-                       arg = (char*) apr_pstrdup(p, tmp_buf->buf);
-                       buffer_free(tmp_buf);
-               } else {
-                       arg = (char*) apr_pstrdup(p, buffer->buf);
-               }
-               buffer_free(buffer);
-
-       } 
-
-       ap_log_rerror( APLOG_MARK, APLOG_DEBUG, 0, r, "URL: %s", arg );
-
-
-       if( ! arg || !arg[0] ) { /* we received no request */
-               osrfLogWarning( OSRF_LOG_MARK, "No Args");
-               return OK;
-       }
-
-       r->allowed |= (AP_METHOD_BIT << M_GET);
-       r->allowed |= (AP_METHOD_BIT << M_POST);
-
-       
-       while( arg && (val = ap_getword(p, (const char**) &arg, '&'))) {
-
-               key = ap_getword(r->pool, (const char**) &val, '=');
-               if(!key || !key[0])
-                       break;
-
-               ap_unescape_url((char*)key);
-               ap_unescape_url((char*)val);
-
-               if(!strcmp(key,"service")) 
-                       service = val;
-
-               if(!strcmp(key,"method"))
-                       method = val;
-
-               if(!strcmp(key,"param"))
-                       string_array_add(sarray, val);
-
-       }
-
-       osrfLogInfo( OSRF_LOG_MARK, "Performing(%ld):  service %s | method %s | \n",
-                       (long) getpid(), service, method );
-
-       int k;
-       for( k = 0; k!= sarray->size; k++ ) {
-               osrfLogInfo( OSRF_LOG_MARK,  "param %s", string_array_get_string(sarray,k));
-       }
-
-       osrf_app_session* session = osrf_app_client_session_init(service);
-
-       osrfLogDebug( OSRF_LOG_MARK, "MOD session service: %s", session->remote_service );
-
-       int req_id = osrfAppSessionMakeRequest( session, NULL, method, 1, sarray );
-       string_array_destroy(sarray);
-
-       osrf_message* omsg = NULL;
-
-       while((omsg = osrfAppSessionRequestRecv( session, req_id, 60 ))) {
-
-                jsonObjectSetKey(response, "status", jsonNewNumberObject(omsg->status_code));
-
-                if( omsg->_result_content ) {
-                        jsonObjectPush( payload, jsonObjectClone(omsg->_result_content));
-
-                } else {
-
-                        char* s = omsg->status_name ? omsg->status_name : "Unknown Error";
-                        char* t = omsg->status_text ? omsg->status_text : "No Error Message";
-                        jsonObjectSetKey(response, "debug", jsonNewObject("\n\n%s:\n%s\n", s, t));
-                        osrfLogError( OSRF_LOG_MARK,  "Gateway received error: %s",
-                                        jsonObjectGetString(jsonObjectGetKeyConst(response, "debug")));
-                        break;
-                }
-
-                osrf_message_free(omsg);
-                omsg = NULL;
-        }
-
-        char* content = jsonObjectToJSON(response);
-       char* xml = json_string_to_xml( content );
-
-       free(content);
-       jsonObjectFree(response);
-
-       
-       /* set content type to text/xml for passing around XML objects */
-       ap_set_content_type(r, "text/xml");
-       ap_rputs(xml,r);
-       free(xml);
-
-       osrf_app_session_request_finish( session, req_id );
-       osrfLogDebug( OSRF_LOG_MARK, "gateway process message successfully");
-
-
-       osrfAppSessionFree(session);
-
-
-       return OK;
-
-}
-
-static void mod_ils_gateway_register_hooks (apr_pool_t *p) {
-       ap_hook_handler(mod_ils_gateway_method_handler, NULL, NULL, APR_HOOK_MIDDLE);
-       ap_hook_child_init(mod_ils_gateway_child_init,NULL,NULL,APR_HOOK_MIDDLE);
-}
-
-
-module AP_MODULE_DECLARE_DATA ils_rest_gateway_module = {
-       STANDARD20_MODULE_STUFF,
-       NULL,
-       NULL,
-       ils_gateway_create_config,
-       NULL,
-       ils_gateway_cmds,
-       mod_ils_gateway_register_hooks,
-};
-
diff --git a/Open-ILS/src/apachemods/mod_rest_gateway.h b/Open-ILS/src/apachemods/mod_rest_gateway.h
deleted file mode 100644 (file)
index 571e3d6..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_protocol.h"
-//#include "apr_compat.h"
-#include "apr_strings.h"
-
-/* our stuff */
-#include "opensrf/transport_client.h"
-#include "opensrf/osrf_message.h"
-#include "opensrf/osrf_app_session.h"
-#include "string_array.h"
-#include "md5.h"
-#include "objson/object.h"
-#include "objson/json_parser.h"
-
-#include "json_xml.h"
-#define GATEWAY_CONFIG "ILSRestGatewayConfig"
-#define MODULE_NAME "ils_rest_gateway_module"
-#define CONFIG_CONTEXT "gateway"
-
-#define GATEWAY_DEFAULT_CONFIG "/openils/conf/opensrf_core.xml"
-
-
-/* our config structure */
-typedef struct { 
-       char* configfile;  /* our bootstrap config file */
-} ils_gateway_config;
-
-module AP_MODULE_DECLARE_DATA ils_rest_gateway_module;
-
index 645579e..fb206a5 100644 (file)
@@ -1,4 +1,4 @@
-LDLIBS += -lobjson -lopensrf #-lfieldmapper 
+LDLIBS +=  -lopensrf #-lfieldmapper 
 LDFLAGS += -Wl,-rpath=$(LIBDIR) -L$(DBI_LIBS)
 CFLAGS += -DOSRF_LOG_PARAMS
 
index 8c4321d..1373659 100644 (file)
@@ -1,7 +1,7 @@
 #include "opensrf/osrf_app_session.h"
 #include "opensrf/osrf_application.h"
 #include "opensrf/osrf_settings.h"
-#include "objson/object.h"
+#include "opensrf/osrf_json.h"
 #include "opensrf/log.h"
 #include "openils/oils_utils.h"
 #include "openils/oils_constants.h"
index 0be1eb7..4ab1579 100644 (file)
@@ -2,10 +2,11 @@
 #include "opensrf/osrf_settings.h"
 #include "opensrf/osrf_message.h"
 #include "opensrf/utils.h"
-#include "objson/object.h"
+#include "opensrf/osrf_json.h"
 #include "opensrf/log.h"
 #include "openils/oils_idl.h"
 #include <dbi/dbi.h>
+#include <objson/object.h>
 
 #include <time.h>
 #include <stdlib.h>
diff --git a/Open-ILS/src/c-apps/oils_fetch.c b/Open-ILS/src/c-apps/oils_fetch.c
deleted file mode 100644 (file)
index 4babd25..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-#include "opensrf/osrf_app_session.h"
-#include "opensrf/osrf_application.h"
-#include "opensrf/osrf_settings.h"
-#include "objson/object.h"
-#include "opensrf/log.h"
-#include "openils/oils_utils.h"
-#include "openils/oils_constants.h"
-#include "openils/oils_event.h"
-#include <dbi/dbi.h>
-#include <openils/fieldmapper_lookup.h>
-
-#define OILS_AUTH_CACHE_PRFX "oils_fetch_"
-
-#define MODULENAME "open-ils.fetch"
-dbi_conn dbhandle; /* our db connection */
-
-/* handy NULL json object to have around */
-static jsonObject* oilsFetchNULL = NULL;
-
-int osrfAppChildInit();
-
-/* turns a singal db result row into a jsonObject */
-jsonObject* oilsFetchMakeJSON( dbi_result result, char* hint );
-
-osrfHash* fmClassMap = NULL;
-
-
-int osrfAppInitialize() {
-       osrfLogInfo(OSRF_LOG_MARK, "Initializing Fetch Server...");
-
-       oilsFetchNULL = jsonNewObject(NULL);
-       fmClassMap = osrfNewHash();
-
-       int i;
-       char* hint;
-       char* apiname;
-
-       osrfList* keys = fm_classes();
-       if(!keys) return 0;
-
-       /* cycle through all of the classes and register a 
-        * retrieve method for each */
-       for( i = 0; i < keys->size; i++ ) {
-
-               hint = OSRF_LIST_GET_INDEX(keys, i);    
-               i++;
-               apiname = OSRF_LIST_GET_INDEX(keys, i); 
-               if(!(hint && apiname)) break;
-
-               osrfHashSet( fmClassMap, hint, apiname );
-
-               char method[256];
-               snprintf(method, sizeof(method), "open-ils.fetch.%s.retrieve", apiname);
-
-               osrfAppRegisterMethod( MODULENAME, 
-                               method, "oilsFetchDoRetrieve", "", 1, 0 );
-       }
-
-       return 0;
-}
-
-
-/**
- * Connects to the database 
- */
-int osrfAppChildInit() {
-
-       dbi_initialize(NULL);
-
-       char* driver = osrf_settings_host_value("/apps/%s/app_settings/databases/driver", MODULENAME);
-       char* user       = osrf_settings_host_value("/apps/%s/app_settings/databases/database/user", MODULENAME);
-       char* host       = osrf_settings_host_value("/apps/%s/app_settings/databases/database/host", MODULENAME);
-       char* port       = osrf_settings_host_value("/apps/%s/app_settings/databases/database/port", MODULENAME);
-       char* db                 = osrf_settings_host_value("/apps/%s/app_settings/databases/database/db", MODULENAME);
-       char* pw                 = osrf_settings_host_value("/apps/%s/app_settings/databases/database/pw", MODULENAME);
-
-       dbhandle = dbi_conn_new(driver);
-
-       if(!dbhandle) {
-               osrfLogError(OSRF_LOG_MARK, "Error creating database driver %s", driver);
-               return -1;
-       }
-
-       osrfLogInfo(OSRF_LOG_MARK, "oils_fetch connecting to database.  host=%s, "
-               "port=%s, user=%s, pw=%s, db=%s", host, port, user, pw, db );
-
-       if(host) dbi_conn_set_option(dbhandle, "host", host );
-       if(port) dbi_conn_set_option_numeric( dbhandle, "port", atoi(port) );
-       if(user) dbi_conn_set_option(dbhandle, "username", user);
-       if(pw) dbi_conn_set_option(dbhandle, "password", pw );
-       if(db) dbi_conn_set_option(dbhandle, "dbname", db );
-
-       free(user);
-       free(host);
-       free(port);
-       free(db);
-       free(pw);
-
-       if (dbi_conn_connect(dbhandle) < 0) {
-               const char* err;
-               dbi_conn_error(dbhandle, &err);
-               osrfLogError( OSRF_LOG_MARK, "Error connecting to database: %s", err);
-               return -1;
-       }
-
-       osrfLogInfo(OSRF_LOG_MARK, "%s successfully connected to the database", MODULENAME);
-
-       return 0;
-}
-
-
-
-int oilsFetchDoRetrieve( osrfMethodContext* ctx ) {
-
-       OSRF_METHOD_VERIFY_CONTEXT(ctx); 
-
-       char* id                = jsonObjectToSimpleString(jsonObjectGetIndex(ctx->params, 0));
-       char* meth      = strdup(ctx->method->name);
-       char* strtk;
-
-       strtok_r(meth, ".", &strtk); /* open-ils */
-       strtok_r(NULL, ".", &strtk); /* fetch */
-       char* schema    = strtok_r(NULL, ".", &strtk); 
-       char* object    = strtok_r(NULL, ".", &strtk);
-
-       osrfLogDebug(OSRF_LOG_MARK, "%s retrieving %s.%s "
-                       "object with id %s", MODULENAME, schema, object, id );
-
-       /* construct the SQL */
-       char sql[256];
-       snprintf( sql, sizeof(sql), "select * from %s.%s where id = %s;", schema, object, id );
-
-       /* find the object hint from the api name */
-       char hintbuf[256];
-       snprintf(hintbuf, sizeof(hintbuf), "%s.%s", schema, object );
-       char* hint = osrfHashGet( fmClassMap, hintbuf );
-
-       osrfLogDebug(OSRF_LOG_MARK, "%s SQL =  %s", MODULENAME, sql);
-
-       dbi_result result = dbi_conn_queryf(dbhandle, sql);
-
-       if(result) {
-
-               /* there should be one row at the most  */
-               dbi_result_next_row(result); 
-
-               /* JSONify the result */
-               jsonObject* obj = oilsFetchMakeJSON( result, hint );
-
-               /* clean up the query */
-               dbi_result_free(result); 
-
-               osrfAppRespondComplete( ctx, obj ); 
-               jsonObjectFree(obj);
-
-       } else {
-
-               osrfLogDebug(OSRF_LOG_MARK, "%s returned no results for query %s", MODULENAME, sql);
-               osrfAppRespondComplete( ctx, oilsFetchNULL );
-       }
-
-       free(id);
-       free(meth);
-       return 0;
-}
-
-
-jsonObject* oilsFetchMakeJSON( dbi_result result, char* hint ) {
-       if(!(result && hint)) return NULL;
-
-       jsonObject* object = jsonParseString("[]");
-       jsonObjectSetClass(object, hint);
-
-       int attr;  
-       int fmIndex; 
-       int columnIndex = 1; 
-       unsigned short type;
-       const char* columnName; 
-
-       /* cycle through the column list */
-       while( (columnName = dbi_result_get_field_name(result, columnIndex++)) ) {
-
-               /* determine the field type and storage attributes */
-               type = dbi_result_get_field_type(result, columnName);
-               attr = dbi_result_get_field_attribs(result, columnName);
-
-               /* fetch the fieldmapper index */
-               if( (fmIndex = fm_ntop(hint, (char*) columnName)) < 0 ) continue;
-
-               switch( type ) {
-
-                       case DBI_TYPE_INTEGER :
-
-                               if( attr & DBI_INTEGER_SIZE8 ) 
-                                       jsonObjectSetIndex( object, fmIndex, 
-                                               jsonNewNumberObject(dbi_result_get_longlong(result, columnName)));
-                               else 
-                                       jsonObjectSetIndex( object, fmIndex, 
-                                               jsonNewNumberObject(dbi_result_get_long(result, columnName)));
-
-                               break;
-
-                       case DBI_TYPE_DECIMAL :
-                               jsonObjectSetIndex( object, fmIndex, 
-                                               jsonNewNumberObject(dbi_result_get_double(result, columnName)));
-                               break;
-
-                       case DBI_TYPE_STRING :
-                               jsonObjectSetIndex( object, fmIndex, 
-                                       jsonNewObject(dbi_result_get_string(result, columnName)));
-                               break;
-
-                       case DBI_TYPE_DATETIME :
-                               jsonObjectSetIndex( object, fmIndex, 
-                                       jsonNewNumberObject(dbi_result_get_datetime(result, columnName)));
-                               break;
-
-                       case DBI_TYPE_BINARY :
-                               osrfLogError( OSRF_LOG_MARK, 
-                                       "Can't do binary at column %s : index %d", columnName, columnIndex - 1);
-               }
-       }
-
-       return object;
-}
-
-
-