bloritsch 02/01/11 08:27:53
Modified: src/java/org/apache/cocoon Main.java
src/java/org/apache/cocoon/matching
AbstractRegexpMatcher.java
Log:
apply fix for bug# 5791
Revision Changes Path
1.7 +16 -16 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Main.java 10 Jan 2002 20:11:46 -0000 1.6
+++ Main.java 11 Jan 2002 16:27:53 -0000 1.7
@@ -97,7 +97,7 @@
* Command line entry point.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.6 $ $Date: 2002/01/10 20:11:46 $
+ * @version CVS $Revision: 1.7 $ $Date: 2002/01/11 16:27:53 $
*/
public class Main {
@@ -700,17 +700,21 @@
translatedLinks.put(link, translatedRelativeLink);
}
- // 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) {
- log.warn(" [broken link]--> " + filename);
- resourceUnavailable(file);
- } else {
- log.info(" [" + type + "]--> " + filename);
+ try {
+ // 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) {
+ log.warn(" [broken link]--> " + filename);
+ resourceUnavailable(file);
+ } else {
+ log.info(" [" + type + "]--> " + filename);
+ }
+ } catch (ResourceNotFoundException rnfe) {
+ this.log.warn("Could not process URI: " + deparameterizedURI);
}
return absoluteLinks;
@@ -848,11 +852,7 @@
links,
stream,
this.log);
- try {
cocoon.process(env);
- } catch (ResourceNotFoundException rnfe) {
- this.log.warn("Could not process URI: " + deparameterizedURI);
- }
return env.getContentType();
}
1.2 +24 -8
xml-cocoon2/src/java/org/apache/cocoon/matching/AbstractRegexpMatcher.java
Index: AbstractRegexpMatcher.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/AbstractRegexpMatcher.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractRegexpMatcher.java 3 Jan 2002 12:31:17 -0000 1.1
+++ AbstractRegexpMatcher.java 11 Jan 2002 16:27:53 -0000 1.2
@@ -27,7 +27,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @authos <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
- * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $
+ * @version CVS $Revision: 1.2 $ $Date: 2002/01/11 16:27:53 $
*/
public abstract class AbstractRegexpMatcher extends AbstractPreparableMatcher
implements ThreadSafe {
@@ -36,28 +36,44 @@
* Compile the pattern in a <code>org.apache.regexp.REProgram</code>.
*/
public Object preparePattern(String pattern) throws PatternException {
+ if (pattern == null)
+ {
+ throw new PatternException("null passed as a pattern", null);
+ }
+
+ if (pattern.length() == 0)
+ {
+ pattern = "^$";
+ if (getLogger().isWarnEnabled()) {
+ getLogger().warn("The empty pattern string was rewritten to '^$'"
+ + " to match for empty strings. If you intended"
+ + " to match all strings, please change your"
+ + " pattern to '.*'");
+ }
+ }
+
try {
RECompiler compiler = new RECompiler();
REProgram program = compiler.compile(pattern);
return program;
-
+
} catch (RESyntaxException rse) {
getLogger().debug("Failed to compile the pattern '" + pattern + "'",
rse);
throw new PatternException(rse.getMessage(), rse);
}
}
-
+
/**
* Match the prepared pattern against the value returned by {@link
#getMatchString(Map, Parameters)}.
*/
public Map preparedMatch(Object preparedPattern, Map objectModel, Parameters
parameters) {
-
+
RE re = new RE((REProgram)preparedPattern);
String match = getMatchString(objectModel, parameters);
-
+
if (match == null)
return null;
-
+
if(re.match(match)) {
/* Handle parenthesised subexpressions. XXX: could be faster if we count
* parens *outside* the generated code.
@@ -71,10 +87,10 @@
return map;
}
-
+
return null;
}
-
+
/**
* Get the string to test against the regular expression. To be defined
* by concrete subclasses.
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]