Skip to content

Commit c22e43a

Browse files
feat(ExceptionResolver): Check database settings to determine whether to send mail or not
1 parent 55f747a commit c22e43a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/main/java/org/wise/portal/spring/impl/WISESimpleMappingExceptionResolver.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@
3737
import org.springframework.core.env.Environment;
3838
import org.springframework.web.servlet.ModelAndView;
3939
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
40+
import org.wise.portal.dao.ObjectNotFoundException;
41+
import org.wise.portal.domain.portal.Portal;
4042
import org.wise.portal.domain.user.User;
4143
import org.wise.portal.presentation.web.controllers.ControllerUtil;
4244
import 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

Comments
 (0)