SK.gnome.dwarf.mail.smtp.proc.agent
Class MessageCheck

java.lang.Object
  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.GenericServer
          extended bySK.gnome.dwarf.thread.ThreadServer
              extended bySK.gnome.dwarf.mail.smtp.proc.MailAgent
                  extended bySK.gnome.dwarf.mail.smtp.proc.agent.MessageCheck
All Implemented Interfaces:
Preprocessing, SK.gnome.dwarf.Reportable, java.lang.Runnable, SK.gnome.dwarf.Server, SK.gnome.dwarf.Service
Direct Known Subclasses:
ClamAVScanner, MessageSyntax, NOD32Antivir

public abstract class MessageCheck
extends MailAgent
implements Preprocessing

Provides agent for general message checking.

This service is intended as a superclass of any mail agent which checks the message correctness, like antispam agents, antivirus agents, and other filtering agents, for example.

The fail methods should be called from a subclass to indicate that the message does not fulfil the agent's criteria for correctness and to interrupt the current checking process.

If a local user and folder name is setup via the setStoreTo(String) method, the checked message will be stored to the given local folder prior to throwing an exception indicating the failure. In this case no DSN notification will be issued by the server for the failed recipients at all.

Please note that this agent's failure causes all message recipients to be marked as finished.


Field Summary
 
Fields inherited from class SK.gnome.dwarf.mail.smtp.proc.MailAgent
context, required
 
Fields inherited from class SK.gnome.dwarf.thread.ThreadServer
daemon, thread
 
Fields inherited from class SK.gnome.dwarf.GenericService
initParameters, parent
 
Fields inherited from interface SK.gnome.dwarf.Service
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED
 
Constructor Summary
MessageCheck(java.lang.String name)
           
 
Method Summary
protected  void fail(MailAgentMessage message, java.util.Collection recipients, java.lang.String status, java.lang.String msg)
          Indicates a failed message.
protected  void fail(MailAgentMessage message, java.util.Collection recipients, java.lang.String status, java.lang.String msg, java.lang.Exception exception)
          Indicates a failed message.
protected  void init(MailAgentContext context)
          Initializes the mail agent.
 void setFailedState(java.lang.String state)
          Sets the final state of the failed messages.
 void setStoreTo(java.lang.String target)
          Sets the local folder to store the failed messaged to.
 
Methods inherited from class SK.gnome.dwarf.mail.smtp.proc.MailAgent
destroy, filter, init, isRequired, postprocess, preprocess, setRequired, storeMessage
 
Methods inherited from class SK.gnome.dwarf.thread.ThreadServer
enableThread, finish, loop, run, setDaemon, shutdown, start, stop
 
Methods inherited from class SK.gnome.dwarf.GenericServer
addService, addService, getAuthenticator, getLogger, getParameters, getService, getServices, getServices, removeService, report
 
Methods inherited from class SK.gnome.dwarf.GenericService
getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getName, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface SK.gnome.dwarf.Service
getFullName, getName, getState, log, log, login, logout
 

Constructor Detail

MessageCheck

public MessageCheck(java.lang.String name)
Method Detail

setStoreTo

public void setStoreTo(java.lang.String target)
Sets the local folder to store the failed messaged to.

The target argument must be in the form of "user/folder name", where the first part is the local user name nad the second one is a full name of the folder to store the failed messages to. If the second part is missing, the default MailFolder.INBOX folder will be used.

Parameters:
target - the user/folder string

setFailedState

public void setFailedState(java.lang.String state)
Sets the final state of the failed messages.

It may be either "FAILED" or "REJECTED" string. The second one causes the server to not generate a DSN notification to the failed message's sender.

Parameters:
state - the failed recipient state

init

protected void init(MailAgentContext context)
             throws MailException
Description copied from class: MailAgent
Initializes the mail agent.

Initializes the contained MailFilter instances.

Overrides:
init in class MailAgent
Parameters:
context - the mail context associated with this agent
Throws:
MailException - if an error occured

fail

protected void fail(MailAgentMessage message,
                    java.util.Collection recipients,
                    java.lang.String status,
                    java.lang.String msg)
             throws java.io.IOException,
                    MailException,
                    FailedDeliveryException
Indicates a failed message.

It calls the fail(MailAgentMessage, Collection, String, String, Exception) method with the last argument equal to null.

Parameters:
message - the checked message
recipients - the recipient collection
status - the numeric SMTP status code (X.Y.Z)
msg - the SMTP reason phrase
Throws:
java.io.IOException - if an I/O error occured
MailException - if another error occured
FailedDeliveryException - if the message fails

fail

protected void fail(MailAgentMessage message,
                    java.util.Collection recipients,
                    java.lang.String status,
                    java.lang.String msg,
                    java.lang.Exception exception)
             throws java.io.IOException,
                    MailException,
                    FailedDeliveryException
Indicates a failed message.

If the agent is setup to store the failed messages then the checked message is stored to the given local folder. After that a FailedDeliveryException is thrown immediately with the desired final state, status code and msg reason phrase to indicate the message failure.

Parameters:
message - the checked message
recipients - the recipient collection
status - the numeric SMTP status code (X.Y.Z)
msg - the SMTP reason phrase
exception - the causing error
Throws:
java.io.IOException - if an I/O error occured
MailException - if another error occured
FailedDeliveryException - if the message fails
See Also:
setFailedState(String)


Copyright (c) 2004-2005, Gnome Ltd. All rights reserved.