Class LayoutDescriptionService

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

@Service public class LayoutDescriptionService extends Object
Converts a page or site container tree into the description the MCP tools return. The section grammar lives in the editor's cssClass tokens only (FlexContainer/GridContainer over CellContainer, grid-cols/grid-rows and the cell spans, a missing token reading as 1); style values are read from the model's style fields, never parsed back from the generated tokens.
  • Field Details

  • Constructor Details

    • LayoutDescriptionService

      public LayoutDescriptionService()
  • Method Details

    • filterAccessible

      public org.exoplatform.portal.config.model.ModelObject filterAccessible(org.exoplatform.portal.config.model.ModelObject modelObject, String username)
      Drops, recursively, every container and application the user has no access permission on. Only page permissions are considered by the platform; an element-level permission is legacy data this filter still honours, as the page read does.
    • toPageDescription

      public PageDescription toPageDescription(org.exoplatform.portal.config.model.ModelObject pageTree, String pageRef, LayoutVersion version)
    • toPageDescription

      public PageDescription toPageDescription(org.exoplatform.portal.config.model.ModelObject pageTree, String pageRef, LayoutVersion version, String username)
      Parameters:
      pageTree - the page read, filtered by access permission
      pageRef - the live page reference
      version - the version read
      username - the reader, whose settings the configurable applications answer; null to read no settings
      Returns:
      the page description
    • toSiteDescription

      public SiteDescription toSiteDescription(org.exoplatform.portal.config.model.PortalConfig site, org.exoplatform.portal.config.model.ModelObject layout, String label, String description, boolean draft)
      Parameters:
      site - the live site, for its properties
      layout - the site layout to describe, the draft's when the user has one, already filtered by access permission
      label - the site label resolved in the user's language
      description - the site description resolved in the user's language
      draft - whether the layout is the user's draft
      Returns:
      the site description
    • toSiteDescription

      public SiteDescription toSiteDescription(org.exoplatform.portal.config.model.PortalConfig site, org.exoplatform.portal.config.model.ModelObject layout, String label, String description, org.exoplatform.portal.mop.SiteKey layoutSiteKey, boolean draft, String username)
      Parameters:
      site - the live site, for its properties
      layout - the site layout to describe, the draft's when the user has one, already filtered by access permission
      label - the site label resolved in the user's language
      description - the site description resolved in the user's language
      layoutSiteKey - the site holding the layout, the user's draft site or the live site; null to read no settings
      draft - whether the layout is the user's draft
      username - the reader, whose settings the configurable applications answer; null to read no settings
      Returns:
      the site description
    • toSiteLayout

      public LayoutModel toSiteLayout(SiteLayoutUpdate update, org.exoplatform.portal.config.model.PortalConfig stored, boolean copyWindows, String username, Locale locale) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Rebuilds a site layout from a set_site_layout call over the stored tree, every value checked before anything is written. The windows the caller cannot see stay in place; a container they cannot see refuses the call.
      Parameters:
      update - the four arguments of the call
      stored - the site whose stored layout is rebuilt, the user's draft or the live site
      copyWindows - true when the layout is the live one and the result becomes a new draft: every kept window is then a copy carrying the live window's preferences, as createDraftSite makes them
      username - the caller
      locale - the caller's locale, for the title of an application added from the catalog
      Returns:
      the tree to save, ready for toSite, its style values checked as the save checks them, so a refusal precedes any write
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when an addressed container or window is not in the stored layout
      IllegalAccessException - when the stored layout holds an element the caller cannot see and the call would not keep it in place
    • toSiteLayout

      public LayoutModel toSiteLayout(SiteLayoutUpdate update, org.exoplatform.portal.config.model.PortalConfig stored, boolean copyWindows, String username, Locale locale, ImageConsumption images) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Parameters:
      images - the call's image consumption, on which a styling block carrying an image_upload_id claims its id before any write
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • toPageLayout

      public LayoutModel toPageLayout(List<SectionDescription> sections, org.exoplatform.portal.config.model.Page stored, String username, Locale locale) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Parameters:
      sections - the page's sections as set_page_layout takes them
      stored - the stored page the ids address, as the storage holds it: the live page when the user has no draft, their draft otherwise
      username - the editing user
      locale - the user's language, for the catalog names
      Returns:
      the page to write, its sections parent's children replaced
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • toPageLayout

      public LayoutModel toPageLayout(List<SectionDescription> sections, org.exoplatform.portal.config.model.Page stored, String username, Locale locale, ImageConsumption images) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Parameters:
      images - the call's image consumption, on which a styling block carrying an image_upload_id claims its id before any write
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • toStyledPage

      public LayoutModel toStyledPage(List<ElementStyling> elements, org.exoplatform.portal.config.model.Page stored, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      elements - the elements of a set_layout_styles call
      stored - the stored page the ids address: the live page when the user has no draft, their draft otherwise
      username - the editing user
      Returns:
      the page to write, its structure as stored
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • toStyledPage

      public LayoutModel toStyledPage(List<ElementStyling> elements, org.exoplatform.portal.config.model.Page stored, String username, ImageConsumption images) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      images - the call's image consumption, on which a block carrying an image_upload_id claims its id before any write
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • toDisplayedPage

      public LayoutModel toDisplayedPage(List<ElementDisplay> elements, org.exoplatform.portal.config.model.Page stored, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      elements - the elements of a set_layout_visibility call
      stored - the stored page the ids address: the live page when the user has no draft, their draft otherwise
      username - the editing user
      Returns:
      the page to write, its structure as stored
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • toStyledSite

      public LayoutModel toStyledSite(List<ElementStyling> elements, org.exoplatform.portal.config.model.PortalConfig stored, boolean copyWindows, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      elements - the elements of a set_layout_styles call
      stored - the site whose stored layout the ids address, the user's draft or the live site
      copyWindows - whether the result becomes a new draft built from the live layout, in which case every window becomes a copy carrying its preferences
      username - the editing user
      Returns:
      the site layout to write, its structure as stored
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • toStyledSite

      public LayoutModel toStyledSite(List<ElementStyling> elements, org.exoplatform.portal.config.model.PortalConfig stored, boolean copyWindows, String username, ImageConsumption images) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      images - the call's image consumption, on which a block carrying an image_upload_id claims its id before any write
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • toDisplayedSite

      public LayoutModel toDisplayedSite(List<ElementDisplay> elements, org.exoplatform.portal.config.model.PortalConfig stored, boolean copyWindows, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      elements - the elements of a set_layout_visibility call
      stored - the site whose stored layout the ids address, the user's draft or the live site
      copyWindows - whether the result becomes a new draft built from the live layout, in which case every window becomes a copy carrying its preferences
      username - the editing user
      Returns:
      the site layout to write, its structure as stored
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • toMovedPage

      public PlacedLayout toMovedPage(String applicationId, ApplicationPosition position, org.exoplatform.portal.config.model.Page stored, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      applicationId - the window of a move_layout_application call
      position - where it goes
      stored - the stored page the ids address: the live page when the user has no draft, their draft otherwise
      username - the editing user
      Returns:
      the page to write and the path of the moved window
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • toPlacedPage

      public PlacedLayout toPlacedPage(ApplicationToPlace application, ApplicationPosition position, org.exoplatform.portal.config.model.Page stored, String username, Locale locale) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      application - the catalog application of a move_layout_application call
      locale - the user's language, for the catalog names
      Returns:
      the page to write and the path of the new window
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • toRemovedPage

      public LayoutModel toRemovedPage(String applicationId, org.exoplatform.portal.config.model.Page stored, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Returns:
      the page to write, the window removed
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • toMovedSite

      public PlacedLayout toMovedSite(String applicationId, ApplicationPosition position, org.exoplatform.portal.config.model.PortalConfig stored, boolean copyWindows, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      stored - the site whose stored layout the ids address, the user's draft or the live site
      Returns:
      the site layout to write and the path of the moved window
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • toPlacedSite

      public PlacedLayout toPlacedSite(ApplicationToPlace application, ApplicationPosition position, org.exoplatform.portal.config.model.PortalConfig stored, boolean copyWindows, String username, Locale locale) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • toRemovedSite

      public LayoutModel toRemovedSite(String applicationId, org.exoplatform.portal.config.model.PortalConfig stored, boolean copyWindows, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • describeSites

      public List<SiteSummary> describeSites(String username, String keyword)
      Parameters:
      username - the reader
      keyword - null for the portal sites alone, as the sites administration lists them; otherwise the portal sites whose name or label contains it, then the group sites whose own name (for a space, the group name it was created with, which a rename leaves as is) contains it
      Returns:
      the sites the user can view, the portal sites by display order then label, sorted here because the portal's site query is cached by its predicates alone, the sort of its first caller serving every later one
    • describeNavigation

      public List<NavigationItemDescription> describeNavigation(org.exoplatform.portal.mop.SiteKey siteKey, boolean includeHidden, String username)
      Parameters:
      siteKey - the site whose navigation is read; the caller has checked it can be viewed
      includeHidden - whether the hidden and system items are wanted; they are returned only to a user who can edit the site's navigation
      username - the reader
      Returns:
      the navigation tree the user can view, draft items excluded
    • describeNavigationItem

      public NavigationItemDescription describeNavigationItem(org.exoplatform.portal.mop.SiteKey siteKey, long nodeId, String username) throws IllegalAccessException
      One navigation item with its children, as describeNavigation lists it, for a user who edits the site's navigation, the writer of the item: the hidden items are included, and the item itself is not filtered by the view right on its page, which the permissions just written may have taken from them; its labels are, as the navigation drawer's own label read is, so they are omitted then; its children are listed as describeNavigation lists them.
      Parameters:
      siteKey - the site the item belongs to
      nodeId - the item
      username - the reader
      Returns:
      the item, null when it is absent from the site's navigation or is a draft
      Throws:
      IllegalAccessException - the user cannot edit the site's navigation
    • describeApplications

      public List<LayoutApplicationEntry> describeApplications(Long categoryId, String keyword, String username, Locale locale)
      Parameters:
      categoryId - a category, null for every category
      keyword - a text the name or description must contain, null for no filter
      username - the reader
      locale - the language of the names
      Returns:
      the enabled catalog instances the user may place, then, with no category filter, each application a code plugin places without a catalog instance that no such instance carries
    • toDisplay

      public DisplayMode toDisplay(String cssClass)
    • breakpointValue

      public int breakpointValue(String cssClass, String prefix)
      Parameters:
      cssClass - the container's class tokens
      prefix - grid-cols, grid-rows, grid-cell-colspan or grid-cell-rowspan
      Returns:
      the value of the token at the editor's current breakpoint, 1 when the token is absent, as the editor's parser reads it
    • toStyling

      public StylingDescription toStyling(LayoutModel model, StylingDestination destination)