Search in sources :

Example 96 with ExecutionContext

use of org.xwiki.context.ExecutionContext in project xwiki-platform by xwiki.

the class HtmlPackager method initializeContexts.

private XWikiContext initializeContexts(ExecutionContextManager ecm, Execution execution, ExportURLFactory urlf, XWikiContext originalContext) throws ExecutionContextException {
    XWikiContext renderContext = originalContext.clone();
    // Override the current action to ensure we always render a view action.
    renderContext.put("action", "view");
    // Set the URL Factories/Serializer to use
    renderContext.setURLFactory(urlf);
    ExecutionContext executionContext = ecm.clone(execution.getContext());
    // Bridge with old XWiki Context, required for legacy code.
    executionContext.setProperty("xwikicontext", renderContext);
    // Push a clean new Execution Context since we don't want the main Execution Context to be used for
    // rendering the HTML pages to export. It's cleaner to isolate it as we do. Note that the new
    // Execution Context automatically gets initialized with a new Velocity Context by
    // the VelocityRequestInitializer class.
    execution.pushContext(executionContext);
    // Use the filesystem URL format for all code using the url module to generate URLs (webjars, etc).
    Utils.getComponent(URLContextManager.class).setURLFormatId("filesystem");
    return renderContext;
}
Also used : URLContextManager(org.xwiki.url.URLContextManager) ExecutionContext(org.xwiki.context.ExecutionContext) XWikiContext(com.xpn.xwiki.XWikiContext)

Example 97 with ExecutionContext

use of org.xwiki.context.ExecutionContext in project xwiki-platform by xwiki.

the class DownloadAction method getContext.

private XWikiContext getContext() {
    Execution execution = Utils.getComponent(Execution.class);
    ExecutionContext econtext = execution.getContext();
    return econtext != null ? (XWikiContext) econtext.getProperty("xwikicontext") : null;
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext)

Example 98 with ExecutionContext

use of org.xwiki.context.ExecutionContext in project xwiki-platform by xwiki.

the class DeleteJobTest method configure.

@Override
public void configure() throws Exception {
    super.configure();
    Execution execution = mocker.getInstance(Execution.class);
    ExecutionContext executionContext = mock(ExecutionContext.class);
    when(execution.getContext()).thenReturn(executionContext);
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext)

Example 99 with ExecutionContext

use of org.xwiki.context.ExecutionContext in project xwiki-platform by xwiki.

the class WikiUIExtensionParametersTest method setUp.

@Before
public void setUp() throws Exception {
    VelocityManager velocityManager = componentManager.registerMockComponent(VelocityManager.class);
    execution = componentManager.registerMockComponent(Execution.class);
    modelContext = componentManager.registerMockComponent(ModelContext.class);
    velocityEngine = mock(VelocityEngine.class);
    velocityContext = new VelocityContext();
    ExecutionContext executionContext = mock(ExecutionContext.class);
    when(execution.getContext()).thenReturn(executionContext);
    when(velocityManager.getVelocityContext()).thenReturn(velocityContext);
    when(velocityManager.getVelocityEngine()).thenReturn(velocityEngine);
}
Also used : ModelContext(org.xwiki.model.ModelContext) VelocityEngine(org.xwiki.velocity.VelocityEngine) Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) VelocityManager(org.xwiki.velocity.VelocityManager) VelocityContext(org.apache.velocity.VelocityContext) Before(org.junit.Before)

Example 100 with ExecutionContext

use of org.xwiki.context.ExecutionContext in project xwiki-platform by xwiki.

the class WikiUIExtensionRendererTest method setUp.

@Before
public void setUp() throws Exception {
    execution = cm.registerMockComponent(Execution.class);
    ExecutionContext executionContext = mock(ExecutionContext.class);
    renderingContext = mock(MutableRenderingContext.class);
    cm.registerComponent(RenderingContext.class, renderingContext);
    cm.registerMockComponent(Transformation.class, "macro");
    contentParser = cm.registerMockComponent(ContentParser.class);
    when(execution.getContext()).thenReturn(executionContext);
    xdom = mock(XDOM.class);
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) XDOM(org.xwiki.rendering.block.XDOM) ContentParser(org.xwiki.component.wiki.internal.bridge.ContentParser) MutableRenderingContext(org.xwiki.rendering.internal.transformation.MutableRenderingContext) Before(org.junit.Before)

Aggregations

ExecutionContext (org.xwiki.context.ExecutionContext)114 Execution (org.xwiki.context.Execution)62 XWikiContext (com.xpn.xwiki.XWikiContext)47 Before (org.junit.Before)31 Test (org.junit.Test)25 XWiki (com.xpn.xwiki.XWiki)19 DocumentReference (org.xwiki.model.reference.DocumentReference)19 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)15 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)14 ComponentManager (org.xwiki.component.manager.ComponentManager)9 ExecutionContextException (org.xwiki.context.ExecutionContextException)9 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)9 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)8 ExecutionContextManager (org.xwiki.context.ExecutionContextManager)8 List (java.util.List)6 Map (java.util.Map)6 Properties (java.util.Properties)6 Session (javax.mail.Session)6 MimeMessage (javax.mail.internet.MimeMessage)6 XWikiException (com.xpn.xwiki.XWikiException)5