org.mmbase.module.builders
Class MediaParts

java.lang.Object
  |
  +--org.mmbase.module.core.MMTable
        |
        +--org.mmbase.module.core.MMObjectBuilder
              |
              +--org.mmbase.module.builders.MediaParts
Direct Known Subclasses:
AudioParts, VideoParts

public abstract class MediaParts
extends MMObjectBuilder

MediaParts is the main class for mediaobjects. All media type builders (eg. AudioParts) builders extend from this one. MediaParts implements the replace command GETURL to get the url to a mediafile. MediaParts also implements an urlCache which comes in handy when queries lots of audioparts at once. (This takes time since urls aren't stored directly in a mediapart but through rawaudios/videos etc..) To use the urlCache you have to set the XML builder property 'UrlCaching' to 'true'. default is false. For each object whos url is requested two types of cache entries will me made. One is for requests coming from the internal www server, and one for requests coming from outside. VPRO uses this to send request from employees who visit the site to a local RealServer instead of the main RealServer. If an audiopart or videopart node changes locally or remotely, the related UrlCache entries will be removed immediately.

Version:
$Id: MediaParts.java,v 1.5 2001/05/08 16:26:46 vpro Exp $
Author:
David van Zeventer

Field Summary
static LRUHashtable urlCache
           
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
broadcastChanges, className, database, debug, description, descriptions, fields, NODE_MAX_SIZE, nodeCache, obj2type, OBJ2TYPE_MAX_SIZE, oType, replaceCache, searchAge, sortedDBLayout, TEMPNODE_DEFAULT_SIZE, TemporaryNodes, virtual
 
Fields inherited from class org.mmbase.module.core.MMTable
mmb, tableName
 
Constructor Summary
MediaParts()
           
 
Method Summary
abstract  java.lang.String doGetUrl(scanpage sp, int number, int userSpeed, int userChannels)
          Retrieves the media file url elated with the object.
 int getChannelsParam(java.lang.String channels)
          Parses the channels parameter value.
abstract  int getMinChannels()
          Gets minimal channel setting from mediautil
abstract  int getMinSpeed()
          Gets minimal speed setting from mediautil
 int getNumberParam(java.lang.String number)
          Parses the number parameter value.
 int getSpeedParam(java.lang.String speed)
          Parses the speed parameter value.
 java.lang.String getUrl(scanpage sp, int number, int userSpeed, int userChannels)
          Retrieves the media file url elated with the object.
 boolean init()
          Initializes and gets builder properties.
 boolean nodeLocalChanged(java.lang.String machine, java.lang.String number, java.lang.String builder, java.lang.String ctype)
          Called when a node was changed on a local server.
 boolean nodeRemoteChanged(java.lang.String machine, java.lang.String number, java.lang.String builder, java.lang.String ctype)
          Called when a node was changed by a remote server.
 void removeFromUrlCache(java.lang.String number)
          Removes the entries related with this objectnumber from the urlCache.
 boolean removeRaws(java.lang.String buildername, int number)
          Removes related rawaudio/video objects.
 java.lang.String replace(scanpage sp, java.util.StringTokenizer command)
          replace all for frontend code Replace commands available are GETURL (gets mediafile url for an objectnumber), from cache or not depending on builder property.
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addField, addLocalObserver, addRemoteObserver, buildSet, checkAddTmpField, commit, convertMMNode2SQL, count, create, createAlias, created, debug, deleteNodeCache, executeFunction, fieldLocalChanged, getAge, getAliasedNode, getCacheNumbers, getCacheSize, getCacheSize, getClassName, getDBByte, getDBKey, getDBState, getDBText, getDBType, getDefaultTeaser, getDefaultUrl, getDescription, getDescriptions, getDutchSName, getEditFields, getField, getFieldNames, getFields, getFullTableName, getFunctionParameters, getGUIIndicator, getGUIIndicator, getHardNode, getHTML, getInitParameter, getInitParameters, getList, getMachineName, getMaintainer, getNewNode, getNewTmpNode, getNextField, getNode, getNode, getNodeType, getNumberFromName, getPluralName, getPluralName, getPluralNames, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getSortedFields, getSortedListFields, getTableName, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, getXMLSetup, hostname_function, init_obj2type, insert, insert, insertDone, isNodeCached, isVirtual, isXMLConfig, preCommit, preEdit, process, putTmpNode, readSearchResults, removeField, removeNode, removeRelations, removeTmpNode, search, search, search, searchIn, searchIn, searchIn, searchNumbers, searchVector, searchVector, searchVector, searchVector, searchVectorIn, searchVectorIn, searchVectorIn, searchVectorIn, searchWithWhere, sendFieldChangeSignal, setClassName, setDBLayout_xml, setDBLayout, setDebug, setDefaults, setDescription, setDescriptions, setDutchSName, setInitParameter, setMaintainer, setMMBase, setPluralNames, setSearchAge, setSingularNames, setTableName, setValue, setVersion, setXmlConfig, setXMLPath, setXMLValues, signalNewObject, testValidData, toXML, waitUntilNodeChanged, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

urlCache

public static LRUHashtable urlCache
Constructor Detail

MediaParts

public MediaParts()
Method Detail

init

public boolean init()
Initializes and gets builder properties.
Overrides:
init in class MMObjectBuilder
Returns:
true always

nodeLocalChanged

public boolean nodeLocalChanged(java.lang.String machine,
                                java.lang.String number,
                                java.lang.String builder,
                                java.lang.String ctype)
Called when a node was changed on a local server.
Overrides:
nodeLocalChanged in class MMObjectBuilder
Parameters:
machine - Name of the node that was changed.
number - the object number of the node that was changed.
builder - the buildername of the object that was changed
ctype - the node changed type
Returns:
true, always

nodeRemoteChanged

public boolean nodeRemoteChanged(java.lang.String machine,
                                 java.lang.String number,
                                 java.lang.String builder,
                                 java.lang.String ctype)
Called when a node was changed by a remote server.
Overrides:
nodeRemoteChanged in class MMObjectBuilder
Parameters:
machine - Name of the node that was changed.
number - the object number of the node that was changed.
builder - the buildername of the object that was changed
ctype - the node changed type
Returns:
true, always

removeFromUrlCache

public void removeFromUrlCache(java.lang.String number)
Removes the entries related with this objectnumber from the urlCache.
Parameters:
number -  

removeRaws

public boolean removeRaws(java.lang.String buildername,
                          int number)
Removes related rawaudio/video objects.
Parameters:
buildername - the buildername of which type this number is.
number - objectnumber of audio/videopart.
Returns:
true if remove was succesful, false otherwise.

replace

public java.lang.String replace(scanpage sp,
                                java.util.StringTokenizer command)
replace all for frontend code Replace commands available are GETURL (gets mediafile url for an objectnumber), from cache or not depending on builder property.
Overrides:
replace in class MMObjectBuilder
Parameters:
sp - the scanpage
sp - the stringtokenizer reference with the replace command.
Returns:
a String the result value of the replace command or null.

getUrl

public java.lang.String getUrl(scanpage sp,
                               int number,
                               int userSpeed,
                               int userChannels)
Retrieves the media file url elated with the object.
Parameters:
sp - the scanpage
number - objectnumber requested.
userSpeed - speed settings.
userChannels - channel settings.
Returns:
a String with url of the media file or null;

doGetUrl

public abstract java.lang.String doGetUrl(scanpage sp,
                                          int number,
                                          int userSpeed,
                                          int userChannels)
Retrieves the media file url elated with the object. A subclass must provide an implementation of this method.
Parameters:
sp - the scanpage
number - objectnumber requested.
userSpeed - speed settings.
userChannels - channel settings.
Returns:
a String with url of the media file or null;

getMinSpeed

public abstract int getMinSpeed()
Gets minimal speed setting from mediautil
Returns:
minimal speed setting

getMinChannels

public abstract int getMinChannels()
Gets minimal channel setting from mediautil
Returns:
minimal channel setting

getNumberParam

public int getNumberParam(java.lang.String number)
Parses the number parameter value.
Parameters:
number - the object number as string parameter
Returns:
the objectnumber as integer or -1 if it isn't an integer.

getSpeedParam

public int getSpeedParam(java.lang.String speed)
Parses the speed parameter value.
Parameters:
number - the speed setting as string parameter
Returns:
the speed value as integer or minimal settings if it isn't an integer.

getChannelsParam

public int getChannelsParam(java.lang.String channels)
Parses the channels parameter value.
Parameters:
channels - the channels setting as string parameter
Returns:
the channels value as integer or minimal settings if it isn't an integer.


MMBase 2001