org.mmbase.module.builders
Class Images

java.lang.Object
  |
  +--org.mmbase.module.core.MMTable
        |
        +--org.mmbase.module.core.MMObjectBuilder
              |
              +--org.mmbase.module.builders.AbstractServletBuilder
                    |
                    +--org.mmbase.module.builders.AbstractImages
                          |
                          +--org.mmbase.module.builders.Images

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,v 1.64.2.2 2003/03/04 20:05:32 michiel Exp $
Author:
Daniel Ockeloen, Rico Jansen, Michiel Meeuwissen

Inner classes inherited from class org.mmbase.module.builders.AbstractImages
AbstractImages.CKeyCache
 
Field Summary
protected  java.lang.String defaultImageType
           
protected static java.lang.String ImageConvertClass
           
protected  Queue imageRequestQueue
           
protected  java.util.Hashtable imageRequestTable
           
protected  ImageRequestProcessor[] ireqprocessors
           
protected  int MaxConcurrentRequests
           
protected  int MaxRequests
           
 
Fields inherited from class org.mmbase.module.builders.AbstractServletBuilder
usesBridgeServlet
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
broadcastChanges, database, DEFAULT_ALINEA, DEFAULT_EOL, description, descriptions, fields, nodeCache, obj2type, OBJ2TYPE_MAX_SIZE, oType, REPLACE_CACHE, searchAge, sortedDBLayout, TEMPNODE_DEFAULT_SIZE, TemporaryNodes, virtual
 
Fields inherited from class org.mmbase.module.core.MMTable
mmb, tableName
 
Constructor Summary
Images()
           
 
Method Summary
 int cacheImage(java.util.List params)
          Explicity cache this image with params and return the cached node number.
 boolean commit(MMObjectNode node)
          Override the MMObjectBuilder commit, to invalidate the Image Cache AFTER a modifation to the image node.
 int convertAlias(java.lang.String num)
          Check if its a number if not check for name.
protected  void determineImageType(MMObjectNode node)
          Determines the image type of an object and stores the content in the itype field.
protected  java.lang.Object executeFunction(MMObjectNode node, java.lang.String function, java.util.List args)
          The executeFunction of this builder adds the 'cache' function.
protected  byte[] getCachedImage(java.util.List params)
          Determins the ckey, and asks the bytes from icaches.
protected  java.lang.String getGUIIndicatorWithAlt(MMObjectNode node, java.lang.String title, javax.servlet.http.HttpServletResponse res, java.lang.String sessionName)
          An image's gui-indicator is of course some <img src>, but it depends on what kind of image (cached, original) what excactly it must be.
 byte[] getImageBytes(java.util.List params)
          Returns a picture wich belongs to the given param line, with caching.
 byte[] getImageBytes(scanpage sp, java.util.List params)
          Deprecated. Use getImageBytes(params);
 byte[] getImageBytes5(scanpage sp, java.util.List params)
          Deprecated. Use getImageBytes(params);
protected  java.lang.String getImageFormat(MMObjectNode node)
          Returns the image format.
 java.lang.String getImageMimeType(java.util.List params)
          Will return defaultImageType as default type, or one of the strings in params, must contain the following "f(type)" where type will be returned
 java.util.Vector getList(scanpage sp, StringTagger tagger, java.util.StringTokenizer tok)
          Obtains a list of string values by performing the provided command and parameters.
protected  byte[] getOriginalImage(java.util.List params)
          This function should be called when an image/template does not have a cached version yet.
protected  java.lang.String getSGUIIndicator(java.lang.String session, javax.servlet.http.HttpServletResponse res, MMObjectNode node)
          Gui indicator of a whole node.
 boolean init()
          Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called.
 int insert(java.lang.String owner, MMObjectNode node)
          Insert a new object (content provided) in the cloud.
 void removeNode(MMObjectNode node)
          Override the MMObjectBuilder removeNode, to invalidate the Image Cache AFTER a delete-ion of the image node.
 void setDefaults(MMObjectNode node)
          Sets defaults for a node.
 
Methods inherited from class org.mmbase.module.builders.AbstractImages
getAssociation, getDefaultPath, getImageMimeType, getSGUIIndicator
 
