Class ConversionServiceImpl
java.lang.Object
org.nuxeo.runtime.model.DefaultComponent
org.nuxeo.ecm.core.convert.service.ConversionServiceImpl
- All Implemented Interfaces:
ConversionService,Adaptable,Component,Extensible,TimestampedService
Runtime Component that also provides the POJO implementation of the
ConversionService.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<String, ConverterCheckResult> static final Stringstatic final Stringprotected final Map<String, ConverterDescriptor> static final Stringprotected ScheduledExecutorServiceprotected final MimeTypeTranslationHelperFields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(ComponentContext context) Activates the component.protected voidadjustBlobName(String filename, BlobHolder blobHolder, String mimeType) protected voidadjustBlobName(String filename, Blob blob, String mimeType) convert(String converterName, BlobHolder blobHolder, Map<String, Serializable> parameters) Converts a Blob given a converter name.protected BlobHolderconvertBlobToMimeType(BlobHolder bh, String destinationMimeType) protected BlobHolderconvertThroughHTML(BlobHolder blobHolder, String destMimeType) convertToMimeType(String destinationMimeType, BlobHolder blobHolder, Map<String, Serializable> parameters) Converts a Blob given a target destination MimeType.voiddeactivate(ComponentContext context) Deactivates the component.voidendGC()<T> TgetAdapter(Class<T> adapter) Returns an object which is an instance of the given class associated with this object.static StringDeprecated, for removal: This API element is subject to removal in a future version.getConversionResult(String id, boolean cleanTransientStoreEntry) Returns the conversion result for the givenidif any,nullotherwise.Returns the status of a scheduled conversion given itsid, ornullif no conversion scheduled.protected ConvertCacheDescriptorstatic Pathstatic ConvertergetConverter(String converterName) static ConverterDescriptorgetConverterDescriptor(String converterName) getConverterName(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Returns the converter name for the givensourceMimeTypeanddestinationMimeType.getConverterNames(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Returns the list of converter names handling the givensourceMimeTypeanddestinationMimeType.static longDeprecated, for removal: This API element is subject to removal in a future version.since 2025.0, not used anymorestatic intDeprecated, for removal: This API element is subject to removal in a future version.since 2025.0, not used anymoreReturns the names of the registered converters.protected booleanhasSourceMimeType(ConverterDescriptor converterDescriptor, String mimeType) Returns true if the converter has the givenmimeTypeas source mime type, false otherwise.static booleanDeprecated, for removal: This API element is subject to removal in a future version.since 2025.0, not used anymoreisConverterAvailable(String converterName) Checks for converter availability.isConverterAvailable(String converterName, boolean refresh) Checks for converter availability.booleanisSourceMimeTypeSupported(String converterName, String sourceMimeType) Returns true if the converter supports the givensourceMimeType, false otherwise.voidregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) Component implementation.static voidprotected static BlobReplace the image URLs of an HTML blob by absolute local paths.scheduleConversion(String converterName, BlobHolder blobHolder, Map<String, Serializable> parameters) Schedules a conversion given a converter name.scheduleConversionToMimeType(String destinationMimeType, BlobHolder blobHolder, Map<String, Serializable> parameters) Schedules a conversion given a target mime type.static voidsetGCIntervalInMinutes(long interval) Deprecated, for removal: This API element is subject to removal in a future version.since 2025.0, such setting should be done with contributionstatic voidsetMaxCacheSizeInKB(int size) Deprecated, for removal: This API element is subject to removal in a future version.since 2025.0, such setting should be done with contributionvoidstart(ComponentContext context) Start the component.protected voidstartGC(ConvertCacheDescriptor cacheDescriptor) voidstop(ComponentContext context) Stop the component.voidunregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) protected voidupdateResultBlobFileName(BlobHolder srcBh, BlobHolder resultBh) protected voidupdateResultBlobMimeType(BlobHolder resultBh, ConverterDescriptor desc) Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
addRuntimeMessage, addRuntimeMessage, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, unregister, 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
getApplicationStartedOrderMethods inherited from interface org.nuxeo.ecm.core.convert.api.ConversionService
getConverterName, getConverterNames
-
Field Details
-
CONVERTER_EP
- See Also:
-
CONFIG_EP
- See Also:
-
ENFORCE_SOURCE_MIME_TYPE_CHECK
- Since:
- 10.3
- See Also:
-
converterDescriptors
-
translationHelper
-
gcExecutor
- Since:
- 2025.0
-
checkResultCache
-
-
Constructor Details
-
ConversionServiceImpl
public ConversionServiceImpl()
-
-
Method Details
-
activate
Description copied from interface:ComponentActivates the component.This method is called by the runtime when a component is activated.
- Specified by:
activatein interfaceComponent- Overrides:
activatein classDefaultComponent- Parameters:
context- the runtime context
-
deactivate
Description copied from interface:ComponentDeactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivatein interfaceComponent- Overrides:
deactivatein classDefaultComponent- Parameters:
context- the runtime context
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) Component implementation.- Overrides:
registerContributionin classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
unregisterContributionin classDefaultComponent
-
getConvertCacheDescriptor
-
getConverter
-
getConverterDescriptor
-
getGCIntervalInMinutes
Deprecated, for removal: This API element is subject to removal in a future version.since 2025.0, not used anymore -
setGCIntervalInMinutes
@Deprecated(since="2025.0", forRemoval=true) public static void setGCIntervalInMinutes(long interval) Deprecated, for removal: This API element is subject to removal in a future version.since 2025.0, such setting should be done with contribution -
registerConverter
-
getMaxCacheSizeInKB
Deprecated, for removal: This API element is subject to removal in a future version.since 2025.0, not used anymore -
setMaxCacheSizeInKB
Deprecated, for removal: This API element is subject to removal in a future version.since 2025.0, such setting should be done with contribution -
isCacheEnabled
Deprecated, for removal: This API element is subject to removal in a future version.since 2025.0, not used anymore -
getCacheBasePath
Deprecated, for removal: This API element is subject to removal in a future version.since 2025.0, usegetConvertCacheDirectory()instead -
getConvertCacheDirectory
- Since:
- 2025.0
-
getRegistredConverters
Description copied from interface:ConversionServiceReturns the names of the registered converters.- Specified by:
getRegistredConvertersin interfaceConversionService
-
convertThroughHTML
-
convertBlobToMimeType
-
adjustBlobName
-
adjustBlobName
-
replaceURLsByAbsolutePaths
protected static Blob replaceURLsByAbsolutePaths(Blob blob, Path tempDirectory, Function<String, Blob> blobResolver) throws IOExceptionReplace the image URLs of an HTML blob by absolute local paths.- Throws:
IOException- Since:
- 9.1
-
convert
public BlobHolder convert(String converterName, BlobHolder blobHolder, Map<String, Serializable> parameters) throws ConversionExceptionDescription copied from interface:ConversionServiceConverts a Blob given a converter name.- Specified by:
convertin interfaceConversionService- Throws:
ConversionException
-
hasSourceMimeType
Returns true if the converter has the givenmimeTypeas source mime type, false otherwise.- Since:
- 10.3
-
updateResultBlobMimeType
-
updateResultBlobFileName
-
convertToMimeType
public BlobHolder convertToMimeType(String destinationMimeType, BlobHolder blobHolder, Map<String, Serializable> parameters) throws ConversionExceptionDescription copied from interface:ConversionServiceConverts a Blob given a target destination MimeType.- Specified by:
convertToMimeTypein interfaceConversionService- Throws:
ConversionException
-
getConverterNames
public List<String> getConverterNames(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Description copied from interface:ConversionServiceReturns the list of converter names handling the givensourceMimeTypeanddestinationMimeType.Finds the converter names based on the following algorithm:
- Find the converters exactly matching the given
sourceMimeType - If no converter found, find the converters matching a wildcard subtype based on the
sourceMimeType, such has "image/*" - If no converter found and
allowWildcardistrue, find the converters matching a wildcard source mime type "*" - Then, filter only the converters matching the given
destinationMimeType
- Specified by:
getConverterNamesin interfaceConversionService- Parameters:
allowWildcard-trueto allow returning converters with '*' as source mime type.
- Find the converters exactly matching the given
-
getConverterName
public String getConverterName(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Description copied from interface:ConversionServiceReturns the converter name for the givensourceMimeTypeanddestinationMimeType.Follows the algorithm of
ConversionService.getConverterNames(String, String, boolean).- Specified by:
getConverterNamein interfaceConversionService- See Also:
-
isConverterAvailable
Description copied from interface:ConversionServiceChecks for converter availability.Result can be:
ConverterNotRegisteredif converter is not registered.- Error Message / Installation message if converter dependencies are not available an successful check.
Result can be taken from an internal cache.
- Specified by:
isConverterAvailablein interfaceConversionService- Throws:
ConversionException
-
isConverterAvailable
public ConverterCheckResult isConverterAvailable(String converterName, boolean refresh) throws ConverterNotRegistered Description copied from interface:ConversionServiceChecks for converter availability.Result can be:
ConverterNotRegisteredif converter is not registered.- Error Message / Installation message if converter dependencies are not available an successful check.
- Specified by:
isConverterAvailablein interfaceConversionService- Throws:
ConverterNotRegistered
-
isSourceMimeTypeSupported
Description copied from interface:ConversionServiceReturns true if the converter supports the givensourceMimeType, false otherwise.- Specified by:
isSourceMimeTypeSupportedin interfaceConversionService
-
scheduleConversion
public String scheduleConversion(String converterName, BlobHolder blobHolder, Map<String, Serializable> parameters) Description copied from interface:ConversionServiceSchedules a conversion given a converter name.Returns a conversion id to be used by
ConversionService.getConversionResult(String, boolean).- Specified by:
scheduleConversionin interfaceConversionService
-
scheduleConversionToMimeType
public String scheduleConversionToMimeType(String destinationMimeType, BlobHolder blobHolder, Map<String, Serializable> parameters) Description copied from interface:ConversionServiceSchedules a conversion given a target mime type.Returns a conversion id to be used by
ConversionService.getConversionResult(String, boolean).- Specified by:
scheduleConversionToMimeTypein interfaceConversionService
-
getConversionStatus
Description copied from interface:ConversionServiceReturns the status of a scheduled conversion given itsid, ornullif no conversion scheduled.- Specified by:
getConversionStatusin interfaceConversionService
-
getConversionResult
Description copied from interface:ConversionServiceReturns the conversion result for the givenidif any,nullotherwise.- Specified by:
getConversionResultin interfaceConversionService
-
getAdapter
Description copied from interface:AdaptableReturns an object which is an instance of the given class associated with this object. Returnsnullif no such object can be found.- Specified by:
getAdapterin interfaceAdaptable- Overrides:
getAdapterin classDefaultComponent- Parameters:
adapter- the adapter class to look up- Returns:
- a object castable to the given class, or
nullif this object does not have an adapter for the given class
-
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
-
startGC
-
endGC
public void endGC()
-
getConvertCacheDirectory()instead