Package org.eurekastreams.commons.exceptions

Examples of org.eurekastreams.commons.exceptions.SessionException


        {
            // get real session
            HttpSession session = request.getSession();
            if (session == null)
            {
                return new SessionException("Request has no session.");
            }
            String realSessionId = session.getId();
            if (StringUtils.isBlank(realSessionId))
            {
                return new SessionException("Request session has no valid ID.");
            }

            // compare with claimed session
            if (!realSessionId.equals(claimedSessionId))
            {
                log.error("Provided session ID '{}' does not match request session ID '{}'.", claimedSessionId,
                        realSessionId);
                return new SessionException("Provided session ID does not match request session ID.");
            }
        }

        // get the principal (throws if none available)
        Principal principal = getPrincipal(request);
View Full Code Here


     * Tests how exceptions are returned to client.
     */
    @Test
    public void testSessionException()
    {
        Exception exIn = new SessionException("Inner message");
        Exception exOut = coreForbidNestingExceptionTest(exIn);
        assertTrue(exOut instanceof SessionException);
        assertTrue(exOut.getCause() == null || exOut.getCause() == exOut);
        assertTrue(StringUtils.isEmpty(exOut.getMessage()) || !exOut.getMessage().equals(exIn.getMessage()));
    }
View Full Code Here

            {
                oneOf(service).establishSession(with(any(AsyncCallback.class)));
                will(paramInt);
            }
        });
        serviceExecCb.onSuccess(new ActionRequest[] { new ActionResponse(requests[0], new SessionException()) });
        context.assertIsSatisfied();

        // -- service replies with error. SUT should notify app --
        AsyncCallback<String> serviceSessionCb = (AsyncCallback<String>) paramInt.getParam(0);
        final Exception ex = new Exception("Can it handle it?");
View Full Code Here

        // -- make 1, 2, 4 fail with a session exception; 3 will succeed. once all are back, SUT should request session.
        // out of order on purpose. --
        // 1 fails
        ((AsyncCallback) paramInt01.getParam(1)).onSuccess(new ActionRequest[] { new ActionResponse(
                ((ActionRequest[]) paramInt01.getParam(0))[0], new SessionException()) });
        // 4 fails
        ((AsyncCallback) paramInt04.getParam(1)).onSuccess(new ActionRequest[] { new ActionResponse(
                ((ActionRequest[]) paramInt04.getParam(0))[0], new SessionException()) });
        // 3 succeeds
        context.checking(new Expectations()
        {
            {
                oneOf(actionCb03).onSuccess(with(same(result03)));
            }
        });
        ((AsyncCallback) paramInt03.getParam(1)).onSuccess(new ActionRequest[] { new ActionResponse(
                ((ActionRequest[]) paramInt03.getParam(0))[0], result03) });
        context.assertIsSatisfied();
        // 2 fails. since it's the last outstanding, the return will trigger re-establishment
        context.checking(new Expectations()
        {
            {
                oneOf(service).establishSession(with(any(AsyncCallback.class)));
                will(paramInt);
            }
        });
        ((AsyncCallback) paramInt02.getParam(1)).onSuccess(new ActionRequest[] { new ActionResponse(
                ((ActionRequest[]) paramInt02.getParam(0))[0], new SessionException()) });
        context.assertIsSatisfied();

        // -- establishing new session should send request for all 3 that failed in one message --
        context.checking(new Expectations()
        {
View Full Code Here

                will(throwException(ex1));

                oneOf(sessionCb).onFailure(with(equal(ex1)));
            }
        });
        serviceExecCb.onSuccess(new ActionRequest[] { new ActionResponse(requests[0], new SessionException()) });
        context.assertIsSatisfied();

        // -- app asks SUT to try again --
        context.checking(new Expectations()
        {
View Full Code Here

        {
            return new GeneralException("Invalid action.");
        }
        else if (ex instanceof SessionException)
        {
            return new SessionException();
        }
        else
        {
            return new GeneralException("Error performing action.");
        }
View Full Code Here

    private ActionRequest execute(final ActionRequest request, final UserDetails user)
    {
        // check that the session id is the session id stamped in the request
        if (!getThreadLocalRequest().getSession().getId().equals(request.getSessionId()))
        {
            request.setResponse(new SessionException("Session Expired"));
            return request;
        }
        else
        {
            return actionExecutor.execute(request, user);
View Full Code Here

TOP

Related Classes of org.eurekastreams.commons.exceptions.SessionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.