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
Fields Modifier and Type Field Description private CloneComponent
_cloneComponent
private I18nUtils
_i18nUtils
private static SynchronizeComponent
_instance
private AmetysObjectResolver
_resolver
private SkinsManager
_skinsManager
static String
ROLE
Avalon Role
-
Constructor Summary
Constructors Constructor Description SynchronizeComponent()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private Page
_getPageRedirection(Page page)
private boolean
_isContainerPageValid(Page page, Skin skin)
private boolean
_isInfiniteRedirection(Page page, List<String> pagesSequence)
private boolean
_isLinkPageValid(Page page)
private boolean
_isNodePageValid(Page page, Skin skin)
private boolean
_isZoneItemValid(ZoneItem zoneItem)
private void
_sendErrorMailForInfiniteRedirection(Page page)
Node
addNodeWithUUID(Node srcNode, Node parentNode, String nodeName)
Adds a node to a parent node using a source node for name, type and potential UUID.Node
cloneAncestorsAndPreserveUUID(Node srcNode, Session liveSession)
Clones ancestors of a node by preserving the source node UUID.void
cloneContentNodeAndPreserveUUID(Node srcNode, Node clonedNode, Predicate propertyPredicate, Predicate nodePredicate)
Clones a node by preserving the source node UUID for a content.void
cloneContentProperties(Node srcNode, Node clonedNode, Predicate propertyPredicate)
Clones properties of a content nodevoid
cloneEligiblePage(Page page, Skin skin, Session liveSession)
Clones a page and its eligible child pages, recursively.void
cloneNodeAndPreserveUUID(Node srcNode, Node clonedNode, Predicate propertyPredicate, Predicate nodePredicate)
Clones a node by preserving the source node UUID.void
cloneProperties(Node srcNode, Node clonedNode, Predicate propertyPredicate)
Clones properties of a nodevoid
cloneZones(Node pageNode, Page page, Node liveNode)
Clones the zones of a page.static SynchronizeComponent
getInstance()
Deprecated.void
initialize()
void
invalidateHierarchy(Page page, Skin skin, 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, 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
orderNode(Node parentNode, String nodeName, Node liveNode)
Reorder a node, mirroring the order in the default workspace.void
service(ServiceManager smanager)
void
synchronizeACL(Node node, Session liveSession)
Synchronize a node ACL information with node in live session if available This method does NOT save live sessionvoid
synchronizeContent(Content content, Session liveSession)
Will copy the LIVE version of the content into the LIVE workspace.void
synchronizePage(Page page, Skin skin, 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 Detail
-
_instance
private static SynchronizeComponent _instance
-
_cloneComponent
private CloneComponent _cloneComponent
-
_resolver
private AmetysObjectResolver _resolver
-
_skinsManager
private SkinsManager _skinsManager
-
_i18nUtils
private I18nUtils _i18nUtils
-
-
Constructor Detail
-
SynchronizeComponent
public SynchronizeComponent()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getInstance
@Deprecated public static SynchronizeComponent getInstance()
Deprecated.Get the unique instance- Returns:
- the unique instance
-
isHierarchyValid
public boolean isHierarchyValid(Page page, Session liveSession) throws 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:
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
-
_isInfiniteRedirection
private boolean _isInfiniteRedirection(Page page, List<String> pagesSequence)
-
_getPageRedirection
private Page _getPageRedirection(Page page)
-
_isLinkPageValid
private boolean _isLinkPageValid(Page page)
-
_isNodePageValid
private boolean _isNodePageValid(Page page, Skin skin)
-
_isContainerPageValid
private boolean _isContainerPageValid(Page page, Skin skin)
-
_isZoneItemValid
private boolean _isZoneItemValid(ZoneItem zoneItem)
-
addNodeWithUUID
public Node addNodeWithUUID(Node srcNode, Node parentNode, String nodeName) throws 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:
RepositoryException
- if an error occurs.
-
cloneProperties
public void cloneProperties(Node srcNode, Node clonedNode, Predicate propertyPredicate) throws RepositoryException
Clones properties of a node- Parameters:
srcNode
- the source node.clonedNode
- the cloned node.propertyPredicate
- the property selector.- Throws:
RepositoryException
- if an error occurs.
-
cloneContentNodeAndPreserveUUID
public void cloneContentNodeAndPreserveUUID(Node srcNode, Node clonedNode, Predicate propertyPredicate, Predicate nodePredicate) throws 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:
RepositoryException
- if an error occurs.
-
cloneContentProperties
public void cloneContentProperties(Node srcNode, Node clonedNode, Predicate propertyPredicate) throws RepositoryException
Clones properties of a content node- Parameters:
srcNode
- the source node.clonedNode
- the cloned node.propertyPredicate
- the property selector.- Throws:
RepositoryException
- if an error occurs.
-
cloneNodeAndPreserveUUID
public void cloneNodeAndPreserveUUID(Node srcNode, Node clonedNode, Predicate propertyPredicate, Predicate nodePredicate) throws 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:
RepositoryException
- if an error occurs.
-
synchronizeContent
public void synchronizeContent(Content content, Session liveSession) throws 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:
RepositoryException
- If an error occurred
-
cloneAncestorsAndPreserveUUID
public Node cloneAncestorsAndPreserveUUID(Node srcNode, Session liveSession) throws 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:
RepositoryException
- if an error occurs.
-
cloneEligiblePage
public void cloneEligiblePage(Page page, Skin skin, Session liveSession) throws 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:
RepositoryException
- if an error occurs.
-
orderNode
public void orderNode(Node parentNode, String nodeName, Node liveNode) throws 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:
RepositoryException
- if an error occurs.
-
cloneZones
public void cloneZones(Node pageNode, Page page, Node liveNode) throws RepositoryException
Clones the zones of a page.- Parameters:
pageNode
- the JCR Node of the page.page
- the page.liveNode
- the node in the live workspace.- Throws:
RepositoryException
- if an error occurs.
-
invalidateHierarchy
public void invalidateHierarchy(Page page, Skin skin, Session liveSession) throws 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:
RepositoryException
- if an error occurs.
-
synchronizePage
public void synchronizePage(Page page, Skin skin, Session liveSession) throws 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:
RepositoryException
- if an error occurs.
-
_sendErrorMailForInfiniteRedirection
private void _sendErrorMailForInfiniteRedirection(Page page)
-
synchronizeACL
public void synchronizeACL(Node node, 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 workspaceliveSession
- The live session
-
-