Class CaldavManagedModeService
The decision itself — which connector is designated for the caldav
kind, which groups it does not reach, whether it applies to a given user —
is held and answered by ManagedConnectorService in commons-exo, the
same for calendars and mailboxes. What this class adds is the CalDAV
knowledge commons-exo does not have: that the designated id must be a
registration that exists and is active, which provider it is configured
with (the eligibility criterion commons-exo enforces), and the name the
screens print instead of the id.
The dependency runs from CaldavServerService to this class and never
back. This one reads the registry's storage directly — the same storage that
service reads, in the same add-on — precisely so that the registry service
can call checkServerNotManaged(long) on the two writes that would
otherwise leave the mode pointing at a server nobody can synchronise with.
Injecting the registry service here instead would close a bean cycle, which
Spring Boot refuses outright.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckProviderChangeAllowed(long serverId, String providerName) Refuses the edit that would leave the managed row on a provider asking each user for something — the very thing designating it refused.voidcheckServerNotManaged(long serverId) Refuses the registry writes that would strand the mode.voidclearManagedServer(String username) Switches managed mode off: users choose their own server again, and the exclusions go with the designation they qualified.designatedServerFor(String username) The registration this user is to be attached to at login, or null when managed mode does not apply to them - nothing designated, or a population the administrator excluded.The groups the instance's choice does not reach.org.exoplatform.caldav.model.CaldavManagedModegetManagedMode(String username) What the instance decided, and whether it applies to this caller.The registration the instance points everybody at, when managed mode is on.governingServerFor(String username) The registration managed mode governs this user with in the stored state, for a decision that disconnects them: the same rule asdesignatedServerFor(String), except that a user whose identity cannot be resolved is refused rather than counted as excluded.booleanisManagedFor(String username) Whether this user is governed by the instance's choice: managed mode is on and they belong to none of the excluded groups.voidsaveManagedServer(long serverId, List<String> excludedGroups, String username) Points the whole instance at one registration, minus the given groups.
-
Constructor Details
-
CaldavManagedModeService
public CaldavManagedModeService()
-
-
Method Details
-
getManagedServerId
The registration the instance points everybody at, when managed mode is on.- Returns:
- the managed registration's id, null when managed mode is off
-
getExcludedGroups
The groups the instance's choice does not reach.- Returns:
- the excluded eXo group ids, empty when none
-
isManagedFor
Whether this user is governed by the instance's choice: managed mode is on and they belong to none of the excluded groups.Nobody is managed on nobody's behalf: an anonymous caller has no account to govern, and answering true would hide affordances from a page that has no user to hide them from.
- Parameters:
username- the eXo login, null or blank for an anonymous caller- Returns:
- true when the choice applies to them
-
designatedServerFor
The registration this user is to be attached to at login, or null when managed mode does not apply to them - nothing designated, or a population the administrator excluded. The caller does not need to know which: in both cases it does nothing. Recomputed on every call, never stored.- Parameters:
username- the eXo login, null or blank for an anonymous caller- Returns:
- the designated registration's id, or null
-
governingServerFor
The registration managed mode governs this user with in the stored state, for a decision that disconnects them: the same rule asdesignatedServerFor(String), except that a user whose identity cannot be resolved is refused rather than counted as excluded.- Parameters:
username- the eXo login- Returns:
- the designated registration's id, or null when managed mode does not apply
- Throws:
IllegalStateException- when exclusions apply and the identity cannot be resolved
-
getManagedMode
What the instance decided, and whether it applies to this caller.The server is named, not merely identified: every screen showing this prints a name, and having each of them fetch the registry to turn an id into a name would be three round trips for one word. A row deleted out from under the setting leaves the name null rather than failing — the registry refuses that deletion, so this is the belt to that braces.
- Parameters:
username- the eXo login of the caller, null or blank when anonymous- Returns:
- the mode as it stands for that caller
-
saveManagedServer
public void saveManagedServer(long serverId, List<String> excludedGroups, String username) throws IllegalAccessException Points the whole instance at one registration, minus the given groups.This class refuses a registration that does not exist or is deactivated — the row nobody can connect to, which only this add-on can recognise. Everything else is commons-exo's, in one call so that nothing is written when anything is refused: that the caller is an administrator, that the row's provider asks the user for nothing (Personal cannot be designated, because it would produce an instance connector nobody can connect through), and the order of the two writes.
- Parameters:
serverId- technical identifier of the registrationexcludedGroups- the eXo group ids the choice must not reach, null for noneusername- the eXo login of the caller- Throws:
IllegalAccessException- when the caller is not an administratorIllegalArgumentException- carryingcaldav.managed.serverNotEligiblewhen the row is unknown or deactivated, or the commons-exo code when its provider asks the user for something
-
clearManagedServer
Switches managed mode off: users choose their own server again, and the exclusions go with the designation they qualified. The accounts managed mode attached are disconnected in the background; the accounts users connected themselves are untouched.- Parameters:
username- the eXo login of the caller- Throws:
IllegalAccessException- when the caller is not an administrator
-
checkProviderChangeAllowed
Refuses the edit that would leave the managed row on a provider asking each user for something — the very thing designating it refused. Any other row may change provider freely.- Parameters:
serverId- the registration being editedproviderName- the provider it would be configured with after the edit- Throws:
IllegalArgumentException- carryingcaldav.managed.providerNotEligiblewhen the row is the managed one and the provider is not eligible
-
checkServerNotManaged
public void checkServerNotManaged(long serverId) Refuses the registry writes that would strand the mode.- Parameters:
serverId- the registration about to be deactivated or deleted- Throws:
IllegalArgumentException- carryingcaldav.managed.serverInUsewhen managed mode points at that row
-