Search in sources :

Example 31 with Request

use of org.apache.wicket.request.Request in project wicket by apache.

the class CryptoMapper method getCompatibilityScore.

/**
 * {@inheritDoc}
 * <p>
 * This implementation decrypts the URL and passes the decrypted URL to the wrapped mapper.
 * </p>
 * @param request
 *		The request for which to get a compatibility score.
 *
 * @return The compatibility score.
 */
@Override
public int getCompatibilityScore(final Request request) {
    Url decryptedUrl = decryptUrl(request, request.getUrl());
    if (decryptedUrl == null) {
        return 0;
    }
    Request decryptedRequest = request.cloneWithUrl(decryptedUrl);
    return wrappedMapper.getCompatibilityScore(decryptedRequest);
}
Also used : Request(org.apache.wicket.request.Request) Url(org.apache.wicket.request.Url)

Example 32 with Request

use of org.apache.wicket.request.Request in project wicket by apache.

the class CryptoMapper method mapRequest.

@Override
public IRequestHandler mapRequest(final Request request) {
    Url url = decryptUrl(request, request.getUrl());
    if (url == null) {
        return null;
    }
    Request decryptedRequest = request.cloneWithUrl(url);
    IRequestHandler handler = wrappedMapper.mapRequest(decryptedRequest);
    if (handler != null) {
        handler = new RequestSettingRequestHandler(decryptedRequest, handler);
    }
    return handler;
}
Also used : RequestSettingRequestHandler(org.apache.wicket.core.request.handler.RequestSettingRequestHandler) IRequestHandler(org.apache.wicket.request.IRequestHandler) Request(org.apache.wicket.request.Request) Url(org.apache.wicket.request.Url)

Example 33 with Request

use of org.apache.wicket.request.Request in project wicket by apache.

the class ResourceMapper method getCompatibilityScore.

@Override
public int getCompatibilityScore(Request request) {
    Url originalUrl = new Url(request.getUrl());
    PageParameters parameters = extractPageParameters(request, mountSegments.length, parametersEncoder);
    if (parameters != null) {
        parameters.setLocale(resolveLocale());
    }
    removeCachingDecoration(originalUrl, parameters);
    Request requestWithoutDecoration = request.cloneWithUrl(originalUrl);
    int score = super.getCompatibilityScore(requestWithoutDecoration);
    if (score > 0) {
        // pages always have priority over resources
        score--;
    } else {
        score = -1;
    }
    return score;
}
Also used : Request(org.apache.wicket.request.Request) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) ResourceUrl(org.apache.wicket.request.resource.caching.ResourceUrl) Url(org.apache.wicket.request.Url)

Example 34 with Request

use of org.apache.wicket.request.Request in project wicket by apache.

the class SessionSizeModelTest method testToleranceOnProblematicSessions.

/**
 * @see <a href="https://issues.apache.org/jira/browse/WICKET-3355">WICKET-3355</a>
 */
@Test
public void testToleranceOnProblematicSessions() {
    new WicketTester(new MockApplication() {

        @Override
        public Session newSession(final Request request, final Response response) {
            return new TestSession(request);
        }
    });
    SessionSizeModel model = new SessionSizeModel();
    assertEquals(null, model.getObject());
}
Also used : Response(org.apache.wicket.request.Response) MockApplication(org.apache.wicket.mock.MockApplication) Request(org.apache.wicket.request.Request) WicketTester(org.apache.wicket.util.tester.WicketTester) Session(org.apache.wicket.Session) WebSession(org.apache.wicket.protocol.http.WebSession) Test(org.junit.Test)

Example 35 with Request

use of org.apache.wicket.request.Request in project webanno by webanno.

the class LogoutPanel method getAutoLogoutTime.

/**
 * Checks if auto-logout is enabled. For Winstone, we get a max session length of 0, so here it
 * is disabled.
 */
private int getAutoLogoutTime() {
    int duration = 0;
    Request request = RequestCycle.get().getRequest();
    if (request instanceof ServletWebRequest) {
        HttpSession session = ((ServletWebRequest) request).getContainerRequest().getSession();
        if (session != null) {
            duration = session.getMaxInactiveInterval();
        }
    }
    return duration;
}
Also used : HttpSession(javax.servlet.http.HttpSession) ServletWebRequest(org.apache.wicket.protocol.http.servlet.ServletWebRequest) Request(org.apache.wicket.request.Request) ServletWebRequest(org.apache.wicket.protocol.http.servlet.ServletWebRequest)

Aggregations

Request (org.apache.wicket.request.Request)61 Test (org.junit.Test)28 IRequestHandler (org.apache.wicket.request.IRequestHandler)26 Url (org.apache.wicket.request.Url)23 WebRequest (org.apache.wicket.request.http.WebRequest)9 Response (org.apache.wicket.request.Response)8 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)8 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)6 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 IPageRequestHandler (org.apache.wicket.core.request.handler.IPageRequestHandler)5 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)5 ResourceReferenceRequestHandler (org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler)5 MockApplication (org.apache.wicket.mock.MockApplication)4 MockHttpServletRequest (org.apache.wicket.protocol.http.mock.MockHttpServletRequest)4 Session (org.apache.wicket.Session)3 ServletWebRequest (org.apache.wicket.protocol.http.servlet.ServletWebRequest)3 Attributes (org.apache.wicket.request.resource.IResource.Attributes)3 PackageResourceReference (org.apache.wicket.request.resource.PackageResourceReference)3 UrlAttributes (org.apache.wicket.request.resource.ResourceReference.UrlAttributes)3