Class RoleLocalizationSupport

java.lang.Object
io.jmix.security.role.RoleLocalizationSupport

@NullMarked @Component("sec_RoleLocalizationSupport") public class RoleLocalizationSupport extends Object
Shows the name and the description of a role in a locale.

A name or a description that has the key of a message, as a design-time role gets from a msg:// reference, is shown through that message: in the locale, then in the default locale, and the name or the description itself when neither has a text. Otherwise the text is taken from the localized names or descriptions of the role: the entry of the exact locale, then the entry of its language, and the name or the description itself when neither has a text.

  • Field Details

  • Constructor Details

    • RoleLocalizationSupport

      public RoleLocalizationSupport()
  • Method Details

    • getLocalizedName

      public String getLocalizedName(BaseRole role)
      Returns:
      the name of the role in the current user's locale
    • getLocalizedName

      public String getLocalizedName(BaseRole role, Locale locale)
      Returns:
      the name of the role in the given locale
    • getLocalizedDescription

      public @Nullable String getLocalizedDescription(BaseRole role)
      Returns:
      the description of the role in the current user's locale, or null if the role has none or it is blank
    • getLocalizedDescription

      public @Nullable String getLocalizedDescription(BaseRole role, Locale locale)
      Returns:
      the description of the role in the given locale, or null if the role has none or it is blank
    • getLocalizedName

      public String getLocalizedName(BaseRoleModel roleModel)
      Returns:
      the name of the role model in the current user's locale
      See Also:
    • getLocalizedName

      public String getLocalizedName(BaseRoleModel roleModel, Locale locale)
      Returns:
      the name of the role model in the given locale
      See Also:
    • getLocalizedDescription

      public @Nullable String getLocalizedDescription(BaseRoleModel roleModel)
      Returns:
      the description of the role model in the current user's locale, or null if it has none or it is blank
      See Also:
    • getLocalizedDescription

      public @Nullable String getLocalizedDescription(BaseRoleModel roleModel, Locale locale)
      Returns:
      the description of the role model in the given locale, or null if it has none or it is blank
      See Also:
    • localize

      protected @Nullable String localize(@Nullable String messageKey, @Nullable String localizedValues, @Nullable String text, Locale locale)
    • loadLocalizedValues

      protected Map<String,String> loadLocalizedValues(@Nullable String localizedValues)
    • isAbsent

      protected boolean isAbsent(@Nullable String value)
    • nullIfAbsent

      protected @Nullable String nullIfAbsent(@Nullable String value)
      A design-time role without a description holds the empty string its annotation declares by default, a database role holds null; both mean the role has none.