r547 - in trunk: simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/credentials simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages simexplorer-is-web/src/main/webapp
Author: glandais Date: 2008-01-25 17:46:25 +0000 (Fri, 25 Jan 2008) New Revision: 547 Modified: trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/ContentType.java trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/credentials/CredentialManager.java trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java trunk/simexplorer-is-web/src/main/webapp/ExceptionReport.tml Log: Exception page Modified: trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/ContentType.java =================================================================== --- trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/ContentType.java 2008-01-25 16:48:09 UTC (rev 546) +++ trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/ContentType.java 2008-01-25 17:46:25 UTC (rev 547) @@ -43,6 +43,7 @@ * @param is * Input stream * @return Indexable text + * @throws Exception */ public abstract Reader renderToText(InputStream is) throws Exception; Modified: trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/credentials/CredentialManager.java =================================================================== --- trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/credentials/CredentialManager.java 2008-01-25 16:48:09 UTC (rev 546) +++ trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/credentials/CredentialManager.java 2008-01-25 17:46:25 UTC (rev 547) @@ -17,8 +17,6 @@ * ##% */ package fr.cemagref.simexplorer.is.security.credentials; -import java.util.List; - import javax.ejb.Local; import fr.cemagref.simexplorer.is.security.entities.Permission; Modified: trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java =================================================================== --- trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java 2008-01-25 16:48:09 UTC (rev 546) +++ trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java 2008-01-25 17:46:25 UTC (rev 547) @@ -22,6 +22,7 @@ import javax.ejb.Stateless; import javax.persistence.EntityManager; +import javax.persistence.NoResultException; import javax.persistence.PersistenceContext; import javax.persistence.Query; @@ -40,7 +41,7 @@ Object o; try { o = query.getSingleResult(); - } catch (RuntimeException e) { + } catch (NoResultException e) { o = null; } return o; @@ -50,7 +51,7 @@ Object o; try { o = em.find(clazz, arg); - } catch (RuntimeException e) { + } catch (NoResultException e) { o = null; } return o; Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java =================================================================== --- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java 2008-01-25 16:48:09 UTC (rev 546) +++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java 2008-01-25 17:46:25 UTC (rev 547) @@ -18,27 +18,94 @@ package fr.cemagref.simexplorer.is.ui.web.pages; import java.io.FileNotFoundException; +import java.util.List; +import org.apache.tapestry.ioc.annotations.Inject; +import org.apache.tapestry.ioc.services.ExceptionAnalysis; +import org.apache.tapestry.ioc.services.ExceptionAnalyzer; +import org.apache.tapestry.ioc.services.ExceptionInfo; import org.apache.tapestry.services.ExceptionReporter; -public class ExceptionReport extends - org.apache.tapestry.corelib.pages.ExceptionReport implements - ExceptionReporter { +import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; - private boolean unknown; +public class ExceptionReport implements ExceptionReporter { + + private boolean unknown; + + private SimExplorerWebException exception; + + private List<ExceptionInfo> stack; + private ExceptionInfo info; + + private String propertyName; + + private String frame; + + @Inject + private ExceptionAnalyzer analyzer; + + public String getWindowTitle() { + return "Error"; + } - @Override public void reportException(Throwable exception) { - if (exception instanceof FileNotFoundException) { - unknown = false; + if (exception instanceof SimExplorerWebException) { + // unknown = false; + // FIXME debug mode + unknown = true; + this.exception = (SimExplorerWebException) exception; } else { unknown = true; - super.reportException(exception); + ExceptionAnalysis analysis = analyzer.analyze(exception); + stack = analysis.getExceptionInfos(); } } + public String getErrorMessage() { + return "Error"; + } + + public boolean getShowPropertyList() { + // True if either is non-empty + return !(info.getPropertyNames().isEmpty() && info.getStackTrace() + .isEmpty()); + } + + public Object getPropertyValue() + { + return info.getProperty(propertyName); + } + + public List<ExceptionInfo> getStack() { + return stack; + } + + public ExceptionInfo getInfo() { + return info; + } + + public void setInfo(ExceptionInfo info) { + this.info = info; + } + + public String getPropertyName() { + return propertyName; + } + + public void setPropertyName(String propertyName) { + this.propertyName = propertyName; + } + public boolean isUnknown() { return unknown; } + public String getFrame() { + return frame; + } + + public void setFrame(String frame) { + this.frame = frame; + } + } Modified: trunk/simexplorer-is-web/src/main/webapp/ExceptionReport.tml =================================================================== --- trunk/simexplorer-is-web/src/main/webapp/ExceptionReport.tml 2008-01-25 16:48:09 UTC (rev 546) +++ trunk/simexplorer-is-web/src/main/webapp/ExceptionReport.tml 2008-01-25 17:46:25 UTC (rev 547) @@ -1,50 +1,39 @@ -<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> -<head> -<title>Application Exception</title> -</head> -<body> -<h1 class="t-exception-report">An unexpected application exception -has occurred.</h1> +<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" + title="${windowtitle}"> + ${errormessage} -<div class="t-exception-report"> -<ul> - <t:loop source="stack" value="info"> - <li><span class="t-exception-class-name">${info.className}</span> + <t:if test="unknown"> - <t:if test="info.message"> - <div class="t-exception-message">${info.message}</div> - </t:if> <t:if test="showPropertyList"> - <dl> - <t:loop source="info.propertyNames" value="propertyName"> - <dt>${propertyName}</dt> - <dd><t:renderobject object="propertyValue" /></dd> - </t:loop> - <t:if test="info.stackTrace"> - <dt>Stack trace</dt> - <dd> - <ul class="t-stack-trace"> - <t:loop source="info.stackTrace" value="frame"> - <li>${frame}</li> + <div class="t-exception-report"> + <ul> + <t:loop source="stack" value="info"> + <li><span class="t-exception-class-name">${info.className}</span> + + <t:if test="info.message"> + <div class="t-exception-message">${info.message}</div> + </t:if> <t:if test="showPropertyList"> + <dl> + <t:loop source="info.propertyNames" value="propertyName"> + <dt>${propertyName}</dt> + <dd><t:renderobject object="propertyValue" /></dd> </t:loop> - </ul> - </dd> - </t:if> - </dl> - </t:if></li> - </t:loop> -</ul> -</div> -<div class="t-env-data"> -<h2>Request</h2> -<t:renderobject object="request" /> <t:if test="hasSession"> - <h2>Session</h2> - <dl> - <t:loop source="session.attributeNames" value="attributeName"> - <dt>${attributeName}</dt> - <dd><t:renderobject object="attributeValue" /></dd> - </t:loop> - </dl> -</t:if></div> -</body> -</html> + <t:if test="info.stackTrace"> + <dt>Stack trace</dt> + <dd> + <ul class="t-stack-trace"> + <t:loop source="info.stackTrace" value="frame"> + <li>${frame}</li> + </t:loop> + </ul> + </dd> + </t:if> + </dl> + </t:if></li> + </t:loop> + </ul> + </div> + + </t:if> + +</t:layout>
participants (1)
-
glandais@users.labs.libre-entreprise.org