Class BlueMindRuleEngine
- All Implemented Interfaces:
org.exoplatform.emailConnector.service.rules.ServerRuleEngine,org.springframework.core.Ordered
MailFilter.Vacation, read and written through the
dedicated _vacation endpoint of the caller's own mailbox, the
forward its MailFilter.Forwarding, through _forwarding, and
the server rules eXo manages are rules of BlueMind's own, through
_rules, all over the one BlueMind port
BlueMindMailboxTransport. Selected by
email.connector.rulesEngine[.<connectorId>]=bluemind.
Contributed from the add-on's web application. The mail host collects
every ServerRuleEngine by type and keeps the first of the configured
name. This engine is a @Service (the only kind the Kernel/Spring
bridge exports), never final (the bridge proxies it), named
"blueMindAddonRuleEngine" (the bridge exports nothing under a name the receiving
context already holds) and ordered ORDER, ahead of every engine
that states no order: a mail host that still ships a BlueMind engine of its
own therefore uses this one. It takes nothing private to the host: a refused
login reaches the provider through the caller's own MailboxAclSession,
and the host checks a forward's destination before calling any engine.
eXo does not own the reply here. BlueMind holds one reply per mailbox, whoever set it -- eXo, the webmail, another client -- so there is no "ours" and no "set elsewhere": a reply set in the webmail is read and adopted, shown and editable in eXo, and eXo's save replaces it. No script, no hash, no ETag: last writer wins, and the engine reads the reply immediately before writing it.
Each write names one setting. A reply goes through _vacation,
a forward through _forwarding, and the port offers no write of
_filter, so the user's rules, and the setting a save does not touch,
are never sent back.
Days and instants. BlueMind stores the window as two instants. eXo sends the instant of 00:00 on the first day and of 23:59:59.999 on the last day, in the user's zone; it answers days in the zone the caller gives (else the BlueMind account's own zone, from its login answer, else UTC), and keeps a stored instant unchanged when its day in that zone is the day asked for, so saving the form as it was read never moves a window set in the webmail.
What BlueMind decides. The interval between two replies to one sender
and the mail that gets no reply are BlueMind's own rules; the days
eXo passes is not part of BlueMind's model and is not sent. The reply is
plain text in this phase: a text edited in eXo is sent with textHtml
empty; a text left as the server holds it -- a save or a switch-off that does
not touch it -- is sent back as stored, its HTML body and line breaks
included, so a reply written in the webmail keeps its body.
Server rules go through BlueMind's per-rule API, one rule per call
(_rules), never through _filter, whose write re-inserts every
rule of the mailbox under new ids. eXo's rules carry client
"exo", which the webmail does not list, and eXo's
marker in their clientProperties; the engine finds them by that
marker, never by a BlueMind id, and never reads as eXo's, writes or removes
a rule without it (BlueMindRules). A new rule goes after eXo's
others, a replaced one keeps its place: BlueMind places a rule after the
last of its own client and refuses to place one among another client's,
and eXo has no order of its own to give the server rules. The mapping
between eXo's vocabulary and BlueMind's is BlueMindRules'.
Webmail rules. They are not eXo's to list or touch. The engine reads
where they stand so that the answer says, through the name of who manages
them, that they run first -- and only when they do: BlueMind places a
webmail rule after eXo's when the mailbox held no webmail rule before
eXo's first one (MailFilterStore.addRule, master 302bc396).
A change made of several writes (a filter turned from a server rule
into a hop, or back) is undone write by write when one fails
(BlueMindRuleWrites): the per-rule API has no transaction. The hash
the host compares is the SHA-256 of eXo's rules as BlueMind holds them, ids
left out (BlueMindRules.hash(java.util.List<org.exoplatform.bluemind.mail.model.BlueMindExoRule>)), so a change made outside eXo is told
apart and a write over it is refused.
Sessions. Every verb runs in one REST session opened as the caller,
with the IMAP channel's login and password the caller's session resolves.
The session is bluemind-client's: kept for that user, connector and
account and reused by the next verb, renewed once when BlueMind refuses it,
and its key never seen by this engine. The mailbox addressed is the login's
own, from the login answer, never from a request.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe bean name, distinct from the name scanning gives a host's own BlueMind engine.static final StringThe engine name a preset selects.static final intAhead of every engine that states no order: the host keeps the first engine of the configured name.static final StringThe code of a reference that names no rule of eXo's, the one the Sieve engine answers too.static final StringWhy a rule is not written: BlueMind's validators refused it.static final StringWho manages the rules of the webmail, the name the answer gives them when they run before eXo's.Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionBlueMindRuleEngine(BlueMindMailboxTransport transport) The engine over the port. -
Method Summary
Modifier and TypeMethodDescriptionorg.exoplatform.emailConnector.model.ServerRuleSetdeleteRule(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, String ref, String expectedScriptHash) Removes one of the caller's server rules, every copy of its reference.getName()The engine's name.intgetOrder()Where the host sorts this engine among those it collects.org.exoplatform.emailConnector.model.ServerRuleSetlistRules(org.exoplatform.emailConnector.service.acl.MailboxAclSession session) eXo's server rules as BlueMind holds them, in the order BlueMind applies them, read with every other rule of the mailbox so that the answer can say whether the webmail's rules run first.org.exoplatform.emailConnector.model.ServerRuleCapabilitiesprobe(org.exoplatform.emailConnector.service.acl.MailboxAclSession session) What the server can do, decided by attempting it: a login as the caller, a read of the caller's reply and a read of eXo's rules.org.exoplatform.emailConnector.model.ServerRuleSetpublishRules(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, String expectedScriptHash) "Re-publish": BlueMind runs eXo's rules as soon as they are stored, and nothing can deactivate them but a webmail rule that stops, so there is nothing to write; the rules are read, after the same check as a write.org.exoplatform.emailConnector.model.ForwardingSettingreadForwarding(org.exoplatform.emailConnector.service.acl.MailboxAclSession session) Reads the forward of the caller's own mailbox through_forwarding.org.exoplatform.emailConnector.model.ServerVacationreadVacation(org.exoplatform.emailConnector.service.acl.MailboxAclSession session) Reads the reply, its days in the BlueMind account's own zone: the caller's zone is not known on this path.org.exoplatform.emailConnector.model.ServerVacationreadVacation(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, ZoneId zone) Reads the reply, its days in the caller's zone.org.exoplatform.emailConnector.model.ReconcileReportreconcile(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, List<org.exoplatform.emailConnector.model.HopRef> hops, String expectedScriptHash) Makes BlueMind hold exactly the given hops among eXo's rules.org.exoplatform.emailConnector.model.ReconcileReportreconcile(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, List<org.exoplatform.emailConnector.model.HopRef> hops, org.exoplatform.emailConnector.model.ServerRule added, String droppedRef, String expectedScriptHash) Makes BlueMind hold exactly the given hops among eXo's rules, and in the same change adds one of the user's rules or removes one: a hop missing or different is written in place or added, a hop no eXo filter needs any more is removed, the other rules are kept.org.exoplatform.emailConnector.model.ServerRuleSetsaveRule(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, org.exoplatform.emailConnector.model.ServerRule rule, String expectedScriptHash) Adds one of the caller's server rules after eXo's others, or replaces the one holding its reference in place, found by eXo's marker.org.exoplatform.emailConnector.model.ServerForwardingwriteForwarding(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, String destination, String expectedScriptHash) Sets or removes the forward of the caller's own mailbox through_forwarding: one destination, always with a copy kept in the mailbox; removing switches it off.org.exoplatform.emailConnector.model.ServerVacationwriteVacation(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, org.exoplatform.emailConnector.model.VacationSetting vacation, int days, String expectedScriptHash) Replaces the reply through_vacation, then reads back what the server holds.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.exoplatform.emailConnector.service.rules.ServerRuleEngine
readAbsence
-
Field Details
-
NAME
The engine name a preset selects.- See Also:
-
BEAN_NAME
The bean name, distinct from the name scanning gives a host's own BlueMind engine.- See Also:
-
ORDER
public static final int ORDERAhead of every engine that states no order: the host keeps the first engine of the configured name. The add-on's one precedence.- See Also:
-
RULE_NOT_FOUND
The code of a reference that names no rule of eXo's, the one the Sieve engine answers too.- See Also:
-
RULE_REFUSED
Why a rule is not written: BlueMind's validators refused it.- See Also:
-
WEBMAIL_NAME
Who manages the rules of the webmail, the name the answer gives them when they run before eXo's.- See Also:
-
-
Constructor Details
-
BlueMindRuleEngine
The engine over the port.- Parameters:
transport- the port's implementation
-
-
Method Details
-
getName
The engine's name.- Specified by:
getNamein interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Returns:
- "bluemind"
-
getOrder
public int getOrder()Where the host sorts this engine among those it collects.- Specified by:
getOrderin interfaceorg.springframework.core.Ordered- Returns:
ORDER
-
probe
public org.exoplatform.emailConnector.model.ServerRuleCapabilities probe(org.exoplatform.emailConnector.service.acl.MailboxAclSession session) throws org.exoplatform.emailConnector.exception.ServerRuleUnavailableException What the server can do, decided by attempting it: a login as the caller, a read of the caller's reply and a read of eXo's rules. A server without the_vacationendpoint is answered unsupported rather than failed; one without the per-rule API offers no server rules, since eXo never writes the whole_filter.- Specified by:
probein interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Parameters:
session- the caller's own session- Returns:
- the capabilities
- Throws:
org.exoplatform.emailConnector.exception.ServerRuleUnavailableException- when the server cannot be used
-
readVacation
public org.exoplatform.emailConnector.model.ServerVacation readVacation(org.exoplatform.emailConnector.service.acl.MailboxAclSession session) throws org.exoplatform.emailConnector.exception.ServerRuleUnavailableException Reads the reply, its days in the BlueMind account's own zone: the caller's zone is not known on this path.- Specified by:
readVacationin interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Parameters:
session- the caller's own session- Returns:
- what the server holds
- Throws:
org.exoplatform.emailConnector.exception.ServerRuleUnavailableException- when the server cannot be used
-
readVacation
public org.exoplatform.emailConnector.model.ServerVacation readVacation(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, ZoneId zone) throws org.exoplatform.emailConnector.exception.ServerRuleUnavailableException Reads the reply, its days in the caller's zone.- Specified by:
readVacationin interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Parameters:
session- the caller's own sessionzone- the caller's zone; null for the BlueMind account's own zone, else UTC- Returns:
- what the server holds:
VacationState.OWNfor any reply the server holds, whoever set it;ServerVacation.none()when nothing was ever set - Throws:
org.exoplatform.emailConnector.exception.ServerRuleUnavailableException- when the server cannot be used
-
writeVacation
public org.exoplatform.emailConnector.model.ServerVacation writeVacation(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, org.exoplatform.emailConnector.model.VacationSetting vacation, int days, String expectedScriptHash) throws org.exoplatform.emailConnector.exception.ServerRuleUnavailableException Replaces the reply through_vacation, then reads back what the server holds.- Specified by:
writeVacationin interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Parameters:
session- the caller's own sessionvacation- the reply, validated by the callerdays- not part of BlueMind's model; not sentexpectedScriptHash- not used: BlueMind has no script and no version to compare- Returns:
- what the server holds after the write
- Throws:
org.exoplatform.emailConnector.exception.ServerRuleUnavailableException- when the server cannot be used
-
readForwarding
public org.exoplatform.emailConnector.model.ForwardingSetting readForwarding(org.exoplatform.emailConnector.service.acl.MailboxAclSession session) throws org.exoplatform.emailConnector.exception.ServerRuleUnavailableException Reads the forward of the caller's own mailbox through_forwarding.- Specified by:
readForwardingin interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Parameters:
session- the caller's own session- Returns:
- the destinations and whether a copy is kept,
ForwardingSetting.none()when no forward is on - Throws:
org.exoplatform.emailConnector.exception.ServerRuleUnavailableException- when the server cannot be used
-
writeForwarding
public org.exoplatform.emailConnector.model.ServerForwarding writeForwarding(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, String destination, String expectedScriptHash) throws org.exoplatform.emailConnector.exception.ServerRuleUnavailableException Sets or removes the forward of the caller's own mailbox through_forwarding: one destination, always with a copy kept in the mailbox; removing switches it off. BlueMind holds one forward per mailbox whoever set it, so eXo's replaces the one set in the webmail, as the reply does. The host has already checked the destination against those its forwarding guard authorizes for the caller, before calling any engine.- Specified by:
writeForwardingin interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Parameters:
session- the caller's own sessiondestination- the address, normalised; null to switch the forward offexpectedScriptHash- not used: BlueMind has no script- Returns:
- the forward after the write, no script hash
- Throws:
org.exoplatform.emailConnector.exception.ServerRuleUnavailableException- when the server cannot be used
-
listRules
public org.exoplatform.emailConnector.model.ServerRuleSet listRules(org.exoplatform.emailConnector.service.acl.MailboxAclSession session) throws org.exoplatform.emailConnector.exception.ServerRuleUnavailableException, org.exoplatform.emailConnector.exception.ServerRuleUnsupportedException eXo's server rules as BlueMind holds them, in the order BlueMind applies them, read with every other rule of the mailbox so that the answer can say whether the webmail's rules run first.- Specified by:
listRulesin interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Parameters:
session- the caller's own session- Returns:
- the rules;
ServerRuleSet.none()'s state when eXo has none - Throws:
org.exoplatform.emailConnector.exception.ServerRuleUnavailableException- when the server cannot be usedorg.exoplatform.emailConnector.exception.ServerRuleUnsupportedException- when the server has no per-rule API
-
saveRule
public org.exoplatform.emailConnector.model.ServerRuleSet saveRule(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, org.exoplatform.emailConnector.model.ServerRule rule, String expectedScriptHash) throws org.exoplatform.commons.exception.ObjectNotFoundException, org.exoplatform.emailConnector.exception.ServerRuleUnavailableException, org.exoplatform.emailConnector.exception.ServerRuleConflictException, org.exoplatform.emailConnector.exception.ServerRuleUnsupportedException Adds one of the caller's server rules after eXo's others, or replaces the one holding its reference in place, found by eXo's marker.- Specified by:
saveRulein interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Parameters:
session- the caller's own sessionrule- the rule, its folders resolvedexpectedScriptHash- the hash of eXo's rules as eXo last wrote them; when not null and BlueMind holds eXo's rules otherwise, nothing is written- Returns:
- the rules after the write
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the reference names no rule of eXo'sorg.exoplatform.emailConnector.exception.ServerRuleUnavailableException- when the server cannot be usedorg.exoplatform.emailConnector.exception.ServerRuleConflictException- when eXo's rules changed outside eXoorg.exoplatform.emailConnector.exception.ServerRuleUnsupportedException- when BlueMind cannot hold the rule
-
deleteRule
public org.exoplatform.emailConnector.model.ServerRuleSet deleteRule(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, String ref, String expectedScriptHash) throws org.exoplatform.commons.exception.ObjectNotFoundException, org.exoplatform.emailConnector.exception.ServerRuleUnavailableException, org.exoplatform.emailConnector.exception.ServerRuleConflictException, org.exoplatform.emailConnector.exception.ServerRuleUnsupportedException Removes one of the caller's server rules, every copy of its reference.- Specified by:
deleteRulein interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Parameters:
session- the caller's own sessionref- the rule's referenceexpectedScriptHash- as forsaveRule(org.exoplatform.emailConnector.service.acl.MailboxAclSession, org.exoplatform.emailConnector.model.ServerRule, java.lang.String)- Returns:
- the rules after the write
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when no rule of eXo's holds the referenceIllegalArgumentException- when the reference names a hoporg.exoplatform.emailConnector.exception.ServerRuleUnavailableException- when the server cannot be usedorg.exoplatform.emailConnector.exception.ServerRuleConflictException- when eXo's rules changed outside eXoorg.exoplatform.emailConnector.exception.ServerRuleUnsupportedException- when the server has no per-rule API
-
publishRules
public org.exoplatform.emailConnector.model.ServerRuleSet publishRules(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, String expectedScriptHash) throws org.exoplatform.emailConnector.exception.ServerRuleUnavailableException, org.exoplatform.emailConnector.exception.ServerRuleConflictException, org.exoplatform.emailConnector.exception.ServerRuleUnsupportedException "Re-publish": BlueMind runs eXo's rules as soon as they are stored, and nothing can deactivate them but a webmail rule that stops, so there is nothing to write; the rules are read, after the same check as a write.- Specified by:
publishRulesin interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Parameters:
session- the caller's own sessionexpectedScriptHash- as forsaveRule(org.exoplatform.emailConnector.service.acl.MailboxAclSession, org.exoplatform.emailConnector.model.ServerRule, java.lang.String)- Returns:
- the rules as BlueMind holds them
- Throws:
org.exoplatform.emailConnector.exception.ServerRuleUnavailableException- when the server cannot be usedorg.exoplatform.emailConnector.exception.ServerRuleConflictException- when eXo's rules changed outside eXoorg.exoplatform.emailConnector.exception.ServerRuleUnsupportedException- when the server has no per-rule API
-
reconcile
public org.exoplatform.emailConnector.model.ReconcileReport reconcile(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, List<org.exoplatform.emailConnector.model.HopRef> hops, String expectedScriptHash) throws org.exoplatform.emailConnector.exception.ServerRuleUnavailableException, org.exoplatform.emailConnector.exception.ServerRuleConflictException, org.exoplatform.emailConnector.exception.ServerRuleUnsupportedException Makes BlueMind hold exactly the given hops among eXo's rules.- Specified by:
reconcilein interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Parameters:
session- the caller's own sessionhops- the hops to keepexpectedScriptHash- as forsaveRule(org.exoplatform.emailConnector.service.acl.MailboxAclSession, org.exoplatform.emailConnector.model.ServerRule, java.lang.String)- Returns:
- what was done, and the rules afterwards
- Throws:
org.exoplatform.emailConnector.exception.ServerRuleUnavailableException- when the server cannot be usedorg.exoplatform.emailConnector.exception.ServerRuleConflictException- when eXo's rules changed outside eXoorg.exoplatform.emailConnector.exception.ServerRuleUnsupportedException- when BlueMind cannot hold a hop
-
reconcile
public org.exoplatform.emailConnector.model.ReconcileReport reconcile(org.exoplatform.emailConnector.service.acl.MailboxAclSession session, List<org.exoplatform.emailConnector.model.HopRef> hops, org.exoplatform.emailConnector.model.ServerRule added, String droppedRef, String expectedScriptHash) throws org.exoplatform.emailConnector.exception.ServerRuleUnavailableException, org.exoplatform.emailConnector.exception.ServerRuleConflictException, org.exoplatform.emailConnector.exception.ServerRuleUnsupportedException Makes BlueMind hold exactly the given hops among eXo's rules, and in the same change adds one of the user's rules or removes one: a hop missing or different is written in place or added, a hop no eXo filter needs any more is removed, the other rules are kept. The writes go replacements first, additions next, removals last, so that a filter changing where it runs holds both halves for an instant rather than neither; when one fails, the earlier ones are undone (BlueMindRuleWrites).- Specified by:
reconcilein interfaceorg.exoplatform.emailConnector.service.rules.ServerRuleEngine- Parameters:
session- the caller's own sessionhops- the hops to keepadded- a user's rule to add after eXo's others, its folders resolved; null for nonedroppedRef- the reference of a user's rule to remove; null for noneexpectedScriptHash- as forsaveRule(org.exoplatform.emailConnector.service.acl.MailboxAclSession, org.exoplatform.emailConnector.model.ServerRule, java.lang.String)- Returns:
- what was done, and the rules afterwards
- Throws:
org.exoplatform.emailConnector.exception.ServerRuleUnavailableException- when the server cannot be usedorg.exoplatform.emailConnector.exception.ServerRuleConflictException- when eXo's rules changed outside eXoorg.exoplatform.emailConnector.exception.ServerRuleUnsupportedException- when BlueMind cannot hold a hop or the added rule
-