Package org.nuxeo.user.preferences.api
Class UserPreferencesUtil
java.lang.Object
org.nuxeo.user.preferences.api.UserPreferencesUtil
- Since:
- 2025.16
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault global maximum number of user preferences.static final StringRegex used to validate a preference key pattern.static final StringProperty defining the global maximum number of preferences per user.static final StringProperty controlling the sanitizing of preference values. -
Method Summary
Modifier and TypeMethodDescriptionstatic longstatic UserPreferencesnewUserDocPreferences(String key, String value) static UserPreferencesnewUserDocPreferences(List<UserPreference> userPreferences) static UserPreferencesnewUserDocPreferences(Map<String, String> preferences) static UserPreferencenewUserPreference(String key, String value) static StringsanitizeValue(String value) Sanitizes the given value escaping html content.static voidvalidateKey(String key) Validates a preference key against thePREFERENCE_KEY_REGEX.
-
Field Details
-
DEFAULT_PROP_MAX_PREFERENCES
Default global maximum number of user preferences.- See Also:
-
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
Property defining the global maximum number of preferences per user.Default value is
DEFAULT_PROP_MAX_PREFERENCES.- See Also:
-
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
- Returns:
- a new
UserPreferencesfor creation or update.
-
newUserDocPreferences
- Returns:
- a new
UserPreferencesfor creation or update.
-
newUserDocPreferences
- Returns:
- a new
UserPreferencesfor creation or update.
-
newUserPreference
- Returns:
- a new
UserPreferencefor creation or update.
-
sanitizeValue
Sanitizes the given value escaping html content.- Parameters:
value- the value- Returns:
- the sanitized value
-
validateKey
Validates a preference key against thePREFERENCE_KEY_REGEX.- Parameters:
key- the preference key- Throws:
InvalidUserPreferencesKey- if the key is invalid
-