cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicola...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon Main.java
Date Mon, 25 Nov 2002 20:15:44 GMT
nicolaken    2002/11/25 12:15:44

  Modified:    .        changes.xml
               src/java/org/apache/cocoon/components/notification
                        DefaultNotifyingBuilder.java
               src/java/org/apache/cocoon Main.java
  Log:
    <action dev="NKB" type="fix">
     Make the CLI report errors correctly to the screen when a page generation fails.
    </action>
  
  Revision  Changes    Path
  1.288     +5 -2      xml-cocoon2/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/changes.xml,v
  retrieving revision 1.287
  retrieving revision 1.288
  diff -u -r1.287 -r1.288
  --- changes.xml	25 Nov 2002 15:18:30 -0000	1.287
  +++ changes.xml	25 Nov 2002 20:15:44 -0000	1.288
  @@ -40,7 +40,10 @@
    </devs>
   
    <release version="@version@" date="@date@">
  -  <action dev="NKB" type="updated" fixes-bug="12975" due-to="Philipp Schmidt" due-to-email="Philipp.Schmidt@it-care.de">
  +  <action dev="NKB" type="fix">
  +   Make the CLI report errors correctly to the screen when a page generation fails.
  +  </action> 
  +  <action dev="NKB" type="update" fixes-bug="12975" due-to="Philipp Schmidt" due-to-email="Philipp.Schmidt@it-care.de">
      Moved POI to a block. Applied patch without moving the core elementprocessor
      classes in the block.
     </action> 
  
  
  
  1.10      +2 -2      xml-cocoon2/src/java/org/apache/cocoon/components/notification/DefaultNotifyingBuilder.java
  
  Index: DefaultNotifyingBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/notification/DefaultNotifyingBuilder.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultNotifyingBuilder.java	15 Jul 2002 14:52:39 -0000	1.9
  +++ DefaultNotifyingBuilder.java	25 Nov 2002 20:15:44 -0000	1.10
  @@ -211,7 +211,7 @@
     /**
      * Get root Exception.
      */
  -  private static Throwable getRootCause (Throwable t) {
  +  public static Throwable getRootCause (Throwable t) {
       Throwable cause = null;
       if (t instanceof CascadingThrowable) {
         cause = ((CascadingThrowable) t).getCause();
  
  
  
  1.26      +61 -24    xml-cocoon2/src/java/org/apache/cocoon/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/Main.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Main.java	24 Aug 2002 17:34:51 -0000	1.25
  +++ Main.java	25 Nov 2002 20:15:44 -0000	1.26
  @@ -72,6 +72,7 @@
   import org.apache.cocoon.components.notification.SimpleNotifyingBean;
   import org.apache.cocoon.components.notification.DefaultNotifyingBuilder;
   import org.apache.cocoon.components.notification.Notifier;
  +import org.apache.cocoon.components.notification.DefaultNotifyingBuilder;
   import org.apache.log.Hierarchy;
   import org.apache.log.Logger;
   import org.apache.log.Priority;
  @@ -628,7 +629,7 @@
                       }
                   }
               } catch (ResourceNotFoundException rnfe) {
  -                printBroken (url);
  +                printBroken (url, rnfe.getMessage());
               }
           
               links.remove(url);
  @@ -785,7 +786,7 @@
                       absoluteLinks.add(absoluteLink);
                   }    
                   catch (ProcessingException pe) {
  -                    printBroken(absoluteLink);
  +                    printBroken(absoluteLink, pe.getMessage());
                   }                
               }
               
  @@ -802,15 +803,26 @@
               // Process URI
               File file = IOUtils.createFile(destDir, NetUtils.decodePath(filename));
               OutputStream output = new BufferedOutputStream(new FileOutputStream(file));
  -            String type = getPage(deparameterizedURI, parameters, translatedLinks, output);
  -            output.close();
  -            if (type == null) {
  -                printBroken(filename);
  -                resourceUnavailable(file, uri);
  -            } else {
  -              printlnInfo(uri); //(can also output type)
  -            }
  -        } catch (ResourceNotFoundException rnfe) {
  +            
  +             try{
  +                String type = getPage(deparameterizedURI, parameters, translatedLinks,
output);
  +                printlnInfo(uri); //(can also output type)
  +            }
  +             catch(ProcessingException pe){
  +                 printBroken(filename, DefaultNotifyingBuilder.getRootCause(pe).getMessage());
  +                 resourceUnavailable(file, uri);
  +             }
  +             finally{
  +                try{ 
  +                   output.close();
  +                }
  +                catch(IOException ioex){
  +                    this.log.warn(ioex.toString());
  +                }
  +             }
  +
  +        } catch (Exception rnfe) {
  +            System.out.println("XXX"+rnfe);
               this.log.warn("Could not process URI: " + deparameterizedURI);
               if (verbose) System.out.println("Could not process URI: " + deparameterizedURI);
            
           }
  @@ -931,12 +943,12 @@
                           links,
                           stream,
                           new LogKitLogger(this.log));
  -        if(processLenient(env)==true){
  -          return env.getContentType();
  -        }
  -        else{
  -          return null;
  -        }
  +        
  +            //Here Cocoon can throw an exception if there are errors in processing the
page
  +            cocoon.process(env);
  +            //if we get here, the page was created :-)
  +            return env.getContentType();
  +
       }
   
       /** Class <code>NullOutputStream</code> here. */
  @@ -992,12 +1004,37 @@
        * @returns boolean true if no error were cast, false otherwise
        * @exception Exception if an error occurs, except RNFE
        */
  -    private void printBroken(String url) {
  -       System.out.println("");
  -       printlnInfo("-> [broken link] " + url +" <- ");
  -       if (null != this.brokenLinkWriter) {
  -             this.brokenLinkWriter.println(url);
  -       }       
  +    private void printBroken(String url, String cause) {
  +
  +        int screenWidth=67;
  +        int causeWidth= screenWidth - 6;
  +
  +        printlnInfo(""); 
  +        printlnInfo("-> [broken page] " + url +" <- ");     
  +        printlnInfo(""); 
  +        printInfo("     ");      
  +        
  +        int causeLength = cause.length(), currentStart = -causeWidth, currentEnd = 0 ;
        
  +        
  +        do{ 
  +            
  +            currentStart+=causeWidth; 
  +            currentEnd  +=causeWidth;
  +
  +            if(currentEnd>causeLength){
  +                currentEnd=causeLength;   
  +            }
  +
  +           printlnInfo(cause.substring(currentStart, currentEnd) );      
  +           printInfo("     ");       
  +            
  +         }while(currentEnd<causeLength);
  +         
  +         printlnInfo(""); 
  +         
  +        if (null != this.brokenLinkWriter) {
  +            this.brokenLinkWriter.println(url);
  +        }       
       }
       
       /**
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message