Methods inherited from class org.mmbase.module.builders.AbstractServletBuilder
getGUIIndicator, getGUIIndicator, getServletPath, getServletPath, getServletPath, getSuperGUIIndicator
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addField, addLocalObserver, addRemoteObserver, buildSet, checkAddTmpField, convertMMNode2SQL, count, create, createAlias, created, deleteNodeCache, drop, equals, equals, executeFunction, fieldLocalChanged, getAge, getAliasedNode, getAncestors, getCacheNumbers, getCacheSize, getCacheSize, getClassName, getConfigFile, getDBByte, getDBKey, getDBState, getDBText, getDBType, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEditFields, getField, getFieldNames, getFields, getFields, getFullTableName, getFunctionParameters, getHardNode, getHardNode, getHTML, getInitParameter, getInitParameters, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getNewNode, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNode, getNodes, getNodeType, getNumberFromName, getObjectType, getObjectValue, getParentBuilder, getPluralName, getPluralName, getPluralNames, getQuery, getQuery, getQuery, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getSortedFields, getSortedListFields, getTableName, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hashCode, hostname_function, insert, insertDone, isExtensionOf, isNodeCached, isVirtual, nodeLocalChanged, nodeRemoteChanged, preCommit, preEdit, process, putTmpNode, readSearchResults, removeField, removeRelations, removeTmpNode, replace, safeCache, safeCommit, safeInsert, search, search, search, searchIn, searchIn, searchIn, searchList, searchList, searchNumbers, searchVector, searchVector, searchVector, searchVector, searchVectorIn, searchVectorIn, searchVectorIn, searchVectorIn, searchWithWhere, sendFieldChangeSignal, setDBLayout_xml, setDescription, setDescriptions, setInitParameter, setMaintainer, setMMBase, setParentBuilder, setPluralNames, setSearchAge, setSingularNames, setTableName, setValue, setValue, setVersion, setXMLPath, setXMLValues, signalNewObject, testValidData, toString, toString, toXML, updateFields, waitUntilNodeChanged, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
size
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultImageType

protected java.lang.String defaultImageType

ImageConvertClass

protected static java.lang.String ImageConvertClass

MaxConcurrentRequests

protected int MaxConcurrentRequests

MaxRequests

protected int MaxRequests

imageRequestQueue

protected Queue imageRequestQueue

imageRequestTable

protected java.util.Hashtable imageRequestTable

ireqprocessors

protected ImageRequestProcessor[] ireqprocessors
Constructor Detail

Images

public Images()
Method Detail

init

public boolean init()
Description copied from class: MMObjectBuilder
Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called. The method retrieves data from the TypeDef builder, or adds data to that builder if the current builder is not yet registered.
Overrides:
init in class MMObjectBuilder
Following copied from class: org.mmbase.module.core.MMObjectBuilder
Returns:
true if init was completed, false if uncompleted.
See Also:
MMObjectBuilder.create()

executeFunction

