You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by st...@locus.apache.org on 2000/09/29 03:02:53 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon Constants.java Main.java Notifier.java

stefano     00/09/28 18:02:53

  Modified:    src/org/apache/cocoon Tag: xml-cocoon2 Constants.java
                        Main.java Notifier.java
  Log:
  new fancy output from CLI
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +2 -3      xml-cocoon/src/org/apache/cocoon/Attic/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/Constants.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- Constants.java	2000/09/27 16:14:43	1.1.2.5
  +++ Constants.java	2000/09/29 01:02:51	1.1.2.6
  @@ -10,7 +10,7 @@
   
   /**
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/09/27 16:14:43 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/09/29 01:02:51 $
    */
   
   public interface Constants {
  @@ -43,8 +43,7 @@
       public static final String LINK_CONTENT_TYPE     = "application/x-cocoon-links";
       public static final String LINK_VIEW             = "links";
       public static final String LINK_CRAWLING_ROLE    = "static";
  -    public static final String LINK_TRANSLATING_VIEW = "translate-links";
  -    public static final String LINK_TRANSLATED_NAME  = "translated-links";    
  +    public static final String LINK_OBJECT           = "links";
   
       public static final String CATALINA_SERVLET_CLASSPATH = "org.apache.catalina.jsp_classpath";
       public static final String TOMCAT_SERVLET_CLASSPATH = "org.apache.tomcat.jsp_classpath";
  
  
  
  1.1.4.9   +57 -11    xml-cocoon/src/org/apache/cocoon/Attic/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/Main.java,v
  retrieving revision 1.1.4.8
  retrieving revision 1.1.4.9
  diff -u -r1.1.4.8 -r1.1.4.9
  --- Main.java	2000/09/27 16:14:47	1.1.4.8
  +++ Main.java	2000/09/29 01:02:51	1.1.4.9
  @@ -33,7 +33,7 @@
    * Command line entry point.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.4.8 $ $Date: 2000/09/27 16:14:47 $
  + * @version CVS $Revision: 1.1.4.9 $ $Date: 2000/09/29 01:02:51 $
    */
   
   public class Main {
  @@ -113,7 +113,7 @@
               log("Warming up...");
               log("Note: Cocoon is compiling the sitemaps, this might take a while...");
               main.warmup();
  -            log("Starting processing...");
  +            log("Ok, let's go...\n");
               main.process(targets);
               log("Done");
           } catch (Exception e) {
  @@ -224,7 +224,7 @@
           Iterator i = uris.iterator();
           while (i.hasNext()) {
               String uri = (String) i.next();
  -            this.processURI(uri, "");
  +            this.processURI(uri, 0);
           }
       }
   
  @@ -246,13 +246,16 @@
        *  <li>then the file name of the translated URI is returned</li>
        * </ul>
        */
  -    public File processURI(String uri, String level) throws Exception {
  +    public String processURI(String uri, int level) throws Exception {
  +        log(leaf(level) + uri);
  +
           Collection links = getLinks(uri);
           Map translatedLinks = new HashMap(links.size());
           Iterator i = links.iterator();
           while (i.hasNext()) {
  -            String link = (String) i.next();
  -            translatedLinks.put(link, processURI(link, "  " + level));
  +            log(tree(level));
  +            String link = adjustContext(uri, (String) i.next());
  +            translatedLinks.put(link, processURI(link, level + 1));
           }
           
           File outputFile = getFile(uri);
  @@ -269,11 +272,39 @@
               outputFile.renameTo(newFile);
               outputName = newFile.getPath();
           }
  +
  +        log(tree(level));
   
  -        log(level + uri + " [" + type + "] --> " + outputName);
  +        if (type == null) {
  +            log(leaf(level + 1) + "[broken link]--> " + outputName);
  +            PrintStream out = new PrintStream(new FileOutputStream(outputFile));
  +            out.println(
  +               "<html><head><title>Page Not Available</title></head>" +
  +               "<body><h1 align=\"center\">Page Not Available</h1>" +
  +               "<body><p align=\"center\">Generated by " + 
  +                Cocoon.NAME + " " + Cocoon.VERSION + 
  +               "</p></body></html>"
  +            );
  +            out.close();
  +        } else {
  +            log(leaf(level + 1) + "[" + type + "]--> " + outputName);
  +        }
           
  -        return outputFile;
  +        return outputName;
       }        
  +
  +    String leaf(int level) {
  +        if (level == 0) return "";
  +        return tree(level - 2) + "+--";
  +    }
  +
  +    String tree(int level) {
  +        StringBuffer buffer = new StringBuffer();
  +        for (int i = 0; i <= level; i++) {
  +            buffer.append("|  ");
  +        }
  +        return buffer.toString();
  +    }
       
       Collection getLinks(String uri) throws Exception {
           LinkSamplingEnvironment env = new LinkSamplingEnvironment(uri, context);
  @@ -293,7 +324,7 @@
           if (parent != null) parent.mkdirs();
           return f;
       }
  -    
  +
       String getExtension(String file) {
           int lastDot = file.lastIndexOf('.');
           if (lastDot > -1) file = file.substring(lastDot + 1);
  @@ -304,9 +335,24 @@
               return file;
           }
       }
  +    
  +    String adjustContext(String parent, String child) {
  +        if (child.charAt(0) != '/') {
  +            int lastSlash = parent.lastIndexOf('/');
  +            if (lastSlash > -1) {
  +                return parent.substring(0, lastSlash + 1) + child;
  +            } else {
  +                return child;
  +            }
  +        } else {
  +            return child;
  +        }
  +    }
   
       String getDefaultExtension(String type) {
  -        if ("text/html".equals(type)) {
  +        if (type == null) {
  +            return "html";
  +        } else if ("text/html".equals(type)) {
               return "html";
           } else if ("text/xml".equals(type)) {
               return "xml";
  @@ -349,7 +395,7 @@
           } else if ("audio/mpeg".equals(type)) {
               return "mp3";
           } else {
  -            return "xxx";
  +            return "";
           }
       }
   }
  
  
  
  1.1.2.5   +3 -3      xml-cocoon/src/org/apache/cocoon/Attic/Notifier.java
  
  Index: Notifier.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/Notifier.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- Notifier.java	2000/09/27 16:14:50	1.1.2.4
  +++ Notifier.java	2000/09/29 01:02:51	1.1.2.5
  @@ -32,7 +32,7 @@
    *
    * @author <a href="mailto:nicolaken@supereva.it">Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/09/27 16:14:50 $
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/09/29 01:02:51 $
    */
    
   public class Notifier {
  @@ -82,8 +82,8 @@
        */
       public static void notify(Notificable n, ContentHandler ch) throws SAXException {
   
  -        final String URI = Cocoon.ERROR_NAMESPACE_PREFIX;
           final String PREFIX = Cocoon.ERROR_NAMESPACE_PREFIX;
  +        final String URI = Cocoon.ERROR_NAMESPACE_PREFIX;
   
           String buf;
           
  @@ -138,7 +138,7 @@
           ch.endElement(URI, "notify", "notify");
   
           // End the document.
  -        ch.endPrefixMapping(Cocoon.ERROR_NAMESPACE_PREFIX);
  +        ch.endPrefixMapping(PREFIX);
           ch.endDocument();
       }
   }