Node Policies
Node policies provide places where you can hook in behaviors that trigger when nodes are created, updated
or deleted within the graph. Nodes may either be entities or associations. This provides an ideal way to
plug in your custom behaviors for any definition or content instance within your content graph.
The following policies are available:
Policy QName | Description |
---|---|
p:beforeCreateNode | Raised before a piece of content is created |
p:afterCreateNode | Raised after a piece of content has been created and committed to the branch |
p:beforeUpdateNode | Raised before a piece of content is updated |
p:afterUpdateNode | Raised after a piece of content has been updated and committed to the branch |
p:beforeDeleteNode | Raised before a piece of content is deleted |
p:afterDeleteNode | Raised after a piece of content has been deleted and removed from the branch |
p:beforeCreateUpdateAttachment | Raised before an attachment is added to a node |
p:afterCreateUpdateAttachment | Raised after an attachment has been added to a node and committed to the branch |
p:beforeDeleteAttachment | Raised before an attachment has been deleted from a node |
p:afterDeleteAttachment | Raised after an attachment has been delete from a node and committed to the branch |
In addition, the following policies are raised anytime a node is created, updated or deleted (i.e. "touched").
Policy QName | Description |
---|---|
p:beforeTouchNode | Raised before a piece of content is created, updated or deleted |
p:afterTouchNode | Raised after a piece of content has been created, updated or deleted |
The following policies are raised when a node is explicitly refreshed (i.e. via the refresh()
method).
Policy QName | Description |
---|---|
p:beforeRefreshNode | Raised before a piece of content is refreshed |
p:afterRefreshNode | Raised after a piece of content has been refreshed |
The following policies are raised when a node is merged from one branch to another.
These policies fire on the target branch.
Policy QName | Description |
---|---|
p:beforeMergeNode | Raised before a piece of content is merged to the branch |
p:afterMergeNode | Raised after a piece of content is merged to the branch |
Associated Node Policies
For non-association entities within the graph (i.e. content instances with types that inherit from n:node
),
you may hook into "associated node" policies that let you listen for events in which another has been associated
to you.
For example, suppose you have a node called Article
sitting in the graph. You can bind a custom event handler
to the p:afterAssociateNode
policy against this node to listen for other nodes that become associated to it.
Suppose you now add an association to an Author
article. When you do, once the association has been created, thep:afterAssociateNode
policy will fire and you will have the chance to take action. You could send an email,
update a property or fire off a web hook.
Associated Node policies can be used for firing events on parent nodes when their child associated with an a:child
association
is updated. For example, suppose you have a type Article
which has Review
s associated with a:has-review
, an association type
that inherits from a:child
. You can configure policies like p:afterUpdateAssociatedNode
to fire on the article when any changes are
made to its child reviews.
The following policies are available:
Policy QName | Description |
---|---|
p:beforeAssociateNode | Raised before an associated node is added (either associated or created) |
p:afterAssociateNode | Raised after an associated node is added (either associated or created) |
p:beforeUpdateAssociatedNode | Raised before an associated node is updated |
p:afterUpdateAssociatedNode | Raised after an associated node is updated |
p:beforeUnassociateNode | Raised before an associated node is removed (either unassociated or deleted) |
p:afterUnassociateNode | Raised after an associated node is removed (either unassociated or deleted) |
p:beforeReadAssociatedNodeAttachment | Raised before a child node's attachment is read |
p:afterReadAssociatedNodeAttachment | Raised after a child node's attachment is read |
p:beforeCreateUpdateAssociatedNodeAttachment | Raised before a child node's attachment is created or updated |
p:afterCreateUpdateAssociatedNodeAttachment | Raised after a child node's attachment is created or updated |
p:beforeDeleteAssociatedNodeAttachment | Raised before a child node's attachment is deleted |
p:afterDeleteAssociatedNodeAttachment | Raised after a child node's attachment is deleted |
Node Feature Policies
When features are added, updated or removed from a node, you may hook into "feature" policies that listen for these
events and bind behaviors to them.
The following policies are available:
Policy QName | Description |
---|---|
p:beforeAddFeature | Raised before a feature is added to a node |
p:afterAddFeature | Raised after a feature is added to a node |
p:beforeUpdateFeature | Raised before a feature is updated against a node |
p:afterUpdateFeature | Raised after a feature is updated against a node |
p:beforeRemoveFeature | Raised before a feature is removed from a node |
p:afterRemoveFeature | Raised after a feature is removed from a node |
Method Signatures
The following method signatures apply for the policies mentioned above:
p:afterReadNode
(JavaScript)
function afterReadNode(node);
(Java)
public void afterReadNode(Node node);
p:beforeCreateNode
(JavaScript)
function beforeCreateNode(node);
(Java)
public void beforeCreateNode(Node node);
p:afterCreateNode
(JavaScript)
function afterCreateNode(node);
(Java)
public void afterCreateNode(Node node);
p:beforeUpdateNode
(JavaScript)
function beforeUpdateNode(node, originalNode);
(Java)
public void beforeUpdateNode(Node node, Node originalNode);
p:afterUpdateNode
(JavaScript)
function afterUpdateNode(node, originalNode);
(Java)
public void afterUpdateNode(Node node, Node originalNode);
p:beforeDeleteNode
(JavaScript)
function beforeDeleteNode(node, originalNode);
(Java)
public void beforeDeleteNode(Node node, Node originalNode);
p:afterDeleteNode
(JavaScript)
function afterDeleteNode(node);
(Java)
public void afterDeleteNode(Node node);
p:beforeTouchNode
(JavaScript)
function beforeTouchNode(node);
(Java)
public void beforeTouchNode(Node node);
p:afterTouchNode
(JavaScript)
function afterTouchNode(node);
(Java)
public void afterTouchNode(Node node);
p:beforeRefreshNode
(JavaScript)
function beforeRefreshNode(node);
(Java)
public void beforeRefreshNode(Node node);
p:afterRefreshNode
(JavaScript)
function afterRefreshNode(node);
(Java)
public void afterRefreshNode(Node node);
p:beforeMergeNode
(JavaScript)
function beforeMergeNode(targetNode, sourceNode, mergeContext);
(Java)
public void beforeRefreshNode(Node targetNode, Node sourceNode, NodeMergeContext mergeContext);
p:afterMergeNode
(JavaScript)
function afterMergeNode(targetNode, sourceNode, mergeContext);
(Java)
public void afterMergeNode(Node targetNode, Node sourceNode, NodeMergeContext mergeContext);
p:beforeAssociateNode
(JavaScript)
function beforeAssociateNode(node, association, associatedNode);
(Java)
public void beforeAssociateNode(Node node, Association association, Node associatedNode);
p:afterAssociateNode
(JavaScript)
function afterAssociateNode(node, association, associatedNode);
(Java)
public void afterAssociateNode(Node node, Association association, Node associatedNode);
p:beforeUpdateAssociatedNode
(JavaScript)
function beforeUpdateAssociatedNode(node, association, associatedNode);
(Java)
public void beforeUpdateAssociatedNode(Node node, Association association, Node associatedNode);
p:afterUpdateAssociatedNode
(JavaScript)
function afterUpdateAssociatedNode(node, association, associatedNode);
(Java)
public void afterUpdateAssociatedNode(Node node, Association association, Node associatedNode);
p:beforeUnassociateNode
(JavaScript)
function beforeUnassociateNode(node, association, associatedNode);
(Java)
public void beforeUnassociateNode(Node node, Association association, Node associatedNode);
p:afterUnassociateNode
(JavaScript)
function afterUnassociateNode(node, association, associatedNode);
(Java)
public void afterUnassociateNode(Node node, Association association, Node associatedNode);
p:beforeReadAssociatedNodeAttachment
(JavaScript)
function beforeReadAssociatedNodeAttachment(node, association, associatedNode, attachmentId);
(Java)
public void beforeReadAssociatedNodeAttachment(Node node, Association association, Node associatedNode, String attachmentId);
p:afterReadAssociatedNodeAttachment
(JavaScript)
function afterReadAssociatedNodeAttachment(node, association, associatedNode, attachment);
(Java)
public void afterReadAssociatedNodeAttachment(Node node, Association association, Node associatedNode, Attachment attachment);
p:beforeCreateUpdateAssociatedNodeAttachment
(JavaScript)
function beforeCreateUpdateAssociatedNodeAttachment(node, association, associatedNode, attachmentId, contentType, filename);
(Java)
public void beforeCreateUpdateAssociatedNodeAttachment(Node node, Association association, Node associatedNode, String attachmentId, String contentType, String filename);
p:afterCreateUpdateAssociatedNodeAttachment
(JavaScript)
function beforeCreateUpdateAssociatedNodeAttachment(node, association, associatedNode, attachment);
(Java)
public void beforeCreateUpdateAssociatedNodeAttachment(Node node, Association association, Node associatedNode, Attachment attachment);
p:beforeDeleteAssociatedNodeAttachment
(JavaScript)
function beforeDeleteAssociatedNodeAttachment(node, association, associatedNode, attachment);
(Java)
public void beforeDeleteAssociatedNodeAttachment(Node node, Association association, Node associatedNode, Attachment attachment);
p:afterDeleteAssociatedNodeAttachment
(JavaScript)
function afterDeleteAssociatedNodeAttachment(node, association, associatedNode, attachment);
(Java)
public void afterDeleteAssociatedNodeAttachment(Node node, Association association, Node associatedNode, Attachment attachment);
p:beforeAddFeature
(JavaScript)
function beforeAddFeature(node, definition, configuration);
(Java)
public void beforeAddFeature(Node node, FeatureDefinition definition, ObjectNode configuration);
p:afterAddFeature
(JavaScript)
function afterAddFeature(node, definition, configuration);
(Java)
public void afterAddFeature(Node node, FeatureDefinition definition, ObjectNode configuration);
p:beforeUpdateFeature
(JavaScript)
function beforeUpdateFeature(node, definition, configuration);
(Java)
public void beforeUpdateFeature(Node node, FeatureDefinition definition, ObjectNode configuration);
p:afterUpdateFeature
(JavaScript)
function afterUpdateFeature(node, definition, configuration);
(Java)
public void afterUpdateFeature(Node node, FeatureDefinition definition, ObjectNode configuration);
p:beforeRemoveFeature
(JavaScript)
function beforeRemoveFeature(node, definition, configuration);
(Java)
public void beforeRemoveFeature(Node node, FeatureDefinition definition, ObjectNode configuration);
p:afterRemoveFeature
(JavaScript)
function afterRemoveFeature(node, definition, configuration);
(Java)
public void afterRemoveFeature(Node node, FeatureDefinition definition, ObjectNode configuration);