Expresso 5-6

com.jcorporate.expresso.services.dbobj
Class MimeTypes

java.lang.Object
  extended bycom.jcorporate.expresso.core.dataobjects.BaseDataObject
      extended bycom.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
          extended bycom.jcorporate.expresso.core.dbobj.DBObject
              extended bycom.jcorporate.expresso.core.dbobj.SecuredDBObject
                  extended bycom.jcorporate.expresso.services.dbobj.MimeTypes
All Implemented Interfaces:
Cacheable, ContextNested, DataObject, LookupInterface, Securable, Serializable

public class MimeTypes
extends SecuredDBObject

This table provides for mapping between files and mime types. Here we try to put every mime type that we are aware of and provide the following services:

Version:
$Revision: 1.19 $ $Date: 2004/11/17 20:48:18 $
Author:
Michael Rimov
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.jcorporate.expresso.core.dbobj.DBObject
DBObject.FieldError, DBObject.FieldUpdate
 
Field Summary
static String FLD_DESCRIPTION
           
static String FLD_FILE_EXTENSIONS
           
static String FLD_MIMEICON
           
static String FLD_MIMENUMBER
          Field Names for the MIMETYPES table
static String FLD_MIMETYPE
           
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
ADD, ALL_FUNCTIONS, CACHE_NAME, CACHE_TTY, DELETE, SEARCH, SYSTEM_ACCOUNT, SYSTEM_ACCOUNT_NAME, UPDATE
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.DBObject
ATTRIBUTE_ERROR, ATTRIBUTE_ERROR_MESSAGE, ATTRIBUTE_PAGE_LIMIT, BIG_DECIMAL_ZERO, EMAIL_MASK, EVENT_ADD, EVENT_DELETE, EVENT_UPDATE, FLOAT_MASK, INT_MASK, IS_CHECK_RELATIONAL_INTEGRITY, UPDATE_CHANGED_ONLY, WHERE_KEYWORD
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
anyFieldsDistinct, anyFieldsToRetrieve, appendCustomWhere, caseSensitiveQuery, customWhereClause, dbKey, distinctFields, localConnection, LONGBINARY_READ_DEFAULT_SIZE, maxRecords, myClassName, myUpdates, offsetRecord, recordSet, retrieveFields, sMetadataMap, sortKeys
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
currentStatus, globalMask
 
Fields inherited from interface com.jcorporate.expresso.core.dataobjects.DataObject
STATUS_CURRENT, STATUS_DELETED, STATUS_NEW, STATUS_UPDATED
 
Constructor Summary
MimeTypes()
           
MimeTypes(ControllerRequest request)
          For using DBObjects within Controllers.
MimeTypes(int uid)
           
 
Method Summary
 void add()
          As per usual add, but it resets the fileMap so future calls to it will show the appropriate changes
 void clearFileMap()
           
 void delete()
          As per usual delete, but it resets the fileMap so future calls to it will show the appropriate changes
 int getExpectedDefaultPopulation()
          Useful method for unit testing to make sure that everything got added during setup as expected.
static javax.activation.MimetypesFileTypeMap getFileMap(String dataContext)
          Use this function to get a javax.activation.MimetypesFileTypeMap object that is intantiated with the data stored in the MimeTypes table rather than the system default.
 String getIconURL()
          Returns the icon URL associated with this MimeType object
static MimeTypes getMimeType(String fileName, String dataContext)
          Give it a file name and a data context and we'll get the MimeType object associated with it.
static MimeTypes getMimeTypeFromMimeId(int mimeNumber, String dataContext)
          Given a Expresso standard MimeTypes "MimeNumber" field and a data context and we'll get the MimeType object associated with it.
 Vector getValidValues(String fieldName)
          Returns the valid values for any particular field
 Vector getValues()
          Method to return a Vector of ValidValue Template method--not implemented in this superclass.
 void populateDefaultValues()
          populateDefaultValues is called by the schema object to allow a table to populate itself with any desired values.
