Class NavigationLayoutService

java.lang.Object
io.meeds.layout.service.NavigationLayoutService

@Service public class NavigationLayoutService extends Object
  • Field Details

    • PAGE_UNREACHABLE_EVENT

      public static final String PAGE_UNREACHABLE_EVENT
      Broadcast when a page stops being reachable through any navigation node, while the page itself still exists. Deliberately NOT LayoutService.PAGE_REMOVED: that event means the page's own data is gone, and a listener acting on it is entitled to clean up everything attached to the page — which would destroy live data here.
      See Also:
    • NODE_NAME_NOT_ACCEPTED

      public static final String NODE_NAME_NOT_ACCEPTED
      See Also:
    • SCHEDULE_END_BEFORE_START

      public static final String SCHEDULE_END_BEFORE_START
      See Also:
    • SCHEDULE_START_PAST

      public static final String SCHEDULE_START_PAST
      See Also:
    • SCHEDULE_ON_HIDDEN_NODE

      public static final String SCHEDULE_ON_HIDDEN_NODE
      See Also:
    • SCHEDULE_INCOMPLETE

      public static final String SCHEDULE_INCOMPLETE
      See Also:
    • PARENT_NODE_NOT_FOUND_MESSAGE

      public static final String PARENT_NODE_NOT_FOUND_MESSAGE
      See Also:
    • NODE_NOT_FOUND_MESSAGE

      public static final String NODE_NOT_FOUND_MESSAGE
      See Also:
  • Constructor Details

    • NavigationLayoutService

      public NavigationLayoutService()
  • Method Details

    • createNode

      public org.exoplatform.portal.mop.navigation.NodeData createNode(NavigationCreateModel nodeModel, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException, IllegalArgumentException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
      IllegalArgumentException
    • createNodeWithPage

      public org.exoplatform.portal.mop.navigation.NodeData createNodeWithPage(NavigationCreateModel nodeModel, PageCreateModel pageModel, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Creates a navigation item for a caller outside the navigation drawer, a tool or an API, with the page it points to when one is to be created. The name is checked here and never in createNode(NavigationCreateModel, String), which keeps passing the platform's own draft and imported names through: the drawer's character class, no draft marker, unique among the parent's stored children, hidden and draft ones included. The item is appended after the parent's last child when no previous node is named. The page is created first, in the parent's site, then the node: a node failure removes the page, and a node whose labels then failed is removed, by the id its write returned, before it; a second write each, no atomicity. A node write that throws is taken as having written nothing: this method never looks a node up by name, which cannot tell its own from one another caller wrote under that name meanwhile.
      Parameters:
      nodeModel - the item, its pageRef set here when a page model is given
      pageModel - the page to create, null for an item pointing at an existing page or none
      username - the user creating the item
      Returns:
      the created node
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - parent, page template or referenced page absent
      IllegalAccessException - the user cannot edit the site's navigation
      IllegalArgumentException - the name refused (NODE_NAME_NOT_ACCEPTED), the schedule refused, both checked before the page is created, or the page model
    • getDefaultParentNodeId

      public Long getDefaultParentNodeId(org.exoplatform.portal.mop.SiteKey siteKey)
      The site's top menu lists the items under the first root item it keeps, and nothing while that item has no items the viewer sees under it, so a new item goes under that first item by default. The menu's skip of an item whose page the viewer cannot read depends on the viewer and is not applied here.
      Parameters:
      siteKey - the site
      Returns:
      the id of the navigation root's first child the top menu keeps: one with items under it, whatever its visibility, or one displayed, or scheduled with a window that holds the present time; the root's when there is none, null when the site has no navigation
    • getEditableNode

      public org.exoplatform.portal.mop.navigation.NodeData getEditableNode(long nodeId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Parameters:
      nodeId - the node
      username - the user about to change it
      Returns:
      the node, whatever the user's view right on its page
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - the node is absent
      IllegalAccessException - the user cannot edit the site's navigation
    • createDraftNode

      public org.exoplatform.portal.mop.navigation.NodeData createDraftNode(Long nodeId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • updateNode

      public void updateNode(long nodeId, NavigationUpdateModel nodeModel, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException, IllegalArgumentException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
      IllegalArgumentException
    • updateNodeAndPagePermissions

      public org.exoplatform.portal.mop.navigation.NodeData updateNodeAndPagePermissions(long nodeId, NavigationItemUpdate update, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Changes on a navigation item what a caller outside the navigation drawer was given and keeps every other stored value, the schedule a drawer re-picks included: the node state is merged over the stored one and the translations over the raw stored descriptions, never over the labels getNodeLabels(long, String) synthesizes from the navigation bundle, so a bundle-keyed node keeps its key unless a label is given. The item's page steps come first and the node last, each step's inverse run on a later failure: a page created from the model, the LINK page's link, the page's permissions merged over its current ones; a second write each, no atomicity.
      Parameters:
      nodeId - the item
      update - what to change
      username - the user changing it
      Returns:
      the node as stored
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - node, page or template absent
      IllegalAccessException - the user cannot edit the site's navigation, or the page whose link or permissions change
      IllegalArgumentException - the schedule refused
    • deleteNode

      public void deleteNode(long nodeId, long delay, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • undoDeleteNode

      public void undoDeleteNode(long nodeId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • init

      @PostConstruct public void init()
    • destroy

      @PreDestroy public void destroy()
      Lets a deletion that is running end, up to STOP_TIMEOUT seconds, then runs the deletions still waiting for their delay.
    • deletePendingNodes

      public void deletePendingNodes()
      Runs the deletions still waiting for their delay, which would be lost with this node: their undo is no longer possible.
    • moveNode

      public void moveNode(long nodeId, Long destinationParentId, Long previousNodeId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • getNode

      public org.exoplatform.portal.mop.navigation.NodeData getNode(long nodeId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • getNodeLabels

      public NodeLabel getNodeLabels(long nodeId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • getNodeUri

      public String getNodeUri(long nodeId, String username) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      IllegalAccessException
      org.exoplatform.commons.exception.ObjectNotFoundException
    • getNodeUri

      public String getNodeUri(org.exoplatform.portal.mop.navigation.NodeData node)
    • getReachablePages

      public Set<org.exoplatform.portal.mop.page.PageKey> getReachablePages(org.exoplatform.portal.mop.SiteKey siteKey)
      Parameters:
      siteKey - the site whose navigation is walked
      Returns:
      the pages that a node of the site's navigation leads to, pages of other sites included, whereas the search index resolves a page's path in its own site's navigation
    • deleteNode

      public void deleteNode(long nodeId)
    • findNode

      public org.exoplatform.portal.mop.navigation.NodeContext<org.exoplatform.portal.mop.navigation.NodeContext<Object>> findNode(org.exoplatform.portal.mop.navigation.NodeContext<org.exoplatform.portal.mop.navigation.NodeContext<Object>> node, String name)
    • toNodeLabel

      public NodeLabel toNodeLabel(Map<Locale, org.exoplatform.portal.mop.State> nodeLabels)