Merge 1.4 to HEAD (excl records management)

svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4306 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4307 .
   rm -rf root/projects/records-mgmt


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4637 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-12-18 15:28:54 +00:00
parent 12d9c52193
commit 19c95ce58f
6 changed files with 99 additions and 12 deletions

View File

@@ -28,6 +28,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.node.NodeServicePolicies.BeforeAddAspectPolicy;
import org.alfresco.repo.node.NodeServicePolicies.BeforeCreateChildAssociationPolicy;
import org.alfresco.repo.node.NodeServicePolicies.BeforeCreateNodeAssociationPolicy;
import org.alfresco.repo.node.NodeServicePolicies.BeforeCreateNodePolicy;
import org.alfresco.repo.node.NodeServicePolicies.BeforeCreateStorePolicy;
import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteChildAssociationPolicy;
@@ -37,6 +38,7 @@ import org.alfresco.repo.node.NodeServicePolicies.BeforeUpdateNodePolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnCreateAssociationPolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodeAssociationPolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnCreateStorePolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnDeleteAssociationPolicy;
@@ -110,6 +112,8 @@ public abstract class AbstractNodeServiceImpl implements NodeService
private ClassPolicyDelegate<OnAddAspectPolicy> onAddAspectDelegate;
private ClassPolicyDelegate<BeforeRemoveAspectPolicy> beforeRemoveAspectDelegate;
private ClassPolicyDelegate<OnRemoveAspectPolicy> onRemoveAspectDelegate;
private AssociationPolicyDelegate<BeforeCreateNodeAssociationPolicy> beforeCreateNodeAssociationDelegate;
private AssociationPolicyDelegate<OnCreateNodeAssociationPolicy> onCreateNodeAssociationDelegate;
private AssociationPolicyDelegate<BeforeCreateChildAssociationPolicy> beforeCreateChildAssociationDelegate;
private AssociationPolicyDelegate<OnCreateChildAssociationPolicy> onCreateChildAssociationDelegate;
private AssociationPolicyDelegate<BeforeDeleteChildAssociationPolicy> beforeDeleteChildAssociationDelegate;
@@ -183,6 +187,8 @@ public abstract class AbstractNodeServiceImpl implements NodeService
beforeRemoveAspectDelegate = policyComponent.registerClassPolicy(NodeServicePolicies.BeforeRemoveAspectPolicy.class);
onRemoveAspectDelegate = policyComponent.registerClassPolicy(NodeServicePolicies.OnRemoveAspectPolicy.class);
beforeCreateNodeAssociationDelegate = policyComponent.registerAssociationPolicy(NodeServicePolicies.BeforeCreateNodeAssociationPolicy.class);
onCreateNodeAssociationDelegate = policyComponent.registerAssociationPolicy(NodeServicePolicies.OnCreateNodeAssociationPolicy.class);
beforeCreateChildAssociationDelegate = policyComponent.registerAssociationPolicy(NodeServicePolicies.BeforeCreateChildAssociationPolicy.class);
onCreateChildAssociationDelegate = policyComponent.registerAssociationPolicy(NodeServicePolicies.OnCreateChildAssociationPolicy.class);
beforeDeleteChildAssociationDelegate = policyComponent.registerAssociationPolicy(NodeServicePolicies.BeforeDeleteChildAssociationPolicy.class);
@@ -392,6 +398,34 @@ public abstract class AbstractNodeServiceImpl implements NodeService
NodeServicePolicies.OnRemoveAspectPolicy policy = onRemoveAspectDelegate.get(nodeRef, aspectTypeQName);
policy.onRemoveAspect(nodeRef, aspectTypeQName);
}
/**
* @see NodeServicePolicies.BeforeCreateNodeAssociationPolicy#beforeCreateChildAssociation(NodeRef,
* NodeRef, QName, QName)
*/
protected void invokeBeforeCreateNodeAssociation(NodeRef parentNodeRef, QName assocTypeQName, QName assocQName)
{
// get qnames to invoke against
Set<QName> qnames = getTypeAndAspectQNames(parentNodeRef);
// execute policy for node type
NodeServicePolicies.BeforeCreateNodeAssociationPolicy policy = beforeCreateNodeAssociationDelegate.get(parentNodeRef, qnames, assocTypeQName);
policy.beforeCreateNodeAssociation(parentNodeRef, assocTypeQName, assocQName);
}
/**
* @see NodeServicePolicies.OnCreateNodeAssociationPolicy#onCreateChildAssociation(ChildAssociationRef)
*/
protected void invokeOnCreateNodeAssociation(ChildAssociationRef childAssocRef)
{
// Get the parent reference and the assoc type qName
NodeRef parentNodeRef = childAssocRef.getParentRef();
QName assocTypeQName = childAssocRef.getTypeQName();
// get qnames to invoke against
Set<QName> qnames = getTypeAndAspectQNames(parentNodeRef);
// execute policy for node type and aspects
NodeServicePolicies.OnCreateNodeAssociationPolicy policy = onCreateNodeAssociationDelegate.get(parentNodeRef, qnames, assocTypeQName);
policy.onCreateNodeAssociation(childAssocRef);
}
/**
* @see NodeServicePolicies.BeforeCreateChildAssociationPolicy#beforeCreateChildAssociation(NodeRef,

View File

@@ -200,6 +200,31 @@ public interface NodeServicePolicies
*/
public void onRemoveAspect(NodeRef nodeRef, QName aspectTypeQName);
}
public interface BeforeCreateNodeAssociationPolicy extends AssociationPolicy
{
/**
* Called before a new node is created with the details of the new child association.
*
* @param parentNodeRef
* @param assocTypeQName the type of the association
* @param assocQName the name of the association
*/
public void beforeCreateNodeAssociation(
NodeRef parentNodeRef,
QName assocTypeQName,
QName assocQName);
}
public interface OnCreateNodeAssociationPolicy extends AssociationPolicy
{
/**
* Called after a node is created with the created association details
*
* @param childAssocRef the child association that has been created
*/
public void onCreateNodeAssociation(ChildAssociationRef childAssocRef);
}
public interface BeforeCreateChildAssociationPolicy extends AssociationPolicy
{

View File

@@ -267,6 +267,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// Invoke policy behaviour
invokeBeforeUpdateNode(parentRef);
invokeBeforeCreateNode(parentRef, assocTypeQName, assocQName, nodeTypeQName);
invokeBeforeCreateNodeAssociation(parentRef, assocTypeQName, assocQName);
// get the store that the parent belongs to
StoreRef storeRef = parentRef.getStoreRef();
@@ -318,6 +319,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// Invoke policy behaviour
invokeOnCreateNode(childAssocRef);
invokeOnCreateNodeAssociation(childAssocRef);
invokeOnUpdateNode(parentRef);
if (propertiesAfter != null)
{

View File

@@ -32,14 +32,17 @@ public class AssociationPolicyRegistration extends PolicyRegistration
@Override
public void register()
{
// Register the association behaviour
if (this.associationType == null)
{
this.policyComponent.bindAssociationBehaviour(this.policyName, this.className, this.behaviour);
}
else
for (QName policyName : this.policyNames)
{
this.policyComponent.bindAssociationBehaviour(this.policyName, this.className, this.associationType, this.behaviour);
// Register the association behaviour
if (this.associationType == null)
{
this.policyComponent.bindAssociationBehaviour(policyName, this.className, this.behaviour);
}
else
{
this.policyComponent.bindAssociationBehaviour(policyName, this.className, this.associationType, this.behaviour);
}
}
}

View File

@@ -3,6 +3,8 @@
*/
package org.alfresco.repo.policy.registration;
import org.alfresco.service.namespace.QName;
/**
* Deal with the registration of a class policy
*
@@ -17,8 +19,11 @@ public class ClassPolicyRegistration extends PolicyRegistration
@Override
public void register()
{
// Register the class behaviour
this.policyComponent.bindClassBehaviour(this.policyName, this.className, this.behaviour);
for (QName policyName : this.policyNames)
{
// Register the class behaviour
this.policyComponent.bindClassBehaviour(policyName, this.className, this.behaviour);
}
}
}

View File

@@ -3,6 +3,9 @@
*/
package org.alfresco.repo.policy.registration;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.service.namespace.QName;
@@ -17,8 +20,8 @@ public abstract class PolicyRegistration
/** The policy componenet **/
protected PolicyComponent policyComponent;
/** The policy name **/
protected QName policyName;
/** The policy names **/
protected List<QName> policyNames;
/** The class name **/
protected QName className;
@@ -43,7 +46,22 @@ public abstract class PolicyRegistration
*/
public void setPolicyName(String policyName)
{
this.policyName = QName.createQName(policyName);
this.policyNames = new ArrayList<QName>(1);
this.policyNames.add(QName.createQName(policyName));
}
/**
* Set the policy names. The behaviour will be added for each for the policies.
*
* @param policyNames the policy names
*/
public void setPolicyNames(List<String> policyNames)
{
this.policyNames = new ArrayList<QName>(policyNames.size());
for (String policyName : policyNames)
{
this.policyNames.add(QName.createQName(policyName));
}
}
/**