Search in sources :

Example 6 with ServletRequest

use of org.xwiki.container.servlet.ServletRequest in project xwiki-platform by xwiki.

the class ContextAndActionURLNormalizerTest method createMockRequest.

private HttpServletRequest createMockRequest() {
    ServletRequest request = mock(ServletRequest.class);
    when(this.container.getRequest()).thenReturn(request);
    HttpServletRequest httpRequest = mock(HttpServletRequest.class);
    when(request.getHttpServletRequest()).thenReturn(httpRequest);
    return httpRequest;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(org.xwiki.container.servlet.ServletRequest)

Example 7 with ServletRequest

use of org.xwiki.container.servlet.ServletRequest in project xwiki-platform by xwiki.

the class DefaultServletContainerInitializer method initializeRequest.

@Override
public void initializeRequest(HttpServletRequest httpServletRequest, Object xwikiContext) throws ServletContainerException {
    // 1) Create an empty request. From this point forward request initializers can use the
    // Container object to get any data they want from the Request.
    this.container.setRequest(new ServletRequest(httpServletRequest));
    // 2) Create an empty Execution context so that the Container initializers can put things in the
    // execution context when they execute.
    this.execution.setContext(new ExecutionContext());
    // XWikiContext object whereas new code uses the Container component.
    if (xwikiContext != null) {
        ExecutionContext ec = this.execution.getContext();
        String key = "xwikicontext";
        if (ec.hasProperty(key)) {
            ec.setProperty(key, xwikiContext);
        } else {
            ec.newProperty(key).inherited().initial(xwikiContext).declare();
        }
    }
    // 4) Call the request initializers to populate the Request further.
    try {
        RequestInitializerManager manager = this.componentManager.getInstance(RequestInitializerManager.class);
        manager.initializeRequest(this.container.getRequest());
    } catch (Exception e) {
        throw new ServletContainerException("Failed to initialize request", e);
    }
    // 5) Call Execution Context initializers to perform further Execution Context initializations
    try {
        ExecutionContextManager manager = this.componentManager.getInstance(ExecutionContextManager.class);
        manager.initialize(this.execution.getContext());
    } catch (Exception e) {
        throw new ServletContainerException("Failed to initialize Execution Context", e);
    }
}
Also used : ServletRequest(org.xwiki.container.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletContainerException(org.xwiki.container.servlet.ServletContainerException) ExecutionContext(org.xwiki.context.ExecutionContext) ExecutionContextManager(org.xwiki.context.ExecutionContextManager) RequestInitializerManager(org.xwiki.container.RequestInitializerManager) ServletContainerException(org.xwiki.container.servlet.ServletContainerException)

Example 8 with ServletRequest

use of org.xwiki.container.servlet.ServletRequest in project xwiki-platform by xwiki.

the class ContextAndActionURLNormalizerTest method createMockRequest.

private HttpServletRequest createMockRequest() {
    ServletRequest request = mock(ServletRequest.class);
    when(this.container.getRequest()).thenReturn(request);
    HttpServletRequest httpRequest = mock(HttpServletRequest.class);
    when(request.getHttpServletRequest()).thenReturn(httpRequest);
    return httpRequest;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(org.xwiki.container.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest)

Aggregations

ServletRequest (org.xwiki.container.servlet.ServletRequest)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 Request (org.xwiki.container.Request)3 XWikiContext (com.xpn.xwiki.XWikiContext)2 XWikiException (com.xpn.xwiki.XWikiException)2 BaseObject (com.xpn.xwiki.objects.BaseObject)1 XWikiServletRequest (com.xpn.xwiki.web.XWikiServletRequest)1 XWikiServletResponse (com.xpn.xwiki.web.XWikiServletResponse)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 HttpSession (javax.servlet.http.HttpSession)1 Expectations (org.jmock.Expectations)1 Before (org.junit.Before)1 Logger (org.slf4j.Logger)1 DocumentAccessBridge (org.xwiki.bridge.DocumentAccessBridge)1 Container (org.xwiki.container.Container)1 RequestInitializerManager (org.xwiki.container.RequestInitializerManager)1 ServletContainerException (org.xwiki.container.servlet.ServletContainerException)1 ServletResponse (org.xwiki.container.servlet.ServletResponse)1 ExecutionContext (org.xwiki.context.ExecutionContext)1 ExecutionContextManager (org.xwiki.context.ExecutionContextManager)1