Package com.day.cq.replication
Class DefaultAggregateHandler
- java.lang.Object
-
- com.day.cq.replication.DefaultAggregateHandler
-
- All Implemented Interfaces:
AggregateHandler
public class DefaultAggregateHandler extends java.lang.Object implements AggregateHandler
Implements an aggregate handler that detects hierarchy nodes as aggregate root.
-
-
Constructor Summary
Constructors Constructor Description DefaultAggregateHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isAggregateRoot(Node node)
Checks if the given node is an aggregate root.boolean
isRemoveNodes()
Checks if this handler removes the nodes in theprocessForReplication(javax.jcr.Session, ReplicationAction)
for a delete replication.java.util.List<java.lang.String>
prepareForReplication(Session session, ReplicationActionType type, java.lang.String path)
Returns a list of aggregate roots of the subtree starting at the specified path that are relevant for the given replication action.void
processForReplication(Session session, ReplicationAction action)
Processes the aggregate addressed by the replication action.void
setRemoveNodes(boolean removeNodes)
Sets the flag that controls if this handler should remove the node in theprocessForReplication(javax.jcr.Session, ReplicationAction)
.
-
-
-
Method Detail
-
isRemoveNodes
public boolean isRemoveNodes()
Checks if this handler removes the nodes in theprocessForReplication(javax.jcr.Session, ReplicationAction)
for a delete replication.- Returns:
- the remove nodes flag.
-
setRemoveNodes
public void setRemoveNodes(boolean removeNodes)
Sets the flag that controls if this handler should remove the node in theprocessForReplication(javax.jcr.Session, ReplicationAction)
. the default isfalse
.- Parameters:
removeNodes
- the flag
-
isAggregateRoot
public boolean isAggregateRoot(Node node)
Checks if the given node is an aggregate root.- Specified by:
isAggregateRoot
in interfaceAggregateHandler
- Parameters:
node
- node to test- Returns:
true
if the node is a hierarchy node.
-
prepareForReplication
public java.util.List<java.lang.String> prepareForReplication(Session session, ReplicationActionType type, java.lang.String path) throws ReplicationException
Returns a list of aggregate roots of the subtree starting at the specified path that are relevant for the given replication action. The specified start path should be included in the list in any case. Returns the all aggregate roots that matchisAggregateRoot(javax.jcr.Node)
recursively, but only for DELETE and DEACTIVATE action types.- Specified by:
prepareForReplication
in interfaceAggregateHandler
- Parameters:
session
- session to use for traversaltype
- replication action typepath
- start path- Returns:
- a list of aggregate roots.
- Throws:
ReplicationException
- to abort the replication in the preparation stage
-
processForReplication
public void processForReplication(Session session, ReplicationAction action) throws ReplicationException
Processes the aggregate addressed by the replication action. The aggregate handler may or may not save the changes. Deletes all paths passed by the action. but only for DELETE actions. The changes are not saved.- Specified by:
processForReplication
in interfaceAggregateHandler
- Parameters:
session
- the session to use to process the contentaction
- the replication action- Throws:
ReplicationException
- to abort the replication in the preparation stage
-
-