Class MailFlagHandler

  • All Implemented Interfaces:
    EventHandler

    @ConfigurationDescription(properties={@Property(name="IsCritical",type=BOOLEAN,defaultValue="true",description="Whether the event handler is critical and problems handling the event should abort all handling of the current event."),,,,,,,,,,,,,,,,,})
    public class MailFlagHandler
    extends AbstractEventHandler
    An event handler for setting flags and/or moving messages from mail events. This allows for flagging or otherwise change handled messages so that they do not get handled again.
    This handler considers a changed message as consumed.
    • Field Detail

      • CONF_IS_CRITICAL

        protected static final String CONF_IS_CRITICAL
        Configuration key: Whether the event handler is critical and problems handling the event should abort all handling of the current event.
        See Also:
        Constant Field Values
      • CONF_HANDLE_CONSUMED

        public static final String CONF_HANDLE_CONSUMED
        Configuration key for whether this handler should also handle (set flags, move, expunge) messages of which the corresponding mail event has been consumed.
        See Also:
        Constant Field Values
      • HANDLE_CONSUMED

        protected final boolean HANDLE_CONSUMED
        Whether this handler should also handle (set flags, move, expunge) messages of which the corresponding mail event has been consumed.
      • CONF_CHANGE_FLAG_ANSWERED

        public static final String CONF_CHANGE_FLAG_ANSWERED
        Configuration key for whether to change the answered flag of the messages from mail events.
        See Also:
        Constant Field Values
      • CONF_SET_FLAG_ANSWERED

        public static final String CONF_SET_FLAG_ANSWERED
        Configuration key for how to set the answered flag of messages from mail events. This only applies if the corresponding flag should be changed.
        See Also:
        Constant Field Values
      • CHANGE_FLAG_ANSWERED

        protected final boolean CHANGE_FLAG_ANSWERED
        Whether to change the answered flag of the messages from mail events.
      • SET_FLAG_ANSWERED

        protected final boolean SET_FLAG_ANSWERED
        How to set the answered flag of messages from mail events. This only applies if the corresponding flag should be changed.
      • CONF_CHANGE_FLAG_DELETED

        public static final String CONF_CHANGE_FLAG_DELETED
        Configuration key for whether to change the deleted flag of the messages from mail events.
        See Also:
        Constant Field Values
      • CONF_SET_FLAG_DELETED

        public static final String CONF_SET_FLAG_DELETED
        Configuration key for how to set the deleted flag of messages from mail events. This only applies if the corresponding flag should be changed.
        See Also:
        Constant Field Values
      • CHANGE_FLAG_DELETED

        protected final boolean CHANGE_FLAG_DELETED
        Whether to change the deleted flag of the messages from mail events.
      • SET_FLAG_DELETED

        protected final boolean SET_FLAG_DELETED
        How to set the deleted flag of messages from mail events. This only applies if the corresponding flag should be changed.
      • CONF_CHANGE_FLAG_DRAFT

        public static final String CONF_CHANGE_FLAG_DRAFT
        Configuration key for whether to change the draft flag of the messages from mail events.
        See Also:
        Constant Field Values
      • CONF_SET_FLAG_DRAFT

        public static final String CONF_SET_FLAG_DRAFT
        Configuration key for how to set the draft flag of messages from mail events. This only applies if the corresponding flag should be changed.
        See Also:
        Constant Field Values
      • CHANGE_FLAG_DRAFT

        protected final boolean CHANGE_FLAG_DRAFT
        Whether to change the draft flag of the messages from mail events.
      • SET_FLAG_DRAFT

        protected final boolean SET_FLAG_DRAFT
        How to set the draft flag of messages from mail events. This only applies if the corresponding flag should be changed.
      • CONF_CHANGE_FLAG_FLAGGED

        public static final String CONF_CHANGE_FLAG_FLAGGED
        Configuration key for whether to change the flagged flag of the messages from mail events.
        See Also:
        Constant Field Values
      • CONF_SET_FLAG_FLAGGED

        public static final String CONF_SET_FLAG_FLAGGED
        Configuration key for how to set the flagged flag of messages from mail events. This only applies if the corresponding flag should be changed.
        See Also:
        Constant Field Values
      • CHANGE_FLAG_FLAGGED

        protected final boolean CHANGE_FLAG_FLAGGED
        Whether to change the flagged flag of the messages from mail events.
      • SET_FLAG_FLAGGED

        protected final boolean SET_FLAG_FLAGGED
        How to set the flagged flag of messages from mail events. This only applies if the corresponding flag should be changed.
      • CONF_CHANGE_FLAG_RECENT

        public static final String CONF_CHANGE_FLAG_RECENT
        Configuration key for whether to change the recent flag of the messages from mail events.
        See Also:
        Constant Field Values
      • CONF_SET_FLAG_RECENT

        public static final String CONF_SET_FLAG_RECENT
        Configuration key for how to set the recent flag of messages from mail events. This only applies if the corresponding flag should be changed.
        See Also:
        Constant Field Values
      • CHANGE_FLAG_RECENT

        protected final boolean CHANGE_FLAG_RECENT
        Whether to change the recent flag of the messages from mail events.
      • SET_FLAG_RECENT

        protected final boolean SET_FLAG_RECENT
        How to set the recent flag of messages from mail events. This only applies if the corresponding flag should be changed.
      • CONF_CHANGE_FLAG_SEEN

        public static final String CONF_CHANGE_FLAG_SEEN
        Configuration key for whether to change the seen flag of the messages from mail events.
        See Also:
        Constant Field Values
      • CONF_SET_FLAG_SEEN

        public static final String CONF_SET_FLAG_SEEN
        Configuration key for how to set the seen flag of messages from mail events. This only applies if the corresponding flag should be changed.
        See Also:
        Constant Field Values
      • CHANGE_FLAG_SEEN

        protected final boolean CHANGE_FLAG_SEEN
        Whether to change the seen flag of the messages from mail events.
      • SET_FLAG_SEEN

        protected final boolean SET_FLAG_SEEN
        How to set the seen flag of messages from mail events. This only applies if the corresponding flag should be changed.
      • CONF_CHANGE_FLAG_USER

        public static final String CONF_CHANGE_FLAG_USER
        Configuration key for whether to change the user flag of the messages from mail events.
        See Also:
        Constant Field Values
      • CONF_SET_FLAG_USER

        public static final String CONF_SET_FLAG_USER
        Configuration key for how to set the user flag of messages from mail events. This only applies if the corresponding flag should be changed.
        See Also:
        Constant Field Values
      • CHANGE_FLAG_USER

        protected final boolean CHANGE_FLAG_USER
        Whether to change the user flag of the messages from mail events.
      • SET_FLAG_USER

        protected final boolean SET_FLAG_USER
        How to set the user flag of messages from mail events. This only applies if the corresponding flag should be changed.
      • CONF_TARGET_FOLDER

        public static final String CONF_TARGET_FOLDER
        Configuration key for the name of the target folder in case the messages of mail events should be moved.
        See Also:
        Constant Field Values
      • TARGET_FOLDER

        protected final String TARGET_FOLDER
        The name of the target folder in case the messages of mail events should be moved.
      • CONF_EXPUNGE

        public static final String CONF_EXPUNGE
        Configuration key for whether the folder of messages from mail events should be expunged. This really deletes messages that have deleted flag set. Therefore if you want do delete a handled message finally, set the deleted flag and expunge the folder.
        See Also:
        Constant Field Values
      • EXPUNGE

        protected final boolean EXPUNGE
        Whether the folder of messages from mail events should be expunged. This really deletes messages that have deleted flag set. Therefore if you want do delete a handled message finally, set the deleted flag and expunge the folder.
    • Constructor Detail

      • MailFlagHandler

        public MailFlagHandler​(org.apache.commons.configuration2.Configuration conf,
                               EventManager eventManager,
                               Registry registry)
        Default constructor for a plugin of an EventManager called by a service registry. This constructor just reads the configuration values.
        Parameters:
        conf - The configuration as provided from the registry.
        eventManager - The event manager this event handler is a plugin of.
        registry - The registry of this plugin.
    • Method Detail

      • handleEvent

        public boolean handleEvent​(Event eve,
                                   boolean consumed)
                            throws EventHandlingException
        Description copied from interface: EventHandler
        This method actually processes an event. What is done depends on the implementation of the event handler. Some restrictions may apply depending on the produced event. Only events will be received for which the event handler is registered. However, to improve robustness, an event handler should check the event before processing. If it cannot handle the provided event, this method should just return.
        Event handling is usually synchronously, that is, this method will only be executed by one thread at a time. If another event of the same type occurs while still handling the previous event, the second event will be suspended until the previous event has been completely handled. There is no need to start a separate thread while handling to improve performance. But it is not forbidden to do so. Handling that takes place in a new thread is not exclusive any more and therefore must not consume the event!
        Parameters:
        eve - The event that occurred and for which this event handler is registered.
        consumed - Whether the event has been consumed by a previous event handler.
        Returns:
        Whether the event has been consumed (that is changed) while handling it. If the event has been consumed before the current handing, it will have to remain consumed (implementations must return true).
        Throws:
        EventHandlingException - If there have been problems handling the event, an EventHandlingException may be thrown. If this is critical, the event handling for the current event will stop. If it is non-critical, other event handlers will also get the event for handling it.
        If event handling fails, the corresponding event handler needs to roll back its changes, especially a consuming event handler.