org.mmbase.module.builders
Class ImageCaches

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.ImageCaches
All Implemented Interfaces:
EventListener, NodeEventListener, RelationEventListener, ImagesInterface

public class ImageCaches
extends AbstractImages

ImageCaches (aka as 'icaches') is a system-like builder used by builders with the 'Images' class. It contains the converted images.

Version:
$Id: ImageCaches.java 42792 2010-07-02 07:01:27Z michiel $
Author:
Daniel Ockeloen, Michiel Meeuwissen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mmbase.module.builders.AbstractImages
AbstractImages.CKeyCache
 
Field Summary
static String FIELD_ID
           
(package private) static String GUI_IMAGETEMPLATE
           
static Parameter[] WAIT_PARAMETERS
           
 
Fields inherited from class org.mmbase.module.builders.AbstractImages
DIMENSION_PARAMETERS, FIELD_FILESIZE, FIELD_HEIGHT, FIELD_ITYPE, FIELD_WIDTH, handleCache, HEIGHT_PARAMETERS, IMAGE_HANDLE_FIELDS, WIDTH_PARAMETERS
 
Fields inherited from class org.mmbase.module.builders.AbstractServletBuilder
externalUrlField, FIELD_FILENAME, FIELD_HANDLE, FIELD_MIMETYPE, FORMAT_PARAMETERS, GUI_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
ImageCaches()
           
 
Method Summary
protected  boolean addFileName(MMObjectNode node, String servlet)
          Adds a filename to the path to a servlet, unless this does not make sense (not filename can be determined) or it was explicitely set not to, using the servlet context init parameter 'mmbase.servlet.<association>addfilename.
protected  void appendExtension(StringBuilder buf, String ext)
           
protected  Object executeFunction(MMObjectNode node, String function, List<?> args)
          Every image of course has a format and a mimetype.
 MMObjectNode getCachedNode(int imageNumber, String template)
          Finds a icache node in the icaches table
protected  Dimension getDimensionForEmptyHandle(MMObjectNode node)
          If icache does not yet have a filled handle field, neither filled width/heigh fields (can occur after a update).
 StringBuilder getFileName(MMObjectNode node, StringBuilder buf)
           
protected  String getGUIIndicatorWithAlt(MMObjectNode node, String alt, Parameters a)
          The GUI indicator of an image can have an alt-text.
 String getImageFormat(MMObjectNode node)
          Returns the image format.
protected  MMObjectNode getLegacyCachedNode(int imageNumber, String template)
          Finds a icache node in the icache table, supposing 'legacy' ckeys (where all +'s are removed).
 String getMimeType(List<String> params)
           
protected  String getSGUIIndicatorForNode(MMObjectNode node, Parameters a)
          Returns GUI Indicator for node
protected  boolean handleEmpty(MMObjectNode node)
          Whether the 'handle' field of this icaches node is to be considered empty, and a conversion must therefor still be triggered.
 boolean init()
          Read 'externalUrlField' property
 int insert(String owner, MMObjectNode node)
          Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided).
protected  void invalidate(MMObjectNode imageNode)
          Invalidate the Image Cache for a specific Node method only accessable on package level, since only Images should call it..
 void removeNode(MMObjectNode node)
          Override the MMObjectBuilder removeNode, to invalidate the LRU ImageCache, when a node gets deleted.
 boolean waitForConversion(MMObjectNode node)
          If a icache node is created with empty 'handle' field, then the handle field can be filled automaticly.
 
Methods inherited from class org.mmbase.module.builders.AbstractImages
checkHandle, getAssociation, getBlobCache, getDefaultImageType, getDefaultPath, getDimension, getFileSize, getHandleFields, getMimeType, getSGUIIndicator, storesDimension, storesFileSize, storesImageType
 
Methods inherited from class org.mmbase.module.builders.AbstractServletBuilder
commit, getBinary, getDefaultFileName, getGUIIndicator, getGUIIndicator, getServletPath, getServletPath, getSession, getSuperGUIIndicator
 
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, 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, shutdown, 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
 

Field Detail

FIELD_ID

public static final String FIELD_ID
See Also:
Constant Field Values

WAIT_PARAMETERS

public static final Parameter[] WAIT_PARAMETERS

GUI_IMAGETEMPLATE

