cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Per-Olof Norén <>
Subject Questions about mime-types and DatabaseReader (Berin?)
Date Mon, 15 Oct 2001 08:26:20 GMT
I saw Berins name in the source of DatabaseReader so i aim this mail in his direction,
though anyone who feels responsible for this piece of code is more than welcome to attend

I´ve been using cocoon for quite awhile, just recently starting to actually develop/modify
the components,
so if theese questions are "stupid" its possibly because of this :-)
Anyway, here goes:

1. Mime types. 
In the current implentation it is not possible to assign a database field containing the mime
type to output the blob as.
In AbstractReader (superclass of DatabaseReader, naturally) following is stated
     * Get the mime-type of the output of this <code>Serializer</code>
     * This default implementation returns null to indicate that the
     * mime-type specified in the sitemap is to be used
    public String getMimeType() {
        return null;

If implementing a way to configure a database column to assign the mime-type, is it as simple
as just overloading this method?
If doing so, does it cause implications in the sitemap behaviour (SoC)?

2. Content-lengths
Here comes the known MS buggy implementation that causes pdf files not to show up if no content-length
is supplied.
At a closer inspection, one sees java.sql.Blob.length() that should return the length of the
blob data. I´ve made some empirical
inspections of two drivers´: oracle and postgresql, all latest and theese two returns correct
length of the blob. If one (like I did) was
to put the content-length header in the serialize method, the sitemap handling of content-length
would be overkill, correct?
As a bonus, no ByteArray buffering is needed to get the content-length for a blob. I think
there is a way to tell the sitemap that this component
is "self-contain" in the content-length matter? Any pointers welcome :-)

3. Getting the Blob data
This is a tricky matter since this is driver dependant. My little "research" tells me that
postgresql driver does not implement the 
java.sql.Blob.getBinaryStream() in way that actually returns anything on the stream (read()
== -1). However if one uses the getBytes method it does. I extended the DatabaseReader into
ByteArrayDatabaseReader implementing only serialize() which uses getBytes instead of getBinaryStream.
This is sortof ugly, is it possible for the DataSource to be configurable for the driver capablitity
in this matter?

/Per-Olof Norén

View raw message