// load and/or verify decorator macros configuration
TemplateDescriptor macrosDescriptor = null;
// create reusable decoration base descriptor
LocatorDescriptor descriptor = null;
try
{
descriptor = decorationLocator.createLocatorDescriptor(null);
}
catch (TemplateLocatorException tle)
{
log.error("getVelocityEngine(): unable create base descriptor", tle);
}
descriptor.setMediaType(layoutMediaType);
descriptor.setCountry(layoutCountry);
descriptor.setLanguage(layoutLanguage);
descriptor.setType(layoutType);
// get decoration configuration properties descriptor
descriptor.setName(layoutDecoration + "/" + JetspeedVelocityPowerTool.DECORATOR_TYPE + ".properties");
TemplateDescriptor propertiesDescriptor = null;
try
{
propertiesDescriptor = decorationLocator.locateTemplate(descriptor);
}
catch (TemplateLocatorException tle)
{
// fallback to generic template type
try
{
descriptor.setType(JetspeedVelocityPowerTool.GENERIC_TEMPLATE_TYPE);
propertiesDescriptor = decorationLocator.locateTemplate(descriptor);
}
catch (TemplateLocatorException tleFallback)
{
}
}
// load configuration properties
Configuration configuration = null;
if (propertiesDescriptor != null)
{
try
{
configuration = new PropertiesConfiguration(propertiesDescriptor.getAbsolutePath());
}
catch (ConfigurationException ce)
{
log.warn("getVelocityEngine(): unable read decorator properties from " + propertiesDescriptor.getAbsolutePath(), ce);
}
}
if (configuration != null)
{
// get decoration template macros extension and suffix
String ext = configuration.getString("template.extension");
String macros = configuration.getString("template.macros");
// get decoration template macros descriptor if defined
if ((ext != null) && (ext.length() > 0) && (macros != null) && (macros.length() > 0))
{
descriptor.setName(layoutDecoration + "/" + JetspeedVelocityPowerTool.DECORATOR_TYPE + macros + ext);
try
{
macrosDescriptor = decorationLocator.locateTemplate(descriptor);
}
catch (TemplateLocatorException tle)
{
// fallback to extends decoration, (assume macros named the
// same in the parent decoration as configured here)
try
{
String parent = configuration.getString("extends");
if ((parent != null) && (parent.length() > 0))
{
descriptor.setName(parent + "/" + JetspeedVelocityPowerTool.DECORATOR_TYPE + macros + ext);
macrosDescriptor = decorationLocator.locateTemplate(descriptor);
}
}
catch (TemplateLocatorException tleExtends)
{