Package org.ametys.web.synchronization
Class SynchronizeComponent
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.web.synchronization.SynchronizeComponent
- All Implemented Interfaces:
Initializable
,Component
,LogEnabled
,Serviceable
public class SynchronizeComponent
extends AbstractLogEnabled
implements Component, Serviceable, Initializable
Helper for common processing used while synchronizing.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionjavax.jcr.Node
addNodeWithUUID
(javax.jcr.Node srcNode, javax.jcr.Node parentNode, String nodeName) Adds a node to a parent node using a source node for name, type and potential UUID.javax.jcr.Node
cloneAncestorsAndPreserveUUID
(javax.jcr.Node srcNode, javax.jcr.Session liveSession) Clones ancestors of a node by preserving the source node UUID.void
cloneContentNodeAndPreserveUUID
(javax.jcr.Node srcNode, javax.jcr.Node clonedNode, Predicate propertyPredicate, Predicate nodePredicate) Clones a node by preserving the source node UUID for a content.void
cloneContentProperties
(javax.jcr.Node srcNode, javax.jcr.Node clonedNode, Predicate propertyPredicate) Clones properties of a content nodevoid
cloneEligiblePage
(Page page, Skin skin, javax.jcr.Session liveSession) Clones a page and its eligible child pages, recursively.void
cloneNodeAndPreserveUUID
(javax.jcr.Node srcNode, javax.jcr.Node clonedNode, Predicate propertyPredicate, Predicate nodePredicate) Clones a node by preserving the source node UUID.void
cloneProperties
(javax.jcr.Node srcNode, javax.jcr.Node clonedNode, Predicate propertyPredicate) Clones properties of a nodevoid
cloneZones
(javax.jcr.Node pageNode, SitemapElement sitemapElement, javax.jcr.Node liveNode) Clones the zones of a page.static SynchronizeComponent
Deprecated.void
void
invalidateHierarchy
(Page page, Skin skin, javax.jcr.Session liveSession) Invalidates the hierarchy of a page if neededboolean
isDateValid
(Page page) Returns true if the publication date of the given page are valid.boolean
isHierarchyValid
(Page page, javax.jcr.Session liveSession) Returns true if the hierarchy of the given Page is valid, ie if all its ancestors are valid and synchronized in the live workspace.boolean
isPageValid
(Page page, Skin skin) Returns true if the given page should be synchronized in the live workspace.void
Reorder a node, mirroring the order in the default workspace.void
service
(ServiceManager smanager) 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 sessionvoid
synchronizeContent
(Content content, javax.jcr.Session liveSession) Will copy the LIVE version of the content into the LIVE workspace.void
synchronizeContents
(AmetysObjectIterable<Content> contents, javax.jcr.Session liveSession) Synchronize a list of content to the targeted sessionvoid
synchronizePage
(Page page, Skin skin, javax.jcr.Session liveSession) Synchronizes a page with the live workspace.Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
ROLE
Avalon Role
-
-
Constructor Details
-
SynchronizeComponent
public SynchronizeComponent()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- 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
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
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 copyliveSession
- 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
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 workspaceliveSession
- 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 contentsliveSession
- the target session- Throws:
AmetysRepositoryException
- if an error occurred while synchronizing
-