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
Nested ClassesModifier and TypeClassDescriptionstatic classclass -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected Map<String, ContextExtensionFactoryDescriptor> protected static final org.apache.logging.log4j.Loggerstatic final Stringprotected Map<String, OutputFormatDescriptor> static final Stringprotected Map<String, TemplateProcessorDescriptor> protected static final StringFields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContextExtensions(DocumentModel currentDocument, DocumentWrapper wrapper, Map<String, Object> ctx) protected Stringprotected StringbuildTemplateSearchQuery(String targetType) detachTemplateBasedDocument(DocumentModel targetDoc, String templateName, boolean save) Detach a Template from aDocumentModelfindProcessor(Blob templateBlob) Finds theTemplateProcessorfor a givenBlob.protected TemplateProcessorDescriptorfindProcessorByExtension(String extension) protected TemplateProcessorDescriptorfindProcessorDescriptor(Blob templateBlob) findProcessorName(Blob templateBlob) Finds the template processor name for a givenBlob.getAvailableOfficeTemplates(CoreSession session, String targetType) Retrieve theTemplateSourceDocumentthat 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) FindTemplateSourceDocuments that can be bound to a given doc type.getAvailableTemplates(CoreSession session, String targetType) FindTemplateSourceDocuments that can be bound to a given doc type.getDescriptor(String name) Retrieve the DocumentModels using a givenTemplateSourceDocumentgetOutputFormatDescriptor(String outputFormatId) The returnedOutputFormatDescriptorcontains either an operation chain or a mime-type use to convert the output of a rendered document.getProcessor(String name) Get aTemplateProcessorby it's name.Returns all registeredTemplateProcessorsgetTemplateDoc(CoreSession session, String name) Returns a template with a given templateName.Retrieve the Map used for mapping Document Types to Template Names.protected voidmakeTemplateBasedDocument(DocumentModel targetDoc, DocumentModel sourceTemplateDoc, boolean save) Associate aDocumentModelto aTemplateSourceDocument.protected voidvoidUpdate Type2Template Mapping from the data contained in the source DocumentModel.voidstart(ComponentContext context) Start the component.voidstop(ComponentContext context) Stop the component.protected voidprotected <T> List<T> wrap(List<DocumentModel> docs, Class<T> adapter) Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterContribution, unregisterExtensionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
-
processors
-
contextFactories
-
outputFormats
-
type2Template
-
invalidator
-
-
Constructor Details
-
TemplateProcessorComponent
public TemplateProcessorComponent()
-
-
Method Details
-
start
Description copied from interface:ComponentStart the component. This method is called after all the components were resolved and activated- Specified by:
startin interfaceComponent- Overrides:
startin classDefaultComponent
-
stop
Description copied from interface:ComponentStop the component.- Specified by:
stopin interfaceComponent- Overrides:
stopin classDefaultComponent
-
registerInvalidator
protected void registerInvalidator() -
unregisterInvalidator
protected void unregisterInvalidator() -
findProcessor
Description copied from interface:TemplateProcessorServiceFinds theTemplateProcessorfor a givenBlob. The template processor is found based on mime-types.- Specified by:
findProcessorin interfaceTemplateProcessorService- Returns:
- the
TemplateProcessor
-
findProcessorName
Description copied from interface:TemplateProcessorServiceFinds the template processor name for a givenBlob. The template processor is found based on mime-types.- Specified by:
findProcessorNamein interfaceTemplateProcessorService- Returns:
- the
TemplateProcessorname
-
findProcessorDescriptor
-
addContextExtensions
public void addContextExtensions(DocumentModel currentDocument, DocumentWrapper wrapper, Map<String, Object> ctx) - Specified by:
addContextExtensionsin interfaceTemplateProcessorService
-
getReservedContextKeywords
- Specified by:
getReservedContextKeywordsin interfaceTemplateProcessorService
-
getRegistredContextExtensions
- Specified by:
getRegistredContextExtensionsin interfaceTemplateProcessorService
-
findProcessorByMimeType
-
findProcessorByExtension
-
getDescriptor
-
getProcessor
Description copied from interface:TemplateProcessorServiceGet aTemplateProcessorby it's name. Name is defined in the associated descriptor.- Specified by:
getProcessorin interfaceTemplateProcessorService- Returns:
- the
TemplateProcessor
-
buildTemplateSearchQuery
-
buildTemplateSearchByNameQuery
-
getAvailableTemplateDocs
Description copied from interface:TemplateProcessorServiceFindTemplateSourceDocuments that can be bound to a given doc type.- Specified by:
getAvailableTemplateDocsin interfaceTemplateProcessorService- Parameters:
targetType- the target Document Type- Returns:
- List of applicable DocumentModel
-
getTemplateDoc
Description copied from interface:TemplateProcessorServiceReturns a template with a given templateName.- Specified by:
getTemplateDocin interfaceTemplateProcessorService- Parameters:
name- the name of the template
-
wrap
-
getAvailableOfficeTemplates
public List<TemplateSourceDocument> getAvailableOfficeTemplates(CoreSession session, String targetType) Description copied from interface:TemplateProcessorServiceRetrieve theTemplateSourceDocumentthat can be used as an Office template (i.e that support to store the template file as main blob of target DocumentModel)- Specified by:
getAvailableOfficeTemplatesin interfaceTemplateProcessorService
-
getAvailableTemplates
Description copied from interface:TemplateProcessorServiceFindTemplateSourceDocuments that can be bound to a given doc type.- Specified by:
getAvailableTemplatesin interfaceTemplateProcessorService- Parameters:
targetType- the target Document Type- Returns:
- List of applicable
TemplateSourceDocument
-
getLinkedTemplateBasedDocuments
Description copied from interface:TemplateProcessorServiceRetrieve the DocumentModels using a givenTemplateSourceDocument- Specified by:
getLinkedTemplateBasedDocumentsin interfaceTemplateProcessorService- Parameters:
source- theTemplateSourceDocument
-
getRegisteredTemplateProcessors
Description copied from interface:TemplateProcessorServiceReturns all registeredTemplateProcessors- Specified by:
getRegisteredTemplateProcessorsin interfaceTemplateProcessorService- Returns:
- collection of registered
TemplateProcessorDescriptor
-
getTypeMapping
Description copied from interface:TemplateProcessorServiceRetrieve 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:
getTypeMappingin interfaceTemplateProcessorService- Returns:
- the Type2Template mapping
-
registerTypeMapping
Description copied from interface:TemplateProcessorServiceUpdate Type2Template Mapping from the data contained in the source DocumentModel.- Specified by:
registerTypeMappingin interfaceTemplateProcessorService
-
makeTemplateBasedDocument
public DocumentModel makeTemplateBasedDocument(DocumentModel targetDoc, DocumentModel sourceTemplateDoc, boolean save) Description copied from interface:TemplateProcessorServiceAssociate aDocumentModelto aTemplateSourceDocument. If the DocumentModel is not already aTemplateBasedDocument, the associated facet will be automatically added.- Specified by:
makeTemplateBasedDocumentin 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:TemplateProcessorServiceDetach a Template from aDocumentModel- Specified by:
detachTemplateBasedDocumentin 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:
getOutputFormatsin interfaceTemplateProcessorService- Returns:
- the list of registered Ouput formats used to convert output of a rendered document.
-
getOutputFormatDescriptor
Description copied from interface:TemplateProcessorServiceThe returnedOutputFormatDescriptorcontains either an operation chain or a mime-type use to convert the output of a rendered document.- Specified by:
getOutputFormatDescriptorin interfaceTemplateProcessorService- Returns:
OutputFormatDescriptor
-