protected  void setupFields()
          Table definition of the MimeTypes tables
 void update()
          As per usual update, but it resets the fileMap so future calls to it will show the appropriate changes
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
canRequesterAdd, canRequesterDelete, canRequesterRead, canRequesterUpdate, checkAllowed, copyAttributes, count, createSecurityCache, deleteAll, find, getRequestingUid, getString, getString, getString, getString, getString, getString, getSystemUid, instantiate, isAllowed, retrieve, search, searchAndRetrieveList, searchAndRetrieveList, setRequestingUid
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.DBObject
addDetail, addField, addField, addFieldError, addFoundKeys, addIfNeeded, addIndex, addKey, addOrUpdate, addSortKey, addTransition, addVirtualField, addVirtualField, addVirtualField, addVirtualField, average, basicAdd, cacheIsChangedComparison, checkAllReferredToBy, checkAllRefs, checkAllRefsPublic, checkDeleteDetailPerm, checkField, checkRef, checkRef, clear, clearDistinctFields, clearError, clearFieldsToRetrieve, clearSortKeys, containsWildCards, delete, deleteAll, deleteDetails, denotesRange, equals, forKey, formatDateTime, get, getAllAttributes, getAttribute, getAttributesIterator, getBooleanFieldValue, getCacheSize, getCacheStatsMap, getCacheUtil, getCheckZeroUpdate, getCustomWhereClause, getDataContext, getDataField, getDataTransferObject, getDBName, getDetails, getDistinctFieldCount, getDistinctFields, getField, getFieldBigDecimal, getFieldBoolean, getFieldByte, getFieldByteArray, getFieldData, getFieldDate, getFieldDecimalFormatted, getFieldDouble, getFieldErrorMessage, getFieldFloat, getFieldInt, getFieldLong, getFieldMetaData, getFieldShort, getFieldsToRetrieveCount, getFilterClass, getFoundCount, getFoundKeysArray, getIndexArray, getISOValuesDefault, getISOValuesDefault, getISOValuesDefault, getKey, getKeyFieldListIterator, getLength, getLengthInt, getLocalConnection, getLocale, getLogger, getLookupObject, getMax, getMax, getMaxRecords, getMyKeys, getMyUpdatesArray, getOffsetRecord, getPatternMatcher, getPrecision, getSerializedForm, getStringFilter, getThisDBbj, getThisDBObj, getValidValueDescrip, getValidValuesList, getValuesDefault, getValuesDefault, getValuesDefault, hasError, hasErrors, haveAllKeys, initialize, isCached, isChanged, isDistinct, isEmpty, isFieldDistinct, isFieldNull, isFieldsToRetrieve, isFieldToRetrieve, isMultiValued, isReadOnly, isSecret, isVirtual, loadFromConnection, logChange, max, min, newInstance, noNewLine, noQuotes, notifyListeners, referredToBy, removeAttribute, removeFromCache, retrieveFromCache, saveBinaryField, search, set, setAttribute, setCacheSize, setCharset, setCheckZeroUpdate, setConnection, setConnection, setCustomWhereClause, setCustomWhereClause, setDataContext, setDataField, setDataTransferObject, setDefaultValue, setDescription, setField, setField, setField, setField, setField, setField, setField, setField, setField, setField, setFieldData, setFieldData, setFieldDistinct, setFieldsToRetrieve, setFilterClass, setFilterClass, setKeys, setLocale, setLookupField, setLookupObject, setMask, setMaxRecords, setMultiValued, setName, setOffsetRecord, setReadOnly, setSchema, setSecret, setSortKey, setStringFilter, setStringFiltersOnAll, setTargetDbSchema, setTargetTable, sqlAggrFunction, sum, toDebugString, update, updateAll, updateAll, verify
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
addInParam, addOutParam, buildWhereClause, buildWhereClauseBuffer, checkZeroUpdate, constructNewMetaData, createAndExecuteSearch, createAndRunStoreProcedure, getConnectionPool, getCustomStringFieldValue, getDef, getDistinctFieldArrayList, getExecutor, getFieldsToRetrieveIterator, getJDBCMetaData, getJDBCUtil, getMappedDataContext, getMetaData, getQueryInterface, getSerialForm, loadFromConnection, makeLimitationStub, quoteIfNeeded, runStoredProcedure, runStoredProcedureAndRetrieveList, selectFieldString, setCaseSensitiveQuery, setDBConnectionPool, setDBName, setMappedDataContext, setOriginalDBName, setTargetStoreProcedure
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
getGlobalMask, getStatus, isGlobalMasked, setFieldsWithDefaults, setGlobalMask, setStatus
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FLD_MIMENUMBER

public static final String FLD_MIMENUMBER
Field Names for the MIMETYPES table

See Also:
Constant Field Values

FLD_MIMETYPE

public static final String FLD_MIMETYPE
See Also:
Constant Field Values

FLD_DESCRIPTION

public static final String FLD_DESCRIPTION
See Also:
Constant Field Values

FLD_MIMEICON

public static final String FLD_MIMEICON
See Also:
Constant Field Values

FLD_FILE_EXTENSIONS

public static final String FLD_FILE_EXTENSIONS
See Also:
Constant Field Values
Constructor Detail

MimeTypes

public MimeTypes()
          throws DBException
See Also:
SecuredDBObject

MimeTypes

public MimeTypes(int uid)
          throws DBException
Parameters:
uid - The owning user id

MimeTypes

public MimeTypes(ControllerRequest request)
          throws DBException
For using DBObjects within Controllers. Initializes based upon the current user and the requested db. [Of course this can be modified later]

Parameters:
request - - The controller request handed to you by the framework.
Method Detail

getValues

public Vector getValues()
                 throws DBException
