Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.platform.filemanager.core.listener
Class MimetypeIconUpdater

java.lang.Object
  extended by org.nuxeo.ecm.platform.filemanager.core.listener.MimetypeIconUpdater
All Implemented Interfaces:
EventListener

public class MimetypeIconUpdater
extends Object
implements EventListener

Listener responsible for computing the mimetype of a new or edited blob and the common:icon field if necessary.

The common:size is also maintained as the length of the main blob to preserve backward compatibility.

The logic of this event listener is divided into static public methods to make it easy to override this event listener with a custom implementation.

Author:
ogrisel

Field Summary
 BlobsExtractor blobExtractor
           
static String ICON_FIELD
           
static String ICON_SCHEMA
           
static String MAIN_BLOB_FIELD
           
static String MAIN_EXTERNAL_FILENAME_FIELD
          Deprecated. 
 
Constructor Summary
MimetypeIconUpdater()
           
 
Method Summary
 MimetypeRegistry getMimetypeRegistry()
           
 void handleEvent(Event event)
          Handle the given event.
 void recursivelyUpdateBlobs(DocumentModel doc, MimetypeRegistry mimetypeService, Iterator<Property> dirtyChildren)
          Deprecated. now we use BlobsExtractor that cache path fields.
 void setDefaultIcon(DocumentModel doc)
          If the icon field is empty, initialize it to the document type icon
 void updateBlobProperty(DocumentModel doc, MimetypeRegistry mimetypeService, Property dirtyProperty)
          Update the mimetype of a blob along with the icon and size fields of the document if the blob is the main blob of the document.
 void updateFilename(DocumentModel doc)
          Backward compatibility for external filename field: if edited, it might affect the main blob mimetype
 void updateIconField(MimetypeEntry mimetypeEntry, DocumentModel doc)
          Compute the main icon of a Nuxeo document based on the mimetype of the main attached blob with of fallback on the document type generic icon.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICON_SCHEMA

public static final String ICON_SCHEMA
See Also:
Constant Field Values

ICON_FIELD

public static final String ICON_FIELD
See Also:
Constant Field Values

MAIN_BLOB_FIELD

public static final String MAIN_BLOB_FIELD
See Also:
Constant Field Values

MAIN_EXTERNAL_FILENAME_FIELD

@Deprecated
public static final String MAIN_EXTERNAL_FILENAME_FIELD
Deprecated. 
See Also:
Constant Field Values

blobExtractor

public final BlobsExtractor blobExtractor
Constructor Detail

MimetypeIconUpdater

public MimetypeIconUpdater()
Method Detail

getMimetypeRegistry

public MimetypeRegistry getMimetypeRegistry()
                                     throws Exception
Throws:
Exception

handleEvent

public void handleEvent(Event event)
                 throws ClientException
Description copied from interface: EventListener
Handle the given event. The listener can cancel the event by calling Event.cancel()

Specified by:
handleEvent in interface EventListener
Parameters:
event - the event
Throws:
ClientException

recursivelyUpdateBlobs

@Deprecated
public void recursivelyUpdateBlobs(DocumentModel doc,
                                              MimetypeRegistry mimetypeService,
                                              Iterator<Property> dirtyChildren)
                            throws Exception
Deprecated. now we use BlobsExtractor that cache path fields.

Recursively call updateBlobProperty on every dirty blob embedded as direct children or contained in one of the container children.

Throws:
Exception

updateBlobProperty

public void updateBlobProperty(DocumentModel doc,
                               MimetypeRegistry mimetypeService,
                               Property dirtyProperty)
                        throws Exception
Update the mimetype of a blob along with the icon and size fields of the document if the blob is the main blob of the document.

Throws:
Exception

updateFilename

public void updateFilename(DocumentModel doc)
                    throws PropertyException
Backward compatibility for external filename field: if edited, it might affect the main blob mimetype

Throws:
PropertyException

setDefaultIcon

public void setDefaultIcon(DocumentModel doc)
                    throws Exception
If the icon field is empty, initialize it to the document type icon

Throws:
Exception

updateIconField

public void updateIconField(MimetypeEntry mimetypeEntry,
                            DocumentModel doc)
                     throws Exception
Compute the main icon of a Nuxeo document based on the mimetype of the main attached blob with of fallback on the document type generic icon.

Throws:
Exception

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.