|
|||||||||
| Home >> All >> com >> jcorporate >> expresso >> services >> [ dbobj overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.jcorporate.expresso.services.dbobj
Class MediaDBObject

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
- All Implemented Interfaces:
- com.jcorporate.expresso.core.cache.Cacheable, com.jcorporate.expresso.core.dataobjects.ContextNested, com.jcorporate.expresso.core.dataobjects.DataObject, com.jcorporate.expresso.core.dbobj.LookupInterface, com.jcorporate.expresso.core.dataobjects.Securable, java.io.Serializable
- public class MediaDBObject
- extends com.jcorporate.expresso.core.dbobj.SecuredDBObject
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();
- Since:
- Expresso 5.1
- Version:
- $Revision: 1.9 $ on $Date: 2004/11/17 20:48:18 $
| Nested Class Summary |
| Nested classes inherited from class com.jcorporate.expresso.core.dbobj.DBObject |
com.jcorporate.expresso.core.dbobj.DBObject.FieldError, com.jcorporate.expresso.core.dbobj.DBObject.FieldUpdate |
| Field Summary | |
static java.lang.String |
FLD_FILE_SUFFIX
Suffix for the filename field. |
static java.lang.String |
FLD_MIME_SUFFIX
Suffix for the mime number field. |
static java.lang.String |
FLD_SIZE_SUFFIX
Suffix for the file size field. |
private com.jcorporate.expresso.core.dataobjects.jdbc.LobField |
lf
The LOBField object for streaming data into and out of the Database |
private static org.apache.log4j.Logger |
log
The Log4j Logger |
| 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(com.jcorporate.expresso.core.db.DBConnection newConnection)
Constructor that sets the connection on create |
|
MediaDBObject(com.jcorporate.expresso.core.db.DBConnection newConnection,
java.lang.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(com.jcorporate.expresso.core.dbobj.RequestContext request)
For using DBObjects within Controllers. |
|
| Method Summary | |
protected void |
addBlobField(java.lang.String fieldName,
java.lang.String fieldDescription)
Adds a BLOB field definition to this DBObject. |
java.lang.String |
getBlobFilename(java.lang.String fieldName)
Convenience method to get the LOB attachment filename |
java.lang.String |
getBlobFileSize(java.lang.String fieldName)
Convenience method to get the LOB attachment content length |
int |
getBlobFileSizeInt(java.lang.String fieldName)
Convenience method to get the LOB attachment content length as an integer |
java.lang.String |
getBlobMimeType(java.lang.String fieldName)
Convenience method to get the LOB attachment mime content type |
void |
release()
Release the associated data with the blob fields. |
java.io.InputStream |
retrieveBlob(java.lang.String fieldName)
Retrieves a BLOB from the database. |
void |
saveBlob(java.lang.String fieldName)
This method is for saving a BLOB field that has been processed by the DefaultAutoElement object. |
void |
saveBlob(java.lang.String fieldName,
java.io.InputStream value,
int fileSize)
Saves a file to the blob field, |
void |
saveBlob(java.lang.String fieldName,
java.io.InputStream value,
java.lang.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 |
lf
private com.jcorporate.expresso.core.dataobjects.jdbc.LobField lf
- The LOBField object for streaming data into and out of the Database
log
private static final org.apache.log4j.Logger log
- The Log4j Logger
FLD_FILE_SUFFIX
public static final java.lang.String FLD_FILE_SUFFIX
- Suffix for the filename field.
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
- See Also:
- Constant Field Values
FLD_MIME_SUFFIX
public static final java.lang.String FLD_MIME_SUFFIX
- Suffix for the mime number field. This field contains a pointer into the
MimeTypes table.
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
- See Also:
- Constant Field Values
FLD_SIZE_SUFFIX
public static final java.lang.String FLD_SIZE_SUFFIX
- Suffix for the file size field. This field contains the size of the blob
that was saved to the database.
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
- See Also:
- Constant Field Values
| Constructor Detail |
MediaDBObject
public MediaDBObject()
throws com.jcorporate.expresso.core.db.DBException
- Default Constructor.
MediaDBObject
public MediaDBObject(com.jcorporate.expresso.core.db.DBConnection newConnection) throws com.jcorporate.expresso.core.db.DBException
- Constructor that sets the connection on create
MediaDBObject
public MediaDBObject(com.jcorporate.expresso.core.db.DBConnection newConnection, java.lang.String setupTablesContext) throws com.jcorporate.expresso.core.db.DBException
-
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. If a specific connection is not used,
there is no way to use commit() and rollback() in the event of failure, as a
different DBConnection might be used for each phase of the transaction.
Critial sections should therefore explicity request a DBConnection from the
connection pool and pass it to each of the DB objects in that section.
This constructor is neceesary to work with otherDBMap and transaction capabilities
MediaDBObject
public MediaDBObject(int newUid)
throws com.jcorporate.expresso.core.db.DBException
- Constructor: Specify a DB connection AND user
MediaDBObject
public MediaDBObject(com.jcorporate.expresso.core.dbobj.RequestContext request) throws com.jcorporate.expresso.core.db.DBException
- For using DBObjects within Controllers. Initializes based upon the current
user and the requested db. [Of course this can be modified later]
| Method Detail |
getBlobFilename
public java.lang.String getBlobFilename(java.lang.String fieldName) throws com.jcorporate.expresso.core.db.DBException
- Convenience method to get the LOB attachment filename
getBlobMimeType
public java.lang.String getBlobMimeType(java.lang.String fieldName) throws com.jcorporate.expresso.core.db.DBException
- Convenience method to get the LOB attachment mime content type
getBlobFileSize
public java.lang.String getBlobFileSize(java.lang.String fieldName) throws com.jcorporate.expresso.core.db.DBException
- Convenience method to get the LOB attachment content length
getBlobFileSizeInt
public int getBlobFileSizeInt(java.lang.String fieldName) throws com.jcorporate.expresso.core.db.DBException
- Convenience method to get the LOB attachment content length as
an integer
addBlobField
protected void addBlobField(java.lang.String fieldName, java.lang.String fieldDescription) throws com.jcorporate.expresso.core.db.DBException
- Adds a BLOB field definition to this DBObject.
Using this method creates several supporting fields.
- BlobFieldName + '_mimeType': An integer value that points to the mime type in the MimeTypes table. When the BLOB is retrieved, the content stream mime type can be set allowing for the web browser to properly interpret the incoming stream.
- BlobFieldName + '_fileName': A file name for the BLOB field. While this is optional, it allows the WebBrowser to assign a default file name when it saves the BLOB locally
- BlobFieldName + '_fileSize': This field gets set when a file is uploaded into the database table. It allows for the browser to determine what percentage of the BLOB is transferred to the browser
saveBlob
public void saveBlob(java.lang.String fieldName) throws com.jcorporate.expresso.core.db.DBException
- This method is for saving a BLOB field that has been processed by the
DefaultAutoElement object. We have all the information we need because
the file to save, mime types, etc, have all been saved as attributes of
the fieldName specified. Do not call this method if you have not either
set the appropriate attributes yourself or have called
DefaultAutoElement.parseSingleInput().
This method also deletes the uploaded temp file upon completion. Create the
File object and call one of the other saveBlob objects yourself if you do
not want this behavior.
saveBlob
public void saveBlob(java.lang.String fieldName, java.io.InputStream value, java.lang.String fileName, int fileSize) throws com.jcorporate.expresso.core.db.DBException
- Saves a BLOB field to the database
saveBlob
public void saveBlob(java.lang.String fieldName, java.io.InputStream value, int fileSize) throws com.jcorporate.expresso.core.db.DBException
- Saves a file to the blob field,
retrieveBlob
public java.io.InputStream retrieveBlob(java.lang.String fieldName) throws com.jcorporate.expresso.core.db.DBException
- Retrieves a BLOB from the database. This functiona allocates a DBConnection
object and all the corresponding input streams. You must process the BLOB
before doing anything else to this particular DBObject, and then call
the release() function to release the DBConnection and close the appropriate
InputStreams.
release
public void release()
- Release the associated data with the blob fields. Very important that this
is called once you've retrieved/set the BLOB fields.
|
|||||||||
| Home >> All >> com >> jcorporate >> expresso >> services >> [ dbobj overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC