| com.jcorporate.expresso.core.dbobj.SecuredDBObject com.jcorporate.expresso.services.dbobj.MediaDBObject
All known Subclasses: com.jcorporate.expresso.services.dbobj.tests.MediaTest,
MediaDBObject | public class MediaDBObject extends SecuredDBObject (Code) | | 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();
author: Michael Rimov, Peter Pilgrim version: $Revision: 1.9 $ on $Date: 2004/11/17 20:48:18 $ since: Expresso 5.1 |
Constructor Summary | |
public | MediaDBObject() Default Constructor. | public | MediaDBObject(DBConnection newConnection) | public | 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. | public | MediaDBObject(int newUid) Constructor: Specify a DB connection AND user
Parameters: newUid - User ID attempting to use this object.If this is SecuredDBObject.SYSTEM_ACCOUNT, thenfull permissions are granted. | public | MediaDBObject(RequestContext request) For using DBObjects within Controllers. |
FLD_FILE_SUFFIX | final public static String FLD_FILE_SUFFIX(Code) | | 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
|
FLD_MIME_SUFFIX | final public static String FLD_MIME_SUFFIX(Code) | | 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
|
FLD_SIZE_SUFFIX | final public static String FLD_SIZE_SUFFIX(Code) | | 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
|
MediaDBObject | public MediaDBObject(DBConnection newConnection) throws DBException(Code) | | Constructor that sets the connection on create
Parameters: newConnection - The dbConnection object to associate with thisobject |
MediaDBObject | public MediaDBObject(DBConnection newConnection, String setupTablesContext) throws DBException(Code) | |
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
Parameters: newConnection - The DBConnection to utilize Parameters: setupTablesContext - The data context that contains the setup (andsecurity) tables for this object |
MediaDBObject | public MediaDBObject(int newUid) throws DBException(Code) | | Constructor: Specify a DB connection AND user
Parameters: newUid - User ID attempting to use this object.If this is SecuredDBObject.SYSTEM_ACCOUNT, thenfull permissions are granted. Note that you cannot log inas SecuredDBObject.SYSTEM_ACCOUNT,t can only be used from within a method. throws: DBException - If the object cannot be created |
MediaDBObject | public MediaDBObject(RequestContext request) throws DBException(Code) | | 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. throws: DBException - upon construction error |
addBlobField | protected void addBlobField(String fieldName, String fieldDescription) throws DBException(Code) | | 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
Parameters: fieldName - The name of the field to create. Parameters: fieldDescription - The 'friendly name' of the field to create throws: DBException - upon creation error. |
getBlobFileSizeInt | public int getBlobFileSizeInt(String fieldName) throws DBException(Code) | | Convenience method to get the LOB attachment content length as
an integer
throws: DBException - if a database error occurs |
release | public void release()(Code) | | Release the associated data with the blob fields. Very important that this
is called once you've retrieved/set the BLOB fields.
|
retrieveBlob | public java.io.InputStream retrieveBlob(String fieldName) throws DBException(Code) | | 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.
Parameters: fieldName - The name of the field to retrieve java.io.InputStream the contents of the BLOB field. [May be null] throws: DBException - upon retrieval error |
saveBlob | public void saveBlob(String fieldName) throws DBException(Code) | | 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.
Parameters: fieldName - The field Name to save throws: DBException - If unable to save the file to the database throws: IllegalStateException - if unable to retrieve the appropriate attributes. throws: IllegalArgumentException - if fieldName doesn't exist or is null. See Also: com.jcorporate.expresso.services.controller.ui.DefaultAutoElement.parseSingleInput |
saveBlob | public void saveBlob(String fieldName, java.io.InputStream value, String fileName, int fileSize) throws DBException(Code) | | Saves a BLOB field to the database
Parameters: fieldName - the field Name to save Parameters: value - A binary stream to become the value of the new strea, Parameters: fileName - The name of the 'file' to store Parameters: fileSize - The size of the file to save. |
saveBlob | public void saveBlob(String fieldName, java.io.InputStream value, int fileSize) throws DBException(Code) | | Saves a file to the blob field,
Parameters: fieldName - the field name to save to the database Parameters: value - A java.io.InputStream to save into the database Parameters: fileSize - the size of the stream that is getting saved to the database throws: DBException - upon communication error |
Methods inherited from com.jcorporate.expresso.core.dbobj.SecuredDBObject | public void add() throws DBException(Code)(Java Doc) public boolean canRequesterAdd() throws DBException(Code)(Java Doc) public boolean canRequesterDelete() throws DBException(Code)(Java Doc) public boolean canRequesterRead() throws DBException(Code)(Java Doc) public boolean canRequesterUpdate() throws DBException(Code)(Java Doc) public boolean checkAllowed(String requestedFunction) throws DBException(Code)(Java Doc) public void copyAttributes(DBObject returnObj) throws DBException(Code)(Java Doc) public synchronized int count() throws com.jcorporate.expresso.core.db.DBException(Code)(Java Doc) protected synchronized void createSecurityCache() throws CacheException(Code)(Java Doc) public void delete() throws DBException(Code)(Java Doc) public synchronized void deleteAll() throws com.jcorporate.expresso.core.db.DBException(Code)(Java Doc) public boolean find() throws DBException(Code)(Java Doc) public int getRequestingUid()(Code)(Java Doc) protected String getString(String stringCode, Object[] args) throws DBException(Code)(Java Doc) protected String getString(String stringCode) throws DBException(Code)(Java Doc) protected String getString(String stringCode, String arg1) throws DBException(Code)(Java Doc) protected String getString(String stringCode, String arg1, String arg2) throws DBException(Code)(Java Doc) protected String getString(String stringCode, String arg1, String arg2, String arg3) throws DBException(Code)(Java Doc) protected String getString(String stringCode, String arg1, String arg2, String arg3, String arg4) throws DBException(Code)(Java Doc) public int getSystemUid()(Code)(Java Doc) public static SecuredDBObject instantiate(String className) throws DBException(Code)(Java Doc) public void isAllowed(String requestedFunction) throws SecurityException, DBException(Code)(Java Doc) public void retrieve() throws DBException(Code)(Java Doc) public synchronized void search() throws DBException(Code)(Java Doc) public synchronized ArrayList searchAndRetrieveList() throws DBException(Code)(Java Doc) public synchronized ArrayList searchAndRetrieveList(String sortKeys) throws DBException(Code)(Java Doc) public void setRequestingUid(int newUid)(Code)(Java Doc) public void update() throws DBException(Code)(Java Doc)
|
|
|