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 SummaryFieldsModifier and TypeFieldDescriptionprotected final Map<String,ConverterCheckResult> protected final GlobalConfigDescriptorstatic final Stringstatic final Stringprotected final Map<String,ConverterDescriptor> static final Stringprotected GCTaskprotected Threadprotected final MimeTypeTranslationHelperFields inherited from class org.nuxeo.runtime.model.DefaultComponentlastModified, name
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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 StringgetConversionResult(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.static 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 longstatic intReturns 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 booleanisConverterAvailable(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) static voidsetMaxCacheSizeInKB(int size) voidstart(ComponentContext context) Start the component.protected voidstartGC()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.DefaultComponentaddRuntimeMessage, addRuntimeMessage, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterExtensionMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.runtime.model.ComponentgetApplicationStartedOrderMethods inherited from interface org.nuxeo.ecm.core.convert.api.ConversionServicegetConverterName, getConverterNames
- 
Field Details- 
CONVERTER_EP- See Also:
 
- 
CONFIG_EP- See Also:
 
- 
ENFORCE_SOURCE_MIME_TYPE_CHECK- Since:
- 10.3
- See Also:
 
- 
converterDescriptors
- 
translationHelper
- 
config
- 
gcThread
- 
gcTask
- 
checkResultCache
 
- 
- 
Constructor Details- 
ConversionServiceImplpublic ConversionServiceImpl()
 
- 
- 
Method Details- 
activateDescription copied from interface:ComponentActivates the component.This method is called by the runtime when a component is activated. - Specified by:
- activatein interface- Component
- Overrides:
- activatein class- DefaultComponent
- Parameters:
- context- the runtime context
 
- 
deactivateDescription copied from interface:ComponentDeactivates the component.This method is called by the runtime when a component is deactivated. - Specified by:
- deactivatein interface- Component
- Overrides:
- deactivatein class- DefaultComponent
- Parameters:
- context- the runtime context
 
- 
registerContributionpublic void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) Component implementation.- Overrides:
- registerContributionin class- DefaultComponent
 
- 
unregisterContributionpublic void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
- unregisterContributionin class- DefaultComponent
 
- 
getConverter
- 
getConverterDescriptor
- 
getGCIntervalInMinutespublic static long getGCIntervalInMinutes()
- 
setGCIntervalInMinutespublic static void setGCIntervalInMinutes(long interval) 
- 
registerConverter
- 
getMaxCacheSizeInKBpublic static int getMaxCacheSizeInKB()
- 
setMaxCacheSizeInKBpublic static void setMaxCacheSizeInKB(int size) 
- 
isCacheEnabledpublic static boolean isCacheEnabled()
- 
getCacheBasePath
- 
getRegistredConvertersDescription copied from interface:ConversionServiceReturns the names of the registered converters.- Specified by:
- getRegistredConvertersin interface- ConversionService
 
- 
convertThroughHTML
- 
convertBlobToMimeType
- 
adjustBlobName
- 
adjustBlobName
- 
replaceURLsByAbsolutePathsprotected 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
 
- 
convertpublic 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 interface- ConversionService
- Throws:
- ConversionException
 
- 
hasSourceMimeTypeReturns true if the converter has the givenmimeTypeas source mime type, false otherwise.- Since:
- 10.3
 
- 
updateResultBlobMimeType
- 
updateResultBlobFileName
- 
convertToMimeTypepublic 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 interface- ConversionService
- Throws:
- ConversionException
 
- 
getConverterNamespublic 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 interface- ConversionService
- allowWildcard-- trueto allow returning converters with '*' as source mime type.
 
- Find the converters exactly matching the given 
- 
getConverterNamepublic 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 interface- ConversionService
- See Also:
 
- 
isConverterAvailableDescription 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 interface- ConversionService
- Throws:
- ConversionException
 
- 
isConverterAvailablepublic 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 interface- ConversionService
- Throws:
- ConverterNotRegistered
 
- 
isSourceMimeTypeSupportedDescription copied from interface:ConversionServiceReturns true if the converter supports the givensourceMimeType, false otherwise.- Specified by:
- isSourceMimeTypeSupportedin interface- ConversionService
 
- 
scheduleConversionpublic 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 interface- ConversionService
 
- 
scheduleConversionToMimeTypepublic 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 interface- ConversionService
 
- 
getConversionStatusDescription copied from interface:ConversionServiceReturns the status of a scheduled conversion given itsid, ornullif no conversion scheduled.- Specified by:
- getConversionStatusin interface- ConversionService
 
- 
getConversionResultDescription copied from interface:ConversionServiceReturns the conversion result for the givenidif any,nullotherwise.- Specified by:
- getConversionResultin interface- ConversionService
 
- 
getAdapterDescription 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 interface- Adaptable
- Overrides:
- getAdapterin class- DefaultComponent
- 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
 
- 
startDescription copied from interface:ComponentStart the component. This method is called after all the components were resolved and activated- Specified by:
- startin interface- Component
- Overrides:
- startin class- DefaultComponent
 
- 
stopDescription copied from interface:ComponentStop the component.- Specified by:
- stopin interface- Component
- Overrides:
- stopin class- DefaultComponent
 
- 
startGCprotected void startGC()
- 
endGCpublic void endGC()
 
-