Class ScopedGroupsTreeService

java.lang.Object
sk.iway.iwcm.doc.ScopedGroupsTreeService

public class ScopedGroupsTreeService extends Object
Builds jsTree folder nodes within the configured scope of applications such as News and Blog.

The scope is resolved from GroupsDB during construction and contains configured roots and their visible descendants. Visible ancestors outside that scope provide navigation paths but cannot be selected. Folder permissions determine visibility and selection unless the caller explicitly disables those checks for an application-managed scope.

Supports initial tree loading, lazy child loading, and folder-name searches through getItems(int, int, String, String).

  • Constructor Details

    • ScopedGroupsTreeService

      public ScopedGroupsTreeService(List<LabelValue> folders, Identity user, String domain)
      Resolves the application folder scope with folder permission checks enabled.
      Parameters:
      folders - configured roots whose values contain a positive folder ID, optionally followed by * to preserve recursive article filtering
      user - user whose permissions and tree sorting preferences apply; null produces an empty scope
      domain - domain to include when multiDomainEnabled is enabled; must not be null in that case
      See Also:
    • ScopedGroupsTreeService

      public ScopedGroupsTreeService(List<LabelValue> folders, Identity user, String domain, boolean checkGroupsPerms)
      Resolves configured roots, visible descendants, and navigation ancestors from the folder cache.

      Descendants are traversed regardless of a root's * suffix. The suffix is retained in the node's article filter, and a suffixed value takes precedence for duplicate root IDs. Folders that fail visibility checks are skipped together with their descendant traversal.

      With permission checks enabled, only editable folders are selectable; viewable folders remain available for navigation. Users restricted to individual pages without editable folders receive an empty scope. Ancestors added above the configured roots are never selectable.

      Parameters:
      folders - configured roots whose values contain a positive folder ID, optionally followed by *; labels are unused, and invalid or nonpositive IDs are ignored
      user - user whose permissions and tree sorting preferences apply; null produces an empty scope
      domain - domain to include when multiDomainEnabled is enabled; must not be null in that case
      checkGroupsPerms - whether to enforce folder edit and view permissions; false trusts the caller's configured scope while retaining domain and hidden-folder checks
  • Method Details

    • getItems

      public List<GroupsJsTreeItem> getItems(int parentId, int selectedId, String searchValue, String searchType)
      Creates a flat list of jsTree nodes for initial loading, lazy child loading, or searching.

      Without a search, parentId == 0 loads the roots and opens navigation ancestors and the selected folder's path, including direct children of every opened folder. If the requested selection is unavailable, the first selectable folder collected during construction is selected if one exists. A nonzero parent ID loads only that folder's direct children.

      A nonblank search takes precedence over both IDs and returns matching folder names with their scoped ancestors opened. Comparisons ignore case and diacritics. Search and lazy-load responses do not mark any node as selected. Nodes outside the selectable set are disabled.

      Parameters:
      parentId - parent folder whose children to load, or 0 for the initial tree
      selectedId - preferred selectable folder for initial loading; ignored for searches and lazy child loading
      searchValue - folder-name search text, or null or a blank string to load the tree
      searchType - comparison mode: startwith, endwith, or equals; any other value, including null, uses substring matching
      Returns:
      nodes ordered by the user's tree sorting preferences, with parent IDs and loading states set for jsTree; empty if no nodes qualify or a requested lazy-load parent is unknown
    • isSelectable

      public boolean isSelectable(int groupId)
      Checks whether a folder belongs to the selectable scope resolved during construction.
      Parameters:
      groupId - folder ID to check
      Returns:
      true if the folder is selectable; false for navigation-only, excluded, or unknown folders