Attachment Policies

Attachment policies provide places where you can hook in behaviors that trigger when attachments are read, created, updated or deleted against a node.

Unlike other policy handlers, these will only fire at the instance when an attachment is created, updated, or deleted, and will not fire upon a branch merge or release.

When configuring your attachments, you can specify an attachment ID you wish to fire your policy. For example, suppose you are configuring a webhook rule that you only want to fire when the default attahchment is updated. In this case, you can specify the "default" key for your attachment policy to have it only fire for default, and not some other attachment id. If you do not specify an attachment ID, the rule will fire for all attachent ids, except for those beginning with _preview_, which we exclude since these are system generated attachments.

The following policies are available:

Policy QName Description
p:beforeReadAttachment Raised before a node's attachment is read
p:afterReadAttachment Raised after a node's attachment is read
p:beforeCreateUpdateAttachment Raised before an node's attachment is added to a node (either created or updated)
p:afterCreateUpdateAttachment Raised after an node's attachment is added to a node (either created or updated)
p:beforeDeleteAttachment Raised before an attachment is deleted from a node
p:afterDeleteAttachment Raised after an attachment is deleted from a node

Method Signatures

The following method signatures apply for the policies mentioned above:

p:beforeReadAttachment

(JavaScript)    
function beforeReadAttachment(node, attachmentId);

(Java)          
public void beforeReadAttachment(Node node, String attachmentId);

p:afterReadAttachment

(JavaScript)    
function afterReadAttachment(node, attachmentId);

(Java)          
public void afterReadAttachment(Node node, String attachmentId);

p:beforeCreateUpdateAttachment

(JavaScript)    
function beforeCreateUpdateAttachment(node, attachmentId, contentType, filename);

(Java)        
public void beforeCreateUpdateAttachment(Node node, String attachmentId, String contentType, String filename);

p:afterCreateUpdateAttachment

(JavaScript)    
function afterCreateUpdateAttachment(Node node, Attachment attachment);

(Java)       
public void afterCreateUpdateAttachment(Node node, Attachment attachment);

p:beforeDeleteAttachment

(JavaScript)    
function beforeDeleteAttachment(node, attachment);

(Java)          
public void beforeDeleteAttachment(Node node, Attachment attachment);

p:afterDeleteAttachment

(JavaScript)    
function afterDeleteAttachment(node, attachment);

(Java)          
public void afterDeleteAttachment(Node node, Attachment attachment);