Class CmsUsedCategoriesList

java.lang.Object
org.opencms.gwt.CmsUsedCategoriesList

public class CmsUsedCategoriesList extends Object
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 Details

  • Constructor Details

  • 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 context
      category - the category to store
      Throws:
      CmsException - if something goes wrong
    • fromJson

      public static CmsUsedCategoriesList fromJson(String json)
      Deserializes a used categories list from JSON.
      Parameters:
      json - the JSON representation
      Returns:
      the used categories list
    • add

      public void add(String category)
      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

      public void limit(int maxEntries)
      Removes all but the last 'maxEntries' entries if there are more entries than that.
      Parameters:
      maxEntries - the numer of entries to keep
    • toJson

      public String toJson()
      Converts the list to JSON.
      Returns:
      the JSON representation for this list