Search in sources :

Example 11 with ExecutionContextException

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

the class XWikiDocument method backupContext.

public static void backupContext(Map<String, Object> backup, XWikiContext context) {
    // The XWiki Context isn't recreated when the Execution Context is cloned so we have to backup some of its data.
    // Backup the current document on the XWiki Context.
    backup.put("doc", context.getDoc());
    backup.put("cdoc", context.get("cdoc"));
    backup.put("tdoc", context.get("tdoc"));
    // Backup the secure document
    backup.put(CKEY_SDOC, context.get(CKEY_SDOC));
    // Clone the Execution Context to provide isolation. The clone will have a new Velocity and Script Context.
    Execution execution = Utils.getComponent(Execution.class);
    try {
        execution.pushContext(Utils.getComponent(ExecutionContextManager.class).clone(execution.getContext()));
    } catch (ExecutionContextException e) {
        throw new RuntimeException("Failed to clone the Execution Context", e);
    }
    // Bridge with old XWiki Context, required for legacy code.
    execution.getContext().setProperty(XWikiContext.EXECUTIONCONTEXT_KEY, context);
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContextException(org.xwiki.context.ExecutionContextException)

Aggregations

ExecutionContextException (org.xwiki.context.ExecutionContextException)11 ExecutionContext (org.xwiki.context.ExecutionContext)8 XWikiContext (com.xpn.xwiki.XWikiContext)6 XWikiException (com.xpn.xwiki.XWikiException)4 Execution (org.xwiki.context.Execution)3 ExecutionContextManager (org.xwiki.context.ExecutionContextManager)3 XWiki (com.xpn.xwiki.XWiki)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 EmbeddableComponentManager (org.xwiki.component.embed.EmbeddableComponentManager)2 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)2 ComponentManager (org.xwiki.component.manager.ComponentManager)2 InitializationException (org.xwiki.component.phase.InitializationException)2 DefaultDistributionJob (org.xwiki.extension.distribution.internal.job.DefaultDistributionJob)2 DistributionJob (org.xwiki.extension.distribution.internal.job.DistributionJob)2 DistributionRequest (org.xwiki.extension.distribution.internal.job.DistributionRequest)2 DocumentReference (org.xwiki.model.reference.DocumentReference)2 XWikiConfig (com.xpn.xwiki.XWikiConfig)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 XWikiStubContextProvider (com.xpn.xwiki.util.XWikiStubContextProvider)1 XWikiServletRequestStub (com.xpn.xwiki.web.XWikiServletRequestStub)1