Class IntegrityChecker
- All Implemented Interfaces:
NodeServicePolicies.OnAddAspectPolicy,NodeServicePolicies.OnCreateAssociationPolicy,NodeServicePolicies.OnCreateChildAssociationPolicy,NodeServicePolicies.OnCreateNodePolicy,NodeServicePolicies.OnDeleteAssociationPolicy,NodeServicePolicies.OnDeleteChildAssociationPolicy,NodeServicePolicies.OnDeleteNodePolicy,NodeServicePolicies.OnRemoveAspectPolicy,NodeServicePolicies.OnUpdatePropertiesPolicy,AssociationPolicy,ClassPolicy,Policy,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.
- Author:
- Derek Hulley
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy
Policy.Arg -
Field Summary
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnCreateAssociationPolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnDeleteAssociationPolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnDeleteChildAssociationPolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy
ARG_0, ARG_1, ARG_2, QNAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidbeforeCommit(boolean readOnly) voidvoidRuns several types of checks, querying specifically for events that will necessitate each type of test.voidinit()Registers the system-level policy behavioursstatic booleanvoidonAddAspect(NodeRef nodeRef, QName aspectTypeQName) Called after an aspect has been added to a nodevoidonCreateAssociation(AssociationRef nodeAssocRef) Called after a regular node association is created.voidonCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNew) This handles the creation of secondary child associations.voidonCreateNode(ChildAssociationRef childAssocRef) Called when a new node has been created.voidonDeleteAssociation(AssociationRef nodeAssocRef) Called after a regular node association is deleted.voidonDeleteChildAssociation(ChildAssociationRef childAssocRef) Called after a node child association has been deleted.voidonDeleteNode(ChildAssociationRef childAssocRef, boolean isArchivedNode) No checking performed: The association changes will be handledvoidonRemoveAspect(NodeRef nodeRef, QName aspectTypeQName) Called after an aspect has been removed from a nodevoidonUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after) Called after a node's properties have been changed.voidsetDictionaryService(DictionaryService dictionaryService) voidsetEnabled(boolean enabled) voidsetFailOnViolation(boolean failOnViolation) voidsetMaxErrorsPerTransaction(int maxLogNumberPerTransaction) voidsetNodeService(NodeService nodeService) voidsetPolicyComponent(PolicyComponent policyComponent) voidsetStoresToIgnore(List<String> storesToIgnore) voidsetTenantService(TenantService tenantService) voidsetTraceOn(boolean traceOn) static voidDowngrade violations to warnings within the current transaction.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.alfresco.util.transaction.TransactionListener
getCustomOrder
-
Constructor Details
-
IntegrityChecker
public IntegrityChecker()
-
-
Method Details
-
setWarnInTransaction
public static void setWarnInTransaction()Downgrade violations to warnings within the current transaction. This is temporary and is dependent on there being a current transaction active against the current thread. When set, this will override the globalfailure behaviour. -
isWarnInTransaction
public static boolean isWarnInTransaction()- Returns:
- Returns true if the current transaction should only warn on violations. If
false, the global setting will take effect. - See Also:
-
setPolicyComponent
- Parameters:
policyComponent- the component to register behaviour with
-
setDictionaryService
- Parameters:
dictionaryService- the dictionary against which to confirm model details
-
setNodeService
- Parameters:
nodeService- the node service to use for browsing node structures
-
setTenantService
-
setEnabled
public void setEnabled(boolean enabled) - Parameters:
enabled- set to false to disable integrity checking completely
-
setTraceOn
public void setTraceOn(boolean traceOn) - Parameters:
traceOn- set totrueto enable stack traces recording of events
-
setFailOnViolation
public void setFailOnViolation(boolean failOnViolation) - Parameters:
failOnViolation- set totrueto force failure by RuntimeException when a violation occurs.
-
setMaxErrorsPerTransaction
public void setMaxErrorsPerTransaction(int maxLogNumberPerTransaction) - Parameters:
maxLogNumberPerTransaction- upper limit on how many violations are logged when multiple violations have been found.
-
setStoresToIgnore
- Parameters:
storesToIgnore- stores (eg. workspace://version2Store) which will be ignored by integrity checker. Note: assumes associations are within a store.
-
init
public void init()Registers the system-level policy behaviours -
onCreateNode
Description copied from interface:NodeServicePolicies.OnCreateNodePolicyCalled when a new node has been created.- Specified by:
onCreateNodein interfaceNodeServicePolicies.OnCreateNodePolicy- Parameters:
childAssocRef- the created child association reference- See Also:
-
onUpdateProperties
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after) Description copied from interface:NodeServicePolicies.OnUpdatePropertiesPolicyCalled after a node's properties have been changed.- Specified by:
onUpdatePropertiesin interfaceNodeServicePolicies.OnUpdatePropertiesPolicy- Parameters:
nodeRef- reference to the updated nodebefore- the node's properties before the changeafter- the node's properties after the change- See Also:
-
onDeleteNode
No checking performed: The association changes will be handled- Specified by:
onDeleteNodein interfaceNodeServicePolicies.OnDeleteNodePolicy- Parameters:
childAssocRef- the primary parent-child association of the deleted nodeisArchivedNode- indicates whether the node has been archived rather than purged
-
onAddAspect
Description copied from interface:NodeServicePolicies.OnAddAspectPolicyCalled after an aspect has been added to a node- Specified by:
onAddAspectin interfaceNodeServicePolicies.OnAddAspectPolicy- Parameters:
nodeRef- the node to which the aspect was addedaspectTypeQName- the type of the aspect- See Also:
-
onRemoveAspect
Description copied from interface:NodeServicePolicies.OnRemoveAspectPolicyCalled after an aspect has been removed from a node- Specified by:
onRemoveAspectin interfaceNodeServicePolicies.OnRemoveAspectPolicy- Parameters:
nodeRef- the node from which the aspect will be removedaspectTypeQName- the type of the aspect- See Also:
-
onCreateChildAssociation
This handles the creation of secondary child associations.- Specified by:
onCreateChildAssociationin interfaceNodeServicePolicies.OnCreateChildAssociationPolicy- Parameters:
childAssocRef- the child association that has been createdisNew- true if the node is new or false if the node is being linked in- See Also:
-
onDeleteChildAssociation
Description copied from interface:NodeServicePolicies.OnDeleteChildAssociationPolicyCalled after a node child association has been deleted.- Specified by:
onDeleteChildAssociationin interfaceNodeServicePolicies.OnDeleteChildAssociationPolicy- Parameters:
childAssocRef- the child association that has been deleted- See Also:
-
onCreateAssociation
Description copied from interface:NodeServicePolicies.OnCreateAssociationPolicyCalled after a regular node association is created.- Specified by:
onCreateAssociationin interfaceNodeServicePolicies.OnCreateAssociationPolicy- Parameters:
nodeAssocRef- the regular node association that was created- See Also:
-
onDeleteAssociation
Description copied from interface:NodeServicePolicies.OnDeleteAssociationPolicyCalled after a regular node association is deleted.- Specified by:
onDeleteAssociationin interfaceNodeServicePolicies.OnDeleteAssociationPolicy- Parameters:
nodeAssocRef- the regular node association that was removed- See Also:
-
checkIntegrity
Runs several types of checks, querying specifically for events that will necessitate each type of test.The interface contracts also requires that all events for the transaction get cleaned up.
- Throws:
IntegrityException
-
beforeCommit
public void beforeCommit(boolean readOnly) - Specified by:
beforeCommitin interfaceorg.alfresco.util.transaction.TransactionListener
-
beforeCompletion
public void beforeCompletion()- Specified by:
beforeCompletionin interfaceorg.alfresco.util.transaction.TransactionListener
-
afterCommit
public void afterCommit()- Specified by:
afterCommitin interfaceorg.alfresco.util.transaction.TransactionListener
-
afterRollback
public void afterRollback()- Specified by:
afterRollbackin interfaceorg.alfresco.util.transaction.TransactionListener
-