public void insertMessage(EmailID emailId, InputStream in, boolean compress, boolean encrypt) throws MessageStoreException
{
Config config = Config.getConfig();
if (emailId==null || emailId.getVolume()==null || emailId.getUniqueID()==null)
throw new MessageStoreException("assertion failure: null emailID, volume or uniqueId",logger);
if(emailId.getUniqueID() == null)
throw new MessageStoreException("insert message was found to have a null message id.", logger);
logger.debug("insertMessage {"+emailId + ",compress='" + compress + "',encrypt='"+encrypt+"'}");
if (!config.isDefaultPassPhraseModified())
throw new MessageStoreException("failed to archive message. encryption password is not set. {"+emailId+"}",logger);
OutputStream out = null;
createMessageStoreDir(emailId.getVolume());
createMessageDir(emailId);
String messageFileName = getMessageFileName(emailId);
try
{
out = getRawMessageOutputStream(messageFileName,compress,encrypt);
byte[] buf = new byte[1024];
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {
out.write(buf, 0, numRead);
}
} catch(IOException e)
{
throw new MessageStoreException("failed to store message to file {file='" + messageFileName + "'}", e, logger);
} finally {
try
{
if (in !=null)