public class IntegrityChecker extends Object implements NodeServicePolicies.OnCreateNodePolicy, NodeServicePolicies.OnUpdatePropertiesPolicy, NodeServicePolicies.OnDeleteNodePolicy, NodeServicePolicies.OnAddAspectPolicy, NodeServicePolicies.OnRemoveAspectPolicy, NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnDeleteChildAssociationPolicy, NodeServicePolicies.OnCreateAssociationPolicy, NodeServicePolicies.OnDeleteAssociationPolicy, org.alfresco.util.transaction.TransactionListener
In order to fulfill the contract of the interface, this class registers to receive notifications pertinent to changes in the node structure. These are then store away in the persistent store until the request to check integrity is made.
In order to ensure registration of these events, the init()
method must be called.
By default, this service is enabled, but can be disabled using setEnabled(boolean)
.
Tracing of the event stacks is, for performance reasons, disabled by default but can be enabled
using setTraceOn(boolean)
.
When enabled, the integrity check can either fail with a RuntimeException or not. In either
case, the integrity violations are logged as warnings or errors. This behaviour is controleed using
setFailOnViolation(boolean)
and is off by default. In other words, if not set, this service
will only log warnings about integrity violations.
Some integrity checks are not performed here as they are dealt with directly during the modification
operation in the node service
.
setPolicyComponent(PolicyComponent)
,
setDictionaryService(DictionaryService)
,
setMaxErrorsPerTransaction(int)
Policy.Arg
QNAME
ARG_0, ARG_1, ARG_2, QNAME
QNAME
QNAME
QNAME
QNAME
QNAME
QNAME
QNAME
Constructor and Description |
---|
IntegrityChecker() |
Modifier and Type | Method and Description |
---|---|
void |
afterCommit() |
void |
afterRollback() |
void |
beforeCommit(boolean readOnly) |
void |
beforeCompletion() |
void |
checkIntegrity()
Runs several types of checks, querying specifically for events that
will necessitate each type of test.
|
void |
init()
Registers the system-level policy behaviours
|
static boolean |
isWarnInTransaction() |
void |
onAddAspect(org.alfresco.service.cmr.repository.NodeRef nodeRef,
org.alfresco.service.namespace.QName aspectTypeQName)
Called after an aspect has been added to a node
|
void |
onCreateAssociation(org.alfresco.service.cmr.repository.AssociationRef nodeAssocRef)
Called after a regular node association is created.
|
void |
onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef,
boolean isNew)
This handles the creation of secondary child associations.
|
void |
onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
Called when a new node has been created.
|
void |
onDeleteAssociation(org.alfresco.service.cmr.repository.AssociationRef nodeAssocRef)
Called after a regular node association is deleted.
|
void |
onDeleteChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
Called after a node child association has been deleted.
|
void |
onDeleteNode(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef,
boolean isArchivedNode)
No checking performed: The association changes will be handled
|
void |
onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef nodeRef,
org.alfresco.service.namespace.QName aspectTypeQName)
Called after an aspect has been removed from a node
|
void |
onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef nodeRef,
Map<org.alfresco.service.namespace.QName,Serializable> before,
Map<org.alfresco.service.namespace.QName,Serializable> after)
Called after a node's properties have been changed.
|
void |
setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService) |
void |
setEnabled(boolean enabled) |
void |
setFailOnViolation(boolean failOnViolation) |
void |
setMaxErrorsPerTransaction(int maxLogNumberPerTransaction) |
void |
setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService) |
void |
setPolicyComponent(PolicyComponent policyComponent) |
void |
setStoresToIgnore(List<String> storesToIgnore) |
void |
setTenantService(org.alfresco.repo.tenant.TenantService tenantService) |
void |
setTraceOn(boolean traceOn) |
static void |
setWarnInTransaction()
Downgrade violations to warnings within the current transaction.
|
public static void setWarnInTransaction()
failure behaviour
.public static boolean isWarnInTransaction()
false
, the global setting will take effect.setWarnInTransaction()
public void setPolicyComponent(PolicyComponent policyComponent)
policyComponent
- the component to register behaviour withpublic void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
dictionaryService
- the dictionary against which to confirm model detailspublic void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
nodeService
- the node service to use for browsing node structurespublic void setTenantService(org.alfresco.repo.tenant.TenantService tenantService)
public void setEnabled(boolean enabled)
enabled
- set to false to disable integrity checking completelypublic void setTraceOn(boolean traceOn)
traceOn
- set to true
to enable stack traces recording
of eventspublic void setFailOnViolation(boolean failOnViolation)
failOnViolation
- set to true
to force failure by
RuntimeException when a violation occurs.public void setMaxErrorsPerTransaction(int maxLogNumberPerTransaction)
maxLogNumberPerTransaction
- upper limit on how many violations are
logged when multiple violations have been found.public void setStoresToIgnore(List<String> storesToIgnore)
storesToIgnore
- stores (eg. workspace://version2Store) which will be
ignored by integrity checker. Note: assumes associations are within a store.public void init()
public void onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
NodeServicePolicies.OnCreateNodePolicy
onCreateNode
in interface NodeServicePolicies.OnCreateNodePolicy
childAssocRef
- the created child association referencePropertiesIntegrityEvent
,
AssocTargetRoleIntegrityEvent
,
AssocTargetMultiplicityIntegrityEvent
public void onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<org.alfresco.service.namespace.QName,Serializable> before, Map<org.alfresco.service.namespace.QName,Serializable> after)
NodeServicePolicies.OnUpdatePropertiesPolicy
onUpdateProperties
in interface NodeServicePolicies.OnUpdatePropertiesPolicy
nodeRef
- reference to the updated nodebefore
- the node's properties before the changeafter
- the node's properties after the changePropertiesIntegrityEvent
public void onDeleteNode(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef, boolean isArchivedNode)
onDeleteNode
in interface NodeServicePolicies.OnDeleteNodePolicy
childAssocRef
- the primary parent-child association of the deleted nodeisArchivedNode
- indicates whether the node has been archived rather than purgedpublic void onAddAspect(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName aspectTypeQName)
NodeServicePolicies.OnAddAspectPolicy
onAddAspect
in interface NodeServicePolicies.OnAddAspectPolicy
nodeRef
- the node to which the aspect was addedaspectTypeQName
- the type of the aspectPropertiesIntegrityEvent
,
AssocTargetMultiplicityIntegrityEvent
public void onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName aspectTypeQName)
NodeServicePolicies.OnRemoveAspectPolicy
onRemoveAspect
in interface NodeServicePolicies.OnRemoveAspectPolicy
nodeRef
- the node from which the aspect will be removedaspectTypeQName
- the type of the aspectAspectsIntegrityEvent
public void onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef, boolean isNew)
onCreateChildAssociation
in interface NodeServicePolicies.OnCreateChildAssociationPolicy
childAssocRef
- the child association that has been createdisNew
- true if the node is new or false if the node is being linked inAssocSourceTypeIntegrityEvent
,
AssocTargetTypeIntegrityEvent
,
AssocSourceMultiplicityIntegrityEvent
,
AssocTargetMultiplicityIntegrityEvent
,
AssocTargetRoleIntegrityEvent
public void onDeleteChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
NodeServicePolicies.OnDeleteChildAssociationPolicy
onDeleteChildAssociation
in interface NodeServicePolicies.OnDeleteChildAssociationPolicy
childAssocRef
- the child association that has been deletedAssocSourceMultiplicityIntegrityEvent
,
AssocTargetMultiplicityIntegrityEvent
public void onCreateAssociation(org.alfresco.service.cmr.repository.AssociationRef nodeAssocRef)
NodeServicePolicies.OnCreateAssociationPolicy
onCreateAssociation
in interface NodeServicePolicies.OnCreateAssociationPolicy
nodeAssocRef
- the regular node association that was createdAssocSourceTypeIntegrityEvent
,
AssocTargetTypeIntegrityEvent
,
AssocSourceMultiplicityIntegrityEvent
,
AssocTargetMultiplicityIntegrityEvent
public void onDeleteAssociation(org.alfresco.service.cmr.repository.AssociationRef nodeAssocRef)
NodeServicePolicies.OnDeleteAssociationPolicy
onDeleteAssociation
in interface NodeServicePolicies.OnDeleteAssociationPolicy
nodeAssocRef
- the regular node association that was removedAssocSourceMultiplicityIntegrityEvent
,
AssocTargetMultiplicityIntegrityEvent
public void checkIntegrity() throws IntegrityException
The interface contracts also requires that all events for the transaction get cleaned up.
IntegrityException
public void beforeCommit(boolean readOnly)
beforeCommit
in interface org.alfresco.util.transaction.TransactionListener
public void beforeCompletion()
beforeCompletion
in interface org.alfresco.util.transaction.TransactionListener
public void afterCommit()
afterCommit
in interface org.alfresco.util.transaction.TransactionListener
public void afterRollback()
afterRollback
in interface org.alfresco.util.transaction.TransactionListener
Copyright © 2005–2017 Alfresco Software. All rights reserved.