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 the
TemplateProcessorService
interface- Author:
- Tiry
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
class
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected ContextFactoryRegistry
protected static final org.apache.logging.log4j.Logger
static final String
protected OutputFormatRegistry
static final String
protected TemplateProcessorRegistry
protected static final String
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate
(ComponentContext context) Activates the component.void
addContextExtensions
(DocumentModel currentDocument, DocumentWrapper wrapper, Map<String, Object> ctx) protected String
protected String
buildTemplateSearchQuery
(String targetType) void
deactivate
(ComponentContext context) Deactivates the component.detachTemplateBasedDocument
(DocumentModel targetDoc, String templateName, boolean save) Detach a Template from aDocumentModel
findProcessor
(Blob templateBlob) Finds theTemplateProcessor
for a givenBlob
.protected TemplateProcessorDescriptor
findProcessorByExtension
(String extension) protected TemplateProcessorDescriptor
findProcessorDescriptor
(Blob templateBlob) findProcessorName
(Blob templateBlob) Finds the template processor name for a givenBlob
.getAvailableOfficeTemplates
(CoreSession session, String targetType) 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)getAvailableTemplateDocs
(CoreSession session, String targetType) FindTemplateSourceDocument
s that can be bound to a given doc type.getAvailableTemplates
(CoreSession session, String targetType) FindTemplateSourceDocument
s that can be bound to a given doc type.getDescriptor
(String name) Retrieve the DocumentModels using a givenTemplateSourceDocument
getOutputFormatDescriptor
(String outputFormatId) The returnedOutputFormatDescriptor
contains either an operation chain or a mime-type use to convert the output of a rendered document.getProcessor
(String name) Get aTemplateProcessor
by it's name.Returns all registeredTemplateProcessor
sgetTemplateDoc
(CoreSession session, String name) Returns a template with a given templateName.Retrieve the Map used for mapping Document Types to Template Names.protected void
makeTemplateBasedDocument
(DocumentModel targetDoc, DocumentModel sourceTemplateDoc, boolean save) Associate aDocumentModel
to aTemplateSourceDocument
.void
registerContribution
(Object contribution, String extensionPoint, ComponentInstance contributor) protected void
void
Update Type2Template Mapping from the data contained in the source DocumentModel.void
start
(ComponentContext context) Start the component.void
stop
(ComponentContext context) Stop the component.void
unregisterContribution
(Object contribution, String extensionPoint, ComponentInstance contributor) protected void
protected <T> List<T>
wrap
(List<DocumentModel> docs, Class<T> adapter) 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
getApplicationStartedOrder
-
Field Details
-
log
protected static final org.apache.logging.log4j.Logger log -
PROCESSOR_XP
- See Also:
-
CONTEXT_EXTENSION_XP
- See Also:
-
OUTPUT_FORMAT_EXTENSION_XP
- See Also:
-
TEMPLATE_PROCESSOR_INVAL_PUBSUB_TOPIC
- See Also:
-
contextExtensionRegistry
-
processorRegistry
-
outputFormatRegistry
-
type2Template
-
invalidator
-
-
Constructor Details
-
TemplateProcessorComponent
public TemplateProcessorComponent()
-
-
Method Details
-
activate
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
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
Description copied from interface:Component
Stop the component.- Specified by:
stop
in interfaceComponent
- Overrides:
stop
in classDefaultComponent
- Throws:
InterruptedException
-
deactivate
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
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
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
-
addContextExtensions
public void addContextExtensions(DocumentModel currentDocument, DocumentWrapper wrapper, Map<String, Object> ctx) - Specified by:
addContextExtensions
in interfaceTemplateProcessorService
-
getReservedContextKeywords
- Specified by:
getReservedContextKeywords
in interfaceTemplateProcessorService
-
getRegistredContextExtensions
- Specified by:
getRegistredContextExtensions
in interfaceTemplateProcessorService
-
findProcessorByMimeType
-
findProcessorByExtension
-
getDescriptor
-
getProcessor
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
-
buildTemplateSearchQuery
-
buildTemplateSearchByNameQuery
-
getAvailableTemplateDocs
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
Description copied from interface:TemplateProcessorService
Returns a template with a given templateName.- Specified by:
getTemplateDoc
in interfaceTemplateProcessorService
name
- the name of the template
-
wrap
-
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
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
Description copied from interface:TemplateProcessorService
Retrieve the DocumentModels using a givenTemplateSourceDocument
- Specified by:
getLinkedTemplateBasedDocuments
in interfaceTemplateProcessorService
- Parameters:
source
- theTemplateSourceDocument
-
getRegisteredTemplateProcessors
Description copied from interface:TemplateProcessorService
Returns all registeredTemplateProcessor
s- Specified by:
getRegisteredTemplateProcessors
in interfaceTemplateProcessorService
- Returns:
- collection of registered
TemplateProcessorDescriptor
-
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
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
- Specified by:
getOutputFormats
in interfaceTemplateProcessorService
- Returns:
- the list of registered Ouput formats used to convert output of a rendered document.
-
getOutputFormatDescriptor
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
-