Class SynchronizeComponent

java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.web.synchronization.SynchronizeComponent
All Implemented Interfaces:
Initializable, Component, LogEnabled, Serviceable

Helper for common processing used while synchronizing.
  • Field Details

    • ROLE

      public static final String ROLE
      Avalon Role
  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager smanager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • initialize

      public void initialize() throws Exception
      Specified by:
      initialize in interface Initializable
      Throws:
      Exception
    • getInstance

      Deprecated.
      Get the unique instance
      Returns:
      the unique instance
    • isHierarchyValid

      public boolean isHierarchyValid(Page page, javax.jcr.Session liveSession) throws javax.jcr.RepositoryException
      Returns true if the hierarchy of the given Page is valid, ie if all its ancestors are valid and synchronized in the live workspace.
      Parameters:
      page - the source page.
      liveSession - the live Session.
      Returns:
      the hierarchy validity status.
      Throws:
      javax.jcr.RepositoryException - if failed to check page hierarchy
    • isPageValid

      public boolean isPageValid(Page page, Skin skin)
      Returns true if the given page should be synchronized in the live workspace.
      Parameters:
      page - the page to test.
      skin - the skin of the page's site.
      Returns:
      true if the page is valid
    • isDateValid

      public boolean isDateValid(Page page)
      Returns true if the publication date of the given page are valid.
      Parameters:
      page - the page to test.
      Returns:
      true if the publication dates are valid
    • addNodeWithUUID

      public javax.jcr.Node addNodeWithUUID(javax.jcr.Node srcNode, javax.jcr.Node parentNode, String nodeName) throws javax.jcr.RepositoryException
      Adds a node to a parent node using a source node for name, type and potential UUID.
      Parameters:
      srcNode - the source node.
      parentNode - the parent node for the newly created node.
      nodeName - the node name to use.
      Returns:
      the created node.
      Throws:
      javax.jcr.RepositoryException - if an error occurs.
    • cloneProperties

      public void cloneProperties(javax.jcr.Node srcNode, javax.jcr.Node clonedNode, Predicate propertyPredicate) throws javax.jcr.RepositoryException
      Clones properties of a node
      Parameters:
      srcNode - the source node.
      clonedNode - the cloned node.
      propertyPredicate - the property selector.
      Throws:
      javax.jcr.RepositoryException - if an error occurs.
    • cloneContentNodeAndPreserveUUID

      public void cloneContentNodeAndPreserveUUID(javax.jcr.Node srcNode, javax.jcr.Node clonedNode, Predicate propertyPredicate, Predicate nodePredicate) throws javax.jcr.RepositoryException
      Clones a node by preserving the source node UUID for a content.
      Parameters:
      srcNode - the source node.
      clonedNode - the cloned node.
      propertyPredicate - the property selector.
      nodePredicate - the node selector.
      Throws:
      javax.jcr.RepositoryException - if an error occurs.
    • cloneContentProperties

      public void cloneContentProperties(javax.jcr.Node srcNode, javax.jcr.Node clonedNode, Predicate propertyPredicate) throws javax.jcr.RepositoryException
      Clones properties of a content node
      Parameters:
      srcNode - the source node.
      clonedNode - the cloned node.
      propertyPredicate - the property selector.
      Throws:
      javax.jcr.RepositoryException - if an error occurs.
    • cloneNodeAndPreserveUUID

      public void cloneNodeAndPreserveUUID(javax.jcr.Node srcNode, javax.jcr.Node clonedNode, Predicate propertyPredicate, Predicate nodePredicate) throws javax.jcr.RepositoryException
      Clones a node by preserving the source node UUID.
      Parameters:
      srcNode - the source node.
      clonedNode - the cloned node.
      propertyPredicate - the property selector.
      nodePredicate - the node selector.
      Throws:
      javax.jcr.RepositoryException - if an error occurs.
    • synchronizeContent

      public void synchronizeContent(Content content, javax.jcr.Session liveSession) throws javax.jcr.RepositoryException
      Will copy the LIVE version of the content into the LIVE workspace. Works only with JCRAmetysObject. This method DO NOT save the liveSession.
      Parameters:
      content - The content to copy
      liveSession - The session for live
      Throws:
      javax.jcr.RepositoryException - If an error occurred
    • cloneAncestorsAndPreserveUUID

      public javax.jcr.Node cloneAncestorsAndPreserveUUID(javax.jcr.Node srcNode, javax.jcr.Session liveSession) throws javax.jcr.RepositoryException
      Clones ancestors of a node by preserving the source node UUID.
      Parameters:
      srcNode - the source node.
      liveSession - the session to the live workspace.
      Returns:
      the parent node in the live workspace.
      Throws:
      javax.jcr.RepositoryException - if an error occurs.
    • cloneEligiblePage

      public void cloneEligiblePage(Page page, Skin skin, javax.jcr.Session liveSession) throws javax.jcr.RepositoryException
      Clones a page and its eligible child pages, recursively. It is assumed that parent page already exist in the live workspace
      Parameters:
      page - the page to clone.
      skin - the skin of the page's site.
      liveSession - the session to the live workspace.
      Throws:
      javax.jcr.RepositoryException - if an error occurs.
    • orderNode

      public void orderNode(javax.jcr.Node parentNode, String nodeName, javax.jcr.Node liveNode) throws javax.jcr.RepositoryException
      Reorder a node, mirroring the order in the default workspace.
      Parameters:
      parentNode - the parent of the source Node in the default workspace.
      nodeName - the node name.
      liveNode - the node in the live workspace to be reordered.
      Throws:
      javax.jcr.RepositoryException - if an error occurs.
    • cloneZones

      public void cloneZones(javax.jcr.Node pageNode, SitemapElement sitemapElement, javax.jcr.Node liveNode) throws javax.jcr.RepositoryException
      Clones the zones of a page.
      Parameters:
      pageNode - the JCR Node of the page.
      sitemapElement - the page.
      liveNode - the node in the live workspace.
      Throws:
      javax.jcr.RepositoryException - if an error occurs.
    • invalidateHierarchy

      public void invalidateHierarchy(Page page, Skin skin, javax.jcr.Session liveSession) throws javax.jcr.RepositoryException
      Invalidates the hierarchy of a page if needed
      Parameters:
      page - the page.
      skin - the skin of the page's site.
      liveSession - the session to the live workspace.
      Throws:
      javax.jcr.RepositoryException - if an error occurs.
    • synchronizePage

      public void synchronizePage(Page page, Skin skin, javax.jcr.Session liveSession) throws javax.jcr.RepositoryException
      Synchronizes a page with the live workspace. Also synchronizes hierarchy.
      Parameters:
      page - the page.
      skin - the skin of the page's site.
      liveSession - the session to the live workspace.
      Throws:
      javax.jcr.RepositoryException - if an error occurs.
    • synchronizeACL

      public void synchronizeACL(javax.jcr.Node node, javax.jcr.Session liveSession)
      Synchronize a node ACL information with node in live session if available This method does NOT save live session
      Parameters:
      node - The trunk node in default workspace
      liveSession - The live session
    • synchronizeContents

      public void synchronizeContents(AmetysObjectIterable<Content> contents, javax.jcr.Session liveSession) throws AmetysRepositoryException
      Synchronize a list of content to the targeted session
      Parameters:
      contents - the set of contents
      liveSession - the target session
      Throws:
      AmetysRepositoryException - if an error occurred while synchronizing