org.alfresco.repo.processor
Class TemplateServiceImpl

java.lang.Object
  extended by org.alfresco.repo.processor.TemplateServiceImpl
All Implemented Interfaces:
TemplateService

public class TemplateServiceImpl
extends java.lang.Object
implements TemplateService

Implementation of the TemplateService using Spring configured script engines.


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
TemplateServiceImpl()
           
 
Method Summary
 java.util.Map buildDefaultModel(org.alfresco.service.cmr.repository.NodeRef person, org.alfresco.service.cmr.repository.NodeRef companyHome, org.alfresco.service.cmr.repository.NodeRef userHome, org.alfresco.service.cmr.repository.NodeRef template, TemplateImageResolver imageResolver)
          Helper method to build a default model
 TemplateProcessor getTemplateProcessor(java.lang.String engine)
          Return a TemplateProcessor instance for the specified engine name.
 java.lang.String processTemplate(java.lang.String template, java.lang.Object model)
          Process a template against the upplied data model and return the result as a string.
 void processTemplate(java.lang.String template, java.lang.Object model, java.io.Writer out)
          Process a template against the supplied data model and write to the out.
 java.lang.String processTemplate(java.lang.String engine, java.lang.String template, java.lang.Object model)
          Process a template against the supplied data model and write to the out.
 void processTemplate(java.lang.String engine, java.lang.String template, java.lang.Object model, java.io.Writer out)
          Process a template against the supplied data model and write to the out.
 java.lang.String processTemplateString(java.lang.String engine, java.lang.String template, java.lang.Object model)
          Process a given template, provided as a string, against the supplied data model and return the result as a String
 void processTemplateString(java.lang.String engine, java.lang.String template, java.lang.Object model, java.io.Writer out)
          Process a given template, provided as a string, against the supplied data model and report the result back in the provided writer.
 void registerTemplateProcessor(TemplateProcessor templateProcessor)
          Registers a new template processor with the template service
 void setDefaultTemplateEngine(java.lang.String defaultTemplateEngine)
           
 void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
          Set the node service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateServiceImpl

public TemplateServiceImpl()
Method Detail

setDefaultTemplateEngine

public void setDefaultTemplateEngine(java.lang.String defaultTemplateEngine)
Parameters:
defaultTemplateEngine - The default Template Engine name to set.

setNodeService

public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
Set the node service

Parameters:
nodeService - the node service

getTemplateProcessor

public TemplateProcessor getTemplateProcessor(java.lang.String engine)
Description copied from interface: TemplateService
Return a TemplateProcessor instance for the specified engine name. Note that the processor instance is NOT thread safe!

Specified by:
getTemplateProcessor in interface TemplateService
Parameters:
engine - Name of the template engine to get or null for default
Returns:
TemplateProcessor
See Also:
TemplateService.getTemplateProcessor(java.lang.String)

registerTemplateProcessor

public void registerTemplateProcessor(TemplateProcessor templateProcessor)
Description copied from interface: TemplateService
Registers a new template processor with the template service

Specified by:
registerTemplateProcessor in interface TemplateService
Parameters:
templateProcessor - the template processor to register
See Also:
TemplateService.registerTemplateProcessor(org.alfresco.service.cmr.repository.TemplateProcessor)

processTemplate

public java.lang.String processTemplate(java.lang.String template,
                                        java.lang.Object model)
                                 throws TemplateException
Description copied from interface: TemplateService
Process 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:
processTemplate in interface TemplateService
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:
TemplateService.processTemplate(java.lang.String, java.lang.Object)

processTemplate

public void processTemplate(java.lang.String template,
                            java.lang.Object model,
                            java.io.Writer out)
                     throws TemplateException
Description copied from interface: TemplateService
Process 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:
processTemplate in interface TemplateService
Parameters:
template - Template (qualified classpath name or noderef)
model - Object model to process template against
out - Writer object to send output too
Throws:
TemplateException
See Also:
TemplateService.processTemplate(java.lang.String, java.lang.Object, java.io.Writer)

processTemplate

public void processTemplate(java.lang.String engine,
                            java.lang.String template,
                            java.lang.Object model,
                            java.io.Writer out)
                     throws TemplateException
Description copied from interface: TemplateService
Process a template against the supplied data model and write to the out.

Specified by:
processTemplate in interface TemplateService
Parameters:
engine - Name of the template engine to use
template - Template (qualified classpath name or noderef)
model - Object model to process template against
out - Writer object to send output too
Throws:
TemplateException
See Also:
TemplateService.processTemplate(java.lang.String, java.lang.String, java.lang.Object, java.io.Writer)

processTemplate

public java.lang.String processTemplate(java.lang.String engine,
                                        java.lang.String template,
                                        java.lang.Object model)
                                 throws TemplateException
Description copied from interface: TemplateService
Process a template against the supplied data model and write to the out.

Specified by:
processTemplate in interface TemplateService
Parameters:
engine - Name of the template engine to use
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:
TemplateService.processTemplate(java.lang.String, java.lang.String, java.lang.Object)

processTemplateString

public void processTemplateString(java.lang.String engine,
                                  java.lang.String template,
                                  java.lang.Object model,
                                  java.io.Writer out)
                           throws TemplateException
Description copied from interface: TemplateService
Process a given template, provided as a string, against the supplied data model and report the result back in the provided writer.

Specified by:
processTemplateString in interface TemplateService
Parameters:
engine - Name of the template engine to use
template - Template string
model - Object model to process template against
out - Writer object to send output too
Throws:
TemplateException
See Also:
TemplateService.processTemplateString(java.lang.String, java.lang.String, java.lang.Object, java.io.Writer)

processTemplateString

public java.lang.String processTemplateString(java.lang.String engine,
                                              java.lang.String template,
                                              java.lang.Object model)
                                       throws TemplateException
Description copied from interface: TemplateService
Process a given template, provided as a string, against the supplied data model and return the result as a String

Specified by:
processTemplateString in interface TemplateService
Parameters:
engine - Name of the template engine to use
template - Template string
model - Object model to process template against
Returns:
output of the template process as a String
Throws:
TemplateException
See Also:
TemplateService.processTemplateString(java.lang.String, java.lang.String, java.lang.Object)

buildDefaultModel

public java.util.Map buildDefaultModel(org.alfresco.service.cmr.repository.NodeRef person,
                                       org.alfresco.service.cmr.repository.NodeRef companyHome,
                                       org.alfresco.service.cmr.repository.NodeRef userHome,
                                       org.alfresco.service.cmr.repository.NodeRef template,
                                       TemplateImageResolver imageResolver)
Description copied from interface: TemplateService
Helper method to build a default model

Specified by:
buildDefaultModel in interface TemplateService
Parameters:
person - the person node reference
companyHome - the company home node refereence
userHome - the user home node reference
template - the node ref for the template (optional)
imageResolver - the image resolver (optional)
Returns:
See Also:
TemplateService.buildDefaultModel(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.TemplateImageResolver)


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.