use of com.publiccms.common.base.AbstractTaskDirective in project PublicCMS-preview by sanluan.
the class TemplateComponent method init.
@Autowired
private void init(FreeMarkerConfigurer freeMarkerConfigurer, DirectiveComponent directiveComponent) throws IOException, TemplateModelException {
Map<String, Object> freemarkerVariables = new HashMap<>();
adminConfiguration = freeMarkerConfigurer.getConfiguration();
for (Entry<String, AbstractTemplateDirective> entry : directiveComponent.getTemplateDirectiveMap().entrySet()) {
freemarkerVariables.put(directivePrefix + entry.getKey(), entry.getValue());
}
freemarkerVariables.putAll(directiveComponent.getMethodMap());
adminConfiguration.setAllSharedVariables(new SimpleHash(freemarkerVariables, adminConfiguration.getObjectWrapper()));
webConfiguration = new Configuration(Configuration.getVersion());
File webFile = new File(siteComponent.getWebTemplateFilePath());
webFile.mkdirs();
webConfiguration.setDirectoryForTemplateLoading(webFile);
copyConfig(adminConfiguration, webConfiguration);
Map<String, Object> webFreemarkerVariables = new HashMap<String, Object>(freemarkerVariables);
webFreemarkerVariables.put(TemplateCacheComponent.CONTENT_CACHE, new NoCacheDirective());
webConfiguration.setAllSharedVariables(new SimpleHash(webFreemarkerVariables, webConfiguration.getObjectWrapper()));
taskConfiguration = new Configuration(Configuration.getVersion());
File taskFile = new File(siteComponent.getTaskTemplateFilePath());
taskFile.mkdirs();
taskConfiguration.setDirectoryForTemplateLoading(taskFile);
copyConfig(adminConfiguration, taskConfiguration);
for (Entry<String, AbstractTaskDirective> entry : directiveComponent.getTaskDirectiveMap().entrySet()) {
freemarkerVariables.put(directivePrefix + entry.getKey(), entry.getValue());
}
taskConfiguration.setAllSharedVariables(new SimpleHash(freemarkerVariables, taskConfiguration.getObjectWrapper()));
}
use of com.publiccms.common.base.AbstractTaskDirective in project PublicCMS-preview by sanluan.
the class DirectiveComponent method init.
@Autowired
private void init(List<AbstractTemplateDirective> templateDirectiveList, List<AbstractTaskDirective> taskDirectiveList, List<BaseMethod> methodList) {
for (AbstractTemplateDirective directive : templateDirectiveList) {
if (null == directive.getName()) {
directive.setName(getDirectiveName(directive.getClass().getSimpleName()));
}
templateDirectiveMap.put(directive.getName(), directive);
}
log.info(new StringBuilder().append(templateDirectiveMap.size()).append(" template directives created:").append(templateDirectiveMap.keySet()).toString());
for (AbstractTaskDirective directive : taskDirectiveList) {
if (null == directive.getName()) {
directive.setName(getDirectiveName(directive.getClass().getSimpleName()));
}
taskDirectiveMap.put(directive.getName(), directive);
}
log.info(new StringBuilder().append(taskDirectiveMap.size()).append(" task directives created:").append(taskDirectiveMap.keySet()).toString());
for (BaseMethod method : methodList) {
if (null == method.getName()) {
method.setName(StringUtils.uncapitalize(method.getClass().getSimpleName().replaceAll(methodRemoveRegex, BLANK)));
}
methodMap.put(method.getName(), method);
}
log.info(new StringBuilder().append(methodMap.size()).append(" methods created:").append(methodMap.keySet()).toString());
}
Aggregations