@Test public void shouldRemoveFlashIncludedParameters() throws Exception { when(session.getAttribute(FLASH_INCLUDED_PARAMETERS)).thenReturn(singletonMap("Abc", 1002)); interceptor.intercept(stack, null, null); verify(session).removeAttribute(FLASH_INCLUDED_PARAMETERS); }
public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException { @SuppressWarnings("unchecked") Map<String, Object> parameters = (Map<String, Object>) session.getAttribute(FLASH_INCLUDED_PARAMETERS); if (parameters != null) { session.removeAttribute(FLASH_INCLUDED_PARAMETERS); for (Entry<String, Object> parameter : parameters.entrySet()) { result.include(parameter.getKey(), parameter.getValue()); } } response.addRedirectListener(new RedirectListener() { public void beforeRedirect() { Map<String, Object> included = result.included(); if (!included.isEmpty()) { try { session.setAttribute(FLASH_INCLUDED_PARAMETERS, included); } catch (IllegalStateException e) { LOGGER.info("HTTP Session was invalidated. It is not possible to include " + "Result parameters on Flash Scope"); } } } }); stack.next(method, resourceInstance); }
FlashInterceptor implements Interceptor { public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException { @SuppressWarnings("unchecked") Map<String, Object> parameters = (Map<String, Object>) session.getAttribute(FLASH_INCLUDED_PARAMETERS); if (parameters != null) { session.removeAttribute(FLASH_INCLUDED_PARAMETERS); for (Entry<String, Object> parameter : parameters.entrySet()) { result.include(parameter.getKey(), parameter.getValue()); } } response.addRedirectListener(new RedirectListener() { public void beforeRedirect() { Map<String, Object> included = result.included(); if (!included.isEmpty()) { try { session.setAttribute(FLASH_INCLUDED_PARAMETERS, included); } catch (IllegalStateException e) { LOGGER.info("HTTP Session was invalidated. It is not possible to include " + "Result parameters on Flash Scope"); } } } }); stack.next(method, resourceInstance); } }
FlashInterceptor implements Interceptor { public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException { @SuppressWarnings("unchecked") Map<String, Object> parameters = (Map<String, Object>) session.getAttribute(FLASH_INCLUDED_PARAMETERS); if (parameters != null) { session.removeAttribute(FLASH_INCLUDED_PARAMETERS); for (Entry<String, Object> parameter : parameters.entrySet()) { result.include(parameter.getKey(), parameter.getValue()); } } response.addRedirectListener(new RedirectListener() { public void beforeRedirect() { Map<String, Object> included = result.included(); if (!included.isEmpty()) { try { session.setAttribute(FLASH_INCLUDED_PARAMETERS, included); } catch (IllegalStateException e) { LOGGER.info("HTTP Session was invalidated. It is not possible to include " + "Result parameters on Flash Scope"); } } } }); stack.next(method, resourceInstance); } FlashInterceptor(HttpSession session, Result result, MutableResponse response); }
FlashInterceptor implements Interceptor { public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException { @SuppressWarnings("unchecked") Map<String, Object> parameters = (Map<String, Object>) session.getAttribute(FLASH_INCLUDED_PARAMETERS); if (parameters != null) { session.removeAttribute(FLASH_INCLUDED_PARAMETERS); for (Entry<String, Object> parameter : parameters.entrySet()) { result.include(parameter.getKey(), parameter.getValue()); } } response.addRedirectListener(new RedirectListener() { public void beforeRedirect() { Map<String, Object> included = result.included(); if (!included.isEmpty()) { try { session.setAttribute(FLASH_INCLUDED_PARAMETERS, included); } catch (IllegalStateException e) { LOGGER.info("HTTP Session was invalidated. It is not possible to include " + "Result parameters on Flash Scope"); } } } }); stack.next(method, resourceInstance); } FlashInterceptor(HttpSession session, Result result, MutableResponse response); boolean accepts(ResourceMethod method); void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance); }
FlashInterceptor implements Interceptor { public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException { @SuppressWarnings("unchecked") Map<String, Object> parameters = (Map<String, Object>) session.getAttribute(FLASH_INCLUDED_PARAMETERS); if (parameters != null) { session.removeAttribute(FLASH_INCLUDED_PARAMETERS); for (Entry<String, Object> parameter : parameters.entrySet()) { result.include(parameter.getKey(), parameter.getValue()); } } response.addRedirectListener(new RedirectListener() { public void beforeRedirect() { Map<String, Object> included = result.included(); if (!included.isEmpty()) { try { session.setAttribute(FLASH_INCLUDED_PARAMETERS, included); } catch (IllegalStateException e) { LOGGER.info("HTTP Session was invalidated. It is not possible to include " + "Result parameters on Flash Scope"); } } } }); stack.next(method, resourceInstance); } FlashInterceptor(HttpSession session, Result result, MutableResponse response); boolean accepts(ResourceMethod method); void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance);  }