[Opensrf-commits] r1299 - trunk/src/javascript

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Apr 8 10:12:31 EDT 2008


Author: erickson
Date: 2008-04-08 09:35:23 -0400 (Tue, 08 Apr 2008)
New Revision: 1299

Removed:
   trunk/src/javascript/opensrf_app_session.js
   trunk/src/javascript/opensrf_config.js
   trunk/src/javascript/opensrf_dom_element.js
   trunk/src/javascript/opensrf_domain_object.js
   trunk/src/javascript/opensrf_msg_stack.js
   trunk/src/javascript/opensrf_transport.js
   trunk/src/javascript/opensrf_utils.js
Log:

The functionality in these files (that isn't deprecated) has been replaced by opensrf.js
Leaving opensrf_jabber_transport.js in place for reference...



Deleted: trunk/src/javascript/opensrf_app_session.js
===================================================================
--- trunk/src/javascript/opensrf_app_session.js	2008-04-07 21:11:41 UTC (rev 1298)
+++ trunk/src/javascript/opensrf_app_session.js	2008-04-08 13:35:23 UTC (rev 1299)
@@ -1,509 +0,0 @@
-/** @file oils_app_session.js
-  * @brief AppRequest and AppSession.
-  * The AppSession class does most of the communication work and the AppRequest 
-  * contains the top level client API.
-  */
-
-/** The default wait time when a client calls recv. It
-  * may be overrided by passing in a value to the recv method
-  */
-AppRequest.DEF_RECV_TIMEOUT = 10000;
-
-/** Provide a pre-built AppSession object and the payload of the REQUEST
-  * message you wish to send
-  */
-function AppRequest( session, payload ) {
-
-	/** Our controling session */
-	this.session = session;
-
-	/** This requests message thread trace */
-	this.thread_trace = null;
-
-	/** This request REQUEST payload */
-	this.payload = payload;
-
-	/** True if this request has completed is request cycle */
-	this.is_complete = false;
-
-	/** Stores responses received from requests */
-	this.recv_queue = new Array();
-}
-
-/** returns true if this AppRequest has completed its request cycle.  */
-AppRequest.prototype.complete = function() {
-	if( this.is_complete ) { return true; }
-	this.session.queue_wait(0);
-	return this.is_complete;
-}
-
-/** When called on an AppRequest object, its status will be
-  * set to complete regardless of its previous status
-  */
-AppRequest.prototype.set_complete = function() {
-	this.is_complete = true;
-}
-
-/** Returns the current thread trace */
-AppRequest.prototype.get_thread_trace = function() {
-	return this.thread_trace;
-}
-
-/** Pushes some payload onto the recv queue */
-AppRequest.prototype.push_queue = function( payload ) {
-	this.recv_queue.push( payload );
-}
-
-/** Returns the current payload of this request */
-AppRequest.prototype.get_payload = function() {
-	return this.payload;
-}
-
-/** Removes this request from the our AppSession's request bucket 
-  * Call this method when you are finished with a particular request 
-  */
-AppRequest.prototype.finish = function() {
-	this.session.remove_request( this );
-}
-
-
-/** Retrieves the current thread trace from the associated AppSession object,
-  * increments that session's thread trace, sets this AppRequest's thread trace
-  * to the new value.  The request is then sent.
-  */
-AppRequest.prototype.make_request = function() {
-	var tt = this.session.get_thread_trace();
-	this.session.set_thread_trace( ++tt );
-	this.thread_trace = tt;
-	this.session.add_request( this );
-	this.session.send( oilsMessage.REQUEST, tt, this.payload );
-}
-
-/** Checks the receive queue for message payloads.  If any are found, the first 
-  * is returned.  Otherwise, this method will wait at most timeout seconds for
-  * a message to appear in the receive queue.  Once it arrives it is returned.
-  * If no messages arrive in the timeout provided, null is returned.
-
-  * NOTE: timeout is in * milliseconds *
-  */
-
-AppRequest.prototype.recv = function( /*int*/ timeout ) {
-
-
-	if( this.recv_queue.length > 0 ) {
-		return this.recv_queue.shift();
-	}
-
-	if( this.is_complete ) { return null; }
-
-	if( timeout == null ) {
-		timeout = AppRequest.DEF_RECV_TIMEOUT;
-	}
-
-	while( timeout > 0 ) {
-
-		var start = new Date().getTime();
-		this.session.queue_wait( timeout );
-
-		if( this.recv_queue.length > 0 ) {
-			return this.recv_queue.shift();
-		}
-
-		// shortcircuit the call if we're already complete
-		if( this.complete() ) { return null; }
-
-		new Logger().debug( "AppRequest looping in recv " 
-				+ this.get_thread_trace() + " with timeout " + timeout, Logger.DEBUG );
-
-		var end = new Date().getTime();
-		timeout -= ( end - start );
-	}
-
-	return null;
-}
-
-/** Resend this AppRequest's REQUEST message, useful for recovering
- * from disconnects, etc.
- */
-AppRequest.prototype.resend = function() {
-
-	new Logger().debug( "Resending msg with thread trace: " 
-			+ this.get_thread_trace(), Logger.DEBUG );
-	this.session.send( oilsMessage.REQUEST, this.get_thread_trace(), this.payload );
-}
-
-
-
-	
-// -----------------------------------------------------------------------------
-// -----------------------------------------------------------------------------
-// AppSession code
-// -----------------------------------------------------------------------------
-
-/** Global cach of AppSession objects */
-AppSession.session_cache = new Array();
-
-// -----------------------------------------------------------------------------
-// Session states
-// -----------------------------------------------------------------------------
-/** True when we're attempting to connect to a remte service */
-AppSession.CONNECTING	= 0; 
-/** True when we have successfully connected to a remote service */
-AppSession.CONNECTED		= 1;
-/** True when we have been disconnected from a remote service */
-AppSession.DISCONNECTED = 2;
-/** The current default method protocol */
-AppSession.PROTOCOL		= 1;
-
-/** Our connection with the outside world */
-AppSession.transport_handle = null;
-
-
-/** Returns the session with the given session id */
-AppSession.find_session = function(session_id) {
-	return AppSession.session_cache[session_id];
-}
-
-/** Adds the given session to the global cache */
-AppSession.push_session = function(session) {
-	AppSession.session_cache[session.get_session_id()] = session;
-}
-
-/** Deletes the session with the given session id from the global cache */
-AppSession.delete_session = function(session_id) {
-	AppSession.session_cache[session_id] = null;
-}
-
-/** Builds a new session.
-  * @param remote_service The remote service we want to make REQUEST's of
-  */
-function AppSession( remote_service ) {
-
-	if (arguments.length == 3) {
-		// it used to be AppSession( username, password, remote_service )
-		remote_service = arguments[2];
-	}
-
-	/** Our logger object */
-	this.logger = new Logger();
-
-	random_num = Math.random() + "";
-	random_num.replace( '.', '' );
-
-	/** Our session id */
-	this.session_id = new Date().getTime() + "" + random_num;
-
-	//this.auth = new userAuth( username, password );
-
-	/** Our AppRequest queue */
-	this.request_queue = new Array();
-
-	/** Our connectivity state */
-	this.state = AppSession.DISCONNECTED;
-
-	var config = new Config();
-	
-	/** The remote ID of the service we are communicating with as retrieved 
-	  * from the config file
-	 */
-	this.orig_remote_id = config.get_value( "remote_service/" + remote_service );
-	if( ! this.orig_remote_id ) { 
-		throw new oils_ex_config( "No remote service id for: " + remote_service );
-	}
-
-	/** The current remote ID of the service we are communicating with */
-	this.remote_id = this.orig_remote_id;
-
-	/** Our current request threadtrace, which is incremented with each 
-	  * newly sent AppRequest */
-	this.thread_trace = 0;
-
-	/** Our queue of AppRequest objects */
-	this.req_queue = new Array();
-
-	/** Our queue of AppRequests that are awaiting a resend of their payload */
-	this.resend_queue = new Array();
-
-	// Build the transport_handle if if doesn't already exist
-	if( AppSession.transport_handle == null ) {
-		this.build_transport();
-	}
-
-	AppSession.push_session( this );
-
-}
-
-/** The transport implementation is loaded from the config file and magically
-  * eval'ed into an object.  All connection settings come from the client 
-  * config.
-  * * This should only be called by the AppSession constructor and only when
-  * the transport_handle is null.
-  */
-AppSession.prototype.build_transport = function() {
-
-	var config = new Config();
-	var transport_impl = config.get_value( "transport/transport_impl" );
-	if( ! transport_impl ) {
-		throw new oils_ex_config( "No transport implementation defined in config file" );
-	}
-
-	var username	= config.get_value( "transport/username" );
-	var password	= config.get_value( "transport/password" );
-	var this_host	= config.get_value( "system/hostname" );
-	var resource	= this_host + "_" + new Date().getTime();
-	var server		= config.get_value( "transport/primary" );
-	var port			= config.get_value( "transport/port" );
-	var tim			= config.get_value( "transport/connect_timeout" );
-	var timeout		= tim * 1000;
-
-	var eval_string = 
-		"AppSession.transport_handle = new " + transport_impl + "( username, password, resource );";
-
-	eval( eval_string );
-	
-	if( AppSession.transport_handle == null ) {
-		throw new oils_ex_config( "Transport implementation defined in config file is not valid" );
-	}
-
-	if( !AppSession.transport_handle.connect( server, port, timeout ) ) {
-		throw new oils_ex_transport( "Connection attempt to remote service timed out" );
-	}
-
-	if( ! AppSession.transport_handle.connected() ) {
-		throw new oils_ex_transport( "AppSession is unable to connect to the remote service" );
-	}
-}
-
-
-/** Adds the given AppRequest object to this AppSession's request queue */
-AppSession.prototype.add_request = function( req_obj ) {
-	new Logger().debug( "Adding AppRequest: " + req_obj.get_thread_trace(), Logger.DEBUG );
-	this.req_queue[req_obj.get_thread_trace()] = req_obj;
-}
-
-/** Removes the AppRequest object from this AppSession's request queue */
-AppSession.prototype.remove_request = function( req_obj ) {
-	this.req_queue[req_obj.get_thread_trace()] = null;
-}
-
-/** Returns the AppRequest with the given thread_trace */
-AppSession.prototype.get_request = function( thread_trace ) {
-	return this.req_queue[thread_trace];
-}
-
-
-/** Returns this AppSession's session id */
-AppSession.prototype.get_session_id = function() { 
-	return this.session_id; 
-}
-
-/** Resets the remote_id for the transport to the original remote_id retrieved
-  * from the config file
-  */
-AppSession.prototype.reset_remote = function() { 
-	this.remote_id = this.orig_remote_id; 
-}
-
-/** Returns the current message thread trace */
-AppSession.prototype.get_thread_trace = function() {
-	return this.thread_trace;
-}
-
-/** Sets the current thread trace */
-AppSession.prototype.set_thread_trace = function( tt ) {
-	this.thread_trace = tt;
-}
-
-/** Returns the state that this session is in (i.e. CONNECTED) */
-AppSession.prototype.get_state = function() {
-	return this.state;
-}
-
-/** Sets the session state.  The state should be one of the predefined 
-  * session AppSession session states.
-  */
-AppSession.prototype.set_state = function(state) {
-	this.state = state;
-}
-
-/** Returns the current remote_id for this session */
-AppSession.prototype.get_remote_id = function() {
-	return this.remote_id;
-}
-
-/** Sets the current remote_id for this session */
-AppSession.prototype.set_remote_id = function( id ) {
-	this.remote_id = id;
-}
-
-/** Pushes an AppRequest object onto the resend queue */
-AppSession.prototype.push_resend = function( app_request ) {
-	this.resend_queue.push( app_request );
-}
-
-/** Destroys the current session.  This will disconnect from the
-  * remote service, remove all AppRequests from the request
-  * queue, and finally remove this session from the global cache
-  */
-AppSession.prototype.destroy = function() {
-
-	new Logger().debug( "Destroying AppSession: " + this.get_session_id(), Logger.DEBUG );
-
-	// disconnect from the remote service
-	if( this.get_state() != AppSession.DISCONNECTED ) {
-		this.disconnect();
-	}
-	// remove us from the global cache
-	AppSession.delete_session( this.get_session_id() );
-
-	// Remove app request references
-	for( var index in this.req_queue ) {
-		this.req_queue[index] = null;
-	}
-}
-
-/** This forces a resend of all AppRequests that are currently 
-  * in the resend queue
-  */
-AppSession.prototype.flush_resend = function() {
-
-	if( this.resend_queue.length > 0 ) {
-		new Logger().debug( "Resending " 
-			+ this.resend_queue.length + " messages", Logger.INFO );
-	}
-
-	var req = this.resend_queue.shift();
-
-	while( req != null ) {
-		req.resend();
-		req = this.resend_queue.shift();
-	}
-}
-
-/** This method tracks down the AppRequest with the given thread_trace and 
-  * pushes the payload into that AppRequest's recieve queue.
-  */
-AppSession.prototype.push_queue = function( dom_payload, thread_trace ) {
-
-	var req = this.get_request( thread_trace );
-	if( ! req ) {
-		new Logger().debug( "No AppRequest exists for TT: " + thread_trace, Logger.ERROR );
-		return;
-	}
-	req.push_queue( dom_payload );
-}
-
-
-/** Connect to the remote service.  The connect timeout is read from the config.
-  * This method returns null if the connection fails.  It returns a reference
-  * to this AppSession object otherwise.
-  */
-AppSession.prototype.connect = function() {
-
-	if( this.get_state() == AppSession.CONNECTED ) { 
-		return this;
-	}
-
-	var config = new Config();
-	var rem = config.get_value( "transport/connect_timeout" );
-	if( ! rem ) {
-		throw new oils_ex_config( "Unable to retreive timeout value from config" );
-	}
-
-	var remaining = rem * 1000; // milliseconds
-
-	this.reset_remote();
-	this.set_state( AppSession.CONNECTING );
-	this.send( oilsMessage.CONNECT, 0, "" );
-
-	new Logger().debug( "CONNECTING with timeout: " + remaining, Logger.DEBUG );
-
-	while( this.get_state() != AppSession.CONNECTED && remaining > 0 ) {
-
-		var starttime = new Date().getTime();
-		this.queue_wait( remaining );
-		var endtime = new Date().getTime();
-		remaining -= (endtime - starttime);
-	}
-
-	if( ! this.get_state() == AppSession.CONNECTED ) {
-		return null;
-	}
-
-	return this;
-}
-
-/** Disconnects from the remote service */
-AppSession.prototype.disconnect = function() {
-
-	if( this.get_state() == AppSession.DISCONNECTED ) {
-		return;
-	}
-
-	this.send( oilsMessage.DISCONNECT, this.get_thread_trace(), "" );
-	this.set_state( AppSession.DISCONNECTED );
-	this.reset_remote();
-}
-
-
-/** Builds a new message with the given type and thread_trace.  If the message
-  * is a REQUEST, then the payload is added as well.
-  * This method will verify that the session is in the CONNECTED state before
-  * sending any REQUEST's by attempting to do a connect.
-  *
-  * Note: msg_type and thread_trace must be provided.
-  */
-AppSession.prototype.send = function( msg_type, thread_trace, payload ) {
-
-	if( msg_type == null || thread_trace == null ) {
-		throw new oils_ex_args( "Not enough arguments provided to AppSession.send method" );
-	}
-
-	// go ahead and make sure there's nothing new to process
-	this.queue_wait(0);
-
-	var msg;
-	msg = new oilsMessage( msg_type, AppSession.PROTOCOL );
-
-	msg.setThreadTrace( thread_trace );
-
-	if( msg_type == oilsMessage.REQUEST ) {
-		if( ! payload ) {
-			throw new oils_ex_args( "No payload provided for REQUEST message in AppSession.send" );
-		}
-		msg.add( payload );
-	}
-
-
-	// Make sure we're connected
-	if( (msg_type != oilsMessage.DISCONNECT) && (msg_type != oilsMessage.CONNECT) &&
-			(this.get_state() != AppSession.CONNECTED) ) {
-		if( ! this.connect() ) {
-			throw new oils_ex_session( this.get_session_id() + " | Unable to connect to remote service after redirect" );
-		}
-	}
-
-	this.logger.debug( "AppSession sending tt: " 
-			+ thread_trace + " to " + this.get_remote_id() 
-			+ " " +  msg_type , Logger.INFO );
-
-	AppSession.transport_handle.send( this.get_remote_id(), this.get_session_id(), msg.toString(true) );
-
-}
-
-
-/** Waits up to 'timeout' milliseconds for some data to arrive.
-  * Any data that arrives will be process according to its
-  * payload and message type.  This method will return after
-  * any data has arrived.
-  * @param timeout How many milliseconds to wait or data to arrive
-  */
-AppSession.prototype.queue_wait = function( timeout ) {
-	this.flush_resend(); // necessary if running parallel sessions 
-	new Logger().debug( "In queue_wait " + timeout, Logger.DEBUG );
-	var tran_msg = AppSession.transport_handle.process_msg( timeout );
-	this.flush_resend();
-}
-
-
-

Deleted: trunk/src/javascript/opensrf_config.js
===================================================================
--- trunk/src/javascript/opensrf_config.js	2008-04-07 21:11:41 UTC (rev 1298)
+++ trunk/src/javascript/opensrf_config.js	2008-04-08 13:35:23 UTC (rev 1299)
@@ -1,281 +0,0 @@
-/** @file oils_config.js
-  * Config code and Logger code
-  * The config module is simple.  It parses an xml config file and 
-  * the values from the file are accessed via XPATH queries.
-  */
-
-/** Searches up from Mozilla's chrome directory for the client 
-  * config file and returns the file object
-  */
-function get_config_file() {
-
-	var dirService = Components.classes["@mozilla.org/file/directory_service;1"].
-		getService( Components.interfaces.nsIProperties );
-
-	chromeDir = dirService.get( "AChrom",  Components.interfaces.nsIFile );
-	chromeDir.append(myPackageDir);
-	chromeDir.append("content");
-	chromeDir.append("conf");
-	chromeDir.append("client_config.xml");
-	return chromeDir;
-
-}
-
-
-/** Constructor. You may provide an optional path to the config file. **/
-function Config( config_file ) {
-
-	if( Config.config != null ) { return Config.config; }
-
-	config_file = get_config_file();
-
-	// ------------------------------------------------------------------
-	// Grab the data from the config file
-	// ------------------------------------------------------------------
-	var data = "";
-	var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"]
-			.createInstance(Components.interfaces.nsIFileInputStream);
-
-	var sstream = Components.classes["@mozilla.org/scriptableinputstream;1"]
-			.createInstance(Components.interfaces.nsIScriptableInputStream);
-
-	fstream.init(config_file, 1, 0, false);
-	sstream.init(fstream);
-	data += sstream.read(-1);
-
-	sstream.close();
-	fstream.close();
-	
-	
-
-	var DOMParser = new Components.Constructor(
-		"@mozilla.org/xmlextras/domparser;1", "nsIDOMParser" );
-
-	this.config_doc = new DOMParser().parseFromString( data, "text/xml" );
-
-	Config.config = this;
-
-}
-
-/** Returns the value stored in the config file found with the
-  * given xpath expression
-  * E.g.  config.get_value( "/oils_config/dirs/log_dir" );
-  * Note, the 'oils_config' node is the base of the xpath expression,
-  * so something like this will also work:
-  * config.get_value( "dirs/log_dir" );
-  */
-Config.prototype.get_value = function( xpath_query ) {
-
-	var evaluator = Components.classes["@mozilla.org/dom/xpath-evaluator;1"].
-		createInstance( Components.interfaces.nsIDOMXPathEvaluator );
-
-	var xpath_obj = evaluator.evaluate( xpath_query, this.config_doc.documentElement, null, 0, null );
-	if( ! xpath_obj ) { return null; }
-
-	var node = xpath_obj.iterateNext();
-	if( node == null ) {
-		throw new oils_ex_config( "No config option matching " + xpath_query );
-	}
-
-	return node.firstChild.nodeValue;
-}	
-
-
-
-
-
-
-// ------------------------------------------------------------------
-// Logger code.
-// ------------------------------------------------------------------
-/** The global logging object */
-Logger.logger		= null;
-/** No logging level */
-Logger.NONE			= 0;
-/** Error log level */
-Logger.ERROR		= 1;
-/** Info log level */
-Logger.INFO			= 2;
-/* Debug log level */
-Logger.DEBUG		= 3;
-
-/** There exists a single logger object that all components share.
-  * Calling var logger = new Logger() will return the same one
-  * with each call.  This is so we only need one file handle for
-  * each type of log file.
-  */
-function Logger() {
-
-	if( Logger.logger != null ) { return Logger.logger }
-
-	var config = new Config();
-	this.log_level = config.get_value( "system/log_level" );
-
-	this.stdout_log = config.get_value( "system/stdout_log" );
-
-	if( ! this.stdout_log || this.stdout_log < 0 || this.stdout_log > 2 ) {
-		throw new oils_ex_config( "stdout_log setting is invalid: " + this.stdout_log + 
-				". Should be 0, 1, or 2." );
-	}
-
-	// ------------------------------------------------------------------
-	// Load up all of the log files
-	// ------------------------------------------------------------------
-	var transport_file = config.get_value( "logs/transport" );
-	if( transport_file == null ) {
-		throw new oils_ex_config( "Unable to load transport log file: 'logs/transport'" );
-	}
-
-	var debug_file = config.get_value( "logs/debug" );
-	if( debug_file == null ) {
-		throw new oils_ex_config( "Unable to load debug log file: 'logs/debug'" );
-	}
-	
-	var error_file = config.get_value( "logs/error" );
-	if( error_file == null ) {
-		throw new oils_ex_config( "Unable to load debug log file: 'logs/error'" );
-	}
-
-
-	// ------------------------------------------------------------------
-	// Build the file objects
-	// ------------------------------------------------------------------
-	var transport_file_obj = Logger.get_log_file( transport_file );
-
-	var debug_file_obj = Logger.get_log_file( debug_file );
-
-	var error_file_obj = Logger.get_log_file( error_file );
-
-
-	// ------------------------------------------------------------------
-	// Build all of the file stream objects
-	// ------------------------------------------------------------------
-	this.transport_stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
-			.createInstance(Components.interfaces.nsIFileOutputStream);
-
-	this.debug_stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
-			.createInstance(Components.interfaces.nsIFileOutputStream);
-
-	this.error_stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
-			.createInstance(Components.interfaces.nsIFileOutputStream);
-
-	// ------------------------------------------------------------------
-	// Init all of the streams
-	// use 0x02 | 0x10 to open file for appending.
-	// ------------------------------------------------------------------
-	this.transport_stream.init(transport_file_obj,	0x02 | 0x10 | 0x08, 0664, 0 ); 
-	this.debug_stream.init(	debug_file_obj,			0x02 | 0x10 | 0x08, 0664, 0 ); 
-	this.error_stream.init(	error_file_obj,			0x02 | 0x10 | 0x08, 0664, 0 ); 
-
-	Logger.logger = this;
-
-}
-
-/** Internal.  Returns a XPCOM nsIFile object for the log file we're interested in */
-Logger.get_log_file = function( log_name ) {
-
-	var dirService = Components.classes["@mozilla.org/file/directory_service;1"].
-		getService( Components.interfaces.nsIProperties );
-
-	logFile = dirService.get( "AChrom",  Components.interfaces.nsIFile );
-	logFile.append(myPackageDir);
-	logFile.append("content");
-	logFile.append("log");
-	logFile.append( log_name );
-
-	if( ! logFile.exists() ) {
-		logFile.create( 0, 0640 );
-	}
-
-	return logFile;
-}
-
-
-
-/** Internal. Builds a log message complete with data, etc. */
-Logger.prototype.build_string = function( message, level ) {
-
-	if( ! (message && level) ) { return null; }
-
-	var lev = "INFO";
-	if( level == Logger.ERROR ) { lev = "ERROR"; }
-	if( level == Logger.DEBUG ) { lev = "DEBUG"; }
-
-	var date		= new Date();
-	var year		= date.getYear();
-	year += 1900;
-
-	var month	= ""+date.getMonth();
-	if(month.length==1) {month="0"+month;}
-	var day		= ""+date.getDate();
-	if(day.length==1) {day="0"+day;}
-	var hour		= ""+date.getHours();
-	if(hour.length== 1){hour="0"+hour;}
-	var min		= ""+date.getMinutes();
-	if(min.length==1){min="0"+min;}
-	var sec		= ""+date.getSeconds();
-	if(sec.length==1){sec="0"+sec;}
-	var mil		= ""+date.getMilliseconds();
-	if(mil.length==1){sec="0"+sec;}
-
-	var date_string = year + "-" + month + "-" + day + " " + 
-		hour + ":" + min + ":" + sec + "." + mil;
-
-	var str_array = message.split('\n');
-	var ret_array = new Array();
-	for( var i in str_array ) {
-		ret_str = "[" + date_string +  "] " + lev + " " + str_array[i] + "\n";
-		ret_array.push( ret_str );
-	}
-
-	var line = "-------------------------\n";
-	ret_array.unshift( line );
-
-	return ret_array;
-}
-
-/** Internal. Does the actual writing */
-Logger.prototype._log = function( data, stream, level ) {
-
-	if( ! data ) { return; }
-	if( ! stream ) { 
-		throw oils_ex_logger( "No file stream open for log message: " + data ); 
-	}
-	if( ! level ) { level = Logger.DEBUG; }
-
-	if( level > this.log_level ) { return; }
-	var str_array = this.build_string( data, level );
-	if( ! str_array ) { return; }
-
-	for( var i in str_array ) {
-		if( this.stdout_log > 0 ) { dump( str_array[i] ); }
-		if( this.stdout_log < 2 ) { stream.write( str_array[i], str_array[i].length ); }
-	}
-
-	// write errors to the error log if they were destined for anywhere else
-	if( level == Logger.ERROR && stream != this.error_stream ) {
-		for( var i in str_array ) {
-			if( this.stdout_log > 0 ) { dump( str_array[i] ); }
-			if( this.stdout_log < 2 ) { this.error_stream.write( str_array[i], str_array[i].length ); }
-		}
-	}
-}
-	
-
-
-/** Writes the message to the error log */
-Logger.prototype.error = function( message, level ) {
-	this._log( message, this.error_stream, level );
-}
-
-
-/** Writes to the debug log */
-Logger.prototype.debug = function( message, level ) {
-	this._log( message, this.debug_stream, level );
-}
-
-
-/** Writes to the transport log */
-Logger.prototype.transport = function( message, level ) {
-	this._log( message, this.transport_stream, level );
-}

Deleted: trunk/src/javascript/opensrf_dom_element.js
===================================================================
--- trunk/src/javascript/opensrf_dom_element.js	2008-04-07 21:11:41 UTC (rev 1298)
+++ trunk/src/javascript/opensrf_dom_element.js	2008-04-08 13:35:23 UTC (rev 1299)
@@ -1,263 +0,0 @@
-/** @file oils_dom_element.js
-  * -----------------------------------------------------------------------------
-  * This file holds all of the core OILS DOM elements.
-  *  -----------------------------------------------------------------------------
-
-  * -----------------------------------------------------------------------------
-  * Make sure you load md5.js into  your script/html/etc. before loading this 
-  * file
-  * -----------------------------------------------------------------------------
-  * 
-  * -----------------------------------------------------------------------------
-  * 1. Use these if you are running via xpcshell, but not if you are running
-  * 	directly from mozilla.
-  * 2. BTW. XMLSerializer doesn't like being run outside of mozilla, so
-  *		toString() fails.
-  * 
-  * var DOMParser = new Components.Constructor(
-  * 		"@mozilla.org/xmlextras/domparser;1", "nsIDOMParser" );
-  * 
-  * 	var XMLSerializer = new Components.Constructor(
-  * 		"@mozilla.org/xmlextras/xmlserializer;1", "nsIDOMSerializer" );
-  *  -----------------------------------------------------------------------------
-  * 
-  * 
-  */
-
-/**
-  *  -----------------------------------------------------------------------------
-  *  DOM - Top level generic class
-  *  -----------------------------------------------------------------------------
-  */
-
-function DOM() { 
-	this.doc = null; 
-	this.root = null;
-	this.element = null;
-}
-
-/** Returns a string representation of the XML doc.  If full_bool
-  * is true, it will return the entire doc and not just the relevant
-  * portions (i.e. our object's element).
-  */
-DOM.prototype.toString = function(full_bool) {
-	if( full_bool ) {
-		return new XMLSerializer().serializeToString(this.doc);
-	} else {
-		return new XMLSerializer().serializeToString(this.element);
-	}
-}
-
-/** Initializes a document and sets this.doc, this.root and this.element */
-DOM.prototype.init = function( elementName ) {
-	
-	this.doc = new DOMParser().parseFromString( 
-		"<?xml version='1.0' encoding='UTF-8'?><oils:root xmlns:oils='http://open-ils.org/namespaces/oils_v1'></oils:root>", "text/xml" );
-	this.root = this.doc.documentElement;
-	this.element = this.doc.createElement( "oils:" + elementName );
-	return this.element;
-}
-
-/** Good for creating objects from raw xml.  This builds a new doc and inserts
-  * the node provided.  So you can build a dummy object, then call replaceNode  
-  * with the new xml to build an object from XML on the fly.
-  */
-DOM.prototype._replaceNode = function( name, new_element ) {
-
-	var node = this.doc.importNode( new_element, true );
-
-	if( node.nodeName != "oils:" + name ) {
-		throw new oils_ex_dom( "Invalid Tag to " + name + "::replaceNode()" );
-	}
-
-	this.doc = new DOMParser().parseFromString( 
-		"<?xml version='1.0' encoding='UTF-8'?><oils:root xmlns:oils='http://open-ils.org/namespaces/oils_v1'></oils:root>", "text/xml" );
-	this.root = this.doc.documentElement;
-
-	this.root.appendChild( node );
-	this.element = this.root.firstChild;
-	return this;
-}
-
-
-
-// -----------------------------------------------------------------------------
-// domainObjectAttr
-// -----------------------------------------------------------------------------
-
-domainObjectAttr.prototype	= new DOM();
-domainObjectAttr.prototype.constructor = domainObjectAttr;
-domainObjectAttr.baseClass	= DOM.prototype.constructor;
-
-/** A domainObjectAttr is a single XML node with 'name' and 'value' attributes */
-function domainObjectAttr( name, value ) {
-
-	var node = this.init( "domainObjectAttr" );
-	if( ! name && value ) { return; }
-	node.setAttribute( "name", name );
-	node.setAttribute( "value", value );
-	this.root.appendChild( node );
-}
-
-
-/** Returns the attribute name */
-domainObjectAttr.prototype.getName = function() {
-	return this.element.getAttribute("name"); 
-}
-
-/** Returns the attribut value. */
-domainObjectAttr.prototype. getValue = function() {
-	return this.element.getAttribute("value"); 
-}
-
-/** Sets the attribute value. */
-domainObjectAttr.prototype. setValue = function( value ) {
-	return this.element.setAttribute("value", value ); 
-}
-
-/** Pass in the this.element component of a domainObjectAttr and this will
-  * replace the old element with the new one 
-  */
-domainObjectAttr.prototype.replaceNode = function( domainObjectAttr_element ) {
-	return this._replaceNode( "domainObjectAttr", domainObjectAttr_element );
-}
-
-// -----------------------------------------------------------------------------
-// userAuth
-// -----------------------------------------------------------------------------
-
-
-userAuth.prototype = new DOM();
-userAuth.prototype.constructor = userAuth;
-userAuth.baseClass = DOM.prototype.constructor;
-
-function userAuth( username, secret ) {
-
-	var node = this.init( "userAuth" );
-	if( !( username && secret) ) { return; }
-	node.setAttribute( "username", username );
-
-	//There is no way to specify the hash seed with the 
-	//md5 utility provided
-	var hash = hex_md5( secret );
-	node.setAttribute( "secret", hash );
-	node.setAttribute( "hashseed", "" ); 
-
-	this.root.appendChild( node );
-}
-
-userAuth.prototype.getUsername = function() {
-	return this.element.getAttribute( "username" );
-}
-
-userAuth.prototype.getSecret = function() {
-	return this.element.getAttribute( "secret" );
-}
-
-userAuth.prototype.getHashseed = function() {
-	return this.element.getAttribute( "hashseed" );
-}
-
-userAuth.prototype.replaceNode = function( userAuth_element ) {
-	return this._replaceNode( "userAuth", userAuth_element );
-}
-
-
-// -----------------------------------------------------------------------------
-// domainObject
-// -----------------------------------------------------------------------------
-
-domainObject.prototype = new DOM(); 
-domainObject.baseClass = DOM.prototype.constructor;
-domainObject.prototype.constructor = domainObject;
-
-/** Holds the XML for a DomainObject (see oils_domain_object.js or the DomainObject class) */
-function domainObject( name ) {
-	this._init_domainObject( name ); 
-}
-
-/** Initializes the domainObject XML node */
-domainObject.prototype._init_domainObject = function( name ) {
-
-	var node = this.init( "domainObject" );
-
-	if( ! name ) { return; }
-	node.setAttribute( "name", name );
-	this.root.appendChild( node ); 
-
-}
-
-/** Pass in any DOM Element or DomainObject and this method will as the
-  * new object as the next child of the root (domainObject) node 
-  */
-domainObject.prototype.add = function( new_DOM ) {
-
-	this.element.appendChild( 
-			new_DOM.element.cloneNode( true ) );
-}
-
-/** Removes the original domainObject XML node and replaces it with the
-  * one provided.  This is useful for building new domainObject's from
-  * raw xml.  Just create a new one, then call replaceNode with the new XML.
-  */
-domainObject.prototype.replaceNode = function( domainObject_element ) {
-	return this._replaceNode( "domainObject", domainObject_element );
-}
-
-
-
-// -----------------------------------------------------------------------------
-// Param 
-// -----------------------------------------------------------------------------
-
-
-param.prototype = new DOM();
-param.baseClass = DOM.prototype.constructor;
-param.prototype.constructor = param;
-
-function param( value ) {
-	var node = this.init( "param" );
-	node.appendChild( this.doc.createTextNode( value ) );
-	this.root.appendChild( node );
-}
-
-param.prototype.getValue = function() {
-	return this.element.textContent;
-}
-
-param.prototype.replaceNode = function( param_element ) {
-	return this._replaceNode( "param", param_element );
-}
-
-
-// -----------------------------------------------------------------------------
-// domainObjectCollection
-// -----------------------------------------------------------------------------
-
-domainObjectCollection.prototype = new DOM();
-domainObjectCollection.prototype.constructor = 
-	domainObjectCollection;
-domainObjectCollection.baseClass = DOM.prototype.constructor;
-
-function domainObjectCollection( name ) {
-	var node = this.init( "domainObjectCollection" );	
-	this.root.appendChild( node );
-	if(name) { this._initCollection( name ); }
-}
-
-domainObjectCollection.prototype._initCollection = function( name ) {
-	if( name ) {
-		this.element.setAttribute( "name", name );
-	}
-}
-
-domainObjectCollection.prototype.add = function( new_domainObject ) {
-	this.element.appendChild( 
-			new_domainObject.element.cloneNode( true ) );
-}
-
-domainObjectCollection.prototype.replaceNode = function( new_node ) {
-	return this._replaceNode( "domainObjectCollection", new_node );
-}
-
-

Deleted: trunk/src/javascript/opensrf_domain_object.js
===================================================================
--- trunk/src/javascript/opensrf_domain_object.js	2008-04-07 21:11:41 UTC (rev 1298)
+++ trunk/src/javascript/opensrf_domain_object.js	2008-04-08 13:35:23 UTC (rev 1299)
@@ -1,627 +0,0 @@
-// -----------------------------------------------------------------------------
-// This houses all of the domain object code.
-// -----------------------------------------------------------------------------
-
-
-
-
-// -----------------------------------------------------------------------------
-// DomainObject 
-
-DomainObject.prototype					= new domainObject();
-DomainObject.prototype.constructor	= DomainObject;
-DomainObject.prototype.baseClass		= domainObject.prototype.constructor;
-
-/** Top level DomainObject class.  This most provides convience methods
-  * and a shared superclass
-  */
-function DomainObject( name ) {
-	if( name ) { this._init_domainObject( name ); }
-}
-
-/** Returns the actual element of the given domainObjectAttr. */
-DomainObject.prototype._findAttr = function ( name ) {
-	
-	var nodes = this.element.childNodes;
-
-	if( ! nodes || nodes.length < 1 ) {
-		throw new oils_ex_dom( "Invalid xml object in _findAttr: " + this.toString() );
-	}
-
-	var i=0;
-	var node = nodes.item(i);
-
-	while( node != null ) {
-
-		if( node.nodeName == "oils:domainObjectAttr" &&
-				node.getAttribute("name") == name ) {
-			return node;
-		}
-
-		node = nodes.item(++i);
-	}
-
-	return null;
-}
-
-
-
-
-/** Returns the value stored in the given attribute */
-DomainObject.prototype.getAttr = function ( name ) {
-
-	var node = this._findAttr( name );
-	if( node ) { return node.getAttribute( "value" ); }
-	else { 
-		throw new oils_ex_dom( "getAttr(); Getting nonexistent attribute: " + name ); 
-	}
-}
-
-/** Updates the value held by the given attribute */
-DomainObject.prototype.setAttr = function ( name, value ) {
-
-	var node = this._findAttr( name );
-	if( node ) {
-		node.setAttribute( "value", value );
-	} else { 
-		throw new oils_ex_dom( "setAttr(); Setting nonexistent attribute: " + name ); 
-	}
-}
-
-/** This takes a raw DOM Element node and creates the DomainObject that the node
-  * embodies and returns the object.  All new DomainObjects should be added to
-  * this list if they require this type of dynamic functionality.
-  * NOTE Much of this will be deprecated as move to a more JSON-centric wire protocol
-  */
-DomainObject.newFromNode = function( node ) {
-
-	switch( node.getAttribute("name") ) {
-
-		case "oilsMethod":
-			return new oilsMethod().replaceNode( node );
-		
-		case "oilsMessage":
-			return new oilsMessage().replaceNode( node );
-
-		case "oilsResponse":
-			return new oilsResponse().replaceNode( node );
-
-		case "oilsResult":
-			return new oilsResult().replaceNode( node );
-
-		case "oilsConnectStatus":
-			return new oilsConnectStatus().replaceNode( node );
-
-		case "oilsException":
-			return new oilsException().replaceNode( node );
-
-		case "oilsMethodException":
-			return new oilsMethodException().replaceNode( node );
-
-		case "oilsBrokenSession":
-			return new oilsBrokenSession().replaceNode( node );
-
-		case "oilsScalar":
-			return new oilsScalar().replaceNode( node );
-
-		case "oilsPair":
-			return new oilsPair().replaceNode( node );
-
-		case "oilsArray":
-			return new oilsArray().replaceNode( node );
-
-		case "oilsHash":
-			return new oilsHash().replaceNode( node );
-
-
-	}
-
-}
-
-
-
-// -----------------------------------------------------------------------------
-// oilsMethod
-
-oilsMethod.prototype = new DomainObject();
-oilsMethod.prototype.constructor = oilsMethod;
-oilsMethod.prototype.baseClass = DomainObject.prototype.constructor;
-
-/**
-  * oilsMethod Constructor
-  * 
-  * @param method_name The name of the method your are sending
-  * to the remote server
-  * @param params_array A Javascript array of the params (any
-  * Javascript data type)
-  */
-
-function oilsMethod( method_name, params_array ) {
-	this._init_domainObject( "oilsMethod" );
-	this.add( new domainObjectAttr( "method", method_name ) );
-
-	if( params_array ) {
-		var params = this.doc.createElement( "oils:params" );
-		this.element.appendChild( params ); 
-		params.appendChild( this.doc.createTextNode( 
-				js2JSON( params_array ) ) ); 
-	}
-}
-
-
-/** Locates the params node of this method */
-oilsMethod.prototype._getParamsNode = function() {
-
-	var nodes = this.element.childNodes;
-	if( ! nodes || nodes.length < 1 ) { return null; }
-	var x=0;
-	var node = nodes.item(x);
-	while( node != null ) {
-		if( node.nodeName == "oils:params" ) {
-			return node;
-		}
-		node = nodes.item(++x);
-	}
-
-	return null;
-}
-
-
-/** Returns an array of param objects  */
-oilsMethod.prototype.getParams = function() {
-	var node = this._getParamsNode();
-	if(node != null ) { 
-		return JSON2js( node.textContent ); 
-	}
-}
-
-
-
-// -----------------------------------------------------------------------------
-// oilsMessage
-
-// -----------------------------------------------------------------------------
-// oilsMessage message types
-// -----------------------------------------------------------------------------
-/** CONNECT Message type */
-oilsMessage.CONNECT		= 'CONNECT';
-/** DISCONNECT Message type */
-oilsMessage.DISCONNECT	= 'DISCONNECT';
-/** STATUS Message type */
-oilsMessage.STATUS		= 'STATUS';
-/** REQUEST Message type */
-oilsMessage.REQUEST		= 'REQUEST';
-/** RESULT Message type */
-oilsMessage.RESULT		= 'RESULT';
-
-
-oilsMessage.prototype = new DomainObject();
-oilsMessage.prototype.constructor = oilsMessage;
-oilsMessage.prototype.baseClass = DomainObject.prototype.constructor;
-
-/** Core XML object for message passing */
-function oilsMessage( type, protocol ) {
-
-	if( !( type && protocol) ) { 
-		type = oilsMessage.CONNECT; 
-		protocol = "1";
-	}
-
-	if( ! (	type == oilsMessage.CONNECT		||
-				type == oilsMessage.DISCONNECT	||
-				type == oilsMessage.STATUS			||
-				type == oilsMessage.REQUEST		||
-				type == oilsMessage.RESULT	) ) {
-		throw new oils_ex_message( "Attempt to create oilsMessage with incorrect type: " + type );
-	}
-
-	this._init_domainObject( "oilsMessage" );
-
-	this.add( new domainObjectAttr( "type", type ) );
-	this.add( new domainObjectAttr( "threadTrace", 0 ) );
-	this.add( new domainObjectAttr( "protocol", protocol ) );	
-
-	// user_auth used to be a parameter for oilsMessage
-	//if( user_auth ) { this.add( user_auth ); }
-
-}
-
-/** Builds a new oilsMessage from raw xml.
-  * Checks are taken to make sure the xml is supposed to be an oilsMessage.  
-  * If not, an oils_ex_dom exception is throw.
-  */
-oilsMessage.newFromXML = function( xml ) {
-
-	try {
-
-		if( ! xml || xml == "" ) { throw 1; }
-
-		var doc = new DOMParser().parseFromString( xml, "text/xml" );
-		if( ! doc ) { throw 1; }
-
-		var root = doc.documentElement;
-		if( ! root ) { throw 1; }
-
-		// -----------------------------------------------------------------------------
-		// There are two options here.  One is that we were provided the full message
-		// xml (i.e. contains the <oils:root> tag.  The other option is that we were
-		// provided just the message xml portion (top level element is the 
-		// <oils:domainObject>
-		// -----------------------------------------------------------------------------
-		
-		var element;
-		if( root.nodeName == "oils:root"  ) { 
-
-			element = root.firstChild;
-			if( ! element ) { throw 1; }
-
-		} else { 
-
-			if( root.nodeName == "oils:domainObject" ) { 
-				element = root;
-
-			} else { throw 1; }
-
-		}
-
-
-		if( element.nodeName != "oils:domainObject" ) { throw 1; } 
-		if( element.getAttribute( "name" ) != "oilsMessage" ) { throw 1; }
-
-		return new oilsMessage().replaceNode( element );
-
-	} catch( E ) {
-
-		if( E && E.message ) {
-			throw new oils_ex_dom( "Bogus XML for creating oilsMessage: " + E.message + "\n" + xml );
-
-		} else {
-			throw new oils_ex_dom( "Bogus XML for creating oilsMessage:\n" + xml );
-		}
-	}
-
-	return msg;
-}
-
-
-
-/** Adds a copy of the given DomainObject to the message */
-oilsMessage.prototype.addPayload = function( new_DomainObject ) {
-	this.add( new_DomainObject );
-}
-
-
-/** Returns the top level DomainObject contained in this message
-  *
-  * Note:  The object retuturned will be the actual object, not just a 
-  * generic DomainObject - e.g. oilsException.
-  */
-oilsMessage.prototype.getPayload = function() {
-	
-	var nodes = this.element.childNodes;
-	var x=0;
-	var node = nodes.item(0);
-
-	while( node != null ) {
-
-		if( node.nodeName == "oils:domainObject" ) {
-
-			new Logger().debug( "Building oilsMessage payload from\n" + 
-				new XMLSerializer().serializeToString( node ), Logger.DEBUG );
-			return DomainObject.newFromNode( node );
-		}
-		node = nodes.item(++x);
-	}
-
-	return null;
-}
-
-oilsMessage.prototype.getUserAuth = function() {
-
-	var nodes = this.element.getElementsByTagName( "oils:userAuth" );
-	if( ! nodes ) { return null; }
-
-	var auth_elem = nodes.item(0); // should only be one
-	if ( ! auth_elem ) { return null; }
-
-	return new userAuth().replaceNode( auth_elem );
-
-}
-
-/** Returns the type of the message */
-oilsMessage.prototype.getType = function() {
-	return this.getAttr( "type" );
-}
-
-/** Returns the message protocol */
-oilsMessage.prototype.getProtocol = function() {
-	return this.getAttr( "protocol" );
-}
-
-/** Returns the threadTrace */
-oilsMessage.prototype.getThreadTrace = function() {
-	return this.getAttr( "threadTrace" );
-}
-
-/** Sets the thread trace - MUST be an integer */
-oilsMessage.prototype.setThreadTrace = function( trace ) {
-	this.setAttr( "threadTrace", trace );
-}
-
-/** Increments the thread trace by 1 */
-oilsMessage.prototype.updateThreadTrace = function() {
-	var tt = this.getThreadTrace();
-	return this.setThreadTrace( ++tt );
-}
-
-
-
-
-
-// -----------------------------------------------------------------------------
-// oilsResponse
-
-
-// -----------------------------------------------------------------------------
-// Response codes
-// -----------------------------------------------------------------------------
-
-/**
-  * Below are the various response statuses
-  */
-oilsResponse.STATUS_CONTINUE						= 100
-
-oilsResponse.STATUS_OK								= 200
-oilsResponse.STATUS_ACCEPTED						= 202
-oilsResponse.STATUS_COMPLETE						= 205
-
-oilsResponse.STATUS_REDIRECTED					= 307
-
-oilsResponse.STATUS_BADREQUEST					= 400
-oilsResponse.STATUS_UNAUTHORIZED					= 401
-oilsResponse.STATUS_FORBIDDEN						= 403
-oilsResponse.STATUS_NOTFOUND						= 404
-oilsResponse.STATUS_NOTALLOWED					= 405
-oilsResponse.STATUS_TIMEOUT						= 408
-oilsResponse.STATUS_EXPFAILED						= 417
-oilsResponse.STATUS_INTERNALSERVERERROR		= 500
-oilsResponse.STATUS_NOTIMPLEMENTED				= 501
-oilsResponse.STATUS_VERSIONNOTSUPPORTED		= 505
-
-
-oilsResponse.prototype = new DomainObject();
-oilsResponse.prototype.constructor = oilsResponse;
-oilsResponse.prototype.baseClass = DomainObject.prototype.constructor;
-
-/** Constructor.  status is the text describing the message status and
-  * statusCode must correspond to one of the oilsResponse status code numbers
-  */
-function oilsResponse( name, status, statusCode ) {
-	if( name && status && statusCode ) {
-		this._initResponse( name, status, statusCode );
-	}
-}
-
-/** Initializes the reponse XML */
-oilsResponse.prototype._initResponse = function( name, status, statusCode ) {
-
-	this._init_domainObject( name );
-	this.add( new domainObjectAttr( "status", status ));
-	this.add( new domainObjectAttr( "statusCode", statusCode ) );
-}
-
-
-
-/** Returns the status of the response */
-oilsResponse.prototype.getStatus = function() {
-	return this.getAttr( "status" );
-}
-
-/** Returns the statusCode of the response */
-oilsResponse.prototype.getStatusCode = function() {
-	return this.getAttr("statusCode");
-}
-
-
-oilsConnectStatus.prototype = new oilsResponse();
-oilsConnectStatus.prototype.constructor = oilsConnectStatus;
-oilsConnectStatus.prototype.baseClass = oilsResponse.prototype.constructor;
-
-/** Constructor.  These give us info on our connection attempts **/
-function oilsConnectStatus( status, statusCode ) {
-	this._initResponse( "oilsConnectStatus", status, statusCode );
-}
-
-
-oilsResult.prototype = new oilsResponse();
-oilsResult.prototype.constructor = oilsResult;
-oilsResult.prototype.baseClass = oilsResponse.prototype.constructor;
-
-
-/** Constructor.  These usually carry REQUEST responses */
-function oilsResult( status, statusCode ) {
-	if( status && statusCode ) {
-		this._initResponse( "oilsResult", status, statusCode );
-	}
-}
-
-/** Returns the top level DomainObject within this result message.
-  * Note:  The object retuturned will be the actual object, not just a 
-  * generic DomainObject - e.g. oilsException.
-  */
-oilsResult.prototype.getContent = function() {
-
-	var nodes = this.element.childNodes;
-	if( ! nodes || nodes.length < 1 ) {
-		throw new oils_ex_dom("Content node for oilsResult is invalid\n" + this.toString() );
-	}
-	var x = 0;
-	var node = nodes.item(x);
-	while( node != null ) {
-
-		if( node.nodeName == "oils:domainObject"					||
-				node.nodeName == "oils:domainObjectCollection" ) {
-
-			//return DomainObject.newFromNode( node );
-			return JSON2js( node.textContent );
-		}
-		node = nodes.item(++x);
-	}
-
-	throw new oils_ex_dom("Content node for oilsResult is invalid\n" + this.toString() );
-}
-
-
-oilsException.prototype = new oilsResponse();
-oilsException.prototype.constructor = oilsException;
-oilsException.prototype.baseClass = oilsResponse.prototype.constructor;
-
-/** Top level exception */
-function oilsException( status, statusCode ) {
-	if( status && statusCode ) {
-		this._initResponse( "oilsException", status, statusCode );
-	}
-}
-
-
-oilsMethodException.prototype = new oilsException();
-oilsMethodException.prototype.constructor = oilsMethodException;
-oilsMethodException.prototype.baseClass = oilsException.prototype.constructor;
-
-/** Method exception */
-function oilsMethodException( status, statusCode ) {
-	if( status && statusCode ) {
-		this._initResponse( "oilsMethodException", status, statusCode );
-	}
-}
-
-oilsBrokenSession.prototype = new oilsException();
-oilsBrokenSession.prototype.constructor = oilsBrokenSession;
-oilsBrokenSession.prototype.baseClass = oilsException.prototype.constructor;
-
-/** broken session exception */
-function oilsBrokenSession( status, statusCode ) {
-	if( status && statusCode ) {
-		this._initResponse( "oilsBrokenSession", status, statusCode );
-	}
-}
-
-
-// -----------------------------------------------------------------------------
-// oilsScalar
-
-
-oilsScalar.prototype = new DomainObject();
-oilsScalar.prototype.constructor = oilsScalar;
-oilsScalar.prototype.baseClass = DomainObject.prototype.constructor;
-
-/** Contains a single JSON item as its text content */
-function oilsScalar( value ) {
-	this._init_domainObject( "oilsScalar" );
-	this.element.appendChild( this.doc.createTextNode( value ) );
-}
-
-/** Returns the contained item as a Javascript object */
-oilsScalar.prototype.getValue = function() {
-	return JSON2js( this.element.textContent );
-}
-
-
-// -----------------------------------------------------------------------------
-// oilsPair
-
-
-oilsPair.prototype = new DomainObject()
-oilsPair.prototype.constructor = oilsPair;
-oilsPair.prototype.baseClass = DomainObject.prototype.constructor;
-
-function oilsPair( key, value ) {
-
-	this._init_domainObject( "oilsPair" );
-	this.element.appendChild( this.doc.createTextNode( value ) );
-	this.element.setAttribute( "key", key );
-}
-
-oilsPair.prototype.getKey = function() {
-	return this.element.getAttribute( "key" );
-}
-
-oilsPair.prototype.getValue = function() {
-	return this.element.textContent;
-}
-
-
-
-// -----------------------------------------------------------------------------
-// oilsArray - is a domainObjectCollection that stores a list of domainObject's
-// or domainObjectCollections.
-// -----------------------------------------------------------------------------
-
-oilsArray.prototype = new domainObjectCollection()
-oilsArray.prototype.constructor = oilsArray;
-oilsArray.prototype.baseClass = domainObjectCollection.prototype.constructor;
-
-function oilsArray( obj_list ) {
-	this._initCollection( "oilsArray" );
-	if(obj_list) { this.initArray( obj_list ); }
-}
-
-// -----------------------------------------------------------------------------
-// Adds the array of objects to the array, these should be actual objects, not
-// DOM nodes/elements, etc.
-// -----------------------------------------------------------------------------
-oilsArray.prototype.initArray = function( obj_list ) {
-	if( obj_array != null && obj_array.length > 0 ) {
-		for( var i= 0; i!= obj_array.length; i++ ) {
-			this.add( obj_array[i] );
-		}
-	}
-}
-
-// -----------------------------------------------------------------------------
-// Returns an array of DomainObjects or domainObjectCollections.  The objects
-// returned will already be 'cast' into the correct object. i.e. you will not
-// receieve an array of DomainObjects, but instead an array of oilsScalar's or
-// an array of oilsHashe's, etc.
-// -----------------------------------------------------------------------------
-oilsArray.prototype.getObjects = function() {
-
-	var obj_list = new Array();
-	var nodes = this.element.childNodes;
-	var i=0;
-	var node = nodes.item(i);
-
-	while( node != null ) {
-
-		if( node.nodeName == "oils:domainObject"					||
-				node.nodeName == "oils:domainObjectCollection" ) {
-			obj_list[i++] = DomainObject.newFromNode( node );
-		}
-		node = nodes.item(i);
-	}
-
-	return obj_list;
-}
-
-
-// -----------------------------------------------------------------------------
-// oilsHash - an oilsHash is an oilsArray except it only stores oilsPair's
-// -----------------------------------------------------------------------------
-
-oilsHash.prototype = new oilsArray();
-oilsHash.prototype.constructor = oilsHash;
-oilsHash.prototype.baseClass = oilsArray.prototype.constructor;
-
-function oilsHash( pair_array ) {
-	this._initCollection("oilsHash");
-	if(pair_array) { this.initArray( pair_array ); }
-}
-
-// -----------------------------------------------------------------------------
-// Returns the array of oilsPairs objects that this hash contains
-// -----------------------------------------------------------------------------
-oilsHash.prototype.getPairs = function() {
-	return this.getObjects();
-}
-
-

Deleted: trunk/src/javascript/opensrf_msg_stack.js
===================================================================
--- trunk/src/javascript/opensrf_msg_stack.js	2008-04-07 21:11:41 UTC (rev 1298)
+++ trunk/src/javascript/opensrf_msg_stack.js	2008-04-08 13:35:23 UTC (rev 1299)
@@ -1,205 +0,0 @@
-// -----------------------------------------------------------------------------
-// Message stack code.
-// -----------------------------------------------------------------------------
-
-
-
-// -----------------------------------------------------------------------------
-// These just have to be defined for the 'static' methods to work
-// -----------------------------------------------------------------------------
-function Transport() {}
-function Message() {}
-function Application() {}
-
-/** Transport handler.  
-  * Takes a transport_message as parameter
-  * Parses the incoming message data and builds one or more oilsMessage objects
-  * from the XML.  Each message is passed in turn to the Message.handler
-  * method.
-  */
-Transport.handler = function( msg ) {
-
-	if( msg.is_error_msg ) {
-		throw new oils_ex_session( "Receved error message from jabber server for recipient: " + msg.get_sender() );
-		return;
-	}
-
-	var remote_id	= msg.get_sender();
-	var session_id = msg.get_thread();
-	var body			= msg.get_body();
-
-	var session		= AppSession.find_session( session_id );
-
-	if( ! session ) {
-		new Logger().debug( "No AppSession found with id: " + session_id );
-		return;
-	}
-
-	session.set_remote_id( remote_id );
-
-	var nodelist; // oilsMessage nodes
-
-
-	// -----------------------------------------------------------------------------
-	// Parse the incoming XML
-	// -----------------------------------------------------------------------------
-	try {
-
-		var doc = new DOMParser().parseFromString( body, "text/xml" );
-		nodelist = doc.documentElement.getElementsByTagName( "oils:domainObject" );
-
-		if( ! nodelist || nodelist.length < 1 ) {
-			nodelist = doc.documentElement.getElementsByTagName( "domainObject" );
-			if( ! nodelist || nodelist.length < 1 ) { throw 1; }
-		}
-
-	} catch( E ) {
-
-		var str = "Error parsing incoming message document";
-
-		if( E ) { throw new oils_ex_dom( str + "\n" + E.message + "\n" + body ); 
-		} else { throw new oils_ex_dom( str + "\n" + body ); }
-
-	}
-	
-	// -----------------------------------------------------------------------------
-	// Pass the messages up the chain.
-	// -----------------------------------------------------------------------------
-	try {
-
-		var i = 0;
-		var node = nodelist.item(i); // a single oilsMessage
-
-		while( node != null ) {
-
-			if( node.getAttribute("name") != "oilsMessage" ) {
-				node = nodelist.item(++i);
-				continue;
-			}
-				
-			var oils_msg = new oilsMessage().replaceNode( node );  
-
-
-			// -----------------------------------------------------------------------------
-			// this is really inefficient compared to the above line of code,
-			// however, this resolves some namespace oddities in DOMParser - 
-			// namely, DOMParser puts dummy namesapaces in "a0" when, I'm assuming, it 
-			// can't find the definition for the namesapace included.
-			// -----------------------------------------------------------------------------
-			//	var oils_msg = oilsMessage.newFromXML( new XMLSerializer().serializeToString( node ) );
-
-			new Logger().transport( "Transport passing up:\n" + oils_msg.toString(true), Logger.INFO );
-
-			// Pass the message off to the message layer
-			Message.handler( session, oils_msg );
-			node = nodelist.item(++i);
-		}
-
-	} catch( E ) {
-
-		var str = "Processing Error";
-
-		if( E ) { throw new oils_ex_session( str + "\n" + E.message + "\n" + body ); } 
-		else { throw new oils_ex_session( str + "\n" + body ); }
-	}
-}
-
-/** Checks to see what type of message has arrived.  If it is a 'STATUS' message,
-  * the appropriate transport layer actions are taken.  Otherwise (RESULT), the
-  * message is passed to the Application.handler method.
-  */
-Message.handler = function( session, msg ) {
-
-	var msg_type					= msg.getType();
-	var domain_object_payload	= msg.getPayload();
-	var tt							= msg.getThreadTrace();
-
-	var code = domain_object_payload.getStatusCode();
-
-	new Logger().debug( "Message.handler received " + msg_type + " from " +
-			session.get_remote_id() + " with thread_trace " + tt + " and status " + code, Logger.INFO );
-	new Logger().debug( "Message.handler received:\n" + domain_object_payload.toString(), Logger.DEBUG );
-
-	if( msg_type == oilsMessage.STATUS ) {
-
-		switch( code ) {
-
-			case  oilsResponse.STATUS_OK + "": {
-				session.set_state( AppSession.CONNECTED );
-				new Logger().debug( " * Connected Successfully: " + tt, Logger.INFO );
-				return;
-			}
-
-			case oilsResponse.STATUS_TIMEOUT + "": {
-				return Message.reset_session( session, tt, "Disconnected because of timeout" );
-			}
-
-			case oilsResponse.STATUS_REDIRECTED + "": {
-				return Message.reset_session( session, tt, "Disconnected because of redirect" );
-			}
-
-			case oilsResponse.STATUS_EXPFAILED + "": {
-				return Message.reset_session( session, tt, "Disconnected because of mangled session" );
-			}
-
-			case oilsResponse.STATUS_NOTALLOWED + "": {
-				new Logger().debug( "Method Not Allowed", Logger.ERROR );
-				session.destroy();
-				break; // we want the exception to be thrown below
-			}
-
-			case oilsResponse.STATUS_CONTINUE +"": {
-				return;
-			}
-
-			case oilsResponse.STATUS_COMPLETE + "": {
-				var req = session.get_request(tt);
-				if( req ) { 
-					req.set_complete(); 
-					new Logger().debug( " * Request completed: " + tt, Logger.INFO );
-				}
-				return;
-			}
-
-			default: { break; } 
-		}
-
-	}
-
-	// throw any exceptions received from the server
-	if( domain_object_payload instanceof oilsException ) {
-		throw new oils_ex_session( domain_object_payload.getStatus() );
-	}
-
-	new Logger().debug( "Message Layer passing up:\n" + domain_object_payload.toString(), Logger.DEBUG );
-
-	Application.handler( session, domain_object_payload, tt );
-
-}
-
-/** Utility method for cleaning up a session.  Sets state to disconnected.
-  * resets the remoted_id, pushes the current app_request onto the resend
-  * queue. Logs a message.
-  */
-Message.reset_session = function( session, thread_trace, message ) {
-	session.set_state( AppSession.DISCONNECTED );
-	session.reset_remote();
-	var req = session.get_request( thread_trace );
-	if( req && !req.complete() ) { session.push_resend( req ); }
-	new Logger().debug( " * " + message + " : " + thread_trace, Logger.INFO );
-}
-
-
-/** Pushes all incoming messages onto the session message queue. **/
-Application.handler = function( session, domain_object_payload, thread_trace ) {
-
-	new Logger().debug( "Application Pushing onto queue: " 
-			+ thread_trace + "\n" + domain_object_payload.toString(), Logger.DEBUG );
-
-	session.push_queue( domain_object_payload, thread_trace );
-}
-
-
-	
-
-	

Deleted: trunk/src/javascript/opensrf_transport.js
===================================================================
--- trunk/src/javascript/opensrf_transport.js	2008-04-07 21:11:41 UTC (rev 1298)
+++ trunk/src/javascript/opensrf_transport.js	2008-04-08 13:35:23 UTC (rev 1299)
@@ -1,64 +0,0 @@
-/** @file oils_transport.js
-  * Houses the top level transport 'abstract' classes
-  * You can think of this like a header file which provides the 
-  * interface that any transport code must implement
-  */
-
-
-// ------------------------------------------------------------------
-// TRANSPORT_CONNECTION
-
-/** Constructor */
-function transport_connection( username, password, resource ) { }
-
-/** Connects to the transport host */
-transport_connection.prototype.connect = function(  host, /*int*/ port, /*int*/ timeout ) {}
-
-/** Sends a new message to recipient, with session_id and body */
-transport_connection.prototype.send = function( recipient, session_id, body ) {}
-
-
-/** Returns a transport_message.  This function will return 
-  * immediately if there is a message available.  Otherwise, it will
-  * wait at most 'timeout' seconds for one to arrive.  Returns
-  * null if a message does not arrivae in time.
-
-  * 'timeout' is specified in milliseconds
-  */
-transport_connection.prototype.recv = function( /*int*/ timeout ) {}
-
-/** This method calls recv and then passes the contents on to the
-  * message processing stack.
-  */
-transport_connection.prototype.process_msg = function( /*int*/ timeout ) {
-	var msg = this.recv( timeout );
-	if( msg ) { Transport.handler( msg ); }
-}
-
-/** Disconnects from the transpot host */
-transport_connection.prototype.disconnect = function() {}
-
-/** Returns true if this connection instance is currently connected
-  * to the transport host.
-  */
-transport_connection.prototype.connected = function() {}
-
-
-
-// ------------------------------------------------------------------
-// TRANSPORT_MESSAGE
-	
-
-/** Constructor */
-function transport_message( sender, recipient, session_id, body ) {}
-
-/** Returns the sender of the message */
-transport_message.prototype.get_sender = function() {}
-
-/** Returns the session id */
-transport_message.prototype.get_session = function() {}
-
-/** Returns the message body */
-transport_message.prototype.get_body = function() {}
-	
-

Deleted: trunk/src/javascript/opensrf_utils.js
===================================================================
--- trunk/src/javascript/opensrf_utils.js	2008-04-07 21:11:41 UTC (rev 1298)
+++ trunk/src/javascript/opensrf_utils.js	2008-04-08 13:35:23 UTC (rev 1299)
@@ -1,117 +0,0 @@
-// ------------------------------------------------------------------
-// Houses utility functions
-// ------------------------------------------------------------------
-
-/** Prints to console.  If alert_bool = true, displays a popup as well */
-function _debug( message, alert_bool ) {
-
-	dump( "\n" + new Date() + "\n--------------------------------\n" + 
-			message + "\n-----------------------------------\n" );
-	if( alert_bool == true ) { alert( message ) };
-
-}
-
-
-/** Provides millisec sleep times, enjoy... */
-function sleep(gap){ 
-
-	var threadService = Components.classes["@mozilla.org/thread;1"].
-		getService(Components.interfaces.nsIThread);
-
-	var th = threadService.currentThread;
-	th.sleep(gap);
-}
-
-
-
-/** Top level exception classe */
-function oils_ex() {}
-
-/** Initializes an exception */
-oils_ex.prototype.init_ex = function( name, message ) {
-	if( !(name && message) ) { return; }
-	this.name = name;
-	this.message = name + " : " + message;
-	new Logger().debug( "***\n" + this.message + "\n***", Logger.ERROR );
-}
-
-/** Returns a string representation of an exception */
-oils_ex.prototype.toString = function() {
-	return this.message;
-}
-
-
-oils_ex_transport.prototype = new oils_ex();
-oils_ex_transport.prototype.constructor = oils_ex_transport;
-oils_ex_transport.baseClass = oils_ex.prototype.constructor;
-
-/** Thrown when the transport connection has problems*/
-function oils_ex_transport( message ) {
-	this.init_ex( "Transport Exception", message );
-}
-
-
-oils_ex_transport_auth.prototype = new oils_ex_transport(); 
-oils_ex_transport_auth.prototype.constructor = oils_ex_transport_auth;
-oils_ex_transport_auth.baseClass = oils_ex_transport.prototype.constructor;
-
-/** Thrown when the initial transport connection fails */
-function oils_ex_transport_auth( message ) {
-	this.init_ex( "Transport Authentication Error", message );
-}
-
-oils_ex_dom.prototype = new oils_ex(); 
-oils_ex_dom.prototype.constructor = oils_ex_dom;
-oils_ex_dom.baseClass = oils_ex.prototype.constructor;
-
-/** Thrown when there is an XML problem */
-function oils_ex_dom( message ) {
-	this.init_ex( "DOM Error", message );
-}
-
-oils_ex_message.prototype = new oils_ex();
-oils_ex_message.prototype.constructor = oils_ex_message;
-oils_ex_message.baseClass = oils_ex.prototype.constructor;
-
-/** Thrown when there is a message problem */
-function oils_ex_message( message ) {
-	this.init_ex( "OILS Message Layer Error", message ) ;
-}
-
-oils_ex_config.prototype = new oils_ex();
-oils_ex_config.prototype.constructor = oils_ex_config;
-oils_ex_config.prototype.baseClass = oils_ex.prototype.constructor;
-
-/** Thrown when values cannot be retrieved from the config file */
-function oils_ex_config( message ) {
-	this.init_ex( "OILS Config Exception", message );
-}
-
-oils_ex_logger.prototype = new oils_ex();
-oils_ex_logger.prototype.constructor = oils_ex_logger;
-oils_ex_logger.prototype.baseClass = oils_ex.prototype.constructor;
-
-/** Thrown where there are logging problems */
-function oils_ex_logger( message ) {
-	this.init_ex( "OILS Logger Exception", message );
-}
-
-
-oils_ex_args.prototype = new oils_ex();
-oils_ex_args.prototype.constructor = oils_ex_args;
-oils_ex_args.prototype.baseClass = oils_ex.prototype.constructor;
-
-/** Thrown when when a method does not receive all of the required arguments */
-function oils_ex_args( message ) {
-	this.init_ex( "Method Argument Exception", message );
-}
-
-
-oils_ex_session.prototype = new oils_ex();
-oils_ex_session.prototype.constructor = oils_ex_session;
-oils_ex_session.prototype.baseClass = oils_ex.prototype.constructor;
-
-/** Thrown where there is a session processing problem */
-function oils_ex_session( message ) {
-	this.init_ex( "Session Exception", message );
-}



More information about the opensrf-commits mailing list