|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jcorporate.expresso.core.dataobjects.BaseDataObject
com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
com.jcorporate.expresso.core.dbobj.DBObject
com.jcorporate.expresso.core.dbobj.SecuredDBObject
com.jcorporate.expresso.services.dbobj.MediaDBObject
A MediaDBObject is a DBObject intended to be used for storage of media objects directly in the database. It facilitates generic storage by automatically creating filename and MimeType fields that map to the MimeTypes table for easy downloading. This allows for the ability to store more than one media type in the same table while still allowing the Application to appropriately deal with each MimeType.
This data object conveniently stores and retrieves Binary Large OBjects (BLOBS) or Character Large OBjects (CLOBS). Performance note: Each blob field access requires one more round trip to the database since BLOBs cannot be effectively stored in memory. Thus the lazy loading.Typical Usage:
myMediaDBObject = new myMediaDBObject();
File f = new File("/temp/output.tmp");
FileOutputStream fos = new FileOutputStream(f);
myMediaDBObject.setField("id", 2)
InputStream is = myMediaDBObject.retrieveBlob("picture");
// Copy the input stream to the file output stream
myMediaDBObject.release();
| Nested Class Summary |
| Nested classes inherited from class com.jcorporate.expresso.core.dbobj.DBObject |
DBObject.FieldError, DBObject.FieldUpdate |
| Field Summary | |
static String |
FLD_FILE_SUFFIX
Suffix for the filename field. |
static String |
FLD_MIME_SUFFIX
Suffix for the mime number field. |
static String |
FLD_SIZE_SUFFIX
Suffix for the file size field. |
| 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 | |
MediaDBObject()
Default Constructor. |
|
MediaDBObject(DBConnection newConnection)
Constructor that sets the connection on create |
|
MediaDBObject(DBConnection newConnection,
String setupTablesContext)
Constructor that sets a connection as the object is created - typically this is used when a particular DBConnection is required for the purposes of maintaining a database transaction. |
|
MediaDBObject(int newUid)
Constructor: Specify a DB connection AND user |
|
MediaDBObject(RequestContext request)
For using DBObjects within Controllers. |
|
| Method Summary | |
protected void |
addBlobField(String fieldName,
String fieldDescription)
Adds a BLOB field definition to this DBObject. |
String |
getBlobFilename(String fieldName)
Convenience method to get the LOB attachment filename |
String |
getBlobFileSize(String fieldName)
Convenience method to get the LOB attachment content length |
int |
getBlobFileSizeInt(String fieldName)
Convenience method to get the LOB attachment content length as an integer |
String |
getBlobMimeType(String fieldName)
Convenience method to get the LOB attachment mime content type |
void |
release()
Release the associated data with the blob fields. |
InputStream |
retrieveBlob(String fieldName)
Retrieves a BLOB from the database. |
void |
saveBlob(String fieldName)
This method is for saving a BLOB field that has been processed by the DefaultAutoElement object. |
void |
saveBlob(String fieldName,
InputStream value,
int fileSize)
Saves a file to the blob field, |
void |
saveBlob(String fieldName,
InputStream value,
String fileName,
int fileSize)
Saves a BLOB field to the database |
| Methods inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject |
add, canRequesterAdd, canRequesterDelete, canRequesterRead, canRequesterUpdate, checkAllowed, copyAttributes, count, createSecurityCache, delete, deleteAll, find, getRequestingUid, getString, getString, getString, getString, getString, getString, getSystemUid, instantiate, isAllowed, retrieve, search, searchAndRetrieveList, searchAndRetrieveList, setRequestingUid, update |
| 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 |
public static final String FLD_FILE_SUFFIX
Each blob field has several additional supporting fields. The supporting fields have the name of the original BLOB field plus a suffix that is appended to the BLOB field name to get the supporting field
public static final String FLD_MIME_SUFFIX
Each blob field has several additional supporting fields. The supporting fields have the name of the original BLOB field plus a suffix that is appended to the BLOB field name to get the supporting field
public static final String FLD_SIZE_SUFFIX
Each blob field has several additional supporting fields. The supporting fields have the name of the original BLOB field plus a suffix that is appended to the BLOB field name to get the supporting field
| Constructor Detail |
public MediaDBObject()
throws DBException
DBException - upon initialization error
public MediaDBObject(DBConnection newConnection)
throws DBException
newConnection - The dbConnection object to associate with this
object
public MediaDBObject(DBConnection newConnection,
String setupTablesContext)
throws DBException
This constructor is neceesary to work with otherDBMap and transaction capabilities
newConnection - The DBConnection to utilizesetupTablesContext - The data context that contains the setup (and
security) tables for this object
public MediaDBObject(int newUid)
throws DBException
newUid - User ID attempting to use this object.
If this is SecuredDBObject.SYSTEM_ACCOUNT, then
full permissions are granted. Note that you cannot log in
as SecuredDBObject.SYSTEM_ACCOUNT,
t can only be used from within a method.
DBException - If the object cannot be created
public MediaDBObject(RequestContext request)
throws DBException
request - - The controller request handed to you by the framework.
DBException - upon construction error| Method Detail |
public String getBlobFilename(String fieldName)
throws DBException
DBException - if a database error occurs
public String getBlobMimeType(String fieldName)
throws DBException
DBException - if a database error occurs
public String getBlobFileSize(String fieldName)
throws DBException
DBException - if a database error occurs
public int getBlobFileSizeInt(String fieldName)
throws DBException
DBException - if a database error occurs
protected void addBlobField(String fieldName,
String fieldDescription)
throws DBException
Using this method creates several supporting fields.
fieldName - The name of the field to create.fieldDescription - The 'friendly name' of the field to create
DBException - upon creation error.
public void saveBlob(String fieldName)
throws DBException
fieldName - The field Name to save
DBException - If unable to save the file to the database
IllegalStateException - if unable to retrieve the appropriate attributes.
IllegalArgumentException - if fieldName doesn't exist or is null.DefaultAutoElement.parseSingleInput(com.jcorporate.expresso.core.controller.ControllerRequest, com.jcorporate.expresso.core.dataobjects.DataObject, java.lang.String, java.lang.String, com.jcorporate.expresso.core.controller.ErrorCollection)
public void saveBlob(String fieldName,
InputStream value,
String fileName,
int fileSize)
throws DBException
fieldName - the field Name to savevalue - A binary stream to become the value of the new strea,fileName - The name of the 'file' to storefileSize - The size of the file to save.
DBException
public void saveBlob(String fieldName,
InputStream value,
int fileSize)
throws DBException
fieldName - the field name to save to the databasevalue - A java.io.InputStream to save into the databasefileSize - the size of the stream that is getting saved to the database
DBException - upon communication error
public InputStream retrieveBlob(String fieldName)
throws DBException
fieldName - The name of the field to retrieve
DBException - upon retrieval errorpublic void release()
|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||