public class ConversionServiceImpl extends DefaultComponent implements ConversionService
ConversionService.| Modifier and Type | Field and Description | 
|---|---|
protected Map<String,ConverterCheckResult> | 
checkResultCache  | 
protected GlobalConfigDescriptor | 
config  | 
static String | 
CONFIG_EP  | 
static String | 
CONVERTER_EP  | 
protected Map<String,ConverterDescriptor> | 
converterDescriptors  | 
static String | 
ENFORCE_SOURCE_MIME_TYPE_CHECK  | 
protected GCTask | 
gcTask  | 
protected Thread | 
gcThread  | 
protected static ConversionServiceImpl | 
self  | 
protected MimeTypeTranslationHelper | 
translationHelper  | 
lastModified, name| Constructor and Description | 
|---|
ConversionServiceImpl()  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
activate(ComponentContext context)
Activates the component. 
 | 
protected void | 
adjustBlobName(String filename,
              BlobHolder blobHolder,
              String mimeType)  | 
protected void | 
adjustBlobName(String filename,
              Blob blob,
              String mimeType)  | 
BlobHolder | 
convert(String converterName,
       BlobHolder blobHolder,
       Map<String,Serializable> parameters)
Converts a Blob given a converter name. 
 | 
protected BlobHolder | 
convertBlobToMimeType(BlobHolder bh,
                     String destinationMimeType)  | 
Blob | 
convertBlobToPDF(Blob blob)
Deprecated.  
 | 
protected BlobHolder | 
convertThroughHTML(BlobHolder blobHolder,
                  String destMimeType)  | 
BlobHolder | 
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 | 
getCacheBasePath()  | 
BlobHolder | 
getConversionResult(String id,
                   boolean cleanTransientStoreEntry)
Returns the conversion result for the given  
id if any, null otherwise. | 
ConversionStatus | 
getConversionStatus(String id)
Returns the status of a scheduled conversion given its  
id, or null if no conversion scheduled. | 
static Converter | 
getConverter(String converterName)  | 
static ConverterDescriptor | 
getConverterDescriptor(String converterName)  | 
String | 
getConverterName(String sourceMimeType,
                String destinationMimeType)
Gets the convertName given a source and destination MimeType. 
 | 
List<String> | 
getConverterNames(String sourceMimeType,
                 String destinationMimeType)
Gets the available convertNames given a source and destination MimeType. 
 | 
static long | 
getGCIntervalInMinutes()  | 
static int | 
getMaxCacheSizeInKB()  | 
List<String> | 
getRegistredConverters()
Returns the names of the registered converters. 
 | 
protected boolean | 
hasSourceMimeType(ConverterDescriptor converterDescriptor,
                 String mimeType)
Returns true if the converter has the given  
mimeType as source mime type, false otherwise. | 
static boolean | 
isCacheEnabled()  | 
ConverterCheckResult | 
isConverterAvailable(String converterName)
Checks for converter availability. 
 | 
ConverterCheckResult | 
isConverterAvailable(String converterName,
                    boolean refresh)
Checks for converter availability. 
 | 
boolean | 
isSourceMimeTypeSupported(String converterName,
                         String sourceMimeType)
Returns true if the converter supports the given  
sourceMimeType, false otherwise. | 
void | 
registerContribution(Object contribution,
                    String extensionPoint,
                    ComponentInstance contributor)
Component implementation. 
 | 
static void | 
registerConverter(ConverterDescriptor desc)  | 
protected static Blob | 
replaceURLsByAbsolutePaths(Blob blob,
                          Path tempDirectory,
                          Function<String,Blob> blobResolver)
Replace the image URLs of an HTML blob by absolute local paths. 
 | 
String | 
scheduleConversion(String converterName,
                  BlobHolder blobHolder,
                  Map<String,Serializable> parameters)
Schedules a conversion given a converter name. 
 | 
