add logging back and remove old output code
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 30 Nov 2005 21:14:53 +0000 (21:14 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 30 Nov 2005 21:14:53 +0000 (21:14 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2141 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/apachemods/mod_rest_gateway.c

index 1c184df..21a51a8 100644 (file)
@@ -32,7 +32,7 @@ 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("Unable to load gateway config file...");
+               osrfLogError("Unable to load gateway config file...");
                return;
        }
        fprintf(stderr, "Bootstrapping %d\n", getpid() );
@@ -67,7 +67,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
 
        /* verify we are connected */
        if(!osrf_system_get_transport_client()) {
-               //osrfLogError("Bootstrap Failed, no transport client");
+               osrfLogError("Bootstrap Failed, no transport client");
                return HTTP_INTERNAL_SERVER_ERROR;
        }
 
@@ -79,7 +79,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
                ap_setup_client_block(r,REQUEST_CHUNKED_DECHUNK);
 
                if(! ap_should_client_block(r)) {
-                       //osrfLogWarning("No Post Body");
+                       osrfLogWarning("No Post Body");
                }
 
                char body[1025];
@@ -87,7 +87,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
                buffer = buffer_init(1025);
 
                while(ap_get_client_block(r, body, 1024)) {
-                       //osrfLogDebug("Apache read POST block data: %s\n", body);
+                       osrfLogDebug("Apache read POST block data: %s\n", body);
                        buffer_add( buffer, body );
                        memset(body,0,1025);
                }
@@ -105,11 +105,11 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
 
        } 
 
-       //osrfLogDebug("params args are %s", arg);
+       osrfLogDebug("params args are %s", arg);
 
 
        if( ! arg || !arg[0] ) { /* we received no request */
-               //osrfLogWarning("No Args");
+               osrfLogWarning("No Args");
                return OK;
        }
 
@@ -137,68 +137,23 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
 
        }
 
-       //osrfLogInfo("Performing(%d):  service %s | method %s | \n",
-       //              getpid(), service, method );
+       osrfLogInfo("Performing(%d):  service %s | method %s | \n",
+                       getpid(), service, method );
 
        int k;
        for( k = 0; k!= sarray->size; k++ ) {
-               //osrfLogInfo( "param %s", string_array_get_string(sarray,k));
+               osrfLogInfo( "param %s", string_array_get_string(sarray,k));
        }
 
        osrf_app_session* session = osrf_app_client_session_init(service);
 
-       //osrfLogDebug("MOD session service: %s", session->remote_service );
+       osrfLogDebug("MOD session service: %s", session->remote_service );
 
        int req_id = osrf_app_session_make_req( session, NULL, method, 1, sarray );
        string_array_destroy(sarray);
 
        osrf_message* omsg = NULL;
 
-       //growing_buffer* result_data = buffer_init(256);
-       //buffer_add(result_data, "[");
-
-       /* gather result data */
-       /*
-       while((omsg = osrf_app_session_request_recv( session, req_id, 60 ))) {
-
-               if( omsg->_result_content ) {
-                       char* content = jsonObjectToJSON(omsg->_result_content);
-                       buffer_add(result_data, content);
-                       buffer_add( result_data, ",");
-                       free(content);
-
-               } else {
-
-
-                       growing_buffer* exc_buffer = buffer_init(256);
-                       buffer_add( exc_buffer, "\nReceived Exception:\nName: " );
-                       buffer_add( exc_buffer, omsg->status_name );
-                       buffer_add( exc_buffer, "\nStatus: " );
-                       buffer_add( exc_buffer, omsg->status_text );
-                       buffer_add( exc_buffer, "\nStatus: " );
-
-                       char code[16];
-                       memset(code, 0, 16);
-                       sprintf( code, "%d", omsg->status_code );
-                       buffer_add( exc_buffer, code );
-
-                       exception = json_parse_string("{}");
-                       jsonObjectSetKey(exception, "is_err", json_parse_string("1"));
-                       jsonObjectSetKey(exception, "err_msg", jsonNewObject(exc_buffer->buf) );
-
-                       //osrfLogWarning("*** Looks like we got a "
-                       //              "server exception\n%s", exc_buffer->buf );
-
-                       buffer_free(exc_buffer);
-                       osrf_message_free(omsg);
-                       break;
-               }
-
-               osrf_message_free(omsg);
-               omsg = NULL;
-       }
-       */
-
         while((omsg = osrf_app_session_request_recv( session, req_id, 60 ))) {
 
                 jsonObjectSetKey(response, "status", jsonNewNumberObject(omsg->status_code));
@@ -211,8 +166,8 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
                         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( "Gateway received error: %s",
-                        //                jsonObjectGetString(jsonObjectGetKey(response, "debug")));
+                        osrfLogError( "Gateway received error: %s",
+                                        jsonObjectGetString(jsonObjectGetKey(response, "debug")));
                         break;
                 }
 
@@ -224,6 +179,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
        char* xml = json_string_to_xml( content );
 
        free(content);
+       jsonObjectFree(response);
 
        
        /* set content type to text/xml for passing around XML objects */
@@ -232,12 +188,11 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
        free(xml);
 
        osrf_app_session_request_finish( session, req_id );
-       //osrfLogDebug("gateway process message successfully");
+       osrfLogDebug("gateway process message successfully");
 
 
        osrf_app_session_destroy(session);
 
-       jsonObjectFree(response);
 
        return OK;