use of org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader in project maven-plugins by apache.
the class DocumentModelBuilderTest method getDecorationModelFromFile.
private DecorationModel getDecorationModelFromFile(File descriptorFile) throws IOException, XmlPullParserException {
Reader reader = null;
try {
reader = ReaderFactory.newXmlReader(descriptorFile);
final DecorationModel decorationModel = new DecorationXpp3Reader().read(reader);
reader.close();
reader = null;
return decorationModel;
} finally {
IOUtil.close(reader);
}
}
use of org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader in project maven-plugins by apache.
the class PdfMojo method getDefaultDecorationModel.
/**
* @return the DecorationModel instance from <code>site.xml</code>
* @throws MojoExecutionException if any
*/
private DecorationModel getDefaultDecorationModel() throws MojoExecutionException {
if (this.defaultDecorationModel == null) {
final Locale locale = getDefaultLocale();
final File descriptorFile = siteTool.getSiteDescriptor(siteDirectory, locale);
DecorationModel decoration = null;
if (descriptorFile.exists()) {
XmlStreamReader reader = null;
try {
reader = new XmlStreamReader(descriptorFile);
String siteDescriptorContent = IOUtil.toString(reader);
reader.close();
reader = null;
siteDescriptorContent = siteTool.getInterpolatedSiteDescriptorContent(new HashMap<String, String>(2), project, siteDescriptorContent);
decoration = new DecorationXpp3Reader().read(new StringReader(siteDescriptorContent));
} catch (XmlPullParserException e) {
throw new MojoExecutionException("Error parsing site descriptor", e);
} catch (IOException e) {
throw new MojoExecutionException("Error reading site descriptor", e);
} catch (SiteToolException e) {
throw new MojoExecutionException("Error when interpoling site descriptor", e);
} finally {
IOUtil.close(reader);
}
}
this.defaultDecorationModel = decoration;
}
return this.defaultDecorationModel;
}
Aggregations