org.alfresco.repo.node.integrity
Class IntegrityChecker

java.lang.Object
  extended by 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 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.OnCreateNodePolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy
ARG_0, ARG_1, ARG_2, QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnDeleteChildAssociationPolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnCreateAssociationPolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnDeleteAssociationPolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.policy.Policy
NAMESPACE
 
Constructor Summary
IntegrityChecker()
           
 
Method Summary
 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, java.util.Map before, java.util.Map 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(java.util.List storesToIgnore)
           
 void setTenantService(org.alfresco.repo.tenant.TenantService tenantService)
           
 void setTraceOn(boolean traceOn)
           
static void setWarnInTransaction()
          Downgrade violations to warnings within the current transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegrityChecker

public IntegrityChecker()
Method Detail

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(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
Parameters:
dictionaryService - the dictionary against which to confirm model details

setNodeService

public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
Parameters:
nodeService - the node service to use for browsing node structures

setTenantService

public void setTenantService(org.alfresco.repo.tenant.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(org.alfresco.service.cmr.repository.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(org.alfresco.service.cmr.repository.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 node
before - the node's properties before the change
after - the node's properties after the change
See Also:
PropertiesIntegrityEvent

onDeleteNode

public void onDeleteNode(org.alfresco.service.cmr.repository.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 node
isArchivedNode - indicates whether the node has been archived rather than purged

onAddAspect

public void onAddAspect(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                        org.alfresco.service.namespace.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 added
aspectTypeQName - the type of the aspect
See Also:
PropertiesIntegrityEvent, AssocTargetMultiplicityIntegrityEvent

onRemoveAspect

public void onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                           org.alfresco.service.namespace.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 removed
aspectTypeQName - the type of the aspect
See Also:
AspectsIntegrityEvent

onCreateChildAssociation

public void onCreateChildAssociation(org.alfresco.service.cmr.repository.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 created
isNew - 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(org.alfresco.service.cmr.repository.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(org.alfresco.service.cmr.repository.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(org.alfresco.service.cmr.repository.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.