Class ApplicationDraftService

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

@Service public class ApplicationDraftService extends Object
Resolves the windows a tool write addresses on the user's layout, the way every draft tool does: the layout read is the user's draft when their co-editing revision names one, the published layout otherwise; an id the read does not show does not exist, a container id is refused; and when no draft exists yet the write creates it first and finds each window again on the draft at the place its live window held. Every refusal is a fixed text, the texts the tools answer.
  • Field Details

  • Constructor Details

    • ApplicationDraftService

      public ApplicationDraftService()
  • Method Details

    • resolvePage

      public DraftWindows resolvePage(org.exoplatform.portal.mop.page.PageKey pageKey, String pageRef, List<String> applicationIds, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      The windows the ids name on the user's page, with no write
      Parameters:
      pageKey - the live page
      pageRef - the live page reference as the caller gave it
      applicationIds - the application ids the read answered
      username - the user
      Returns:
      the resolution
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the page, its navigation item, the draft or an application does not exist
      IllegalAccessException - when the user may not edit the page
    • resolveSite

      public DraftWindows resolveSite(long siteId, List<String> applicationIds, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      The windows the ids name on the user's site, with no write
      Parameters:
      siteId - the live site
      applicationIds - the application ids the read answered
      username - the user
      Returns:
      the resolution
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the site or an application does not exist
      IllegalAccessException - when the user may not edit the site
    • createDraft

      public List<ApplicationSettingsContext> createDraft(DraftWindows resolution, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Creates the user's draft of the resolved layout and finds each window again on it, at the place its live window held and of the same application; the live layout read again after the clone still holds each window at its place, no publication came in between (a publication gives every window a new id), else the layout is outdated. A failure of the mapping names the draft just created, as every failure after it does
      Parameters:
      resolution - the windows resolved on the live layout
      username - the user
      Returns:
      the windows' contexts on the draft, in the ids' order
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the page or the site no longer exists
      IllegalAccessException - when the user may not create the draft
    • onCreatedDraft

      public <T> T onCreatedDraft(LayoutWrite<T> write)
      Runs a write on the draft this call created: a failure is answered naming the draft, which stays, so the caller reads the layout again for its ids; a failure the write did not name itself is logged
      Type Parameters:
      T - what the write returns
      Parameters:
      write - the write
      Returns:
      what the write returns
    • translateWriteFailure

      public RuntimeException translateWriteFailure(RuntimeException e, Object layoutKey, String username, String refusal)
      A layout write refused by the storage answers a fixed text: the outdated draft its own, every other failure the given one, its cause logged
      Parameters:
      e - the storage's failure
      layoutKey - the page or site key, for the log
      username - the user, for the log
      refusal - the fixed text every other failure answers
      Returns:
      the exception to throw
    • readEditablePage

      public org.exoplatform.portal.config.model.Page readEditablePage(org.exoplatform.portal.mop.page.PageKey pageKey, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Parameters:
      pageKey - a live page
      username - the user
      Returns:
      the stored live page the user may edit, never a draft page
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when no live page has that key
      IllegalAccessException - when the user may not edit it
    • requireLiveNodeId

      public long requireLiveNodeId(org.exoplatform.portal.mop.page.PageKey pageKey, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      pageKey - a live page
      username - the user
      Returns:
      the navigation node of the page, the key its draft is resolved by
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when no navigation item references it
    • readEditableSite

      public org.exoplatform.portal.config.model.PortalConfig readEditableSite(long siteId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Parameters:
      siteId - a live site
      username - the user
      Returns:
      the live site the user may edit, never a draft site
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when no live site has that id
      IllegalAccessException - when the user may not edit it
    • readDraftSite

      public org.exoplatform.portal.config.model.PortalConfig readDraftSite(long siteId, String username)
      The user's draft of a site, as the site layout editor resumes it: the one the user's co-editing revision names, read through the permission-checked service read
      Parameters:
      siteId - a live site
      username - the user
      Returns:
      the draft site, null when the user has none