Package org.nuxeo.template.service
Class TemplateProcessorComponent
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.template.service.TemplateProcessorComponent
-
- All Implemented Interfaces:
Adaptable
,Component
,Extensible
,TimestampedService
,TemplateProcessorService
public class TemplateProcessorComponent extends DefaultComponent implements TemplateProcessorService
Runtime Component used to handle Extension Points and expose theTemplateProcessorService
interface- Author:
- Tiry
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TemplateProcessorComponent.TemplateProcessorInvalidation
class
TemplateProcessorComponent.TemplateProcessorInvalidator
-
Field Summary
Fields Modifier and Type Field Description static String
CONTEXT_EXTENSION_XP
protected ContextFactoryRegistry
contextExtensionRegistry
protected TemplateProcessorComponent.TemplateProcessorInvalidator
invalidator
protected static org.apache.logging.log4j.Logger
log
static String
OUTPUT_FORMAT_EXTENSION_XP
protected OutputFormatRegistry
outputFormatRegistry
static String
PROCESSOR_XP
protected TemplateProcessorRegistry
processorRegistry
protected static String
TEMPLATE_PROCESSOR_INVAL_PUBSUB_TOPIC
protected Map<String,List<String>>
type2Template
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description TemplateProcessorComponent()
-
Method Summary
-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
addRuntimeMessage, addRuntimeMessage, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
log
protected static final org.apache.logging.log4j.Logger log
-
PROCESSOR_XP
public static final String PROCESSOR_XP
- See Also:
- Constant Field Values
-
CONTEXT_EXTENSION_XP
public static final String CONTEXT_EXTENSION_XP
- See Also:
- Constant Field Values
-
OUTPUT_FORMAT_EXTENSION_XP
public static final String OUTPUT_FORMAT_EXTENSION_XP
- See Also:
- Constant Field Values
-
TEMPLATE_PROCESSOR_INVAL_PUBSUB_TOPIC
protected static final String TEMPLATE_PROCESSOR_INVAL_PUBSUB_TOPIC
- See Also:
- Constant Field Values
-
contextExtensionRegistry
protected ContextFactoryRegistry contextExtensionRegistry
-
processorRegistry
protected TemplateProcessorRegistry processorRegistry
-
outputFormatRegistry
protected OutputFormatRegistry outputFormatRegistry
-
invalidator
protected TemplateProcessorComponent.TemplateProcessorInvalidator invalidator
-
-
Method Detail
-
activate
public void activate(ComponentContext context)
Description copied from interface:Component
Activates the component.This method is called by the runtime when a component is activated.
- Specified by:
activate
in interfaceComponent
- Overrides:
activate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
start
public void start(ComponentContext context)
Description copied from interface:Component
Start the component. This method is called after all the components were resolved and activated- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
stop
public void stop(ComponentContext context) throws InterruptedException
Description copied from interface:Component
Stop the component.- Specified by:
stop
in interfaceComponent
- Overrides:
stop
in classDefaultComponent
- Throws:
InterruptedException
-
deactivate
public void deactivate(ComponentContext context)
Description copied from interface:Component
Deactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivate
in interfaceComponent
- Overrides:
deactivate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
registerInvalidator
protected void registerInvalidator()
-
unregisterInvalidator
protected void unregisterInvalidator()
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
registerContribution
in classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
unregisterContribution
in classDefaultComponent
-
findProcessor
public TemplateProcessor findProcessor(Blob templateBlob)
Description copied from interface:TemplateProcessorService
Finds theTemplateProcessor
for a givenBlob
. The template processor is found based on mime-types.- Specified by:
findProcessor
in interfaceTemplateProcessorService
- Returns:
- the
TemplateProcessor
-
findProcessorName
public String findProcessorName(Blob templateBlob)
Description copied from interface:TemplateProcessorService
Finds the template processor name for a givenBlob
. The template processor is found based on mime-types.- Specified by:
findProcessorName
in interfaceTemplateProcessorService
- Returns:
- the
TemplateProcessor
name
-
findProcessorDescriptor
public TemplateProcessorDescriptor findProcessorDescriptor(Blob templateBlob)
-
addContextExtensions
public void addContextExtensions(DocumentModel currentDocument, DocumentWrapper wrapper, Map<String,Object> ctx)
- Specified by:
addContextExtensions
in interfaceTemplateProcessorService
-
getReservedContextKeywords
public List<String> getReservedContextKeywords()
- Specified by:
getReservedContextKeywords
in interfaceTemplateProcessorService
-
getRegistredContextExtensions
public Map<String,ContextExtensionFactoryDescriptor> getRegistredContextExtensions()
- Specified by:
getRegistredContextExtensions
in interfaceTemplateProcessorService
-
findProcessorByMimeType
protected TemplateProcessorDescriptor findProcessorByMimeType(String mt)
-
findProcessorByExtension
protected TemplateProcessorDescriptor findProcessorByExtension(String extension)
-
getDescriptor
public TemplateProcessorDescriptor getDescriptor(String name)
-
getProcessor
public TemplateProcessor getProcessor(String name)
Description copied from interface:TemplateProcessorService
Get aTemplateProcessor
by it's name. Name is defined in the associated descriptor.- Specified by:
getProcessor
in interfaceTemplateProcessorService
- Returns:
- the
TemplateProcessor
-
getAvailableTemplateDocs
public List<DocumentModel> getAvailableTemplateDocs(CoreSession session, String targetType)
Description copied from interface:TemplateProcessorService
FindTemplateSourceDocument
s that can be bound to a given doc type.- Specified by:
getAvailableTemplateDocs
in interfaceTemplateProcessorService
targetType
- the target Document Type- Returns:
- List of applicable DocumentModel
-
getTemplateDoc
public DocumentModel getTemplateDoc(CoreSession session, String name)
Description copied from interface:TemplateProcessorService
Returns a template with a given templateName.- Specified by:
getTemplateDoc
in interfaceTemplateProcessorService
name
- the name of the template
-
wrap
protected <T> List<T> wrap(List<DocumentModel> docs, Class<T> adapter)
-
getAvailableOfficeTemplates
public List<TemplateSourceDocument> getAvailableOfficeTemplates(CoreSession session, String targetType)
Description copied from interface:TemplateProcessorService
Retrieve theTemplateSourceDocument
that can be used as an Office template (i.e that support to store the template file as main blob of target DocumentModel)- Specified by:
getAvailableOfficeTemplates
in interfaceTemplateProcessorService
-
getAvailableTemplates
public List<TemplateSourceDocument> getAvailableTemplates(CoreSession session, String targetType)
Description copied from interface:TemplateProcessorService
FindTemplateSourceDocument
s that can be bound to a given doc type.- Specified by:
getAvailableTemplates
in interfaceTemplateProcessorService
targetType
- the target Document Type- Returns:
- List of applicable
TemplateSourceDocument
-
getLinkedTemplateBasedDocuments
public List<TemplateBasedDocument> getLinkedTemplateBasedDocuments(DocumentModel source)
Description copied from interface:TemplateProcessorService
Retrieve the DocumentModels using a givenTemplateSourceDocument
- Specified by:
getLinkedTemplateBasedDocuments
in interfaceTemplateProcessorService
- Parameters:
source
- theTemplateSourceDocument
-
getRegisteredTemplateProcessors
public Collection<TemplateProcessorDescriptor> getRegisteredTemplateProcessors()
Description copied from interface:TemplateProcessorService
Returns all registeredTemplateProcessor
s- Specified by:
getRegisteredTemplateProcessors
in interfaceTemplateProcessorService
- Returns:
- collection of registered
TemplateProcessorDescriptor
-
getTypeMapping
public Map<String,List<String>> getTypeMapping()
Description copied from interface:TemplateProcessorService
Retrieve the Map used for mapping Document Types to Template Names. This Map represent the Templates that must be automatically bound at creation time for each Document Type.- Specified by:
getTypeMapping
in interfaceTemplateProcessorService
- Returns:
- the Type2Template mapping
-
registerTypeMapping
public void registerTypeMapping(DocumentModel doc)
Description copied from interface:TemplateProcessorService
Update Type2Template Mapping from the data contained in the source DocumentModel.- Specified by:
registerTypeMapping
in interfaceTemplateProcessorService
-
makeTemplateBasedDocument
public DocumentModel makeTemplateBasedDocument(DocumentModel targetDoc, DocumentModel sourceTemplateDoc, boolean save)
Description copied from interface:TemplateProcessorService
Associate aDocumentModel
to aTemplateSourceDocument
. If the DocumentModel is not already aTemplateBasedDocument
, the associated facet will be automatically added.- Specified by:
makeTemplateBasedDocument
in interfaceTemplateProcessorService
- Parameters:
targetDoc
- the DocumentModel to associate to a templatesourceTemplateDoc
- the DocumentModel holding the templatesave
- flag to indicate if target DocumentModel must be saved or not- Returns:
- the updated DocumentModel
-
detachTemplateBasedDocument
public DocumentModel detachTemplateBasedDocument(DocumentModel targetDoc, String templateName, boolean save)
Description copied from interface:TemplateProcessorService
Detach a Template from aDocumentModel
- Specified by:
detachTemplateBasedDocument
in interfaceTemplateProcessorService
- Parameters:
targetDoc
- the DocumentModel to detachtemplateName
- the name of the template to detachsave
- save flag to indicate if target DocumentModel must be saved or not- Returns:
- the updated DocumentModel
-
invalidateTypeMapping
protected void invalidateTypeMapping()
-
getOutputFormats
public Collection<OutputFormatDescriptor> getOutputFormats()
- Specified by:
getOutputFormats
in interfaceTemplateProcessorService
- Returns:
- the list of registered Ouput formats used to convert output of a rendered document.
-
getOutputFormatDescriptor
public OutputFormatDescriptor getOutputFormatDescriptor(String outputFormatId)
Description copied from interface:TemplateProcessorService
The returnedOutputFormatDescriptor
contains either an operation chain or a mime-type use to convert the output of a rendered document.- Specified by:
getOutputFormatDescriptor
in interfaceTemplateProcessorService
- Returns:
OutputFormatDescriptor
-
-