3737import org .springframework .core .env .Environment ;
3838import org .springframework .web .servlet .ModelAndView ;
3939import org .springframework .web .servlet .handler .SimpleMappingExceptionResolver ;
40+ import org .wise .portal .dao .ObjectNotFoundException ;
41+ import org .wise .portal .domain .portal .Portal ;
4042import org .wise .portal .domain .user .User ;
4143import org .wise .portal .presentation .web .controllers .ControllerUtil ;
4244import org .wise .portal .service .mail .IMailFacade ;
45+ import org .wise .portal .service .portal .PortalService ;
4346
4447/**
4548 * Resolves Exceptions by gathering the following information and
@@ -59,6 +62,9 @@ public class WISESimpleMappingExceptionResolver extends SimpleMappingExceptionRe
5962 @ Autowired
6063 private Environment appProperties ;
6164
65+ @ Autowired
66+ private PortalService portalService ;
67+
6268 private static final String HANDLE_EXCEPTION_PROPERTY_KEY = "handle_exception" ;
6369
6470 private static final String HANDLE_EXCEPTION_MAIL_SUBJECT = "WISE Exception Report" ;
@@ -67,8 +73,13 @@ public class WISESimpleMappingExceptionResolver extends SimpleMappingExceptionRe
6773 public ModelAndView resolveException (HttpServletRequest request , HttpServletResponse response ,
6874 Object handler , Exception exception ) {
6975 exception .printStackTrace ();
70- String sendEmailOnExceptionStr = appProperties .getProperty ("send_email_on_exception" );
71- boolean sendEmailOnException = sendEmailOnExceptionStr .equalsIgnoreCase ("true" );
76+ boolean sendEmailOnException = false ;
77+ try {
78+ Portal portal = portalService .getById (1 );
79+ sendEmailOnException = portal .isSendMailOnException ();
80+ } catch (ObjectNotFoundException e ) {
81+ e .printStackTrace ();
82+ }
7283
7384 if (sendEmailOnException ) {
7485 String portalName = appProperties .getProperty ("wise.name" );
0 commit comments