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