dims        01/08/10 05:21:57

  Modified:    src/org/apache/cocoon/servlet Tag: cocoon_20_branch
                        CocoonServlet.java
  Log:
  - Sync with C2.1 for showtime flag.
  - Patch from "Morrison, John" <[EMAIL PROTECTED]> for "warn if a config 
setting hasn't been set"
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.13.2.13 +46 -14    xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java,v
  retrieving revision 1.13.2.12
  retrieving revision 1.13.2.13
  diff -u -r1.13.2.12 -r1.13.2.13
  --- CocoonServlet.java        2001/08/09 12:24:02     1.13.2.12
  +++ CocoonServlet.java        2001/08/10 12:21:57     1.13.2.13
  @@ -64,7 +64,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.13.2.12 $ $Date: 2001/08/09 12:24:02 $
  + * @version CVS $Revision: 1.13.2.13 $ $Date: 2001/08/10 12:21:57 $
    */
   
   public class CocoonServlet extends HttpServlet {
  @@ -88,6 +88,10 @@
       /** Allow reloading of cocoon by specifying the cocoon-reload parameter with a 
request */
       protected boolean allowReload;
   
  +    /** Allow adding processing time to the response */
  +    protected boolean showTime;
  +    protected boolean hiddenShowTime;
  +
       private static final boolean ALLOW_OVERWRITE = false;
       private static final boolean SILENTLY_RENAME = true;
       private static final boolean SAVE_UPLOADED_FILES_TO_DISK = true;
  @@ -125,7 +129,14 @@
           this.initLogger();
   
           this.forceLoadParameter = conf.getInitParameter("load-class");
  +        if(conf.getInitParameter("load-class") == null) {
  +           log.debug("load-class was not set - defaulting to false?");
  +        }
  +
           this.addClassDirs = 
"true".equals(conf.getInitParameter("init-classloader"));
  +        if(conf.getInitParameter("init-classloader") == null) {
  +           log.debug("init-classloader was not set - defaulting to false");
  +        }
   
           String workDirParam = conf.getInitParameter("work-directory");
           if ((workDirParam != null) && (workDirParam.trim().equals("") == false)) {
  @@ -159,11 +170,25 @@
   
           this.appContext.put(Constants.CONTEXT_CONFIG_URL,
           this.getConfigFile(conf.getInitParameter("configurations")));
  +        if(conf.getInitParameter("configurations") == null) {
  +           log.debug("configurations was not set - defaulting to... ?");
  +        }
   
           // get allow reload parameter, default is true
           String value = conf.getInitParameter("allow-reload");
           this.allowReload = (value == null || value.equals("yes") || 
value.equals("true"));
  +        if(conf.getInitParameter("allow-reload") == null) {
  +           log.debug("allow-reload was not set - defaulting to true");
  +        }
  +
  +        value = conf.getInitParameter("show-time");
  +        this.showTime = "yes".equals(value) || "true".equals(value)
  +            || (this.hiddenShowTime = "hide".equals(value));
   
  +        if(conf.getInitParameter("show-time") == null) {
  +           log.debug("show-time was not set - defaulting to false");
  +        }
  +
           this.createCocoon();
       }
   
  @@ -490,6 +515,7 @@
               return;
           }
   
  +        boolean processed = false;
           try {
               if (uri.charAt(0) == '/') {
                   uri = uri.substring(1);
  @@ -506,7 +532,9 @@
               // Add the object model
               ctxStack.push(env.getObjectModel());
   
  -            if (!this.cocoon.process(env)) {
  +            if (this.cocoon.process(env)) {
  +                processed = true;
  +            } else {
   
                   // means SC_NOT_FOUND
                   res.setStatus(res.SC_NOT_FOUND);
  @@ -570,25 +598,29 @@
               res.setContentType(Notifier.notify(n, res.getOutputStream()));
           }
   
  -        ServletOutputStream out = res.getOutputStream();
  -
           long end = new Date().getTime();
           String timeString = processTime(end - start);
           log.info("'" + uri + "' " + timeString);
   
  -        String showTime = request.getParameter(Constants.SHOWTIME_PARAM);
  +        if (processed) {
  +            ServletOutputStream out = res.getOutputStream();
   
  -        if ((showTime != null) && !showTime.equalsIgnoreCase("no")) {
  -            boolean hide = showTime.equalsIgnoreCase("hide");
  -            out.print((hide) ? "<!-- " : "<p>");
  -
  -            out.print(timeString);
  +            String showTime = request.getParameter(Constants.SHOWTIME_PARAM);
  +            boolean show = this.showTime;
  +            if (showTime != null)
  +                show = !showTime.equalsIgnoreCase("no");
  +            if (show) {
  +                boolean hide = this.hiddenShowTime;
  +                if(showTime != null)
  +                    hide = showTime.equalsIgnoreCase("hide");
  +                out.print((hide) ? "<!-- " : "<p>");
  +                out.print(timeString);
  +                out.println((hide) ? " -->" : "</p>");
  +            }
   
  -            out.println((hide) ? " -->" : "</p>");
  +            out.flush();
  +            out.close();
           }
  -
  -        out.flush();
  -        out.close();
       }
   
       /**
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to