com.ericdaugherty.mail.server.persistence.localDelivery
Class SimpleFileIOProcessor

java.lang.Object
  extended by com.ericdaugherty.mail.server.persistence.localDelivery.SimpleFileIOProcessor
All Implemented Interfaces:
LocalDeliveryProcessor
Direct Known Subclasses:
TestingFileIOProcessor

public class SimpleFileIOProcessor
extends java.lang.Object
implements LocalDeliveryProcessor

This class offers the means of persisting a message to a local user's mailbox.

Author:
Andreas Kyrmegalos

Field Summary
protected  ConfigurationManager configurationManager
          The ConfigurationManager
 
Constructor Summary
SimpleFileIOProcessor()
           
 
Method Summary
 void createUserRepository(java.lang.String userRepository)
           
 long getMessagePersistedSize(User user, java.lang.String messageLocation)
          Returns a message's size on disk
 java.lang.String getUserRepository(User user)
          Gets the user's directory as a String.
 java.lang.Object persistLocalMessage(User user, SMTPMessage message, EmailAddress address)
          Saves a message to the user's directory and returns the full path/filename of the file where it was persisted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configurationManager

protected final ConfigurationManager configurationManager
The ConfigurationManager

Constructor Detail

SimpleFileIOProcessor

public SimpleFileIOProcessor()
Method Detail

createUserRepository

public void createUserRepository(java.lang.String userRepository)
Specified by:
createUserRepository in interface LocalDeliveryProcessor

getUserRepository

public java.lang.String getUserRepository(User user)
Gets the user's directory as a String. This method also verifies that the directory exists.

Specified by:
getUserRepository in interface LocalDeliveryProcessor
Parameters:
user - The user the message belongs to.
Returns:
The full path denoting the user's directory.

getMessagePersistedSize

public long getMessagePersistedSize(User user,
                                    java.lang.String messageLocation)
Returns a message's size on disk

Specified by:
getMessagePersistedSize in interface LocalDeliveryProcessor
Parameters:
user - The user the message belongs to.
messageLocation - The message filename (this is not a full path, since it is generated by a list() file method).
Returns:
The message size on disk is returned.

persistLocalMessage

public java.lang.Object persistLocalMessage(User user,
                                            SMTPMessage message,
                                            EmailAddress address)
                                     throws java.io.IOException
Saves a message to the user's directory and returns the full path/filename of the file where it was persisted.

Specified by:
persistLocalMessage in interface LocalDeliveryProcessor
Parameters:
user - The user the message is addrressed to.
message - The message itself.
address - The user's email address.
Returns:
In the case of a file-system back-end the full path/filename is returned.
Throws:
java.io.IOException