You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by rg...@apache.org on 2006/12/16 01:39:59 UTC
svn commit: r487738 - in
/forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core:
Controller.java exception/ProcessingException.java matcher/REMatcher.java
reader/FileReader.java
Author: rgardler
Date: Fri Dec 15 16:39:59 2006
New Revision: 487738
URL: http://svn.apache.org/viewvc?view=rev&rev=487738
Log:
Improved logging
Modified:
forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java
forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/exception/ProcessingException.java
forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/matcher/REMatcher.java
forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/reader/FileReader.java
Modified: forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java?view=diff&rev=487738&r1=487737&r2=487738
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java (original)
+++ forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java Fri Dec 15 16:39:59 2006
@@ -162,6 +162,9 @@
final AbstractSourceDocument sourceDocs = this
.loadAllSourceDocuments(requestURI, sourceLocs);
+ if (sourceDocs == null) {
+ throw new ProcessingException("Unable to get a source document for request " + requestURI);
+ }
final InternalDocument internalDoc = this.processInputPlugins(
requestURI, sourceDocs);
this.internalDocsCache.put(requestURI, internalDoc);
@@ -290,6 +293,7 @@
if (doc == null) {
for (AbstractSourceNode node : location.getSourceNodes()) {
IReader reader = getReader(node);
+ log.debug("Reader to use is " + reader.toString());
doc = reader.read(this, requestURI, node, location.getMatcher());
if (doc != null) {
addToSourceDocCache(requestURI, doc);
@@ -363,7 +367,7 @@
.get(requestURI);
if (possibleLocs == null || possibleLocs.size() == 0)
throw new LocationmapException(
- "Unable to find a source location for " + requestURI);
+ "Unable to find any potential source locationa for " + requestURI + ". This means that there is no location node in your locationmap that matches this request.");
List<LocationNode> result = new ArrayList<LocationNode>();
Boolean isValid = false;
@@ -376,7 +380,6 @@
loc = sourceLocs.next();
if (sourceExists(requestURI, loc)) {
result.add(loc);
- log.debug("Found valid location");
}
}
if (isValid)
@@ -483,7 +486,7 @@
} catch (final Exception e) {
throw new ProcessingException(
"Unable to create the output documents for "
- + requestURI + " because " + e.getMessage(), e);
+ + requestURI, e);
}
return output;
}
@@ -502,7 +505,7 @@
} catch (final Exception e) {
throw new ProcessingException(
"Unable to create the output documents for "
- + requestURI + " because " + e.getMessage(), e);
+ + requestURI, e);
}
StringBuffer sb = new StringBuffer();
sb.append("<forrestPipeline request=\"");
Modified: forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/exception/ProcessingException.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/exception/ProcessingException.java?view=diff&rev=487738&r1=487737&r2=487738
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/exception/ProcessingException.java (original)
+++ forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/exception/ProcessingException.java Fri Dec 15 16:39:59 2006
@@ -35,7 +35,11 @@
public String getMessage() {
String msg = super.getMessage();
if (getCause() != null) {
+ if (getCause().getMessage() != null) {
msg = msg + " caused by " + getCause().getMessage();
+ } else {
+ msg = msg + " caused by " + getCause().getClass().getName();
+ }
}
return msg;
}
Modified: forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/matcher/REMatcher.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/matcher/REMatcher.java?view=diff&rev=487738&r1=487737&r2=487738
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/matcher/REMatcher.java (original)
+++ forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/matcher/REMatcher.java Fri Dec 15 16:39:59 2006
@@ -1,12 +1,10 @@
package org.apache.forrest.core.matcher;
-import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import org.apache.forrest.core.exception.ProcessingException;
-import org.apache.forrest.core.locationMap.AbstractSourceNode;
import org.apache.log4j.Logger;
import com.sun.org.apache.regexp.internal.RE;
@@ -61,7 +59,7 @@
+ sourceSSP);
} else {
throw new ProcessingException(
- "Unable to extract variable values from requestURI");
+ "Unable to extract variable values from '" + urlString + "' using Regular Expression: " + getPattern());
}
URI newURI;
Modified: forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/reader/FileReader.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/reader/FileReader.java?view=diff&rev=487738&r1=487737&r2=487738
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/reader/FileReader.java (original)
+++ forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/reader/FileReader.java Fri Dec 15 16:39:59 2006
@@ -27,8 +27,8 @@
import org.apache.forrest.core.document.DocumentFactory;
import org.apache.forrest.core.exception.SourceException;
import org.apache.forrest.core.locationMap.AbstractSourceNode;
-import org.apache.forrest.core.locationMap.LocationNode;
import org.apache.forrest.core.matcher.AbstractMatcher;
+import org.apache.log4j.Logger;
/**
* A File reader reads a resource using the file protocol, i.e. it will read
@@ -36,6 +36,7 @@
*
*/
public class FileReader extends AbstractReader {
+ Logger log = Logger.getLogger(FileReader.class);
/*
* (non-Javadoc)
@@ -49,9 +50,16 @@
URL resolvedURL = sourceNode.resolveURL(matcher, requestURI);
final InputStream is = new FileInputStream(new File(resolvedURL.toURI()));
result = DocumentFactory.getSourceDocumentFor(requestURI, is);
+ if (result == null) {
+ log.debug("No source document exists at " + resolvedURL.toExternalForm());
+ } else {
+ log.debug("Read a source document from " + resolvedURL.toExternalForm());
+ }
} catch (final Exception e) {
+ String msg = "Unable to resolve the source URL";
+ log.debug(msg + ": " + e.getMessage());
if (sourceNode.isRequired())
- throw new SourceException("Source URL is invalid", e);
+ throw new SourceException(msg, e);
}
return result;
}