public BlobDataSource read(final URI uri) throws IOException
{
// check if blob was stored for the message
Assert.notNull(uri, "URI cannot be null");
BlobDataSource blobDS;
BlobURI blobUri = new BlobURI().fromURI(uri);
if (blobUri.getProfile().equals(DatabaseConstants.DATABASE_PROFILE)) {
blobDS = dbBlobStorage.read(uri);
} else {
blobDS = cloudBlobStorage.read(uri);
}
// if compressed, add compression handler to data source
if ((blobUri.getCompression() != null && blobUri.getCompression()
.equals(DeflateCompressionHandler.COMPRESSION_TYPE_DEFLATE)) ||
// TODO: deprecated suffix based compression detection
// kept for backward compatibility with 0.3
blobUri.getName().endsWith(BlobStoreConstants.COMPRESS_SUFFIX))
{
CompressionHandler ch = new DeflateCompressionHandler();
return new BlobDataSource(uri, blobDS.getInputStream(), ch);
} else {
return blobDS;
}
}