protected java.lang.Object executeFunction(MMObjectNode node,
                                           java.lang.String function,
                                           java.util.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

setDefaults

public void setDefaults(MMObjectNode node)
Description copied from class: MMObjectBuilder
Sets defaults for a node. Fields "number", "owner" and "otype" are not set by this method.
Overrides:
setDefaults in class MMObjectBuilder
Following copied from class: org.mmbase.module.core.MMObjectBuilder
Parameters:
node - The node to set the defaults of.

getGUIIndicatorWithAlt

protected java.lang.String getGUIIndicatorWithAlt(MMObjectNode node,
                                                  java.lang.String title,
                                                  javax.servlet.http.HttpServletResponse res,
                                                  java.lang.String sessionName)
Description copied from class: AbstractImages
An image's gui-indicator is of course some <img src>, but it depends on what kind of image (cached, original) what excactly it must be.
Overrides:
getGUIIndicatorWithAlt in class AbstractImages
Since:
MMBase-1.6

getSGUIIndicator

protected java.lang.String getSGUIIndicator(java.lang.String session,
                                            javax.servlet.http.HttpServletResponse res,
                                            MMObjectNode node)
Description copied from class: AbstractImages
Gui indicator of a whole node.
Overrides:
getSGUIIndicator in class AbstractImages

getImageMimeType

public java.lang.String getImageMimeType(java.util.List params)
Will return defaultImageType as default type, or one of the strings in params, must contain the following "f(type)" where type will be returned
Parameters:
params - a List of Strings, which could contain the "f(type)" string
Returns:
defaultImageType by default, or the first occurence of "f(type)"

getImageFormat

protected java.lang.String getImageFormat(MMObjectNode node)
Returns the image format. If the node is not an icache node, but e.g. an images node, then it will return either the node's 'itype' field, or (if that field is empty) the default image format, which is defaultImageType.
Overrides:
getImageFormat in class AbstractImages
Since:
MMBase-1.6

cacheImage

public int cacheImage(java.util.List params)
Explicity cache this image with params and return the cached node number. This function is called by servdb. So when servdb is not used for images anymore, this function can be deprecated (and the functionality moved to cacheImage(node, template).
Since:
MMBase-1.6

getImageBytes5

public byte[] getImageBytes5(scanpage sp,
                             java.util.List params)
Deprecated. Use getImageBytes(params);


getImageBytes

public byte[] getImageBytes(scanpage sp,
                            java.util.List params)
Deprecated. Use getImageBytes(params);


getImageBytes

public byte[] getImageBytes(java.util.List params)
Returns a picture wich belongs to the given param line, with caching.
Overrides:
getImageBytes in class AbstractImages
Parameters:
params - The name/id of the picture, followed by operations, which can be performed on the picture..
Returns:
null if something goes wrong, otherwise the picture in a byte[]

getCachedImage

protected byte[] getCachedImage(java.util.List params)
Determins the ckey, and asks the bytes from icaches. Will return null when not in cache, and otherwise a byte [] representing the picture..
Parameters:
params - a List of Strings, containing the name/id of the picture, followed by operations, which can be performed on the picture..
Returns:
null if something goes wrong, otherwise the picture in a byte[]

getOriginalImage

protected byte[] getOriginalImage(java.util.List params)
This function should be called when an image/template does not have a cached version yet. Will return null when something goes wrong otherwise, a byte[] which represents the picture.
Parameters:
params - a List of Strings, containing the name/id of the picture, followed by operations, which can be performed on the picture..
Returns:
null if something goes wrong, otherwise the picture in a byte[]

convertAlias

public int convertAlias(java.lang.String num)
Check if its a number if not check for name.

getList

public java.util.Vector getList(scanpage sp,
                                StringTagger tagger,
                                java.util.StringTokenizer tok)
                         throws ParseException
Description copied from class: MMObjectBuilder
Obtains a list of string values by performing the provided command and parameters. This method is SCAN related and may fail if called outside the context of the SCAN servlet.
Overrides:
getList in class MMObjectBuilder
Following copied from class: org.mmbase.module.core.MMObjectBuilder
Parameters:
sp - The scanpage (containing http and user info) that calls the function
tagger - a Hashtable of parameters (name-value pairs) for the command
tok - a list of strings that describe the (sub)command to execute
Returns:
a Vector containing the result values as a String

determineImageType

protected void determineImageType(MMObjectNode node)
Determines the image type of an object and stores the content in the itype field.
Parameters:
owner - The administrator creating the node
node - The object to change

insert

public int insert(java.lang.String owner,
                  MMObjectNode node)
Insert a new object (content provided) in the cloud. This method attempts to determine the image type of the object.
Overrides:
insert in class MMObjectBuilder
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.

commit

public boolean commit(MMObjectNode node)
Override the MMObjectBuilder commit, to invalidate the Image Cache AFTER a modifation to the image node. This method attempts to determine the image type of the object.
Overrides:
commit in class MMObjectBuilder
Parameters:
node - The node to be committed
Returns:
The committed node.

removeNode

public void removeNode(MMObjectNode node)
Override the MMObjectBuilder removeNode, to invalidate the Image Cache AFTER a delete-ion of the image node. Remove a node from the cloud.
Overrides:
removeNode in class MMObjectBuilder
Parameters:
node - The node to remove.


MMBase build 1.6.5.20030923