org.mmbase.module.builders
Class Images

java.lang.Object
  extended by org.mmbase.util.functions.FunctionProvider
      extended by org.mmbase.module.core.MMTable
          extended by org.mmbase.module.core.MMObjectBuilder
              extended by org.mmbase.module.builders.AbstractServletBuilder
                  extended by org.mmbase.module.builders.AbstractImages
                      extended by org.mmbase.module.builders.Images
All Implemented Interfaces:
EventListener, NodeEventListener, RelationEventListener, ImagesInterface

public class Images
extends AbstractImages

If this class is used as the class for your builder, then an 'handle' byte field is assumed to contain an image. You builder will work together with 'icaches', and with imagemagick (or jai). This means that is has the following properties: ImageConvertClass, ImageConvert.ConverterCommand, ImageConvert.ConverterRoot and MaxConcurrentRequests

Version:
$Id: Images.java 40155 2009-12-08 15:55:13Z michiel $
Author:
Daniel Ockeloen, Rico Jansen, Michiel Meeuwissen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mmbase.module.builders.AbstractImages
AbstractImages.CKeyCache
 
Field Summary
static Parameter[] CACHE_PARAMETERS
           
static Parameter[] CACHEDNODE_PARAMETERS
           
protected  String defaultImageType
          Supposed image type if not could be determined (configurable)
(package private) static Timer deleter
           
static Parameter[] DIMENSION_PARAMETERS
           
(package private) static Map<File,Dimension> dimensions
           
static Parameter[] GUI_PARAMETERS
           
static Parameter[] HEIGHT_PARAMETERS
           
static Parameter[] WIDTH_PARAMETERS
           
 
Fields inherited from class org.mmbase.module.builders.AbstractImages
FIELD_FILESIZE, FIELD_HEIGHT, FIELD_ITYPE, FIELD_WIDTH, handleCache, IMAGE_HANDLE_FIELDS
 
Fields inherited from class org.mmbase.module.builders.AbstractServletBuilder
externalUrlField, FIELD_FILENAME, FIELD_HANDLE, FIELD_MIMETYPE, FORMAT_PARAMETERS, legalizeFileName, MIMETYPE_PARAMETERS, PROPERTY_EXTERNAL_URL_FIELD, usesBridgeServlet
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
AGE_PARAMETERS, broadCastChanges, DEFAULT_ALINEA, DEFAULT_EOL, description, descriptions, EVENT_TYPE_LOCAL, EVENT_TYPE_REMOTE, FIELD_NUMBER, FIELD_OBJECT_TYPE, FIELD_OWNER, fields, genericBlobCache, getFunctions, GUI_INDICATOR, guiFunction, infoFunction, internalVersion, nodeCache, oType, pluralNames, searchAge, singularNames, SYSTEM_OWNER, TEMPNODE_DEFAULT_SIZE, TMP_FIELD_EXISTS, TMP_FIELD_NUMBER, virtual, WRAP_PARAMETERS, wrapFunction
 
Fields inherited from class org.mmbase.module.core.MMTable
maxNodesFromQuery, mmb, storageConnector, tableName
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions
 
Constructor Summary
Images()
           
 
Method Summary
 boolean commit(MMObjectNode node)
          Commit changes to this node to the storage layer.
static File createTemporaryFile(SerializableInputStream in, String template)
           
protected  Object executeFunction(MMObjectNode node, String function, List<?> args)
          The executeFunction of this builder adds the 'cache' function.
protected  void fillImageCacheNode(MMObjectNode image, MMObjectNode icacheNode, String template)
           
 MMObjectNode getCachedNode(MMObjectNode node, String template)
          Returns a icache node for given image node and conversion template.
 String getDefaultImageType()
          The default image type is used when magic could not determin the type
protected  Dimension getDimension(MMObjectNode node, String template)
           
protected  String getGuiForNewImage(MMObjectNode node, String alt, Parameters args)
           
