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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations