Package org.opencms.gwt
Class CmsUsedCategoriesList
java.lang.Object
org.opencms.gwt.CmsUsedCategoriesList
Represents a list of recently used categories for a given user.
You can add categories to this or truncate the list to the n most recently used categories, as well as serialize it to or deserialize it from JSON.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new category entry.static voidaddUsedCategoryForCurrentUser(CmsObject cms, String category) Stores a used category for the current user.static CmsUsedCategoriesListDeserializes a used categories list from JSON.Gets the categories as a set.voidlimit(int maxEntries) Removes all but the last 'maxEntries' entries if there are more entries than that.toJson()Converts the list to JSON.
-
Field Details
-
ADDINFO_USED_CATEGORIES
Additional info key used to store used categories for users.- See Also:
-
CONF_USED_CATEGORIES_LIMIT
Configuration option used to change the maximum number of entries to keep per user.- See Also:
-
USED_CATEGORIES_LIMIT
Default limit for storing used categories.- See Also:
-
-
Constructor Details
-
CmsUsedCategoriesList
public CmsUsedCategoriesList()Creates a new instance.
-
-
Method Details
-
addUsedCategoryForCurrentUser
public static void addUsedCategoryForCurrentUser(CmsObject cms, String category) throws CmsException Stores a used category for the current user.- Parameters:
cms- the current CMS contextcategory- the category to store- Throws:
CmsException- if something goes wrong
-
fromJson
Deserializes a used categories list from JSON.- Parameters:
json- the JSON representation- Returns:
- the used categories list
-
add
Adds a new category entry.If the category is already part of this list, it is moved to the end of the list.
- Parameters:
category- the category to add
-
getCategories
Gets the categories as a set.- Returns:
- the categories
-
limit
Removes all but the last 'maxEntries' entries if there are more entries than that.- Parameters:
maxEntries- the numer of entries to keep
-
toJson
Converts the list to JSON.- Returns:
- the JSON representation for this list
-