@Test public void hodAuthenticationFailedException() { assertNotNull(viewController.hodAuthenticationFailedException(mock(HodAuthenticationFailedException.class), new MockHttpServletRequest(), new MockHttpServletResponse())); verify(controllerUtils).buildErrorModelAndView(any(ErrorModelAndViewInfo.class)); }
@SuppressWarnings("TypeMayBeWeakened") @ExceptionHandler public ModelAndView hodAuthenticationFailedException( final HodAuthenticationFailedException e, final HttpServletRequest request, final HttpServletResponse response ) { response.reset(); response.setStatus(HttpServletResponse.SC_FORBIDDEN); log.error("HodAuthenticationFailedException thrown while viewing document", e); return controllerUtils.buildErrorModelAndView(new ErrorModelAndViewInfo.Builder() .setRequest(request) .setMainMessageCode(HOD_ERROR_MESSAGE_CODE_MAIN) .setSubMessageCode(HOD_ERROR_MESSAGE_CODE_TOKEN_EXPIRED) .setStatusCode(HttpServletResponse.SC_FORBIDDEN) .setAuthError(true) .build()); }
HodViewController extends ViewController<HodViewRequest, ResourceName, HodErrorException> { @SuppressWarnings("TypeMayBeWeakened") @ExceptionHandler public ModelAndView hodAuthenticationFailedException( final HodAuthenticationFailedException e, final HttpServletRequest request, final HttpServletResponse response ) { response.reset(); response.setStatus(HttpServletResponse.SC_FORBIDDEN); log.error("HodAuthenticationFailedException thrown while viewing document", e); return controllerUtils.buildErrorModelAndView(new ErrorModelAndViewInfo.Builder() .setRequest(request) .setMainMessageCode(HOD_ERROR_MESSAGE_CODE_MAIN) .setSubMessageCode(HOD_ERROR_MESSAGE_CODE_TOKEN_EXPIRED) .setStatusCode(HttpServletResponse.SC_FORBIDDEN) .setAuthError(true) .build()); } }
HodViewController extends ViewController<HodViewRequest, ResourceName, HodErrorException> { @SuppressWarnings("TypeMayBeWeakened") @ExceptionHandler public ModelAndView hodAuthenticationFailedException( final HodAuthenticationFailedException e, final HttpServletRequest request, final HttpServletResponse response ) { response.reset(); response.setStatus(HttpServletResponse.SC_FORBIDDEN); log.error("HodAuthenticationFailedException thrown while viewing document", e); return controllerUtils.buildErrorModelAndView(new ErrorModelAndViewInfo.Builder() .setRequest(request) .setMainMessageCode(HOD_ERROR_MESSAGE_CODE_MAIN) .setSubMessageCode(HOD_ERROR_MESSAGE_CODE_TOKEN_EXPIRED) .setStatusCode(HttpServletResponse.SC_FORBIDDEN) .setAuthError(true) .build()); } @SuppressWarnings("TypeMayBeWeakened") @Autowired  HodViewController(final HodViewServerService viewServerService,
                             final ObjectFactory<HodViewRequestBuilder> viewRequestBuilderFactory,
                             final ControllerUtils controllerUtils); }
HodViewController extends ViewController<HodViewRequest, ResourceName, HodErrorException> { @SuppressWarnings("TypeMayBeWeakened") @ExceptionHandler public ModelAndView hodAuthenticationFailedException( final HodAuthenticationFailedException e, final HttpServletRequest request, final HttpServletResponse response ) { response.reset(); response.setStatus(HttpServletResponse.SC_FORBIDDEN); log.error("HodAuthenticationFailedException thrown while viewing document", e); return controllerUtils.buildErrorModelAndView(new ErrorModelAndViewInfo.Builder() .setRequest(request) .setMainMessageCode(HOD_ERROR_MESSAGE_CODE_MAIN) .setSubMessageCode(HOD_ERROR_MESSAGE_CODE_TOKEN_EXPIRED) .setStatusCode(HttpServletResponse.SC_FORBIDDEN) .setAuthError(true) .build()); } @SuppressWarnings("TypeMayBeWeakened") @Autowired  HodViewController(final HodViewServerService viewServerService,
                             final ObjectFactory<HodViewRequestBuilder> viewRequestBuilderFactory,
                             final ControllerUtils controllerUtils); @SuppressWarnings("TypeMayBeWeakened") @ExceptionHandler ModelAndView handleHodErrorException(
            final HodErrorException e,
            final HttpServletRequest request,
            final HttpServletResponse response
    ); @SuppressWarnings("TypeMayBeWeakened") @ExceptionHandler ModelAndView hodAuthenticationFailedException(
            final HodAuthenticationFailedException e,
            final HttpServletRequest request,
            final HttpServletResponse response
    ); @SuppressWarnings("TypeMayBeWeakened") @ExceptionHandler @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) ModelAndView handleGeneralException(
            final Exception e,
            final HttpServletRequest request,
            final ServletResponse response
    ); }
HodViewController extends ViewController<HodViewRequest, ResourceName, HodErrorException> { @SuppressWarnings("TypeMayBeWeakened") @ExceptionHandler public ModelAndView hodAuthenticationFailedException( final HodAuthenticationFailedException e, final HttpServletRequest request, final HttpServletResponse response ) { response.reset(); response.setStatus(HttpServletResponse.SC_FORBIDDEN); log.error("HodAuthenticationFailedException thrown while viewing document", e); return controllerUtils.buildErrorModelAndView(new ErrorModelAndViewInfo.Builder() .setRequest(request) .setMainMessageCode(HOD_ERROR_MESSAGE_CODE_MAIN) .setSubMessageCode(HOD_ERROR_MESSAGE_CODE_TOKEN_EXPIRED) .setStatusCode(HttpServletResponse.SC_FORBIDDEN) .setAuthError(true) .build()); } @SuppressWarnings("TypeMayBeWeakened") @Autowired  HodViewController(final HodViewServerService viewServerService,
                             final ObjectFactory<HodViewRequestBuilder> viewRequestBuilderFactory,
                             final ControllerUtils controllerUtils); @SuppressWarnings("TypeMayBeWeakened") @ExceptionHandler ModelAndView handleHodErrorException(
            final HodErrorException e,
            final HttpServletRequest request,
            final HttpServletResponse response
    ); @SuppressWarnings("TypeMayBeWeakened") @ExceptionHandler ModelAndView hodAuthenticationFailedException(
            final HodAuthenticationFailedException e,
            final HttpServletRequest request,
            final HttpServletResponse response
    ); @SuppressWarnings("TypeMayBeWeakened") @ExceptionHandler @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) ModelAndView handleGeneralException(
            final Exception e,
            final HttpServletRequest request,
            final ServletResponse response
    );  }