use of org.apache.avalon.framework.configuration.DefaultConfiguration 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.");
}
}
Aggregations