Attachment _really_ attached this time.
While I'm spamming people's mailboxes.. here's what a broken page looks
like with the patch:
...
* [0] skin/images/tab-left.gif
X [0] samples/ihtml-sample.html BROKEN: null
* [0] samples/wiki-sample.pdf
...
Total time: 0 minutes 40 seconds
BUILD FAILED
/home/jeff/apache/xml/xml-forrest/build/dist/shbat/forrest.build.xml:604: Java
returned: 1
These changes are mainly to make command-line Cocoon useable from within
cron scripts, where the exit code is now useful, and broken URIs can be
obtained with "grep ^X | cut -d\ -f 3".
--Jeff
On Sun, Jul 20, 2003 at 08:59:14PM +1000, Jeff Turner wrote:
> I thought I'd ask before applying the attached patch to Main.java. It
> does the following:
>
> - Checks if there are any broken links, and if so, does a System.exit(1)
> instead of System.exit(0).
>
> - Print an error message at the point the broken link occurs, in
> addition to listing it in the brokenlinks file. I don't want to have
> to wait 10 mins to discover if there's a broken link :)
>
> - Throw out the code that wraps log output at 67 chars. My terminal is
> a good deal wider than 67 chars, and in any case is able to handle
> wrapping itself :)
>
>
> --Jeff
Index: src/java/org/apache/cocoon/Main.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/Main.java,v
retrieving revision 1.10
diff -u -r1.10 Main.java
--- src/java/org/apache/cocoon/Main.java 19 Jul 2003 12:40:44 -0000 1.10
+++ src/java/org/apache/cocoon/Main.java 20 Jul 2003 11:17:46 -0000
@@ -379,7 +379,9 @@
long duration = System.currentTimeMillis() - startTimeMillis;
System.out.println("Total time: " + (duration / 60000) + " minutes " +
(duration % 60000)/1000 + " seconds");
- System.exit(0);
+
+ int exitCode = (brokenLinks.size() == 0 ? 0 : 1);
+ System.exit(exitCode);
}
private static boolean yesno(String in) {
@@ -692,6 +694,7 @@
}
public void brokenLinkFound(String uri, String message) {
+ this.print("X [0] "+uri+"\tBROKEN: "+message);
brokenLinks.add(uri + "\t" + message);
}
@@ -739,21 +742,9 @@
this.print("Could not create broken link file: " +
brokenLinkReportFile);
}
}
- private void print(String message) {
- int screenWidth = 67;
- int messageWidth = screenWidth - 6;
-
- int messageLength = message.length(), currentStart = -messageWidth,
currentEnd = 0;
- do {
- currentStart += messageWidth;
- currentEnd += messageWidth;
- if (currentEnd>messageLength) {
- currentEnd=messageLength;
- }
-
- System.out.println(message.substring(currentStart, currentEnd));
- } while(currentEnd < messageLength);
+ private void print(String message) {
+ System.out.println(message);
}
}
}