Class LayoutDraftService

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

@Service public class LayoutDraftService extends Object
Resolves the draft a user is editing through the co-editing revision the layout editors record, never through a draft page or a draft site found in storage: the editors re-clone the live layout whenever no revision names a draft, so a leftover draft is a stale copy nobody edits.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.exoplatform.portal.mop.page.PageKey
    createDraftPage(long liveNodeId, String username)
    Creates the user's draft of a page through the editor's own path and records the draft node id as the user's co-editing revision on the live node, so the editor resumes it and the read tools return it; an existing draft page of the same user is written again from the live page and the draft node re-pointed, as the editor's "start again" does.
    org.exoplatform.portal.mop.SiteKey
    createDraftSite(org.exoplatform.portal.config.model.PortalConfig liveSite, String username)
    Creates the user's draft of a site through the editor's own path and records the draft site id as the user's co-editing revision, so the editor resumes it and the read tools return it; an existing draft of the same user is replaced, as the editor's "start again" does.
    org.exoplatform.portal.mop.page.PageKey
    discardDraftPage(org.exoplatform.portal.mop.page.PageKey livePageKey, long liveNodeId, String username)
    Drops the draft the user's revision names and starts a new one from the live page, as the editor's "start again" does.
    org.exoplatform.portal.mop.SiteKey
    discardDraftSite(org.exoplatform.portal.config.model.PortalConfig liveSite, String username)
    Drops the draft the user's revision names and starts a new one from the live layout, as the editor's "start again" does.
    draftNodeName(String liveNodeName, String username)
     
    org.exoplatform.portal.mop.page.PageKey
    draftPageKey(org.exoplatform.portal.mop.page.PageKey livePageKey, String username)
     
    draftSiteName(org.exoplatform.portal.config.model.PortalConfig liveSite, String username)
     
    findLiveNodeId(org.exoplatform.portal.mop.page.PageKey pageKey, String username)
     
    org.exoplatform.portal.mop.page.PageKey
    getDraftPageKey(long liveNodeId, String username)
     
    org.exoplatform.portal.mop.SiteKey
    getDraftSiteKey(long siteId, String username)
     
    boolean
    isDraftNode(String nodeName)
     
    void
    publishPage(org.exoplatform.portal.mop.page.PageKey livePageKey, long liveNodeId, String username)
    Publishes the draft the user's revision names over the live page, as the editor's publish does, then removes the revision; a leftover draft without a revision is never published, nor a page the draft node was re-pointed at.
    void
    publishSite(org.exoplatform.portal.config.model.PortalConfig liveSite, String username)
    Publishes the draft the user's revision names over the live site, as the editor's save does from the stored draft, then removes the revision; a leftover draft without a revision is never published, and the draft is read under the view rule a draft site carries, as the read tools read it.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • LayoutDraftService

      public LayoutDraftService()
  • Method Details

    • getDraftPageKey

      public org.exoplatform.portal.mop.page.PageKey getDraftPageKey(long liveNodeId, String username)
      Parameters:
      liveNodeId - the navigation node of the live page
      username - the user whose draft is looked up
      Returns:
      the key of the draft page the user's revision names, null when the user has no draft of that page: the named node must be the draft node the editor creates for this user and this live node, and point at the page clonePage names for them, since the node's page reference is the user's to re-point through the navigation and would otherwise make any page their draft
    • getDraftSiteKey

      public org.exoplatform.portal.mop.SiteKey getDraftSiteKey(long siteId, String username)
      Parameters:
      siteId - the live site
      username - the user whose draft is looked up
      Returns:
      the key of the draft site the user's revision names, null when the user has no draft of that site: the named site must be the draft site the editor creates for this user and this live site
    • createDraftSite

      public org.exoplatform.portal.mop.SiteKey createDraftSite(org.exoplatform.portal.config.model.PortalConfig liveSite, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Creates the user's draft of a site through the editor's own path and records the draft site id as the user's co-editing revision, so the editor resumes it and the read tools return it; an existing draft of the same user is replaced, as the editor's "start again" does.
      Parameters:
      liveSite - the site drafted
      username - the editing user
      Returns:
      the draft site's key
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the live site does not exist
      IllegalAccessException - when the user may not edit the site
    • publishSite

      public void publishSite(org.exoplatform.portal.config.model.PortalConfig liveSite, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Publishes the draft the user's revision names over the live site, as the editor's save does from the stored draft, then removes the revision; a leftover draft without a revision is never published, and the draft is read under the view rule a draft site carries, as the read tools read it.
      Parameters:
      liveSite - the site published
      username - the editing user
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the user has no draft of the site
      IllegalAccessException - when the user may not edit the site
    • discardDraftSite

      public org.exoplatform.portal.mop.SiteKey discardDraftSite(org.exoplatform.portal.config.model.PortalConfig liveSite, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Drops the draft the user's revision names and starts a new one from the live layout, as the editor's "start again" does.
      Parameters:
      liveSite - the site drafted
      username - the editing user
      Returns:
      the new draft site's key
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the user has no draft of the site
      IllegalAccessException - when the user may not edit the site
    • createDraftPage

      public org.exoplatform.portal.mop.page.PageKey createDraftPage(long liveNodeId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Creates the user's draft of a page through the editor's own path and records the draft node id as the user's co-editing revision on the live node, so the editor resumes it and the read tools return it; an existing draft page of the same user is written again from the live page and the draft node re-pointed, as the editor's "start again" does.
      Parameters:
      liveNodeId - the navigation node of the live page
      username - the editing user
      Returns:
      the draft page's key
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the live node does not exist
      IllegalAccessException - when the user may not edit the page, or may not edit the navigation on the first creation of the draft node
    • publishPage

      public void publishPage(org.exoplatform.portal.mop.page.PageKey livePageKey, long liveNodeId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Publishes the draft the user's revision names over the live page, as the editor's publish does, then removes the revision; a leftover draft without a revision is never published, nor a page the draft node was re-pointed at. The draft, which the user must be able to edit, is read as stored, unfiltered, so a window the user cannot see is published in place as the editor publishes it, and the live page keeps its own permissions.
      Parameters:
      livePageKey - the page published
      liveNodeId - the navigation node of the live page
      username - the editing user
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the user has no draft of the page
      IllegalAccessException - when the user may not edit the page
    • discardDraftPage

      public org.exoplatform.portal.mop.page.PageKey discardDraftPage(org.exoplatform.portal.mop.page.PageKey livePageKey, long liveNodeId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Drops the draft the user's revision names and starts a new one from the live page, as the editor's "start again" does.
      Parameters:
      livePageKey - the page drafted
      liveNodeId - the navigation node of the live page
      username - the editing user
      Returns:
      the new draft page's key
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the user has no draft of the page
      IllegalAccessException - when the user may not edit the page
    • findLiveNodeId

      public Long findLiveNodeId(org.exoplatform.portal.mop.page.PageKey pageKey, String username)
      Parameters:
      pageKey - a page
      username - the user whose draft is looked up
      Returns:
      the id of the navigation node of the page's own site the tools work from: the non-draft node referencing the page on which the user's revision names a draft, so a draft built in the editor from any item of the page is the one resumed, else the first such node in tree order; null when no node references the page
    • isDraftNode

      public boolean isDraftNode(String nodeName)
    • draftNodeName

      public String draftNodeName(String liveNodeName, String username)
      Parameters:
      liveNodeName - the live navigation node's name
      username - the editing user
      Returns:
      the name NavigationLayoutService.createDraftNode gives that user's draft node
    • draftPageKey

      public org.exoplatform.portal.mop.page.PageKey draftPageKey(org.exoplatform.portal.mop.page.PageKey livePageKey, String username)
      Parameters:
      livePageKey - the live page
      username - the editing user
      Returns:
      the key PageLayoutService.clonePage gives that user's draft page
    • draftSiteName

      public String draftSiteName(org.exoplatform.portal.config.model.PortalConfig liveSite, String username)
      Parameters:
      liveSite - the live site
      username - the editing user
      Returns:
      the name SiteLayoutService.createDraftSite gives that user's draft site