You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xang-cvs@xml.apache.org by md...@apache.org on 2001/08/07 08:14:04 UTC

cvs commit: xml-xang/java/src/org/apache/xang/net/http/object/impl HTTPScriptedObject.java

mdierken    01/08/06 23:14:04

  Modified:    java/src/org/apache/xang/net/http/object/impl
                        HTTPScriptedObject.java
  Log:
  Change HTML output of error to use red font for error line.
  
  Revision  Changes    Path
  1.4       +52 -52    xml-xang/java/src/org/apache/xang/net/http/object/impl/HTTPScriptedObject.java
  
  Index: HTTPScriptedObject.java
  ===================================================================
  RCS file: /home/cvs/xml-xang/java/src/org/apache/xang/net/http/object/impl/HTTPScriptedObject.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HTTPScriptedObject.java	2000/05/26 16:58:51	1.3
  +++ HTTPScriptedObject.java	2001/08/07 06:14:04	1.4
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "Xang" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -88,7 +88,7 @@
   	public final static String PARAMETERS_TAG = "parameters";
   	public final static String APP_TAG = "app";
   	public final static String[] FESI_EXTENSIONS = {"FESI.Extensions.BasicIO", "FESI.Extensions.JavaAccess"};
  -	
  +
       public HTTPScriptedObject()
       {
       }
  @@ -98,7 +98,7 @@
           BufferedReader reader = new BufferedReader(new InputStreamReader(new StringBufferInputStream(script)));
           String line;
           int i=0;
  -        
  +
           try
           {
               for (i=0; i < lineNumber-1; i++)
  @@ -107,13 +107,13 @@
                   os.write(TextUtil.encodeToHTML(line));
                   os.write("\n");
               }
  -        
  -            os.write("<b>");
  +
  +            os.write("<b><font color='red'>");
               line = reader.readLine();
               if (line != null)
                   os.write(TextUtil.encodeToHTML(line));
               os.write("\n");
  -            os.write("</b>");
  +            os.write("</font></b>");
   
               while(true)
               {
  @@ -129,7 +129,7 @@
           }
   
       }
  -    
  +
       //////////////////////
       // IHTTPObject
       /** Performs operation specified by 'method'.
  @@ -146,8 +146,8 @@
           else
               return true;
       }
  +
   
  -    
       // method invocation
       /** Performs operation specified by 'method'.
       **      @param context information about this transaction
  @@ -159,16 +159,16 @@
       public boolean dispatchToScript(IHTTPContext context,Vector returnTypes,String method,Hashtable parameters)
       {
   		HTTPScriptContext scriptContext = new HTTPScriptContext( context, returnTypes, method, parameters );
  -		
  +
   		// construct name of method
           String eventName = getEventName( context, parameters );
           String function = loadHandler( eventName );
           String scriptLanguage = loadHandlerType( eventName );
  -		
  +
           // if no handler found, bomb out.
           if (function == null || function.length() < 1)
               return false;
  -            
  +
           // load script
           String script = loadScript( scriptLanguage );
           if (script == null)
  @@ -176,24 +176,24 @@
               reportNoScript( scriptContext.context );
               return false;
           }
  -		
  +
   		//XspDebug.out( script );
  -        
  +
   		//Create the engine and call the script
   		//
           if( scriptLanguage != null || scriptType==-1)
               scriptType = EngineFactory.scriptType( scriptLanguage );
  -        
  +
   		IEngine engine = EngineFactory.createEngine( scriptType );
   		engine.addNamedObject(CONTEXT_TAG, scriptContext.context);
   		engine.addNamedObject(METHOD_TAG, scriptContext.method);
   		engine.addNamedObject(RETURN_TYPES_TAG, scriptContext.returnTypes);
   		engine.addNamedObject(PARAMETERS_TAG, scriptContext.parameters);
   		engine.addNamedObject(APP_TAG, this);
  -		
  +
   		//allow the subClasses a chance
   		initSourceContext( engine );
  -		
  +
   		engine.addScript(script);
   		if( !engine.run(function) )
   		{
  @@ -214,10 +214,10 @@
   					reportThrowable( throwable, context, eventName );
   			}
   		}
  -      
  +
   		return true;
       }
  -	
  +
   	// method invocation
       /** Performs operation specified by 'method'.
        *		@param error the error that occurred
  @@ -233,21 +233,21 @@
           String eventName = ON_ERROR_TAG;
           String function = loadHandler( eventName );
   		String scriptLanguage = loadHandlerType( eventName );
  -		
  +
           // if no handler found, bomb out.
           if (function == null || function.length() < 1)
               return false;
  -            
  +
           // load script
           String script = loadScript( scriptLanguage );
           if (script == null)
   			 return false;
  -        
  +
           //Create the engine and call the script
   		//
           if( scriptLanguage != null )
               scriptType = EngineFactory.scriptType( scriptLanguage );
  -        
  +
   		IEngine engine = EngineFactory.createEngine( scriptType );
   		engine.addNamedObject(CONTEXT_TAG, scriptContext.context);
   		engine.addNamedObject(METHOD_TAG, scriptContext.method);
  @@ -256,10 +256,10 @@
   		engine.addNamedObject(ERROR_TAG, error);
   		engine.addNamedObject(APP_TAG, this);
   		engine.addScript(script);
  -		
  +
   		//allow the subClasses a chance
   		initSourceContext( engine );
  -		
  +
   		if( !engine.run(function) )
   		{
   			Throwable throwable = (Throwable)engine.getLastError();
  @@ -279,10 +279,10 @@
   					reportThrowable( throwable, scriptContext.context, eventName );
   			}
   		}
  -			
  +
   		return true;
       }
  - 
  +
       ////
       // HTTPScriptedObject implementation
       /**
  @@ -291,7 +291,7 @@
       public void initSourceContext(IEngine engine)
       {
       }
  -    
  +
       /**
        * This gets the snipped of script code to run for a request/message/event
        */
  @@ -306,7 +306,7 @@
       {
           return null;
       }
  -	
  +
   	/**
   	 * This returns the type of language for this particular function
   	 */
  @@ -314,15 +314,15 @@
   	{
   		return null;
   	}
  -	
  -	
  +
  +
   	/**
   	 * If the execution of a script throws an error allow the
   	 * Object a chance to do something
   	 * If it wants handles the error (such as
   	 * an attempt at script error handling then
   	 * return true, otherwise return false for full reporting)
  -	 * 
  +	 *
   	 * The error might be of types:
   	 *	JSException
   	 *  Exception
  @@ -332,11 +332,11 @@
   	{
   		return dispatchErrorToScript( error, scriptContext );
   	}
  -	
  +
   	protected void reportJSException(JSException jsException, IHTTPContext context, String eventName, String script)
   	{
   		int lineNumber=0;
  -            
  +
           String message = jsException.getMessage();
           Throwable eOriginal = jsException.getOriginatingException();
           if (eOriginal instanceof FESI.Exceptions.EcmaScriptException)
  @@ -348,9 +348,9 @@
           {
               message = eOriginal.getClass().getName() + " caused a " + message;
           }
  -            
  +
           report( jsException, context, eventName, message );
  -		
  +
   		//Dump script
   		//
   		PrintWriter out = getWriter(context);
  @@ -358,17 +358,17 @@
           dumpLine(out,script,lineNumber);
           out.write("</pre>");
   	}
  -	
  +
   	protected void reportException(Exception exception, IHTTPContext context, String eventName)
   	{
   		report( exception, context, eventName, exception.getMessage() );
   	}
  -	
  +
   	protected void reportThrowable(Throwable throwable, IHTTPContext context, String eventName)
   	{
   		report( throwable, context, eventName, throwable.getMessage() );
   	}
  -	
  +
   	protected void report(Throwable throwable, IHTTPContext context, String eventName, String message)
   	{
   		PrintWriter out = getWriter(context);
  @@ -382,14 +382,14 @@
           if (message != null)
               out.write(message);
           out.write("</pre></body></html>");
  -            
  +
           out.write("<!--\n");
           throwable.printStackTrace(out);
           out.write("\n-->");
   
  -        out.flush();		
  +        out.flush();
   	}
  -	
  +
   	protected void reportNoScript(IHTTPContext context)
   	{
   		try
  @@ -401,7 +401,7 @@
           {
           }
       }
  -    
  +
       protected String toMixedCase(String value)
       {
           String s=value;
  @@ -409,22 +409,22 @@
           s = s.substring(0,1).toUpperCase() + s.substring(1,s.length());
           return s;
       }
  -    
  +
       protected String getEventName(IHTTPContext context,Hashtable parameters)
       {
           String s;
           String function;
  -        
  +
           function = "on";
           s = toMixedCase(context.getRequest().getMethod());
           function += s;
  -        
  +
           s = context.getRequest().getMethod();
           if (parameters.get("do:method") != null)
           {
               function += toMixedCase((String)parameters.get("do:method"));
           }
  -        
  +
           return function;
       }
   
  @@ -439,11 +439,11 @@
           }
           return null;
      }
  -    
  +
       ///
   	protected	int scriptType = -1;	//Unknown
  -	
  -    public final static String RCS_STRING = "$Workfile: HTTPScriptedObject.java $ " + "$Revision: 1.3 $";
  +
  +    public final static String RCS_STRING = "$Workfile: HTTPScriptedObject.java $ " + "$Revision: 1.4 $";
   }
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xang-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xang-cvs-help@xml.apache.org