cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upayav...@apache.org
Subject svn commit: rev 54676 - in cocoon/trunk/src/java/org/apache/cocoon/bean: . helpers
Date Tue, 12 Oct 2004 15:57:35 GMT
Author: upayavira
Date: Tue Oct 12 08:57:34 2004
New Revision: 54676

Modified:
   cocoon/trunk/src/java/org/apache/cocoon/bean/BeanListener.java
   cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonBean.java
   cocoon/trunk/src/java/org/apache/cocoon/bean/helpers/Crawler.java
   cocoon/trunk/src/java/org/apache/cocoon/bean/helpers/OutputStreamListener.java
Log:
Fixing it so that broken link referrer works properly (I think!)

Modified: cocoon/trunk/src/java/org/apache/cocoon/bean/BeanListener.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/bean/BeanListener.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/bean/BeanListener.java	Tue Oct 12 08:57:34 2004
@@ -74,7 +74,7 @@
      * @param message        A reason why the link was not generated
      */
     public void brokenLinkFound(String uri, String parentURI, String message, Throwable t);
-    public void brokenLinkFound(String uri, List parentURIs, String message, Throwable t);
+    public void brokenLinkFound(Target target, Throwable t);
     
     /**
      * Signals completion of the generation process. This method can

Modified: cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonBean.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonBean.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonBean.java	Tue Oct 12 08:57:34 2004
@@ -309,11 +309,11 @@
         }
     }
 
-    public void sendBrokenLinkWarning(String uri, List referrers, String warning, Throwable
t) {
+    public void sendBrokenLinkWarning(Target target, Throwable t) {
         Iterator i = listeners.iterator();
         while (i.hasNext()) {
             BeanListener l = (BeanListener) i.next();
-            l.brokenLinkFound(uri, referrers, warning, t);
+            l.brokenLinkFound(target, t);
         }
     }
 
@@ -468,7 +468,7 @@
                             newLinkCount++;
                         }
                     } catch (ProcessingException pe) {
-                        this.sendBrokenLinkWarning(linkTarget.getSourceURI(), linkTarget.getReferringURIs(),
pe.getMessage(), pe);
+                        this.sendBrokenLinkWarning(linkTarget, pe);
                         if (this.brokenLinkGenerate) {
                            if (crawler.addTarget(linkTarget)) {
                                newLinkCount++;
@@ -537,9 +537,7 @@
                 output.close();
                 output = null;
                 this.resourceUnavailable(target);
-                this.sendBrokenLinkWarning(target.getSourceURI(),
-                    target.getReferringURIs(),
-                    DefaultNotifyingBuilder.getRootCause(pe).getMessage(),
+                this.sendBrokenLinkWarning(target,
                     DefaultNotifyingBuilder.getRootCause(pe));
             } finally {
                 if (output != null && status != -1) {

Modified: cocoon/trunk/src/java/org/apache/cocoon/bean/helpers/Crawler.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/bean/helpers/Crawler.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/bean/helpers/Crawler.java	Tue Oct 12 08:57:34
2004
@@ -56,7 +56,11 @@
                 Target existingTarget = (Target)stillNotVisited.get(targetString);
                 existingTarget.addReferringURI(target.getReferringURI());
             }
+        } else {
+            Target visitedTarget = (Target)visitedAlready.get(targetString);
+            visitedTarget.addReferringURI(target.getReferringURI());
         }
+        
         return false;
     }
 

Modified: cocoon/trunk/src/java/org/apache/cocoon/bean/helpers/OutputStreamListener.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/bean/helpers/OutputStreamListener.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/bean/helpers/OutputStreamListener.java	Tue Oct
12 08:57:34 2004
@@ -21,13 +21,12 @@
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.text.DecimalFormat;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
 import org.apache.cocoon.bean.BeanListener;
+import org.apache.cocoon.bean.Target;
 
 /**
  * Command line entry point. Parses command line, create Cocoon bean and invokes it
@@ -107,14 +106,13 @@
      * @deprecated use brokenLinkFound(String, List, String, Throwable) instead
      */
     public void brokenLinkFound(String uri, String parentURI, String message, Throwable t)
{
-        List parents = new ArrayList(1);
-        parents.add(parentURI);
-        brokenLinkFound(uri, parents, message, t);
+        this.print(pad(42,"X [0] ")+uri+"\tBROKEN: "+message);
+        brokenLinks.put(uri + "\t" + message, "");
     }
 
-    public void brokenLinkFound(String uri, List parentURIs, String message, Throwable t)
{
-        this.print(pad(42,"X [0] ")+uri+"\tBROKEN: "+message);
-        brokenLinks.put(uri + "\t" + message, parentURIs);
+    public void brokenLinkFound(Target target, Throwable t) {
+        this.print(pad(42,"X [0] ")+target.getSourceURI()+"\tBROKEN: "+t.getMessage());
+        brokenLinks.put(target.getSourceURI() + "\t" + t.getMessage(), target);
 
     }
 
@@ -181,10 +179,13 @@
                     writer.println("  <link message=\"" + msg + "\">" + uri + "</link>");
                 } else {
                     writer.println("  <link message=\"" + msg + "\" uri=\"" + uri + "\">");
-                    List referrers = (List)brokenLinks.get(linkMsg);
-                    for (Iterator j = referrers.iterator(); j.hasNext();) {
-                        String referrer=(String) j.next();
-                        writer.println("    <referrer uri=\"" + referrer + "\"/>");
+                    Object t = brokenLinks.get(linkMsg);
+                    if (t instanceof Target) {
+                        Target target = (Target)t;
+                        for (Iterator j = target.getReferringURIs().iterator(); j.hasNext();)
{
+                            String referrer=(String) j.next();
+                            writer.println("    <referrer uri=\"" + referrer + "\"/>");
+                        }
                     }
                     writer.println("  </link>");
                 }

Mime
View raw message