cancel
Showing results for 
Search instead for 
Did you mean: 

Blob Based Content Store implemented

andre
Champ in-the-making
Champ in-the-making
Hi,

I've just uploaded my imlementation of a database based content store: http://issues.alfresco.com/secure/attachment/10461/DB_Content_Store.zip

All content is streamed - so handling large files is no problem.

streaming content into and out of the db is done by the class BlobFileDAOImpl (JdbcDaoSupport) using springs AbstractLobCreatingPreparedStatementCallback and AbstractLobStreamingResultSetExtractor.

In order to get an OutputStream fromthe DAO connected to an InputStream returned by the ContentReader I use a pair of PipedStreams.
(see BlobFileContentReader.java->getDirectReadableChannel())

For uploading new Content the data is written to a TempFile first to determine the file size. (Maybe this is not necessary???)

BlobFile.hbm.xml, BlobFile.java and BlobFileImpl.java
are only used in order to get the new table created automatically.

Everything works allmost fine (tested with Oracle 10g XE - thin driver) there is only one problem:

In the the web client th file size is always displayed as 0 KB allthought my implementation of getSize provides the correct value.

I would much appreciate your feedback!
17 REPLIES 17

steve
Champ in-the-making
Champ in-the-making
Hi,
I have made your post sticky because there have been several other community members who are after this functionality!

Great work, by the way.

Steve

paulhh
Champ in-the-making
Champ in-the-making
Hi Andre

Nice work - good to see you busy again!

Is it dependent on any specific database implementation - or will it work on other DBs than Oracle?

Cheers
Paul.

andre
Champ in-the-making
Champ in-the-making
Thanks Steve and Paul,

Basicly it should be no problem to use other DBs if they support the streaming of blobs.

The current DAO-implementation is dependent on Oracle's JDBC driver because of the class org.springframework.jdbc.support.lob.OracleLobHandler.  For othter DBs spring's DefaultLobHandler should be the right choise.

andre
Champ in-the-making
Champ in-the-making
I have just uploaded a new improved version that seems to work with alfresco 2.1. The project can be found here:

http://issues.alfresco.com/browse/AR-195

maybe a forge project at http://forge.alfresco.com/ would be good if anybody is interested in a collaboration on this issue…

olivanja
Champ in-the-making
Champ in-the-making
Hi Andre, sorry for my English.

I`ve tried your source code in my Alfreso and it's runned without problems.

I have a Tomcat 5.5 with JVM 1.5.0.15 in my computer, and a remote DB2 V9.5 database on Open Suse 10.2.
I use db2jcc.jar and db2jcc_license_cu.jar, as JDBC drivers, to connect with the database.
I've added your code such as  jar file in my WEB-INF/lib
I've only had to change some properties in BlobFile.hbm.xml file:

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE hibernate-mapping PUBLIC
    '-//Hibernate/Hibernate Mapping DTD 3.0//EN'
    'http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd'>

<hibernate-mapping>

   <class
         name="de.juwimm.blobfilestore.BlobFileImpl"
         proxy="de.juwimm.blobfilestore.BlobFile"
         table="alf_blob_file"
         dynamic-update="false"
         dynamic-insert="false"
         select-before-update="false"
         optimistic-lock="version" >
      <!– <id name="contentUrl" column="content_url" type="string" length="1024" /> I can't create a primary key with 1024 –>
      <id name="contentUrl" column="content_url" type="string" length="500" />
      <!– <property name="contentBlob" column="content" type="blob"/> I've had to add length property because by defect blob's size isn't so longer. This is max. size for Blob type of DB2 (2GB) –>
      <property name="contentBlob" column="content" type="blob" length="214743647"/>
      <!– <property name="size" column="content_length" type="int" /> –>
      <property name="size" column="content_length" type="integer" />
      <property name="date" column="created_date" type="java.sql.Date" />
     
   </class>
  
</hibernate-mapping>

Now I'm going to try this source code with a DB2 database on iSeries (AS400 V5R4), I expect running without problems.

Well, thanks very much. Good job Andre.

golemwashere
Champ in-the-making
Champ in-the-making
Thanks
that's what was keeping back alfresco adoption in my company….
(My boss is an Oracle DBA and would not trust sticking files in anything else)
please support the project and make it grow!
G.

joechavez
Champ in-the-making
Champ in-the-making
Very interesting. Have you done some benchmarking against the filesystem content store?

pmonks
Star Contributor
Star Contributor
If anyone does perform some benchmarking, it would be ideal if manipulation of content via CIFS was included.  CIFS can generate far more I/O churn on the binary content of files than the other means for manipulating files (APIs, Web Client, WebDAV, FTP, etc.).

In fact this is one of the primary reasons that Alfresco (by default) uses the disk for storing file content rather than BLOBs in the RDBMS (see http://newton.typepad.com/content/2006/09/content_storage.html for a comprehensive treatment of this topic).

Cheers,
Peter

glendesouza
Champ in-the-making
Champ in-the-making
We were planning on using the blob based content store in a production environment. Has anyone used the blob content store and if so - were there any issues observed.