Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

org.alfresco.service.cmr.repository
Interface TemplateService

public interface TemplateService
Template Service.

Provides an interface to services for executing template engine against a template file and data model.

The service provides a configured list of available template engines. The template file can either be in the repository (passed as NodeRef string) or on the classpath. Also a template can be passed directly as a String using the processTemplateString() methods.

The data model is specified to the template engine. The FreeMarker template engine is used by default.

Author:
Kevin Roast

Field Summary
KEY_COMPANY_HOME
KEY_DATE
KEY_IMAGE_RESOLVER
          Keys for default model values
KEY_PERSON
KEY_PRODUCT_NAME
KEY_SHARE_URL
KEY_TEMPLATE
KEY_USER_HOME
Method Summary
buildDefaultModel(NodeRef person, NodeRef companyHome, NodeRef userHome, NodeRef template, TemplateImageResolver imageResolver)
          Helper method to build a default model
org.alfresco.service.cmr.repository.TemplateProcessor
getTemplateProcessor(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.
void
processTemplate(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.
processTemplate(String engine, String templateRef, Object model, Locale locale)
          Process a template using the supplied locale against the supplied data model and write to the out.
void
processTemplate(String engine, String template, Object model, Writer out)
          Process a template 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 String
void
processTemplateString(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.
void
registerTemplateProcessor(org.alfresco.service.cmr.repository.TemplateProcessor templateProcessor)
          Registers a new template processor with the template service
Field Detail
KEY_COMPANY_HOME
public static final String KEY_COMPANY_HOME
See Also:
Constant Field Values

KEY_DATE
public static final String KEY_DATE
See Also:
Constant Field Values

KEY_IMAGE_RESOLVER
public static final String KEY_IMAGE_RESOLVER
Keys for default model values
See Also:
Constant Field Values

KEY_PERSON
public static final String KEY_PERSON
See Also:
Constant Field Values

KEY_PRODUCT_NAME
public static final String KEY_PRODUCT_NAME
See Also:
Constant Field Values

KEY_SHARE_URL
public static final String KEY_SHARE_URL
See Also:
Constant Field Values

KEY_TEMPLATE
public static final String KEY_TEMPLATE
See Also:
Constant Field Values

KEY_USER_HOME
public static final String KEY_USER_HOME
See Also:
Constant Field Values
Method Detail
processTemplate
@Auditable(parameters={
  "template",
  "model"
})
String processTemplate(String template,
                       Object model)
                throws org.alfresco.service.cmr.repository.TemplateException
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.
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:
org.alfresco.service.cmr.repository.TemplateException

processTemplate
@Auditable(parameters={
  "template",
  "model",
  "out"
})
void processTemplate(String template,
                     Object model,
                     Writer out)
              throws org.alfresco.service.cmr.repository.TemplateException
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.
Parameters:
template - Template (qualified classpath name or noderef)
model - Object model to process template against
out - Writer object to send output too
Throws:
org.alfresco.service.cmr.repository.TemplateException

processTemplate
@Auditable(parameters={
  "engine",
  "template",
  "model"
})
String processTemplate(String engine,
                       String template,
                       Object model)
                throws org.alfresco.service.cmr.repository.TemplateException
Process a template against the supplied data model and write to the out.
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:
org.alfresco.service.cmr.repository.TemplateException

processTemplate
@Auditable(parameters={
  "engine",
  "template",
  "model",
  "out"
})
void processTemplate(String engine,
                     String template,
                     Object model,
                     Writer out)
              throws org.alfresco.service.cmr.repository.TemplateException
Process a template against the supplied data model and write to the out.
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:
org.alfresco.service.cmr.repository.TemplateException

processTemplate
@Auditable(parameters={
  "engine",
  "template",
  "model",
  "out",
  "locale"
})
String processTemplate(String engine,
                       String templateRef,
                       Object model,
                       Locale locale)
                throws org.alfresco.service.cmr.repository.TemplateException
Process a template using the supplied locale against the supplied data model and write to the out.
Parameters:
engine - Name of the template engine to use
templateRef - Template ref (qualified classpath name or noderef)
model - Object model to process template against
locale - Locale to process the template as
Throws:
org.alfresco.service.cmr.repository.TemplateException

processTemplateString
@Auditable(parameters={
  "engine",
  "template",
  "model"
})
String processTemplateString(String engine,
                             String template,
                             Object model)
                      throws org.alfresco.service.cmr.repository.TemplateException
Process a given template, provided as a string, against the supplied data model and return the result as a String
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:
org.alfresco.service.cmr.repository.TemplateException

processTemplateString
@Auditable(parameters={
  "engine",
  "template",
  "model",
  "out"
})
void processTemplateString(String engine,
                           String template,
                           Object model,
                           Writer out)
                    throws org.alfresco.service.cmr.repository.TemplateException
Process a given template, provided as a string, against the supplied data model and report the result back in the provided writer.
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:
org.alfresco.service.cmr.repository.TemplateException

getTemplateProcessor
@Auditable(parameters="engine")
org.alfresco.service.cmr.repository.TemplateProcessor getTemplateProcessor(String engine)
Return a TemplateProcessor instance for the specified engine name. Note that the processor instance is NOT thread safe!
Parameters:
engine - Name of the template engine to get or null for default
Returns:
TemplateProcessor

registerTemplateProcessor
@Auditable(parameters="templateProcessor")
void registerTemplateProcessor(org.alfresco.service.cmr.repository.TemplateProcessor templateProcessor)
Registers a new template processor with the template service
Parameters:
templateProcessor - the template processor to register

buildDefaultModel
@Auditable(parameters={
  "person",
  "companyHome",
  "userHome",
  "template",
  "imageResolver"
})
Map<String,ObjectbuildDefaultModel(NodeRef person,
                                     NodeRef companyHome,
                                     NodeRef userHome,
                                     NodeRef template,
                                     TemplateImageResolver imageResolver)
Helper method to build a default model
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:
Map

Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005–2016 Alfresco Software. All rights reserved.

Java API documentation generated with DocFlex/Javadoc 1.6.1 using JavadocPro template set.