int getContent(long messageId, int offset, ByteBuffer dst) throws StoreException
{
DatabaseEntry contentKeyEntry = new DatabaseEntry();
LongBinding.longToEntry(messageId, contentKeyEntry);
DatabaseEntry value = new DatabaseEntry();
ContentBinding contentTupleBinding = ContentBinding.getInstance();
if (getLogger().isDebugEnabled())
{
getLogger().debug("Message Id: " + messageId + " Getting content body from offset: " + offset);
}
try
{
int written = 0;
OperationStatus status = getMessageContentDb().get(null, contentKeyEntry, value, LockMode.READ_UNCOMMITTED);
if (status == OperationStatus.SUCCESS)
{
byte[] dataAsBytes = contentTupleBinding.entryToObject(value);
int size = dataAsBytes.length;
if (offset > size)
{
throw new RuntimeException("Offset " + offset + " is greater than message size " + size
+ " for message id " + messageId + "!");