Class BlueMindRuleWrites

java.lang.Object
org.exoplatform.bluemind.mail.service.BlueMindRuleWrites

public class BlueMindRuleWrites extends Object
The writes of one change to eXo's rules on a BlueMind mailbox, one rule per call, each recorded with what undoes it. BlueMind's per-rule API has no transaction: when a later write fails, rollback() undoes the earlier ones, newest first, so that a change the host asks for as one write -- a filter turned from a server rule into a hop, or back -- leaves the mailbox as it was rather than half done. An undo is best effort: one that fails is logged and the others still run.

A rule removed and then restored by an undo is added again after eXo's other rules, where BlueMind places a new rule: the order of eXo's rules, and so their hash, then differs from what eXo last recorded, and the host reads them as changed outside eXo until "Re-publish" adopts them.

  • Constructor Details

    • BlueMindRuleWrites

      public BlueMindRuleWrites(BlueMindMailbox mailbox)
      The writes on one mailbox.
      Parameters:
      mailbox - the caller's own mailbox, in the job's session
  • Method Details

    • add

      public long add(tools.jackson.databind.node.ObjectNode rule)
      Adds a rule; its undo removes it.
      Parameters:
      rule - the rule
      Returns:
      the id BlueMind gave it
    • update

      public void update(BlueMindExoRule held, tools.jackson.databind.node.ObjectNode rule)
      Replaces a rule in place; its undo writes the rule back as it was.
      Parameters:
      held - the rule as BlueMind held it
      rule - the new rule
    • delete

      public void delete(BlueMindExoRule held)
      Removes a rule; its undo adds it again. A rule already gone is no failure: the mailbox holds what was asked. BlueMind's own removal checks no id (MailboxesService.deleteMailboxRule, master 302bc396), so whether it ever answers not found is not established: the branch is defensive.
      Parameters:
      held - the rule as BlueMind held it
    • rollback

      public void rollback()
      Undoes every write done, the newest first.