Package org.ametys.cms.repository
Class CloneComponent
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.cms.repository.CloneComponent
-
- All Implemented Interfaces:
Component,LogEnabled,ThreadSafe
public class CloneComponent extends AbstractLogEnabled implements Component, ThreadSafe
Helper for common processing used while synchronizing.
-
-
Constructor Summary
Constructors Constructor Description CloneComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NodeaddNodeWithUUID(Node srcNode, Node parentNode, String nodeName)Adds a node to a parent node using a source node for name, type and potential UUID.voidcloneAllProperties(Node srcNode, Node clonedNode, Predicate propertyPredicate)Clones all the properties of a node.NodecloneAncestorsAndPreserveUUID(Node srcNode, Session destSession)Clones ancestors of a node by preserving the source node UUID.NodecloneContentNodeWithWorkflow(Session destSession, Node node)Clone a content node, cloning its workflow along.NodecloneContentNodeWithWorkflow(Session destSession, Node node, Predicate propertyPredicate, Predicate nodePredicate)Clone a content node, cloning its workflow along.NodecloneContentNodeWithWorkflow(Session destSession, Node node, Predicate propertyPredicate, Predicate nodePredicate, String version)Clone a content node, cloning its workflow along.voidcloneNodeAndPreserveUUID(Node srcNode, Node clonedNode, Predicate propertyPredicate, Predicate nodePredicate)Clones a node by preserving the source node UUID.protected voidcloneProperty(Node clonedNode, Property property)Clone a property.protected NodecreateNodeClone(Node srcNode, Node parentNode, String desiredNodeName)Create a clone of the specified node.NodegetOrCloneNode(Session destSession, Node node)Get or clone a node.NodegetOrCloneNode(Session destSession, Node node, String version)Get or clone a node in a specified version.voidorderNode(Node parentNode, String nodeName, Node node)Reorder a node, mirroring the order in the default workspace.-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Constructor Detail
-
CloneComponent
public CloneComponent()
-
-
Method Detail
-
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.
-
cloneAllProperties
public void cloneAllProperties(Node srcNode, Node clonedNode, Predicate propertyPredicate) throws RepositoryException
Clones all the properties of a node.- Parameters:
srcNode- the source node.clonedNode- the cloned node.propertyPredicate- the property selector.- Throws:
RepositoryException- if an error occurs.
-
cloneProperty
protected void cloneProperty(Node clonedNode, Property property) throws RepositoryException
Clone a property.- Parameters:
clonedNode- the node to copy the property to.property- the property to clone.- 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.
-
getOrCloneNode
public Node getOrCloneNode(Session destSession, Node node) throws RepositoryException
Get or clone a node.- Parameters:
destSession- the destination session.node- the node in the source workspace.- Returns:
- the cloned Node in the destination session.
- Throws:
RepositoryException- if an error occurs.
-
getOrCloneNode
public Node getOrCloneNode(Session destSession, Node node, String version) throws RepositoryException
Get or clone a node in a specified version.- Parameters:
destSession- the destination session.node- the node in the source workspace.version- the node version to clone, null to get the current version.- Returns:
- the cloned Node in the destination session.
- Throws:
RepositoryException- if an error occurs.
-
cloneAncestorsAndPreserveUUID
public Node cloneAncestorsAndPreserveUUID(Node srcNode, Session destSession) throws RepositoryException
Clones ancestors of a node by preserving the source node UUID.- Parameters:
srcNode- the source node.destSession- the destination session.- Returns:
- the parent node the destination workspace.
- Throws:
RepositoryException- if an error occurs.
-
cloneContentNodeWithWorkflow
public Node cloneContentNodeWithWorkflow(Session destSession, Node node) throws RepositoryException
Clone a content node, cloning its workflow along.- Parameters:
destSession- the destination session.node- the node to clone.- Returns:
- the cloned node.
- Throws:
RepositoryException- if an error occurs.
-
cloneContentNodeWithWorkflow
public Node cloneContentNodeWithWorkflow(Session destSession, Node node, Predicate propertyPredicate, Predicate nodePredicate) throws RepositoryException
Clone a content node, cloning its workflow along.- Parameters:
destSession- the destination session.node- the node to clone.propertyPredicate- a test on the properties.nodePredicate- a test on the nodes.- Returns:
- the cloned node.
- Throws:
RepositoryException- if an error occurs.
-
cloneContentNodeWithWorkflow
public Node cloneContentNodeWithWorkflow(Session destSession, Node node, Predicate propertyPredicate, Predicate nodePredicate, String version) throws RepositoryException
Clone a content node, cloning its workflow along.- Parameters:
destSession- the destination session.node- the node to clone.propertyPredicate- a test on the properties.nodePredicate- a test on the nodes.version- the version of the node to clone.- Returns:
- the cloned node.
- Throws:
RepositoryException- if an error occurs.
-
createNodeClone
protected Node createNodeClone(Node srcNode, Node parentNode, String desiredNodeName) throws RepositoryException
Create a clone of the specified node.- Parameters:
srcNode- the node to clone.parentNode- the node under which to create the clonde.desiredNodeName- the wanted node name.- Returns:
- the cloned node.
- Throws:
RepositoryException- if an error occurs.
-
orderNode
public void orderNode(Node parentNode, String nodeName, Node node) 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.node- the node in the destination workspace to be reordered.- Throws:
RepositoryException- if an error occurs.
-
-