Description copied from class: DBObject
Method to return a Vector of ValidValue Template method--not implemented in this superclass. This method may be implemented by objects that want to provide a list of valid values for other DB objects. It is strongly recommended that the valid value list be cached (via the CacheManager) for performance. The naming convention used in Expresso is to store the ValidValue list with a cache name the same as the db objects class name with ".validValues" appended TODO: This should be converted to array List versions

Specified by:
getValues in interface LookupInterface
Overrides:
getValues in class DBObject
Returns:
Vector of ValidValue Value/Description pairs for mime types
Throws:
DBException - If the values cannot be retrieved
See Also:
DBObject.getValidValues(java.lang.String)

getExpectedDefaultPopulation

public int getExpectedDefaultPopulation()
Useful method for unit testing to make sure that everything got added during setup as expected.

Returns:
int for what's expected in the database

getValidValues

public Vector getValidValues(String fieldName)
                      throws DBException
Returns the valid values for any particular field

Overrides:
getValidValues in class DBObject
Parameters:
fieldName - the name of the field to retrieve
Returns:
a Vector of vaild value objects
Throws:
DBException - upon error

getMimeType

public static MimeTypes getMimeType(String fileName,
                                    String dataContext)
                             throws DBException
Give it a file name and a data context and we'll get the MimeType object associated with it. Factory style method.

DESIGN REQUEST

This method raises an exception if the MimeType is not found. It should instead return a null, because you cannot distinguished between a data base failure and db failure.

Parameters:
fileName - A name to retrieve the mime type. Note that this will be compared via lower case since thanks to Windows, you can have doc, DoC, DOC, dOC etc... which EXTREMELY complicates the matching process.
dataContext - the data context to get the underlying data from. May be null for default context
Returns:
a MimeType object the specified parameters
Throws:
DBException - if we can't find the appropriate object
DBException - if a data access error occurs or if MIME Type does not in�the database
See Also:
getMimeTypeFromMimeId(int, java.lang.String)

getMimeTypeFromMimeId

public static MimeTypes getMimeTypeFromMimeId(int mimeNumber,
                                              String dataContext)
                                       throws DBException
Given a Expresso standard MimeTypes "MimeNumber" field and a data context and we'll get the MimeType object associated with it. Another factory style method.

Parameters:
mimeNumber - the mime number id from the MimeTypes data object
dataContext - the data context to get the underlying data from. May be null for default context
Returns:
a MimeType object the specified parameters, or null if no matching mime type object exists in the database.
Throws:
DBException - if we can't find the appropriate object
DBException - if a data access error occurs.
See Also:
getMimeTypeFromMimeId(int, java.lang.String)

getFileMap

public static javax.activation.MimetypesFileTypeMap getFileMap(String dataContext)

Use this function to get a javax.activation.MimetypesFileTypeMap object that is intantiated with the data stored in the MimeTypes table rather than the system default. Allows for centralized management of the system mime types rather than dealing with scattered configuration files. If there is an error reading the data, we simply instantiate a default MimetypesFileTypeMap object and return that instead.

Parameters:
dataContext - the dbcontext to use or null if you want to just use the default context.
Returns:
an instantiated MimeTypesFileTypeMap
See Also:
MimetypesFileTypeMap

populateDefaultValues

public void populateDefaultValues()
                           throws DBException
Description copied from class: DBObject
populateDefaultValues is called by the schema object to allow a table to populate itself with any desired values.

The base class implementation does nothing. Override this method in derived classes to achieve your custom behavior.

The calling routine, DBTool.populateTables(), will set dbName on each object, so you can get it from getDataContext(), and you can assume that the user for the population action is Admin.

Overrides:
populateDefaultValues in class DBObject
Throws:
DBException - if an error occurs while populating the table.
See Also:

This function populates the mimeType table with a wide variety of basic MIME types.


getIconURL

public String getIconURL()
Returns the icon URL associated with this MimeType object

Returns:
the appropriate URL for this particular mime type.

setupFields

protected void setupFields()
                    throws DBException
Table definition of the MimeTypes tables

Overrides:
setupFields in class DBObject
Throws:
DBException - If there is an error setting up the fields as requested. For example, if a field allowing null is requested as part of the key

add

public void add()
         throws DBException
As per usual add, but it resets the fileMap so future calls to it will show the appropriate changes

Specified by:
add in interface DataObject
Overrides:
add in class SecuredDBObject
Throws:
DBException - If the user is not permitted to add or if the add fails

update

public void update()
            throws DBException
As per usual update, but it resets the fileMap so future calls to it will show the appropriate changes

Specified by:
update in interface DataObject
Overrides:
update in class SecuredDBObject
Throws:
DBException - if update is not allowed for the current user

delete

public void delete()
            throws DBException
As per usual delete, but it resets the fileMap so future calls to it will show the appropriate changes

Specified by:
delete in interface DataObject
Overrides:
delete in class SecuredDBObject
Throws:
DBException - if delete is not allowed for the current user

clearFileMap

public void clearFileMap()

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.