org.mmbase.module.builders
Class ImageCaches

Package class diagram package 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 45246 2011-02-16 16:35:13Z 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, getFunctionsFunction, 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, getFunctions
 
Constructor Summary
ImageCaches()
           
 
Method Summary
protected  boolean addFileName(MMObjectNode node, String servlet)
           
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()
           
 int insert(String owner, MMObjectNode node)
           
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, getFileName, 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, createIfNotExists, 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()
Overrides:
init in class AbstractServletBuilder

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)
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)
Overrides:
insert in class AbstractServletBuilder

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


MMBase2 Resources 2.0-SNAPSHOT - 2014-09-22T23:09