org.mmbase.module.builders
Class Images

java.lang.Object
  extended byorg.mmbase.module.core.MMTable
      extended byorg.mmbase.module.core.MMObjectBuilder
          extended byorg.mmbase.module.builders.AbstractServletBuilder
              extended byorg.mmbase.module.builders.AbstractImages
                  extended byorg.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.94.2.2 2004/08/26 12:18:26 michiel Exp $
Author:
Daniel Ockeloen, Rico Jansen, Michiel Meeuwissen

Nested Class Summary
 
Nested classes inherited from class org.mmbase.module.builders.AbstractImages
AbstractImages.CKeyCache
 
Field Summary
static Parameter[] CACHE_PARAMETERS
           
protected static java.lang.Class DEFAULT_IMAGECONVERTCLASS
          The ImageConvertInterface implementation to be used (defaults to ConvertImageMagic)
protected  java.lang.String defaultImageType
          Supposed image type if not could be determined (configurable)
static Parameter[] GUI_PARAMETERS
           
protected  java.util.Map imageConvertParams
           
protected  Queue imageRequestQueue
           
protected  java.util.Hashtable imageRequestTable
           
protected  ImageRequestProcessor[] ireqprocessors
           
protected  int maxConcurrentRequests
           
protected static int maxRequests
           
protected static char NOQUOTING
          Parses the 'image conversion template' to a List.
 
Fields inherited from class org.mmbase.module.builders.AbstractServletBuilder
FORMAT_PARAMETERS, MIMETYPE_PARAMETERS, SERVLETPATH_PARAMETERS, usesBridgeServlet
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
AGE_PARAMETERS, broadcastChanges, database, DEFAULT_ALINEA, DEFAULT_EOL, description, descriptions, fields, listCache, nodeCache, 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.
protected  int convertAlias(java.lang.String num)
          Deprecated. This is hackery, and un-mmbase-like.
protected  ByteFieldContainer createCachedImageContainer(java.util.List params)
          This function should be called when an image/template does not have a cached version yet.
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  ByteFieldContainer getCachedImageContainer(java.util.List params)
          Determines the ckey, and asks the bytes from icaches.
protected  java.lang.String getGUIIndicatorWithAlt(MMObjectNode node, java.lang.String title, Parameters args)
          The GUI-indicator of an image-node also needs a res/req object.
 byte[] getImageBytes(java.util.List params)
          Deprecated. Use getImageNode(params);
 byte[] getImageBytes(scanpage sp, java.util.List params)
          Deprecated. Use getImageNode(params);
 byte[] getImageBytes5(scanpage sp, java.util.List params)
          Deprecated. Use getImageNode(params);
 ByteFieldContainer getImageContainer(java.util.List params)
          Returns a picture wich belongs to the given param line, with caching.
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  java.lang.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.
 int insert(java.lang.String owner, MMObjectNode node)
          Insert a new object (content provided) in the cloud.
 boolean nodeLocalChanged(java.lang.String machine, java.lang.String number, java.lang.String builder, java.lang.String ctype)
          Called when a local node is changed.
 boolean nodeRemoteChanged(java.lang.String machine, java.lang.String number, java.lang.String builder, java.lang.String ctype)
          Called when a remote node is changed.
protected  java.util.List parseTemplate(MMObjectNode node, java.lang.String template)
           
 void removeNode(MMObjectNode node)
          Override the MMObjectBuilder removeNode, to invalidate the Image Cache AFTER a delete-ion of the image node.
protected  void removeSurroundingQuotes(java.lang.StringBuffer buf)
          Just a utitility function, used by the function above.
 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, getParameterDefinition, getServletPath, getServletPath, getSuperGUIIndicator
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addField, addLocalObserver, addRemoteObserver, buildSet, checkAddTmpField, convertMMNode2SQL, count, count, create, createAlias, delete, 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, getFunctionParameters, getHardNode, getHardNode, getHTML, getInitParameter, getInitParameters, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getMMBase, getNewNode, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNode, getNodes, getNodes, getNodeType, getNumberFromName, getObjectType, getObjectValue, getParentBuilder, getPluralName, getPluralName, getPluralNames, getQuery, getQuery, getQuery, getRawNodes, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getSortedFields, getSortedListFields, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hashCode, hostname_function, insert, insertDone, isExtensionOf, isNodeCached, isVirtual, preCommit, preEdit, process, processSearchResults, putTmpNode, readSearchResults, removeField, removeRelations, removeSyncNodes, 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, setUniqueValue, setUniqueValue, setValue, setValue, setVersion, setXMLPath, setXMLValues, signalNewObject, testValidData, toString, toString, toXML, updateFields, waitUntilNodeChanged, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
created, getFullTableName, getTableName, size
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CACHE_PARAMETERS

