diff --git a/documentation/reference/pt-BR/properties.xml b/documentation/reference/pt-BR/properties.xml
index e4d23f7..a76c6e5 100644
--- a/documentation/reference/pt-BR/properties.xml
+++ b/documentation/reference/pt-BR/properties.xml
@@ -129,7 +129,7 @@
true
- frameworkdemoiselle.handle.application.exception
+ frameworkdemoiselle.exception.application.handle
Habilita o tratamento automático das exceções da aplicação anotadas com @ApplicationException.
@@ -138,7 +138,7 @@
true
- frameworkdemoiselle.handle.application.exception.page
+ frameworkdemoiselle.exception.default.redirect.page
Define o redirecionamento das exceções da aplicação anotadas com @ApplicationException ocorridas
diff --git a/impl/extension/jsf/pom.xml b/impl/extension/jsf/pom.xml
index 15cb1c9..dd27508 100755
--- a/impl/extension/jsf/pom.xml
+++ b/impl/extension/jsf/pom.xml
@@ -81,6 +81,12 @@
test
+ commons-httpclient
+ commons-httpclient
+ 3.1
+ test
+
+
org.glassfish.web
el-impl
provided
diff --git a/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ExceptionHandlerConfig.java b/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ExceptionHandlerConfig.java
index b335c39..0bbf933 100644
--- a/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ExceptionHandlerConfig.java
+++ b/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ExceptionHandlerConfig.java
@@ -41,22 +41,22 @@ import java.io.Serializable;
import br.gov.frameworkdemoiselle.annotation.Name;
import br.gov.frameworkdemoiselle.configuration.Configuration;
-@Configuration(prefix = "frameworkdemoiselle.handle.")
+@Configuration(prefix = "frameworkdemoiselle.exception")
public class ExceptionHandlerConfig implements Serializable {
private static final long serialVersionUID = 1L;
- @Name("application.exception")
- private boolean handleApplicationException = true;
+ @Name("application.handle")
+ private boolean applicationExceptionHandle = true;
- @Name("application.exception.page")
- private String exceptionPage = "/application_error";
+ @Name("default.redirect.page")
+ private String defaultRedirectExceptionPage = "/application_error";
- public String getExceptionPage() {
- return exceptionPage;
+ public boolean isApplicationExceptionHandle() {
+ return applicationExceptionHandle;
}
-
- public boolean isHandleApplicationException() {
- return handleApplicationException;
+
+ public String getDefaultRedirectExceptionPage() {
+ return defaultRedirectExceptionPage;
}
}
diff --git a/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ExceptionHandlerConfigCompatible.java b/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ExceptionHandlerConfigCompatible.java
new file mode 100644
index 0000000..305c545
--- /dev/null
+++ b/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ExceptionHandlerConfigCompatible.java
@@ -0,0 +1,82 @@
+/*
+ * Demoiselle Framework
+ * Copyright (C) 2010 SERPRO
+ * ----------------------------------------------------------------------------
+ * This file is part of Demoiselle Framework.
+ *
+ * Demoiselle Framework is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License version 3
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License version 3
+ * along with this program; if not, see
+ * or write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301, USA.
+ * ----------------------------------------------------------------------------
+ * Este arquivo é parte do Framework Demoiselle.
+ *
+ * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
+ * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
+ * do Software Livre (FSF).
+ *
+ * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
+ * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
+ * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
+ * para maiores detalhes.
+ *
+ * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
+ * "LICENCA.txt", junto com esse programa. Se não, acesse
+ * ou escreva para a Fundação do Software Livre (FSF) Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
+ */
+package br.gov.frameworkdemoiselle.internal.configuration;
+
+import java.io.Serializable;
+
+import org.slf4j.Logger;
+
+import br.gov.frameworkdemoiselle.annotation.Name;
+import br.gov.frameworkdemoiselle.configuration.Configuration;
+import br.gov.frameworkdemoiselle.util.Beans;
+
+@Deprecated
+@Configuration(prefix = "frameworkdemoiselle.handle")
+public class ExceptionHandlerConfigCompatible implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Deprecated
+ @Name("application.exception")
+ private boolean handleApplicationException = true;
+
+ @Deprecated
+ @Name("application.exception.page")
+ private String exceptionPage = "/application_error";
+
+ @Deprecated
+ public boolean isHandleApplicationException() {
+ Logger logger = Beans.getReference(Logger.class);
+ logger.warn("A propriedade frameworkdemoiselle.handle.application.exception="
+ + handleApplicationException
+ + " não será suportada nas próximas versões do framework. Para evitar futuros problemas atualize a propriedade para frameworkdemoiselle.exception.application.handle="
+ + handleApplicationException);
+
+ return handleApplicationException;
+ }
+
+ @Deprecated
+ public String getExceptionPage() {
+ Logger logger = Beans.getReference(Logger.class);
+ logger.warn("A propriedade frameworkdemoiselle.handle.application.exception.page="
+ + exceptionPage
+ + " não será suportada nas próximas versões do framework. Para evitar futuros problemas atualize a propriedade para frameworkdemoiselle.exception.default.redirect.page="
+ + exceptionPage);
+
+ return exceptionPage;
+ }
+}
diff --git a/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ApplicationExceptionHandler.java b/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ApplicationExceptionHandler.java
index 24e9416..29b0100 100644
--- a/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ApplicationExceptionHandler.java
+++ b/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ApplicationExceptionHandler.java
@@ -43,7 +43,10 @@ import javax.faces.context.ExceptionHandler;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseId;
+import org.slf4j.Logger;
+
import br.gov.frameworkdemoiselle.DemoiselleException;
+import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfigCompatible;
import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfig;
import br.gov.frameworkdemoiselle.util.Beans;
import br.gov.frameworkdemoiselle.util.Exceptions;
@@ -58,19 +61,69 @@ public class ApplicationExceptionHandler extends AbstractExceptionHandler {
}
protected boolean handleException(final Throwable cause, FacesContext facesContext) {
+ // Apenas para manter compatibilidade entre 2.3.x e 2.4.0-RCx
+ ExceptionHandlerConfigCompatible compatibleConfig = Beans.getReference(ExceptionHandlerConfigCompatible.class);
+ // Usuário está utilizando pelo menos uma das propriedades com a forma depreciada de forma explícita
+ if (!(compatibleConfig.getExceptionPage().equals("/application_error") && compatibleConfig.isHandleApplicationException())) {
+ Logger logger = Beans.getReference(Logger.class);
+ logger.warn("As propriedades frameworkdemoiselle.handle.application.exception e"
+ + " frameworkdemoiselle.handle.application.exception.page"
+ + " não serão suportadas nas próximas versões do framework."
+ + " Para evitar futuros problemas atualize as propriedades para"
+ + " frameworkdemoiselle.exception.application.handle e"
+ + " frameworkdemoiselle.exception.default.redirect.page, respectivamente.");
+ return handleExceptionCompatibleConfiguration(compatibleConfig, cause, facesContext);
+ }
+
+ boolean handled = false;
ExceptionHandlerConfig config = Beans.getReference(ExceptionHandlerConfig.class);
+
+ if (config.isApplicationExceptionHandle() && Exceptions.isApplicationException(cause)) {
+
+ if (isRendering(facesContext)) {
+ handled = handlingDuringRenderResponse(cause, config);
+ } else {
+ Faces.addMessage(cause);
+ handled = true;
+ }
+ }
+
+ return handled;
+ }
+
+ @Deprecated
+ private boolean handleExceptionCompatibleConfiguration(ExceptionHandlerConfigCompatible config, final Throwable cause,
+ FacesContext facesContext) {
boolean handled = false;
if (config.isHandleApplicationException() && Exceptions.isApplicationException(cause)) {
if (isRendering(facesContext)) {
- handled = handlingDuringRenderResponse(cause, config);
+ handled = handlingDuringRenderResponseCompatible(cause, config);
} else {
Faces.addMessage(cause);
handled = true;
}
}
+ return handled;
+ }
+ @Deprecated
+ private boolean handlingDuringRenderResponseCompatible(final Throwable cause, final ExceptionHandlerConfigCompatible config) {
+ boolean handled = false;
+ try {
+ Map map = new HashMap();
+ map.put("exception", cause.getMessage());
+ Redirector.redirect(config.getExceptionPage(), map);
+ handled = true;
+ } catch (PageNotFoundException ex) {
+ // TODO Colocar a mensagem no bundle
+ throw new DemoiselleException(
+ "A tela de exibição de erros: \""
+ + ex.getViewId()
+ + "\" não foi encontrada. Caso o seu projeto possua outra, defina no arquivo de configuração a chave \""
+ + "frameworkdemoiselle.handle.application.exception.page" + "\"", ex);
+ }
return handled;
}
@@ -82,7 +135,7 @@ public class ApplicationExceptionHandler extends AbstractExceptionHandler {
* In render response phase an exception interrupt the renderization. So this method will redirect the renderingo to
* an page configured in demoiselle.properties
*
- * @see ExceptionHandlerConfig
+ * @see ExceptionHandlerConfigCompatible
* @param cause
* @param config
* @return
@@ -92,7 +145,7 @@ public class ApplicationExceptionHandler extends AbstractExceptionHandler {
try {
Map map = new HashMap();
map.put("exception", cause.getMessage());
- Redirector.redirect(config.getExceptionPage(), map);
+ Redirector.redirect(config.getDefaultRedirectExceptionPage(), map);
handled = true;
} catch (PageNotFoundException ex) {
// TODO Colocar a mensagem no bundle
--
libgit2 0.21.2