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() );
/* 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;
}
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];
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);
}
}
- //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;
}
}
- //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));
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;
}
char* xml = json_string_to_xml( content );
free(content);
+ jsonObjectFree(response);
/* set content type to text/xml for passing around XML objects */
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;