use of com.xpn.xwiki.job.JobRequestContext in project xwiki-platform by xwiki.
the class JobRequestContextInitializer method onEvent.
@Override
public void onEvent(Event event, Object source, Object data) {
JobStartedEvent jobStartedEvent = (JobStartedEvent) event;
JobRequestContext jobRequestContext = jobStartedEvent.getRequest().getProperty(JobRequestContext.KEY);
if (jobRequestContext != null) {
XWikiContext xcontext = this.xcontextProvider.get();
if (xcontext != null) {
// Wiki id
if (jobRequestContext.isWikiIdSet()) {
xcontext.setWikiId(jobRequestContext.getWikiId());
}
// User
if (jobRequestContext.isUserReferenceSet()) {
xcontext.setUserReference(jobRequestContext.getUserReference());
}
// Document
if (jobRequestContext.isDocumentSet()) {
XWikiDocument document = getDocument(jobRequestContext, xcontext);
xcontext.setDoc(document);
}
// Secure document
if (jobRequestContext.isSDocumentSet()) {
XWikiDocument sdocument = getSDocument(jobRequestContext, xcontext);
xcontext.put(XWikiDocument.CKEY_SDOC, sdocument);
}
// Request
if (jobRequestContext.isRequestSet()) {
xcontext.setRequest(new XWikiServletRequestStub(jobRequestContext.getRequestURL(), jobRequestContext.getRequestParameters()));
}
}
}
}
Aggregations