You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by rm...@apache.org on 2011/04/19 13:41:31 UTC
svn commit: r1095051 - in
/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher:
Dispatcher.java context/RequestContext.java
Author: rmatthews
Date: Tue Apr 19 11:41:31 2011
New Revision: 1095051
URL: http://svn.apache.org/viewvc?rev=1095051&view=rev
Log:
Including error reference number on error messages so problem reported by user can be linked to a particular message and debug details.
Modified:
incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java?rev=1095051&r1=1095050&r2=1095051&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java (original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java Tue Apr 19 11:41:31 2011
@@ -128,13 +128,15 @@ public class Dispatcher {
}
} catch (Throwable e) {
+ String errorRef = Long.toString(System.currentTimeMillis(), 36).toUpperCase();
+
+ LOG.info("error " + errorRef);
LOG.debug(e.getMessage(), e);
- LOG.info("testing");
DebugString error = new DebugString();
- generateErrorPage(e, context, error);
+ generateErrorPage(e, context, error, errorRef);
String message = "failed while processing " + servletPath;
- LOG.error(message + "\n" + error + "\n" + message);
+ LOG.error(message + " (#" + errorRef + ")\n" + error + "\n" + message);
PersistenceSession checkSession = IsisContext.getPersistenceSession();
IsisTransactionManager transactionManager = checkSession.getTransactionManager();
@@ -152,7 +154,7 @@ public class Dispatcher {
// TODO allow these values to be got configuration
// context.raiseError(403);
// context.setRequestPath("/error/security_403.shtml");
- IsisContext.getMessageBroker().addWarning("You did not have the right permissions to perform this.....");
+ IsisContext.getMessageBroker().addWarning("You did not have the right permissions to perform this (#" + errorRef + ")");
context.setRequestPath("/index.shtml");
try {
processTheView(context);
@@ -163,7 +165,7 @@ public class Dispatcher {
// TODO allow these values to be got configuration
// context.raiseError(500);
// context.setRequestPath("/error/server_500.shtml");
- IsisContext.getMessageBroker().addWarning("There was a error while processing this request...."); // TODO include the reference code so it can be looked up
+ IsisContext.getMessageBroker().addWarning("There was a error while processing this request (#" + errorRef + ")");
context.setRequestPath("/index.shtml");
try {
processTheView(context);
@@ -198,7 +200,7 @@ public class Dispatcher {
}
- private void generateErrorPage(Throwable exception, RequestContext requestContext, DebugString error) {
+ private void generateErrorPage(Throwable exception, RequestContext requestContext, DebugString error, String errorRef) {
if (IsisContext.getCurrentTransaction() != null) {
List<String> messages = IsisContext.getMessageBroker().getMessages();
for (String message : messages) {
@@ -217,10 +219,9 @@ public class Dispatcher {
PrintWriter writer;
try {
- String ref = Long.toString(System.currentTimeMillis(), 36).toUpperCase();
- requestContext.addVariable("_error-ref", ref, Scope.INTERACTION);
+ requestContext.addVariable("_error-ref", errorRef, Scope.INTERACTION);
String directory = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.error-snapshots", ".");
- writer = new PrintWriter(new File(directory, "error_" + ref + ".html"));
+ writer = new PrintWriter(new File(directory, "error_" + errorRef + ".html"));
writeErrorContent(requestContext, exception, new DebugString(), writer, true);
} catch (FileNotFoundException e) {
LOG.error("Failed to archive error page", e);
Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java?rev=1095051&r1=1095050&r2=1095051&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java (original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java Tue Apr 19 11:41:31 2011
@@ -57,7 +57,7 @@ public abstract class RequestContext {
ON, OFF, PAGE
}
- private enum DebugLevel {
+ private enum DebugMode {
OFF, ON, SYSADMIN_ONLY
}
@@ -88,7 +88,7 @@ public abstract class RequestContext {
public static final String BACK_TO = "_back_to";
private static final Map<String, Object> globalVariables = new HashMap<String, Object>();
private static final Scope[] SCOPES = new Scope[] { Scope.REQUEST, Scope.INTERACTION, Scope.SESSION, Scope.GLOBAL };
- private static DebugLevel debugLevel = null;
+ private static DebugMode debugMode = null;
private ObjectMapping objectMapping;
private VersionMapping versionMapping;
@@ -757,16 +757,17 @@ public abstract class RequestContext {
}
public boolean isDebugDisabled() {
- if (debugLevel == null) {
- String property = System.getProperties().getProperty("debug");
+ // TODO set up mode on startup
+ if (debugMode == null) {
+ String property = System.getProperties().getProperty("debug-mode");
if (property != null) {
- debugLevel = DebugLevel.valueOf(property);
+ debugMode = DebugMode.valueOf(property);
}
- if (debugLevel == null) {
- debugLevel = DebugLevel.OFF;
+ if (debugMode == null) {
+ debugMode = DebugMode.ON;
}
}
- boolean allowDebug = debugLevel == DebugLevel.ON || (debugLevel == DebugLevel.SYSADMIN_ONLY && getSession().getRoles().contains("sysadmin"));
+ boolean allowDebug = debugMode == DebugMode.ON || (debugMode == DebugMode.SYSADMIN_ONLY && getSession().getRoles().contains("sysadmin"));
return !allowDebug;
}