Class AccountKindService

java.lang.Object
io.meeds.social.core.identity.service.AccountKindService

@Service public class AccountKindService extends Object
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

    Constructors
    Constructor
    Description
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    checkPropertyUpdate(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.
    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.AccountKindPlugin
    Gives the plugin whose group makes its members accounts of its kind.
    io.meeds.social.core.identity.plugin.AccountKindPlugin
    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.
    boolean
    isOfKind(String userName, String kind)
    Tells whether a user is an account of a kind, from its memberships in the kind's group, whatever their membership type.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 from
      userAcl - the ACL service telling the administrators
      plugins - every account kind plugin, empty or null when no add-on contributes one
  • Method Details

    • getPluginByKind

      public io.meeds.social.core.identity.plugin.AccountKindPlugin getPluginByKind(String kind)
      Gives the plugin of an account kind.
      Parameters:
      kind - the account kind
      Returns:
      the plugin, null when no plugin declares that kind
    • getPluginByGroup

      public io.meeds.social.core.identity.plugin.AccountKindPlugin getPluginByGroup(String groupId)
      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

      public Collection<io.meeds.social.core.identity.plugin.AccountKindPlugin> getPlugins()
      Gives every accepted plugin, in the order of their kinds.
      Returns:
      a copy of the accepted plugins
    • isOfKind

      public boolean isOfKind(String userName, String kind)
      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 name
      kind - 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

      public String 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. 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

      public String 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.
      Parameters:
      identity - the identity
      Returns:
      the account kind, null when the identity has none or a kind no plugin declares
    • getDisplayedKind

      public String 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.
      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 updated
      propertyName - the name of the property being changed
      modifierUsername - 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