Class FreeMarkerProcessor
- All Implemented Interfaces:
TemplateProcessor
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringDefault maximum content size for MIME type detection (8 KiB).protected FMContextBuilderprotected FreemarkerEngineprotected static final StringProperty to configure the maximum content size (in bytes) used for MIME type detection.protected static final PatternPattern to detect HTML content by looking for HTML start tag or DOCTYPE declaration at the beginning of the content.protected static final PatternDeprecated, for removal: This API element is subject to removal in a future version.protected freemarker.cache.StringTemplateLoaderprotected static final PatternFields inherited from class org.nuxeo.template.processors.AbstractTemplateProcessor
BUFFER_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected FreemarkerEngineExtract parameters from the Template file.protected StringgetTruncatedContent(Blob result) Extracts content from the blob for MIME type detection, limiting it to a configurable maximum size to avoid performance issues with large files.protected StringguessMimeType(Blob result, MimetypeRegistry mreg) renderTemplate(TemplateBasedDocument templateBasedDocument, String templateName) Perform rendering of the named template against theTemplateBasedDocumentprotected voidsetBlobAttributes(Blob result, TemplateBasedDocument templateBasedDocument) Methods inherited from class org.nuxeo.template.processors.AbstractTemplateProcessor
getSourceTemplateBlob, getWorkingDir
-
Field Details
-
GUESS_MIMETYPE_MAX_SIZE_PROP
Property to configure the maximum content size (in bytes) used for MIME type detection.Accepts size notation like "8KiB", "1MB", etc. using
ByteSize.parse(String).- Since:
- 2025.17
- See Also:
-
DEFAULT_GUESS_MIMETYPE_MAX_SIZE
Default maximum content size for MIME type detection (8 KiB).- Since:
- 2025.17
- See Also:
-
loader
protected freemarker.cache.StringTemplateLoader loader -
fmEngine
-
fmContextBuilder
-
XMLStartPattern
-
HtmlTagPattern
Deprecated, for removal: This API element is subject to removal in a future version.since 2025.17, useHtmlStartPatterninsteadPattern to detect HTML content by matching opening and closing tag pairs.This pattern is deprecated because it requires finding complete tag pairs, which may not work reliably with truncated content where closing tags might be cut off.
-
HtmlStartPattern
Pattern to detect HTML content by looking for HTML start tag or DOCTYPE declaration at the beginning of the content.Anchored to the start of the content (optionally allowing leading whitespace) to avoid false positives from
<html>occurrences in the middle of the content. Uses prefix-based matching to work reliably with truncated content, avoiding the need to find matching opening/closing tag pairs which may be split by truncation.- Since:
- 2025.17
-
-
Constructor Details
-
FreeMarkerProcessor
public FreeMarkerProcessor()
-
-
Method Details
-
getEngine
-
guessMimeType
-
getTruncatedContent
Extracts content from the blob for MIME type detection, limiting it to a configurable maximum size to avoid performance issues with large files.The content is read from the blob's input stream and limited to the configured maximum size using
BoundedInputStream. This prevents loading entire large files into memory when only a small portion is needed for MIME type pattern matching.The blob's encoding is used for reading the content, defaulting to UTF-8 if no encoding is specified.
If the configured maximum size is unlimited (
-1), the entire content will be read without truncation.- Parameters:
result- the blob to extract content from- Returns:
- the content string, truncated if the blob is larger than the configured maximum size, or
nullif the blob isnull - Since:
- 2025.17
-
setBlobAttributes
-
renderTemplate
public Blob renderTemplate(TemplateBasedDocument templateBasedDocument, String templateName) throws IOException Description copied from interface:TemplateProcessorPerform rendering of the named template against theTemplateBasedDocument- Specified by:
renderTemplatein interfaceTemplateProcessor- Throws:
IOException
-
getInitialParametersDefinition
Description copied from interface:TemplateProcessorExtract parameters from the Template file.- Specified by:
getInitialParametersDefinitionin interfaceTemplateProcessor- Returns:
- List of parameters for this template
- Throws:
IOException
-
HtmlStartPatterninstead