use of com.xpn.xwiki.XWikiContext in project xwiki-platform by xwiki.
the class ActionExecutionEventConverter method fromRemote.
@Override
public boolean fromRemote(RemoteEventData remoteEvent, LocalEventData localEvent) {
if (remoteEvent.getEvent() instanceof ActionExecutedEvent || remoteEvent.getEvent() instanceof ActionExecutingEvent) {
// fill the local event
XWikiContext xcontext = unserializeXWikiContext(remoteEvent.getData());
try {
if (xcontext != null) {
localEvent.setSource(unserializeDocument(remoteEvent.getSource()));
localEvent.setData(xcontext);
localEvent.setEvent((Event) remoteEvent.getEvent());
}
} catch (XWikiException e) {
this.logger.error("Failed to convert remote event [{}]", remoteEvent, e);
}
return true;
}
return false;
}
use of com.xpn.xwiki.XWikiContext in project xwiki-platform by xwiki.
the class DocumentEventConverter method fromRemote.
@Override
public boolean fromRemote(RemoteEventData remoteEvent, LocalEventData localEvent) {
if (EVENTS.contains(remoteEvent.getEvent().getClass())) {
// fill the local event
XWikiContext xcontext = unserializeXWikiContext(remoteEvent.getData());
try {
if (xcontext != null) {
localEvent.setData(xcontext);
localEvent.setEvent((Event) remoteEvent.getEvent());
if (remoteEvent.getEvent() instanceof DocumentDeletedEvent) {
localEvent.setSource(unserializeDeletdDocument(remoteEvent.getSource(), xcontext));
} else {
localEvent.setSource(unserializeDocument(remoteEvent.getSource()));
}
}
} catch (XWikiException e) {
this.logger.error("Failed to convert remote event [{}]", remoteEvent, e);
}
return true;
}
return false;
}
use of com.xpn.xwiki.XWikiContext in project xwiki-platform by xwiki.
the class WikiEventConverter method fromRemote.
@Override
public boolean fromRemote(RemoteEventData remoteEvent, LocalEventData localEvent) {
if (this.events.contains(remoteEvent.getEvent().getClass())) {
// fill the local event
XWikiContext context = unserializeXWikiContext(remoteEvent.getData());
if (context != null) {
localEvent.setEvent((Event) remoteEvent.getEvent());
localEvent.setSource(remoteEvent.getSource());
localEvent.setData(unserializeXWikiContext(remoteEvent.getData()));
}
return true;
}
return false;
}
use of com.xpn.xwiki.XWikiContext in project xwiki-platform by xwiki.
the class FOPXSLFORenderer method extendConfiguration.
private void extendConfiguration(DefaultConfiguration writableConfiguration) {
// Add XWiki fonts folder to the configuration.
try {
String fontsPath = this.environment.getResource(FONTS_PATH).getPath();
XWikiContext xcontext = this.xcontextProvider.get();
if (xcontext != null) {
XWikiRequest request = xcontext.getRequest();
if (request != null && request.getSession() != null) {
fontsPath = request.getSession().getServletContext().getRealPath(FONTS_PATH);
}
}
// <renderers>
DefaultConfiguration renderersConfiguration = (DefaultConfiguration) writableConfiguration.getChild(RENDERERS, false);
if (renderersConfiguration == null) {
renderersConfiguration = new DefaultConfiguration(RENDERERS);
writableConfiguration.addChild(renderersConfiguration);
}
// Ensure we have support for PDF rendering.
// <renderer mime="application/pdf">
DefaultConfiguration pdfRenderer = null;
for (Configuration renderer : renderersConfiguration.getChildren()) {
if (MIME_TYPE_PDF.equals(renderer.getAttribute(MIME))) {
pdfRenderer = (DefaultConfiguration) renderer;
}
}
if (pdfRenderer == null) {
pdfRenderer = new DefaultConfiguration("renderer");
pdfRenderer.setAttribute(MIME, MIME_TYPE_PDF);
renderersConfiguration.addChild(pdfRenderer);
}
// <fonts>
DefaultConfiguration fontsConfiguration = (DefaultConfiguration) pdfRenderer.getChild(FONTS, false);
if (fontsConfiguration == null) {
fontsConfiguration = new DefaultConfiguration(FONTS);
pdfRenderer.addChild(fontsConfiguration);
}
// <directory>fontdirectory</directory>
DefaultConfiguration directoryConfiguration = new DefaultConfiguration("directory");
directoryConfiguration.setValue(fontsPath);
fontsConfiguration.addChild(directoryConfiguration);
} catch (Exception e) {
this.logger.warn("Starting with 1.5, XWiki uses the WEB-INF/fonts/ directory as the font directory, " + "and it should contain the FreeFont (http://savannah.gnu.org/projects/freefont/) fonts. " + "FOP cannot access this directory. If this is an upgrade from a previous version, " + "make sure you also copy the WEB-INF/fonts directory from the new distribution package.");
}
}
use of com.xpn.xwiki.XWikiContext in project xwiki-platform by xwiki.
the class DefaultAuthorExecutor method after.
@Override
public void after(AutoCloseable context) {
XWikiContext xwikiContext = this.xcontextProvider.get();
if (xwikiContext != null) {
DefaultAuthorExecutorContext internalContext = (DefaultAuthorExecutorContext) context;
// Restore context document's content author
xwikiContext.put(XWikiDocument.CKEY_SDOC, internalContext.currentSecureDocument);
// Restore XWikiContext#dropPermission hack
if (internalContext.xwikiContextDropPermissionHack != null) {
xwikiContext.put(XWikiConstant.DROPPED_PERMISSIONS, internalContext.xwikiContextDropPermissionHack);
}
// Restore Document#dropPermission hack
if (internalContext.documentDropPermissionHack != null) {
ExecutionContext econtext = this.execution.getContext();
econtext.setProperty(XWikiConstant.DROPPED_PERMISSIONS, internalContext.documentDropPermissionHack);
}
}
}
Aggregations