Package org.alfresco.repo.processor
Class TemplateServiceImpl
java.lang.Object
org.alfresco.repo.processor.TemplateServiceImpl
- All Implemented Interfaces:
TemplateService
Implementation of the TemplateService using Spring configured script engines.
- Author:
- Kevin Roast
-
Field Summary
Fields inherited from interface org.alfresco.service.cmr.repository.TemplateService
KEY_COMPANY_HOME, KEY_DATE, KEY_IMAGE_RESOLVER, KEY_PERSON, KEY_PRODUCT_NAME, KEY_SHARE_URL, KEY_TEMPLATE, KEY_USER_HOME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildDefaultModel(NodeRef person, NodeRef companyHome, NodeRef userHome, NodeRef template, TemplateImageResolver imageResolver) Helper method to build a default modelgetTemplateProcessor(String engine) Return a TemplateProcessor instance for the specified engine name.processTemplate(String template, Object model) Process a template against the upplied data model and return the result as a string.voidprocessTemplate(String template, Object model, Writer out) Process a template against the supplied data model and write to the out.processTemplate(String engine, String template, Object model) Process a template against the supplied data model and write to the out.voidprocessTemplate(String engine, String template, Object model, Writer out) Process a template against the supplied data model and write to the out.processTemplate(String engine, String template, Object model, Locale locale) Process a template using the supplied locale against the supplied data model and write to the out.processTemplateString(String engine, String template, Object model) Process a given template, provided as a string, against the supplied data model and return the result as a StringvoidprocessTemplateString(String engine, String template, Object model, Writer out) Process a given template, provided as a string, against the supplied data model and report the result back in the provided writer.voidregisterTemplateProcessor(TemplateProcessor templateProcessor) Registers a new template processor with the template servicevoidsetDefaultTemplateEngine(String defaultTemplateEngine) voidsetNodeService(NodeService nodeService) Set the node service
-
Constructor Details
-
TemplateServiceImpl
public TemplateServiceImpl()
-
-
Method Details
-
setDefaultTemplateEngine
- Parameters:
defaultTemplateEngine- The default Template Engine name to set.
-
setNodeService
Set the node service- Parameters:
nodeService- the node service
-
getTemplateProcessor
Description copied from interface:TemplateServiceReturn a TemplateProcessor instance for the specified engine name. Note that the processor instance is NOT thread safe!- Specified by:
getTemplateProcessorin interfaceTemplateService- Parameters:
engine- Name of the template engine to get or null for default- Returns:
- TemplateProcessor
- See Also:
-
registerTemplateProcessor
Description copied from interface:TemplateServiceRegisters a new template processor with the template service- Specified by:
registerTemplateProcessorin interfaceTemplateService- Parameters:
templateProcessor- the template processor to register- See Also:
-
processTemplate
Description copied from interface:TemplateServiceProcess a template against the upplied data model and return the result as a string. The template engine used will be determined by the extension of the template.- Specified by:
processTemplatein interfaceTemplateService- Parameters:
template- Template (qualified classpath name or noderef)model- Object model to process template against- Returns:
- output of the template process as a String
- Throws:
TemplateException- See Also:
-
processTemplate
Description copied from interface:TemplateServiceProcess a template against the supplied data model and write to the out. The template engine used will be determined by the extension of the template.- Specified by:
processTemplatein interfaceTemplateService- Parameters:
template- Template (qualified classpath name or noderef)model- Object model to process template againstout- Writer object to send output too- Throws:
TemplateException- See Also:
-
processTemplate
public void processTemplate(String engine, String template, Object model, Writer out) throws TemplateException Description copied from interface:TemplateServiceProcess a template against the supplied data model and write to the out.- Specified by:
processTemplatein interfaceTemplateService- Parameters:
engine- Name of the template engine to usetemplate- Template (qualified classpath name or noderef)model- Object model to process template againstout- Writer object to send output too- Throws:
TemplateException- See Also:
-
processTemplate
public String processTemplate(String engine, String template, Object model, Locale locale) throws TemplateException Description copied from interface:TemplateServiceProcess a template using the supplied locale against the supplied data model and write to the out.- Specified by:
processTemplatein interfaceTemplateService- Parameters:
engine- Name of the template engine to usetemplate- Template ref (qualified classpath name or noderef)model- Object model to process template againstlocale- Locale to process the template as- Throws:
TemplateException- See Also:
-
processTemplate
public String processTemplate(String engine, String template, Object model) throws TemplateException Description copied from interface:TemplateServiceProcess a template against the supplied data model and write to the out.- Specified by:
processTemplatein interfaceTemplateService- Parameters:
engine- Name of the template engine to usetemplate- Template (qualified classpath name or noderef)model- Object model to process template against- Returns:
- output of the template process as a String
- Throws:
TemplateException- See Also:
-
processTemplateString
public void processTemplateString(String engine, String template, Object model, Writer out) throws TemplateException Description copied from interface:TemplateServiceProcess a given template, provided as a string, against the supplied data model and report the result back in the provided writer.- Specified by:
processTemplateStringin interfaceTemplateService- Parameters:
engine- Name of the template engine to usetemplate- Template stringmodel- Object model to process template againstout- Writer object to send output too- Throws:
TemplateException- See Also:
-
processTemplateString
public String processTemplateString(String engine, String template, Object model) throws TemplateException Description copied from interface:TemplateServiceProcess a given template, provided as a string, against the supplied data model and return the result as a String- Specified by:
processTemplateStringin interfaceTemplateService- Parameters:
engine- Name of the template engine to usetemplate- Template stringmodel- Object model to process template against- Returns:
- output of the template process as a String
- Throws:
TemplateException- See Also:
-
buildDefaultModel
public Map<String,Object> buildDefaultModel(NodeRef person, NodeRef companyHome, NodeRef userHome, NodeRef template, TemplateImageResolver imageResolver) Description copied from interface:TemplateServiceHelper method to build a default model- Specified by:
buildDefaultModelin interfaceTemplateService- Parameters:
person- the person node referencecompanyHome- the company home node refereenceuserHome- the user home node referencetemplate- the node ref for the template (optional)imageResolver- the image resolver (optional)- Returns:
- Map
- See Also:
-