static final String GUI_IMAGETEMPLATE
See Also:
Constant Field Values
Constructor Detail

ImageCaches

public ImageCaches()
Method Detail

init

public boolean init()
Description copied from class: AbstractServletBuilder
Read 'externalUrlField' property

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

appendExtension

protected void appendExtension(StringBuilder buf,
                               String ext)
Since:
MMBase-1.9.4

getFileName

public StringBuilder getFileName(MMObjectNode node,
                                 StringBuilder buf)
Specified by:
getFileName in interface ImagesInterface
Overrides:
getFileName in class AbstractServletBuilder

addFileName

protected boolean addFileName(MMObjectNode node,
                              String servlet)
Description copied from class: AbstractServletBuilder
Adds a filename to the path to a servlet, unless this does not make sense (not filename can be determined) or it was explicitely set not to, using the servlet context init parameter 'mmbase.servlet.<association>addfilename.

Overrides:
addFileName in class AbstractServletBuilder

getGUIIndicatorWithAlt

protected String getGUIIndicatorWithAlt(MMObjectNode node,
                                        String alt,
                                        Parameters a)
The GUI indicator of an image can have an alt-text.

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

getSGUIIndicatorForNode

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

Overrides:
getSGUIIndicatorForNode in class AbstractImages

handleEmpty

protected boolean handleEmpty(MMObjectNode node)
Whether the 'handle' field of this icaches node is to be considered empty, and a conversion must therefor still be triggered.

Overrides:
handleEmpty in class AbstractImages
Since:
MMBase-1.8.5

waitForConversion

public boolean waitForConversion(MMObjectNode node)
If a icache node is created with empty 'handle' field, then the handle field can be filled automaticly. Sadly, getValue of MMObjectNode cannot be overriden, so it cannot be done completely automaticly, but that may be more transparent anyway. Call this method (perhaps with node.getFunctionValue("wait", null)) before requesting the handle field. This will method will block until the field is filled.

Parameters:
node - A icache node.

getCachedNode

public MMObjectNode getCachedNode(int imageNumber,
                                  String template)
Finds a icache node in the icaches table

Parameters:
imageNumber - The node number of the image for which it must be searched
template - The image conversion template
Returns:
The icache node or null if it did not exist yet.

getLegacyCachedNode

protected MMObjectNode getLegacyCachedNode(int imageNumber,
                                           String template)
Finds a icache node in the icache table, supposing 'legacy' ckeys (where all +'s are removed).

Parameters:
imageNumber - The node number of the image for which it must be searched
template - The image conversion template
Returns:
The icache node or null if it did not exist.

invalidate

protected void invalidate(MMObjectNode imageNode)
Invalidate the Image Cache for a specific Node method only accessable on package level, since only Images should call it..

Parameters:
imageNode - The image node, which is the original of the cached modifications
Since:
MMBase-1.7

removeNode

public void removeNode(MMObjectNode node)
Override the MMObjectBuilder removeNode, to invalidate the LRU ImageCache, when a node gets deleted. Remove a node from the cloud.

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

getImageFormat

public String getImageFormat(MMObjectNode node)
Returns the image format.

Specified by:
getImageFormat in interface ImagesInterface
Overrides:
getImageFormat in class AbstractImages
Parameters:
node - The object to use.

getDimensionForEmptyHandle

protected Dimension getDimensionForEmptyHandle(MMObjectNode node)
If icache does not yet have a filled handle field, neither filled width/heigh fields (can occur after a update). The dimension can still be given.

Overrides:
getDimensionForEmptyHandle in class AbstractImages
Since:
MMBase-1.8.1

getMimeType

public String getMimeType(List<String> params)

insert

public int insert(String owner,
                  MMObjectNode node)
Description copied from class: MMObjectBuilder
Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided). This method indirectly calls MMObjectBuilder.preCommit(org.mmbase.module.core.MMObjectNode).

Overrides:
insert in class AbstractServletBuilder
Parameters:
owner - The administrator creating the node
node - The object to insert. The object need be of the same type as the current builder.
Returns:
An int value which is the new object's unique number, -1 if the insert failed.

executeFunction

protected Object executeFunction(MMObjectNode node,
                                 String function,
                                 List<?> args)
Every image of course has a format and a mimetype. Two extra functions to get them.

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


MMBase 2.0-SNAPSHOT - null