org.alfresco.repo.node.integrity
Class IntegrityChecker
java.lang.Object
org.alfresco.repo.node.integrity.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
public class IntegrityChecker
- extends java.lang.Object
- implements NodeServicePolicies.OnCreateNodePolicy, NodeServicePolicies.OnUpdatePropertiesPolicy, NodeServicePolicies.OnDeleteNodePolicy, NodeServicePolicies.OnAddAspectPolicy, NodeServicePolicies.OnRemoveAspectPolicy, NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnDeleteChildAssociationPolicy, NodeServicePolicies.OnCreateAssociationPolicy, NodeServicePolicies.OnDeleteAssociationPolicy
Component that generates and processes integrity events, enforcing the dictionary
model's node structure.
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 IntegrityChecker.init()
method must be called.
By default, this service is enabled, but can be disabled using IntegrityChecker.setEnabled(boolean)
.
Tracing of the event stacks is, for performance reasons, disabled by default but can be enabled
using IntegrityChecker.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
IntegrityChecker.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
.
- See Also:
IntegrityChecker.setPolicyComponent(PolicyComponent)
,
IntegrityChecker.setDictionaryService(DictionaryService)
,
#setIntegrityDaoService(IntegrityDaoService)
,
IntegrityChecker.setMaxErrorsPerTransaction(int)
,
#setFlushSize(int)
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy |
Policy.Arg |
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy |
Policy.Arg |
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy |
Policy.Arg |
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy |
Policy.Arg |
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy |
Policy.Arg |
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy |
Policy.Arg |
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy |
Policy.Arg |
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy |
Policy.Arg |
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy |
Policy.Arg |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IntegrityChecker
public IntegrityChecker()
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 global
failure 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:
IntegrityChecker.setWarnInTransaction()
setPolicyComponent
public void setPolicyComponent(PolicyComponent policyComponent)
- Parameters:
policyComponent
- the component to register behaviour with
setDictionaryService
public void setDictionaryService(DictionaryService dictionaryService)
- Parameters:
dictionaryService
- the dictionary against which to confirm model details
setNodeService
public void setNodeService(NodeService nodeService)
- Parameters:
nodeService
- the node service to use for browsing node structures
setTenantService
public void setTenantService(TenantService tenantService)
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 to true
to enable stack traces recording
of events
setFailOnViolation
public void setFailOnViolation(boolean failOnViolation)
- Parameters:
failOnViolation
- set to true
to 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
public void setStoresToIgnore(java.util.List storesToIgnore)
- 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
public void onCreateNode(ChildAssociationRef childAssocRef)
- Description copied from interface:
NodeServicePolicies.OnCreateNodePolicy
- Called when a new node has been created.
- Specified by:
onCreateNode
in interface NodeServicePolicies.OnCreateNodePolicy
- Parameters:
childAssocRef
- the created child association reference- See Also:
PropertiesIntegrityEvent
,
AssocTargetRoleIntegrityEvent
,
AssocTargetMultiplicityIntegrityEvent
onUpdateProperties
public void onUpdateProperties(NodeRef nodeRef,
java.util.Map before,
java.util.Map after)
- Description copied from interface:
NodeServicePolicies.OnUpdatePropertiesPolicy
- Called after a node's properties have been changed.
- Specified by:
onUpdateProperties
in interface NodeServicePolicies.OnUpdatePropertiesPolicy
- Parameters:
nodeRef
- reference to the updated nodebefore
- the node's properties before the changeafter
- the node's properties after the change- See Also:
PropertiesIntegrityEvent
onDeleteNode
public void onDeleteNode(ChildAssociationRef childAssocRef,
boolean isArchivedNode)
- No checking performed: The association changes will be handled
- Specified by:
onDeleteNode
in interface NodeServicePolicies.OnDeleteNodePolicy
- Parameters:
childAssocRef
- the primary parent-child association of the deleted nodeisArchivedNode
- indicates whether the node has been archived rather than purged
onAddAspect
public void onAddAspect(NodeRef nodeRef,
QName aspectTypeQName)
- Description copied from interface:
NodeServicePolicies.OnAddAspectPolicy
- Called after an aspect has been added to a node
- Specified by:
onAddAspect
in interface NodeServicePolicies.OnAddAspectPolicy
- Parameters:
nodeRef
- the node to which the aspect was addedaspectTypeQName
- the type of the aspect- See Also:
PropertiesIntegrityEvent
,
AssocTargetMultiplicityIntegrityEvent
onRemoveAspect
public void onRemoveAspect(NodeRef nodeRef,
QName aspectTypeQName)
- Description copied from interface:
NodeServicePolicies.OnRemoveAspectPolicy
- Called after an aspect has been removed from a node
- Specified by:
onRemoveAspect
in interface NodeServicePolicies.OnRemoveAspectPolicy
- Parameters:
nodeRef
- the node from which the aspect will be removedaspectTypeQName
- the type of the aspect- See Also:
AspectsIntegrityEvent
onCreateChildAssociation
public void onCreateChildAssociation(ChildAssociationRef childAssocRef,
boolean isNew)
- This handles the creation of secondary child associations.
- Specified by:
onCreateChildAssociation
in interface NodeServicePolicies.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:
AssocSourceTypeIntegrityEvent
,
AssocTargetTypeIntegrityEvent
,
AssocSourceMultiplicityIntegrityEvent
,
AssocTargetMultiplicityIntegrityEvent
,
AssocTargetRoleIntegrityEvent
onDeleteChildAssociation
public void onDeleteChildAssociation(ChildAssociationRef childAssocRef)
- Description copied from interface:
NodeServicePolicies.OnDeleteChildAssociationPolicy
- Called after a node child association has been deleted.
- Specified by:
onDeleteChildAssociation
in interface NodeServicePolicies.OnDeleteChildAssociationPolicy
- Parameters:
childAssocRef
- the child association that has been deleted- See Also:
AssocSourceMultiplicityIntegrityEvent
,
AssocTargetMultiplicityIntegrityEvent
onCreateAssociation
public void onCreateAssociation(AssociationRef nodeAssocRef)
- Description copied from interface:
NodeServicePolicies.OnCreateAssociationPolicy
- Called after a regular node association is created.
- Specified by:
onCreateAssociation
in interface NodeServicePolicies.OnCreateAssociationPolicy
- Parameters:
nodeAssocRef
- the regular node association that was created- See Also:
AssocSourceTypeIntegrityEvent
,
AssocTargetTypeIntegrityEvent
,
AssocSourceMultiplicityIntegrityEvent
,
AssocTargetMultiplicityIntegrityEvent
onDeleteAssociation
public void onDeleteAssociation(AssociationRef nodeAssocRef)
- Description copied from interface:
NodeServicePolicies.OnDeleteAssociationPolicy
- Called after a regular node association is deleted.
- Specified by:
onDeleteAssociation
in interface NodeServicePolicies.OnDeleteAssociationPolicy
- Parameters:
nodeAssocRef
- the regular node association that was removed- See Also:
AssocSourceMultiplicityIntegrityEvent
,
AssocTargetMultiplicityIntegrityEvent
checkIntegrity
public void checkIntegrity()
throws IntegrityException
- 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
Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.