Class UserPreferencesUtil

java.lang.Object
org.nuxeo.user.preferences.api.UserPreferencesUtil

public final class UserPreferencesUtil extends Object
Since:
2025.16
  • Field Details

    • DEFAULT_PROP_MAX_PREFERENCES

      public static final String DEFAULT_PROP_MAX_PREFERENCES
      Default global maximum number of user preferences.
      See Also:
    • PREFERENCE_KEY_REGEX

      public static final String PREFERENCE_KEY_REGEX
      Regex used to validate a preference key pattern. Key can have only letters, digits, dashes, underscores and periods characters. Its length must be at least 1 and maximum 100 characters.

      A restrictive pattern avoids to sanitize keys.

      See Also:
    • PROP_MAX_PREFERENCES

      public static final String PROP_MAX_PREFERENCES
      Property defining the global maximum number of preferences per user.

      Default value is DEFAULT_PROP_MAX_PREFERENCES.

      See Also:
    • PROP_SANITIZE_VALUES

      public static final String PROP_SANITIZE_VALUES
      Property controlling the sanitizing of preference values. Sanitizing is enabled by default.
      See Also:
  • Method Details

    • maxPreferences

      public static long maxPreferences()
      Returns:
      the global maximum number of user preferences
    • newUserDocPreferences

      public static UserPreferences newUserDocPreferences(@Nonnull String key, @Nonnull String value)
      Returns:
      a new UserPreferences for creation or update.
    • newUserDocPreferences

      public static UserPreferences newUserDocPreferences(@Nonnull Map<String,String> preferences)
      Returns:
      a new UserPreferences for creation or update.
    • newUserDocPreferences

      public static UserPreferences newUserDocPreferences(@Nonnull List<UserPreference> userPreferences)
      Returns:
      a new UserPreferences for creation or update.
    • newUserPreference

      public static UserPreference newUserPreference(@Nonnull String key, @Nonnull String value)
      Returns:
      a new UserPreference for creation or update.
    • sanitizeValue

      public static String sanitizeValue(String value)
      Sanitizes the given value escaping html content.
      Parameters:
      value - the value
      Returns:
      the sanitized value
    • validateKey

      public static void validateKey(String key)
      Validates a preference key against the PREFERENCE_KEY_REGEX.
      Parameters:
      key - the preference key
      Throws:
      InvalidUserPreferencesKey - if the key is invalid