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
Modifier and TypeFieldDescriptionprotected final Map<String,
ConverterCheckResult> protected final GlobalConfigDescriptor
static final String
static final String
protected final Map<String,
ConverterDescriptor> static final String
protected GCTask
protected Thread
protected final MimeTypeTranslationHelper
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate
(ComponentContext context) Activates the component.protected void
adjustBlobName
(String filename, BlobHolder blobHolder, String mimeType) protected void
adjustBlobName
(String filename, Blob blob, String mimeType) convert
(String converterName, BlobHolder blobHolder, Map<String, Serializable> parameters) Converts a Blob given a converter name.protected BlobHolder
convertBlobToMimeType
(BlobHolder bh, String destinationMimeType) protected BlobHolder
convertThroughHTML
(BlobHolder blobHolder, String destMimeType) convertToMimeType
(String destinationMimeType, BlobHolder blobHolder, Map<String, Serializable> parameters) Converts a Blob given a target destination MimeType.void
deactivate
(ComponentContext context) Deactivates the component.void
endGC()
<T> T
getAdapter
(Class<T> adapter) Returns an object which is an instance of the given class associated with this object.static String
getConversionResult
(String id, boolean cleanTransientStoreEntry) Returns the conversion result for the givenid
if any,null
otherwise.Returns the status of a scheduled conversion given itsid
, ornull
if no conversion scheduled.static Converter
getConverter
(String converterName) static ConverterDescriptor
getConverterDescriptor
(String converterName) getConverterName
(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Returns the converter name for the givensourceMimeType
anddestinationMimeType
.getConverterNames
(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Returns the list of converter names handling the givensourceMimeType
anddestinationMimeType
.static long
static int
Returns the names of the registered converters.protected boolean
hasSourceMimeType
(ConverterDescriptor converterDescriptor, String mimeType) Returns true if the converter has the givenmimeType
as source mime type, false otherwise.static boolean
isConverterAvailable
(String converterName) Checks for converter availability.isConverterAvailable
(String converterName, boolean refresh) Checks for converter availability.boolean
isSourceMimeTypeSupported
(String converterName, String sourceMimeType) Returns true if the converter supports the givensourceMimeType
, false otherwise.void
registerContribution
(Object contribution, String extensionPoint, ComponentInstance contributor) Component implementation.static void
protected static Blob
Replace 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 void
setGCIntervalInMinutes
(long interval) static void
setMaxCacheSizeInKB
(int size) void
start
(ComponentContext context) Start the component.protected void
startGC()
void
stop
(ComponentContext context) Stop the component.void
unregisterContribution
(Object contribution, String extensionPoint, ComponentInstance contributor) protected void
updateResultBlobFileName
(BlobHolder srcBh, BlobHolder resultBh) protected void
updateResultBlobMimeType
(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, 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
Methods 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
-
config
-
gcThread
-
gcTask
-
checkResultCache
-
-
Constructor Details
-
ConversionServiceImpl
public ConversionServiceImpl()
-
-
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
-
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
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) Component implementation.- Overrides:
registerContribution
in classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
unregisterContribution
in classDefaultComponent
-
getConverter
-
getConverterDescriptor
-
getGCIntervalInMinutes
public static long getGCIntervalInMinutes() -
setGCIntervalInMinutes
public static void setGCIntervalInMinutes(long interval) -
registerConverter
-
getMaxCacheSizeInKB
public static int getMaxCacheSizeInKB() -
setMaxCacheSizeInKB
public static void setMaxCacheSizeInKB(int size) -
isCacheEnabled
public static boolean isCacheEnabled() -
getCacheBasePath
-
getRegistredConverters
Description copied from interface:ConversionService
Returns the names of the registered converters.- Specified by:
getRegistredConverters
in 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:ConversionService
Converts a Blob given a converter name.- Specified by:
convert
in interfaceConversionService
- Throws:
ConversionException
-
hasSourceMimeType
Returns true if the converter has the givenmimeType
as 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:ConversionService
Converts a Blob given a target destination MimeType.- Specified by:
convertToMimeType
in interfaceConversionService
- Throws:
ConversionException
-
getConverterNames
public List<String> getConverterNames(String sourceMimeType, String destinationMimeType, boolean allowWildcard) Description copied from interface:ConversionService
Returns the list of converter names handling the givensourceMimeType
anddestinationMimeType
.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
allowWildcard
istrue
, find the converters matching a wildcard source mime type "*" - Then, filter only the converters matching the given
destinationMimeType
- Specified by:
getConverterNames
in interfaceConversionService
allowWildcard
-true
to 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:ConversionService
Returns the converter name for the givensourceMimeType
anddestinationMimeType
.Follows the algorithm of
ConversionService.getConverterNames(String, String, boolean)
.- Specified by:
getConverterName
in interfaceConversionService
- See Also:
-
isConverterAvailable
Description copied from interface:ConversionService
Checks for converter availability.Result can be:
ConverterNotRegistered
if 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:
isConverterAvailable
in interfaceConversionService
- Throws:
ConversionException
-
isConverterAvailable
public ConverterCheckResult isConverterAvailable(String converterName, boolean refresh) throws ConverterNotRegistered Description copied from interface:ConversionService
Checks for converter availability.Result can be:
ConverterNotRegistered
if converter is not registered.- Error Message / Installation message if converter dependencies are not available an successful check.
- Specified by:
isConverterAvailable
in interfaceConversionService
- Throws:
ConverterNotRegistered
-
isSourceMimeTypeSupported
Description copied from interface:ConversionService
Returns true if the converter supports the givensourceMimeType
, false otherwise.- Specified by:
isSourceMimeTypeSupported
in interfaceConversionService
-
scheduleConversion
public String scheduleConversion(String converterName, BlobHolder blobHolder, Map<String, Serializable> parameters) Description copied from interface:ConversionService
Schedules a conversion given a converter name.Returns a conversion id to be used by
ConversionService.getConversionResult(String, boolean)
.- Specified by:
scheduleConversion
in interfaceConversionService
-
scheduleConversionToMimeType
public String scheduleConversionToMimeType(String destinationMimeType, BlobHolder blobHolder, Map<String, Serializable> parameters) Description copied from interface:ConversionService
Schedules a conversion given a target mime type.Returns a conversion id to be used by
ConversionService.getConversionResult(String, boolean)
.- Specified by:
scheduleConversionToMimeType
in interfaceConversionService
-
getConversionStatus
Description copied from interface:ConversionService
Returns the status of a scheduled conversion given itsid
, ornull
if no conversion scheduled.- Specified by:
getConversionStatus
in interfaceConversionService
-
getConversionResult
Description copied from interface:ConversionService
Returns the conversion result for the givenid
if any,null
otherwise.- Specified by:
getConversionResult
in interfaceConversionService
-
getAdapter
Description copied from interface:Adaptable
Returns an object which is an instance of the given class associated with this object. Returnsnull
if no such object can be found.- Specified by:
getAdapter
in interfaceAdaptable
- Overrides:
getAdapter
in classDefaultComponent
- Parameters:
adapter
- the adapter class to look up- Returns:
- a object castable to the given class, or
null
if this object does not have an adapter for the given class
-
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
-
startGC
protected void startGC() -
endGC
public void endGC()
-