use of org.mifos.rest.approval.service.RESTCallInterruptException in project head by mifos.
the class ApprovalServiceTest method createApprovalMethod.
private void createApprovalMethod() throws Exception {
Class[] c = new Class[1];
c[0] = String.class;
MethodArgHolder args = new MethodArgHolder(c, new Object[1], new String[1]);
ApprovalMethod am = new ApprovalMethod("updateCall", StubRESTController.class, args);
try {
approvalService.create(am);
fail("should have thrown interrupt exception");
} catch (RESTCallInterruptException e) {
}
}
use of org.mifos.rest.approval.service.RESTCallInterruptException in project head by mifos.
the class ApprovalServiceTest method createFailureApprovalMethod.
private void createFailureApprovalMethod() throws Exception {
Class[] c = new Class[1];
c[0] = String.class;
MethodArgHolder args = new MethodArgHolder(c, new Object[1], new String[1]);
ApprovalMethod am = new ApprovalMethod("failCall", StubRESTController.class, args);
try {
approvalService.create(am);
fail("should have thrown interrupt exception");
} catch (RESTCallInterruptException e) {
}
}
use of org.mifos.rest.approval.service.RESTCallInterruptException in project head by mifos.
the class AspectJApprovalInterceptorTest method testRESTCallExecution.
@Test
@Transactional
public void testRESTCallExecution() throws Exception {
Assert.assertEquals(0, approvalService.getAllWaiting().size());
try {
stubRestController.createCall("HELLO");
Assert.fail("should throw interrupt exception");
} catch (RESTCallInterruptException e) {
}
Assert.assertEquals(1, approvalService.getAllWaiting().size());
RESTApprovalEntity entity = approvalService.getAllWaiting().get(0);
Assert.assertEquals("arg", entity.getApprovalMethod().getArgsHolder().getNames()[0]);
}
use of org.mifos.rest.approval.service.RESTCallInterruptException in project head by mifos.
the class UncaughtExceptionHandler method doResolveException.
@Override
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
ModelAndView modelAndView = checkForAccessDenied(ex, request);
if (modelAndView == null) {
modelAndView = checkForPageJndiException(ex, request);
}
if (modelAndView == null) {
modelAndView = checkForPageExpiredException(ex, request);
}
if (modelAndView == null) {
modelAndView = checkForMaxUploadSizeExceededException(ex, request);
}
if (request.getRequestURI().endsWith("json")) {
if (modelAndView == null && ex instanceof RESTCallInterruptException) {
// should move to explicit @ExceptionHandler(RESTCallInterruptException) controller method
modelAndView = new ModelAndView();
modelAndView.addObject("status", "interrupt");
modelAndView.addObject("approvalId", ((RESTCallInterruptException) ex).getApprovalId());
modelAndView.addObject("cause", "The call has been interrupt for approval");
return modelAndView;
}
if (modelAndView == null || ex instanceof AccessDeniedException) {
// should move to explicit @ExceptionHandler(Exception) controller method
modelAndView = new ModelAndView();
modelAndView.addObject("status", "error");
modelAndView.addObject("cause", ex.getMessage());
logger.error("REST API exception : URI '" + request.getRequestURI() + "'", ex);
return modelAndView;
}
}
if (modelAndView == null) {
modelAndView = super.doResolveException(request, response, handler, ex);
}
if (modelAndView != null && !"HEAD".equals(request.getMethod())) {
String requestUri = request.getRequestURI();
logger.error("Uncaught exception while accessing '" + requestUri + "'", ex);
modelAndView.addObject("uncaughtException", ex);
modelAndView.addObject("requestUri", requestUri);
if (ex != null) {
Writer result = new StringWriter();
ex.printStackTrace(new PrintWriter(result));
modelAndView.addObject("stackString", result.toString());
}
}
return modelAndView;
}
Aggregations