public static final Parameter[] CACHE_PARAMETERS

GUI_PARAMETERS

public static final Parameter[] GUI_PARAMETERS

imageConvertParams

protected java.util.Map imageConvertParams

DEFAULT_IMAGECONVERTCLASS

protected static final java.lang.Class DEFAULT_IMAGECONVERTCLASS
The ImageConvertInterface implementation to be used (defaults to ConvertImageMagic)


maxConcurrentRequests

protected int maxConcurrentRequests

defaultImageType

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


maxRequests

protected static final int maxRequests
See Also:
Constant Field Values

imageRequestQueue

protected Queue imageRequestQueue

imageRequestTable

protected java.util.Hashtable imageRequestTable

ireqprocessors

protected ImageRequestProcessor[] ireqprocessors

NOQUOTING

protected static final char NOQUOTING
Parses the 'image conversion template' to a List. I.e. it break it up in substrings, with '+' delimiter. However a + char does not count if it is somewhere between brackets (). Brackets nor +-chars count if they are in quotes (single or double)

Since:
MMBase-1.7
See Also:
Constant Field Values
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 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
Parameters:
node - The node to set the defaults of.
Warning: No Java Documentation Available.

getGUIIndicatorWithAlt

protected java.lang.String getGUIIndicatorWithAlt(MMObjectNode node,
                                                  java.lang.String title,
                                                  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 java.lang.String getSGUIIndicatorForNode(MMObjectNode node,
                                                   Parameters args)
Description copied from class: AbstractImages
Returns GUI Indicator for node

Overrides:
getSGUIIndicatorForNode 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.

Specified by:
getImageFormat in class AbstractImages
Since:
MMBase-1.7

parseTemplate

protected java.util.List parseTemplate(MMObjectNode node,
                                       java.lang.String template)

removeSurroundingQuotes

protected void removeSurroundingQuotes(java.lang.StringBuffer buf)
Just a utitility function, used by the function above.

Since:
MMBase-1.7

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 getImageNode(params);


getImageBytes

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


getImageBytes

public byte[] getImageBytes(java.util.List params)
Deprecated. Use getImageNode(params);

Returns an MMObjectNode object holding the picture wich belongs to the given param line.

Specified by:
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 an MMObjectNode object

getImageContainer

public ByteFieldContainer getImageContainer(java.util.List params)
Returns a picture wich belongs to the given param line, with caching.

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 @link{ ByteFieldContainer}

getCachedImageContainer

protected ByteFieldContainer getCachedImageContainer(java.util.List params)
Determines the ckey, and asks the bytes from icaches. Will return null when not in cache, and otherwise a @link{ ByteFieldContainer} 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 @link{ ByteFieldContainer} object

createCachedImageContainer

protected ByteFieldContainer createCachedImageContainer(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 @link{ ByteFieldContainer} object 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 @link{ ByteFieldContainer} object

convertAlias

protected int convertAlias(java.lang.String num)
Deprecated. This is hackery, and un-mmbase-like.

Converts a string into a node-number, in the following a way. If the string represents an integer, this integer is returned, otherwise the String is used to do a search on title. Note that if you use this, the _oalias_ is ignored.


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
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
Throws:
ParseException
Warning: No Java Documentation Available.

determineImageType

protected void determineImageType(MMObjectNode node)
Determines the image type of an object and stores the content in the itype field.

Parameters:
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:
true if commit succesful

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.

nodeLocalChanged

public boolean nodeLocalChanged(java.lang.String machine,
                                java.lang.String number,
                                java.lang.String builder,
                                java.lang.String ctype)
Description copied from class: MMObjectBuilder
Called when a local node is changed. Should be called by subclasses if they override it.

Overrides:
nodeLocalChanged in class MMObjectBuilder
Parameters:
machine - Name of the machine that changed the node.
number - Number of the changed node as a String
builder - type of the changed node
ctype - command type, 'c'=changed, 'd'=deleted', 'r'=relations changed, 'n'=new
Returns:
always true

nodeRemoteChanged

public boolean nodeRemoteChanged(java.lang.String machine,
                                 java.lang.String number,
                                 java.lang.String builder,
                                 java.lang.String ctype)
Description copied from class: MMObjectBuilder
Called when a remote node is changed. Should be called by subclasses if they override it.

Overrides:
nodeRemoteChanged in class MMObjectBuilder
Parameters:
machine - Name of the machine that changed the node.
number - Number of the changed node as a String
builder - type of the changed node
ctype - command type, 'c'=changed, 'd'=deleted', 'r'=relations changed, 'n'=new
Returns:
always true


MMBase build 1.7.1.20041002