String | 
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)  | 
getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterExtensionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitapplicationStarted, getApplicationStartedOrderpublic static final String CONVERTER_EP
public static final String CONFIG_EP
public static final String ENFORCE_SOURCE_MIME_TYPE_CHECK
protected final Map<String,ConverterDescriptor> converterDescriptors
protected final MimeTypeTranslationHelper translationHelper
protected final GlobalConfigDescriptor config
protected static ConversionServiceImpl self
protected final Map<String,ConverterCheckResult> checkResultCache
public ConversionServiceImpl()
public void activate(ComponentContext context)
ComponentThis method is called by the runtime when a component is activated.
activate in interface Componentactivate in class DefaultComponentcontext - the runtime contextpublic void deactivate(ComponentContext context)
ComponentThis method is called by the runtime when a component is deactivated.
deactivate in interface Componentdeactivate in class DefaultComponentcontext - the runtime contextpublic void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
registerContribution in class DefaultComponentpublic void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
unregisterContribution in class DefaultComponentpublic static Converter getConverter(String converterName)
public static ConverterDescriptor getConverterDescriptor(String converterName)
public static long getGCIntervalInMinutes()
public static void setGCIntervalInMinutes(long interval)
public static void registerConverter(ConverterDescriptor desc)
public static int getMaxCacheSizeInKB()
public static void setMaxCacheSizeInKB(int size)
public static boolean isCacheEnabled()
public static String getCacheBasePath()
public List<String> getRegistredConverters()
ConversionServicegetRegistredConverters in interface ConversionService@Deprecated public Blob convertBlobToPDF(Blob blob)
ConversionServiceconvertBlobToPDF in interface ConversionServiceprotected BlobHolder convertThroughHTML(BlobHolder blobHolder, String destMimeType)
protected BlobHolder convertBlobToMimeType(BlobHolder bh, String destinationMimeType)
protected void adjustBlobName(String filename, BlobHolder blobHolder, String mimeType)
protected void adjustBlobName(String filename, Blob blob, String mimeType)
protected static Blob replaceURLsByAbsolutePaths(Blob blob, Path tempDirectory, Function<String,Blob> blobResolver) throws IOException
IOExceptionpublic BlobHolder convert(String converterName, BlobHolder blobHolder, Map<String,Serializable> parameters) throws ConversionException
ConversionServiceconvert in interface ConversionServiceConversionExceptionprotected boolean hasSourceMimeType(ConverterDescriptor converterDescriptor, String mimeType)
mimeType as source mime type, false otherwise.protected void updateResultBlobMimeType(BlobHolder resultBh, ConverterDescriptor desc)
protected void updateResultBlobFileName(BlobHolder srcBh, BlobHolder resultBh)
public BlobHolder convertToMimeType(String destinationMimeType, BlobHolder blobHolder, Map<String,Serializable> parameters) throws ConversionException
ConversionServiceconvertToMimeType in interface ConversionServiceConversionExceptionpublic List<String> getConverterNames(String sourceMimeType, String destinationMimeType)
ConversionServicegetConverterNames in interface ConversionServicepublic String getConverterName(String sourceMimeType, String destinationMimeType)
ConversionServicegetConverterName in interface ConversionServicepublic ConverterCheckResult isConverterAvailable(String converterName) throws ConversionException
ConversionServiceResult can be:
ConverterNotRegistered if converter is not registered.
 Result can be taken from an internal cache.
isConverterAvailable in interface ConversionServiceConversionExceptionpublic ConverterCheckResult isConverterAvailable(String converterName, boolean refresh) throws ConverterNotRegistered
ConversionServiceResult can be:
ConverterNotRegistered if converter is not registered.
 isConverterAvailable in interface ConversionServiceConverterNotRegisteredpublic boolean isSourceMimeTypeSupported(String converterName, String sourceMimeType)
ConversionServicesourceMimeType, false otherwise.isSourceMimeTypeSupported in interface ConversionServicepublic String scheduleConversion(String converterName, BlobHolder blobHolder, Map<String,Serializable> parameters)
ConversionService
 Returns a conversion id to be used by ConversionService.getConversionResult(String, boolean).
scheduleConversion in interface ConversionServicepublic String scheduleConversionToMimeType(String destinationMimeType, BlobHolder blobHolder, Map<String,Serializable> parameters)
ConversionService
 Returns a conversion id to be used by ConversionService.getConversionResult(String, boolean).
scheduleConversionToMimeType in interface ConversionServicepublic ConversionStatus getConversionStatus(String id)
ConversionServiceid, or null if no conversion scheduled.getConversionStatus in interface ConversionServicepublic BlobHolder getConversionResult(String id, boolean cleanTransientStoreEntry)
ConversionServiceid if any, null otherwise.getConversionResult in interface ConversionServicepublic <T> T getAdapter(Class<T> adapter)
Adaptablenull
 if no such object can be found.getAdapter in interface AdaptablegetAdapter in class DefaultComponentadapter - the adapter class to look upnull if this object does not have an adapter for
         the given classpublic void start(ComponentContext context)
Componentstart in interface Componentstart in class DefaultComponentpublic void stop(ComponentContext context)
Componentstop in interface Componentstop in class DefaultComponentprotected void startGC()
public void endGC()
Copyright © 2019 Nuxeo. All rights reserved.