use of org.alfresco.repo.template.QNameAwareObjectWrapper in project alfresco-remote-api by Alfresco.
the class RepositoryTemplateProcessor method initConfig.
/**
* Initialise FreeMarker Configuration
*/
protected void initConfig() {
Configuration config = new Configuration();
// setup template cache
config.setCacheStorage(new StrongCacheStorage());
config.setTemplateUpdateDelay(updateDelay);
// setup template loaders
List<TemplateLoader> loaders = new ArrayList<TemplateLoader>();
for (Store apiStore : searchPath.getStores()) {
TemplateLoader loader = apiStore.getTemplateLoader();
if (loader == null) {
throw new WebScriptException("Unable to retrieve template loader for Web Script store " + apiStore.getBasePath());
}
loaders.add(loader);
}
MultiTemplateLoader loader = new MultiTemplateLoader(loaders.toArray(new TemplateLoader[loaders.size()]));
config.setTemplateLoader(loader);
// use our custom object wrapper that can deal with QNameMap objects directly
config.setObjectWrapper(new QNameAwareObjectWrapper());
// rethrow any exception so we can deal with them
config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
// turn off locale sensitive lookup - to save numerous wasted calls to nodeservice.exists()
config.setLocalizedLookup(false);
// set template encoding
if (defaultEncoding != null) {
config.setDefaultEncoding(defaultEncoding);
}
// set output encoding
config.setOutputEncoding("UTF-8");
config.setIncompatibleImprovements(new Version(2, 3, 20));
config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
templateConfig = config;
}
Aggregations