protected  String getGUIIndicatorWithAlt(MMObjectNode node, String alt, Parameters args)
          The GUI-indicator of an image-node also needs a res/req object.
protected  String getSGUIIndicatorForNode(MMObjectNode node, Parameters args)
          Returns GUI Indicator for node
 boolean init()
          Read configurations (imageConvertClass, maxConcurrentRequest), checks for 'icaches', inits the request-processor-pool.
(package private)  void invalidateTemplateCacheNumberCache(int number)
           
(package private)  void invalidateTemplateCacheNumberCache(String ckey)
           
 void notify(NodeEvent event)
           
 void removeNode(MMObjectNode node)
          Override the MMObjectBuilder removeNode, to invalidate the Image Cache AFTER a deletion of the image node.
 void shutdown()
          clean all acquired resources, because system is shutting down
 
Methods inherited from class org.mmbase.module.builders.AbstractImages
checkHandle, getAssociation, getBlobCache, getDefaultPath, getDimension, getDimensionForEmptyHandle, getFileSize, getHandleFields, getImageFormat, getMimeType, getSGUIIndicator, handleEmpty, storesDimension, storesFileSize, storesImageType
 
Methods inherited from class org.mmbase.module.builders.AbstractServletBuilder
addFileName, getBinary, getDefaultFileName, getFileName, getGUIIndicator, getGUIIndicator, getServletPath, getServletPath, getSession, getSuperGUIIndicator, insert
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addEventListener, addField, addLocalObserver, addRemoteObserver, broadcastChanges, checkAddTmpField, clearBlobCache, create, createAlias, createAlias, delete, equals, equals, executeFunction, fieldLocalChanged, getAncestors, getClassName, getConfigFile, getConfigResource, getDataTypeCollector, getDBState, getDBType, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEmptyNode, getField, getFieldNames, getFields, getFields, getFunction, getFunctionParameters, getFunctions, getGUIIndicator, getHTML, getInitParameter, getInitParameters, getInitParameters, getInternalVersion, getList, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getNewNode, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNodeFromCache, getNodeGUIIndicator, getNumber, getObjectType, getObjectValue, getParentBuilder, getPluralName, getPluralName, getPluralNames, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedInputStream, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hasField, hashCode, hashCode, hostname_function, insert, isExtensionOf, isNodeCached, isNull, isVirtual, loadInitParameters, newFunctionInstance, nodeLocalChanged, nodeRemoteChanged, notify, preCommit, process, removeEventListener, removeField, removeLocalObserver, removeRelations, removeRemoteObserver, removeSyncNodes, replace, safeCache, sendFieldChangeSignal, setDefaults, setDescription, setDescriptions, setFields, setInitParameter, setMaintainer, setPluralNames, setSearchAge, setSingularNames, setUniqueValue, setUniqueValue, setValue, setValue, setVersion, setXMLPath, testValidData, toString, toString, update, updateFields, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
count, count, created, getFullTableName, getMMBase, getNode, getNodes, getNodes, getNodes, getNodeType, getStorageConnector, getTableName, search, searchVector, setMMBase, setTableName, size
 
Methods inherited from class org.mmbase.util.functions.FunctionProvider
addFunction, createParameters, getFunction, getFunctions, getFunctionValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mmbase.module.builders.ImagesInterface
getBinary, getFileName
 

Field Detail

CACHE_PARAMETERS

public static final Parameter[] CACHE_PARAMETERS

CACHEDNODE_PARAMETERS

public static final Parameter[] CACHEDNODE_PARAMETERS

HEIGHT_PARAMETERS

public static final Parameter[] HEIGHT_PARAMETERS

WIDTH_PARAMETERS

public static final Parameter[] WIDTH_PARAMETERS

DIMENSION_PARAMETERS

public static final Parameter[] DIMENSION_PARAMETERS

GUI_PARAMETERS

public static final Parameter[] GUI_PARAMETERS

defaultImageType

protected String defaultImageType
Supposed image type if not could be determined (configurable)


dimensions

