Java Doc for MediaDBObject.java in  » J2EE » Expresso » com » jcorporate » expresso » services » dbobj » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Expresso » com.jcorporate.expresso.services.dbobj 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


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


Field Summary
final public static  StringFLD_FILE_SUFFIX
     Suffix for the filename field.

Each blob field has several additional supporting fields.

final public static  StringFLD_MIME_SUFFIX
     Suffix for the mime number field.
final public static  StringFLD_SIZE_SUFFIX
     Suffix for the file size field.

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.

Method Summary
protected  voidaddBlobField(String fieldName, String fieldDescription)
     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.
public  StringgetBlobFileSize(String fieldName)
    
public  intgetBlobFileSizeInt(String fieldName)
    
public  StringgetBlobFilename(String fieldName)
    
public  StringgetBlobMimeType(String fieldName)
    
public  voidrelease()
     Release the associated data with the blob fields.
public  java.io.InputStreamretrieveBlob(String fieldName)
     Retrieves a BLOB from the database.
public  voidsaveBlob(String fieldName)
     This method is for saving a BLOB field that has been processed by the DefaultAutoElement object.
public  voidsaveBlob(String fieldName, java.io.InputStream value, String fileName, int fileSize)
    
public  voidsaveBlob(String fieldName, java.io.InputStream value, int fileSize)
    

Field Detail
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





Constructor Detail
MediaDBObject
public MediaDBObject() throws DBException(Code)
Default Constructor.
throws:
  DBException - upon initialization error



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




Method Detail
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.



getBlobFileSize
public String getBlobFileSize(String fieldName) throws DBException(Code)
Convenience method to get the LOB attachment content length
throws:
  DBException - if a database error occurs



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



getBlobFilename
public String getBlobFilename(String fieldName) throws DBException(Code)
Convenience method to get the LOB attachment filename
throws:
  DBException - if a database error occurs



getBlobMimeType
public String getBlobMimeType(String fieldName) throws DBException(Code)
Convenience method to get the LOB attachment mime content type
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



Fields inherited from com.jcorporate.expresso.core.dbobj.SecuredDBObject
final public static String ADD(Code)(Java Doc)
final public static String[] ALL_FUNCTIONS(Code)(Java Doc)
final protected static String CACHE_NAME(Code)(Java Doc)
final protected static long CACHE_TTY(Code)(Java Doc)
final public static String DELETE(Code)(Java Doc)
final public static String SEARCH(Code)(Java Doc)
final public static int SYSTEM_ACCOUNT(Code)(Java Doc)
final public static String SYSTEM_ACCOUNT_NAME(Code)(Java Doc)
final public static String UPDATE(Code)(Java Doc)

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)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.