Class AccountKindService
java.lang.Object
io.meeds.social.core.identity.service.AccountKindService
The account kinds add-ons contribute with an
AccountKindPlugin, and
the decisions social takes from them: which kind a group's members are,
whether a user is of a kind, which kind a profile shows, and which profile
properties a modifier may change.
Spring collects the plugins: every AccountKindPlugin bean,
including the @Service beans of the add-ons whose web applications
start after social, which the Kernel/Spring integration declares in this
context before any context creates its beans. They are read at the first
use, not while this service is built, and only once: what each
plugin declares is kept, and no decision calls a plugin again. A plugin that
cannot be accepted, one that fails to answer included, is refused with an
error log, never by failing the startup nor the decisions on the other
kinds.
-
Constructor Summary
ConstructorsConstructorDescriptionAccountKindService(org.exoplatform.services.organization.OrganizationService organizationService, org.exoplatform.portal.config.UserACL userAcl, List<io.meeds.social.core.identity.plugin.AccountKindPlugin> plugins) Builds the service. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckPropertyUpdate(org.exoplatform.social.core.identity.model.Profile profile, String propertyName, String modifierUsername) Refuses the change of a profile property the modifier may not make: the account kind to anyone, and a property a plugin keeps for administrators to a non-administrator when the profile is an account of that plugin's kind.computeAccountKind(String userName) Computes the account kind of a user from its memberships: the first accepted kind, in the order of the kinds as strings (String.compareTo(String), upper case before lower case) in which the plugins are indexed, whose group holds the user.getDisplayedKind(org.exoplatform.social.core.identity.model.Identity identity) Gives the account kind an identity shows next to its name: the kind stored on its profile, when a plugin declares it.getDisplayedKind(org.exoplatform.social.core.identity.model.Profile profile) Gives the account kind a profile shows next to its name: the kind stored on it, when a plugin declares it.io.meeds.social.core.identity.plugin.AccountKindPlugingetPluginByGroup(String groupId) Gives the plugin whose group makes its members accounts of its kind.io.meeds.social.core.identity.plugin.AccountKindPlugingetPluginByKind(String kind) Gives the plugin of an account kind.Collection<io.meeds.social.core.identity.plugin.AccountKindPlugin> Gives every accepted plugin, in the order of their kinds.booleanTells whether a user is an account of a kind, from its memberships in the kind's group, whatever their membership type.
-
Constructor Details
-
AccountKindService
public AccountKindService(org.exoplatform.services.organization.OrganizationService organizationService, org.exoplatform.portal.config.UserACL userAcl, List<io.meeds.social.core.identity.plugin.AccountKindPlugin> plugins) Builds the service. The plugins are kept as given and read at the first use.- Parameters:
organizationService- the organization service the memberships are read fromuserAcl- the ACL service telling the administratorsplugins- every account kind plugin, empty or null when no add-on contributes one
-
-
Method Details
-
getPluginByKind
Gives the plugin of an account kind.- Parameters:
kind- the account kind- Returns:
- the plugin, null when no plugin declares that kind
-
getPluginByGroup
Gives the plugin whose group makes its members accounts of its kind.- Parameters:
groupId- the group id- Returns:
- the plugin, null when no plugin names that group
-
getPlugins
Gives every accepted plugin, in the order of their kinds.- Returns:
- a copy of the accepted plugins
-
isOfKind
Tells whether a user is an account of a kind, from its memberships in the kind's group, whatever their membership type. A failure to read the memberships is never answered as "not of that kind": it is thrown, and a caller deciding a permission treats it as a refusal.- Parameters:
userName- the user namekind- the account kind- Returns:
- true when the user holds a membership in the kind's group, false when it holds none, when the user name is blank or when no plugin declares the kind
- Throws:
IllegalStateException- when the memberships cannot be read
-
computeAccountKind
Computes the account kind of a user from its memberships: the first accepted kind, in the order of the kinds as strings (String.compareTo(String), upper case before lower case) in which the plugins are indexed, whose group holds the user. A user in several kinds' groups thus always gets the same one, whatever the order its memberships came in.- Parameters:
userName- the user name- Returns:
- the account kind, null when no accepted kind's group holds the user
- Throws:
IllegalStateException- when the memberships cannot be read
-
getDisplayedKind
Gives the account kind an identity shows next to its name: the kind stored on its profile, when a plugin declares it.- Parameters:
identity- the identity- Returns:
- the account kind, null when the identity has none or a kind no plugin declares
-
getDisplayedKind
Gives the account kind a profile shows next to its name: the kind stored on it, when a plugin declares it.- Parameters:
profile- the profile- Returns:
- the account kind, null when the profile has none or a kind no plugin declares
-
checkPropertyUpdate
public void checkPropertyUpdate(org.exoplatform.social.core.identity.model.Profile profile, String propertyName, String modifierUsername) throws IllegalAccessException Refuses the change of a profile property the modifier may not make: the account kind to anyone, and a property a plugin keeps for administrators to a non-administrator when the profile is an account of that plugin's kind. A failure to read the memberships refuses the change.- Parameters:
profile- the profile being updatedpropertyName- the name of the property being changedmodifierUsername- the user who makes the change, null for a change the platform makes, which is not an administrator's- Throws:
IllegalAccessException- when the modifier may not change the property, or when the profile's memberships cannot be read
-