static Map<File,Dimension> dimensions

deleter

static Timer deleter
Constructor Detail

Images

public Images()
Method Detail

init

public boolean init()
Read configurations (imageConvertClass, maxConcurrentRequest), checks for 'icaches', inits the request-processor-pool.

Overrides:
init in class AbstractServletBuilder
Returns:
true if init was completed, false if uncompleted.
See Also:
MMObjectBuilder.create()

shutdown

public void shutdown()
Description copied from class: MMObjectBuilder
clean all acquired resources, because system is shutting down

Overrides:
shutdown in class MMObjectBuilder

executeFunction

protected Object executeFunction(MMObjectNode node,
                                 String function,
                                 List<?> args)
The executeFunction of this builder adds the 'cache' function. The cache function accepts a conversion template as argument and returns the cached image node number. Using this you order to pre-cache an image.

Overrides:
executeFunction in class AbstractImages
Since:
MMBase-1.6
See Also:
MMObjectBuilder.executeFunction(org.mmbase.module.core.MMObjectNode, java.lang.String, java.util.List)

getDimension

protected Dimension getDimension(MMObjectNode node,
                                 String template)
Since:
MMBase-1.7.4

fillImageCacheNode

protected void fillImageCacheNode(MMObjectNode image,
                                  MMObjectNode icacheNode,
                                  String template)
Since:
MMBase-1.9.2

getCachedNode

public MMObjectNode getCachedNode(MMObjectNode node,
                                  String template)
Returns a icache node for given image node and conversion template. If such a node does not exist, it is created.

Since:
MMBase-1.8

createTemporaryFile

public static File createTemporaryFile(SerializableInputStream in,
                                       String template)
                                throws IOException
Throws:
IOException

getGuiForNewImage

protected String getGuiForNewImage(MMObjectNode node,
                                   String alt,
                                   Parameters args)
                            throws IOException
Throws:
IOException
Since:
MMBase-1.9.2

getGUIIndicatorWithAlt

protected String getGUIIndicatorWithAlt(MMObjectNode node,
                                        String alt,
                                        Parameters args)
The GUI-indicator of an image-node also needs a res/req object.

Specified by:
getGUIIndicatorWithAlt in class AbstractImages
Since:
MMBase-1.6

getSGUIIndicatorForNode

protected String getSGUIIndicatorForNode(MMObjectNode node,
                                         Parameters args)
Description copied from class: AbstractImages
Returns GUI Indicator for node

Overrides:
getSGUIIndicatorForNode in class AbstractImages

getDefaultImageType

public String getDefaultImageType()
Description copied from class: AbstractImages
The default image type is used when magic could not determin the type

Overrides:
getDefaultImageType in class AbstractImages

commit

public boolean commit(MMObjectNode node)
Description copied from class: MMObjectBuilder
Commit changes to this node to the storage layer. This method indirectly calls MMObjectBuilder.preCommit(org.mmbase.module.core.MMObjectNode). Use only to commit changes - for adding node, use MMObjectBuilder.insert(int, java.lang.String).

Overrides:
commit in class AbstractServletBuilder
Parameters:
node - The node to be committed
Returns:
true if commit successful

removeNode

public void removeNode(MMObjectNode node)
Override the MMObjectBuilder removeNode, to invalidate the Image Cache AFTER a deletion of the image node. Remove a node from the cloud.

Overrides:
removeNode in class MMObjectBuilder
Parameters:
node - The node to remove.

notify

public void notify(NodeEvent event)
Specified by:
notify in interface NodeEventListener
Overrides:
notify in class MMObjectBuilder
See Also:
here we handle all the backward compatibility stuff. this method covers for both node and relation events.

invalidateTemplateCacheNumberCache

void invalidateTemplateCacheNumberCache(int number)
Javadoc:

invalidateTemplateCacheNumberCache

void invalidateTemplateCacheNumberCache(String ckey)
Since:
MMBase-1.7


MMBase 2.0-SNAPSHOT - null