Interface AccountKindPlugin


public interface AccountKindPlugin
Declares a kind of user account that an add-on owns, such as the accounts a bot speaks as. The members of getGroupId() are accounts of that kind: social stores the kind on their profile under Profile#ACCOUNT_KIND, shows the kind's label next to their name, and refuses getAdminOnlyProperties() to anyone but an administrator on their profile. The group membership stays the only source of truth for a permission decision; the profile property is a display copy of it.

Social writes that copy when a membership in the group is saved or removed, and at no other time: a member who joined the group before its plugin was declared, or while its plugin was refused, shows no label until one of its memberships in the group is saved or removed. Decisions read the membership, so they do not depend on the copy.

An add-on contributes a kind by declaring its plugin as a Spring bean annotated @Service, which AccountKindService collects with every other plugin bean. From another web application than social's, only an @Service bean reaches social's context: the class is not final, and the bean has a name social's context does not hold, given explicitly, such as @Service("botAccountKindPlugin"). A plugin whose kind or group an earlier plugin, in the order of the kinds then of the groups, already holds is refused. Social reads a plugin at its first decision on an account kind, which can come before the contributing add-on's context has started: the bean is then created ahead of its context, so a plugin holds no dependency, and a plugin whose creation fails is refused until the next startup. The label shown for a kind is read under the key getLabelKey(String) in the shared resource bundles on the server and in the locale.portlet.Portlets bundle in the browser, which the add-on ships in both.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The prefix of the i18n key of a kind's label, followed by the kind.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Set<String>
    Gives the profile properties that only an administrator may change on the profile of an account of this kind.
    Gives the group whose members are accounts of this kind, whatever their membership type.
    Gives the kind stored on the profiles of the accounts of this kind.
    static String
    Builds the i18n key of the label shown next to the name of an account of a kind.
  • Field Details

    • LABEL_KEY_PREFIX

      static final String LABEL_KEY_PREFIX
      The prefix of the i18n key of a kind's label, followed by the kind.
      See Also:
  • Method Details

    • getLabelKey

      static String getLabelKey(String kind)
      Builds the i18n key of the label shown next to the name of an account of a kind. The key is derived from the kind alone, so that a browser that only reads the kind from a profile can resolve it.
      Parameters:
      kind - the account kind
      Returns:
      the i18n key of the kind's label
    • getKind

      String getKind()
      Gives the kind stored on the profiles of the accounts of this kind.

      The kind is made of letters, digits, _ and - only: it becomes an i18n key, a REST value and a value of the profile popover literal. A plugin declaring another kind is refused.

      Returns:
      the account kind, a non-blank identifier such as bot
    • getGroupId

      String getGroupId()
      Gives the group whose members are accounts of this kind, whatever their membership type.
      Returns:
      the group id, such as /platform/bots
    • getAdminOnlyProperties

      default Set<String> getAdminOnlyProperties()
      Gives the profile properties that only an administrator may change on the profile of an account of this kind.
      Returns:
      the property names, empty by default