Merging from EC-MC: Project compile

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5742 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-05-22 05:00:16 +00:00
parent 2e79d2e6d2
commit e34312ea05
12 changed files with 217 additions and 132 deletions

View File

@@ -927,6 +927,14 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
}
}
/**
* TODO: Implement
*/
public boolean removeSeconaryChildAssociation(ChildAssociationRef childAssocRef)
{
throw new UnsupportedOperationException();
}
/**
* @param nodeRef
* @return Returns all properties keyed by their qualified name

View File

@@ -74,12 +74,11 @@ public class ContentFilterLanguagesMap implements ContentFilterLanguagesService
/**
* @param configService the config service to use to read languages
*/
public ContentFilterLanguagesMap(ConfigService configService)
public void setConfigService(ConfigService configService)
{
this.configService = configService;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.ml.ContentFilterLanguagesService#getFilterLanguages()
*/

View File

@@ -875,11 +875,12 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
public void testRemoveSpecificChild() throws Exception
{
NodeRef parentRef = nodeService.createNode(
ChildAssociationRef pathPrimaryRef = nodeService.createNode(
rootNodeRef,
ASSOC_TYPE_QNAME_TEST_CHILDREN,
QName.createQName("parent_child"),
ContentModel.TYPE_CONTAINER).getChildRef();
ContentModel.TYPE_CONTAINER);
NodeRef parentRef = pathPrimaryRef.getParentRef();
ChildAssociationRef pathARef = nodeService.createNode(
parentRef,
ASSOC_TYPE_QNAME_TEST_CHILDREN,
@@ -890,12 +891,34 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
pathARef.getChildRef(),
ASSOC_TYPE_QNAME_TEST_CHILDREN,
QName.createQName("pathB"));
ChildAssociationRef pathCRef = nodeService.addChild(
parentRef,
pathARef.getChildRef(),
ASSOC_TYPE_QNAME_TEST_CHILDREN,
QName.createQName("pathC"));
// now remove the second association
boolean removed = nodeService.removeChildAssociation(pathBRef);
assertTrue("Association was not removed", removed);
removed = nodeService.removeChildAssociation(pathBRef);
assertFalse("Non-existent association was apparently removed", removed);
// remove the path B association
boolean removedB = nodeService.removeChildAssociation(pathBRef);
assertTrue("Association was not removed", removedB);
removedB = nodeService.removeChildAssociation(pathBRef);
assertFalse("Non-existent association was apparently removed", removedB);
// remove the path C association
boolean removedC = nodeService.removeChildAssociation(pathCRef);
assertTrue("Association was not removed", removedC);
removedC = nodeService.removeSeconaryChildAssociation(pathCRef);
assertFalse("Non-existent association was apparently removed", removedC);
// Now verify that primary associations are caught
try
{
nodeService.removeSeconaryChildAssociation(pathPrimaryRef);
fail("Primary association not detected");
}
catch (IllegalArgumentException e)
{
// Expected
}
}
public void testRemoveChildByRef() throws Exception

View File

@@ -150,7 +150,8 @@ public class MLTranslationInterceptor implements MethodInterceptor
}
}
} else
}
else
{
ret = invocation.proceed();
}

View File

@@ -296,11 +296,11 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// Copy the incomming property map since we may need to modify it later
properties = new HashMap<QName, Serializable>(properties);
}
// Invoke policy behaviour
invokeBeforeUpdateNode(parentRef);
invokeBeforeCreateNode(parentRef, assocTypeQName, assocQName, nodeTypeQName);
invokeBeforeCreateNodeAssociation(parentRef, assocTypeQName, assocQName);
// 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();
@@ -352,16 +352,16 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
ChildAssociationRef childAssocRef = childAssoc.getChildAssocRef();
// Invoke policy behaviour
invokeOnCreateNode(childAssocRef);
invokeOnCreateNodeAssociation(childAssocRef);
invokeOnCreateNode(childAssocRef);
invokeOnCreateNodeAssociation(childAssocRef);
invokeOnUpdateNode(parentRef);
if (propertiesAfter != null)
{
invokeOnUpdateProperties(childAssocRef.getChildRef(), propertiesBefore, propertiesAfter);
}
// done
return childAssocRef;
// done
return childAssocRef;
}
/**
@@ -464,8 +464,8 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// invoke policy behaviour
if (movingStore)
{
// TODO for now indicate that the node has been archived to prevent the version history from being removed
// in the future a onMove policy could be added and remove the need for onDelete and onCreate to be fired here
// TODO for now indicate that the node has been archived to prevent the version history from being removed
// in the future a onMove policy could be added and remove the need for onDelete and onCreate to be fired here
invokeOnDeleteNode(oldAssocRef, nodeToMoveTypeQName, nodeToMoveAspects, true);
invokeOnCreateNode(newAssoc.getChildAssocRef());
}
@@ -584,9 +584,9 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// physically attach the aspect to the node
if (node.getAspects().add(aspectTypeQName) == true)
{
// Invoke policy behaviours
invokeOnUpdateNode(nodeRef);
{
// Invoke policy behaviours
invokeOnUpdateNode(nodeRef);
invokeOnAddAspect(nodeRef, aspectTypeQName);
// update the node status
@@ -600,10 +600,10 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
public void removeAspect(NodeRef nodeRef, QName aspectTypeQName)
throws InvalidNodeRefException, InvalidAspectException
{
// Invoke policy behaviours
invokeBeforeUpdateNode(nodeRef);
// Invoke policy behaviours
invokeBeforeUpdateNode(nodeRef);
invokeBeforeRemoveAspect(nodeRef, aspectTypeQName);
// get the aspect
AspectDefinition aspectDef = dictionaryService.getAspect(aspectTypeQName);
if (aspectDef == null)
@@ -691,12 +691,12 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
public void deleteNode(NodeRef nodeRef)
{
boolean isArchivedNode = false;
boolean isArchivedNode = false;
boolean requiresDelete = false;
// Invoke policy behaviours
invokeBeforeDeleteNode(nodeRef);
// Invoke policy behaviours
invokeBeforeDeleteNode(nodeRef);
// get the node
Node node = getNodeNotNull(nodeRef);
// get the primary parent-child relationship before it is gone
@@ -738,17 +738,17 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
archiveNode(nodeRef, archiveStoreRef);
isArchivedNode = true;
}
// Invoke policy behaviours
invokeOnDeleteNode(childAssocRef, nodeTypeQName, nodeAspectQNames, isArchivedNode);
// Invoke policy behaviours
invokeOnDeleteNode(childAssocRef, nodeTypeQName, nodeAspectQNames, isArchivedNode);
}
public ChildAssociationRef addChild(NodeRef parentRef, NodeRef childRef, QName assocTypeQName, QName assocQName)
{
// Invoke policy behaviours
invokeBeforeUpdateNode(parentRef);
invokeBeforeUpdateNode(parentRef);
invokeBeforeCreateChildAssociation(parentRef, childRef, assocTypeQName, assocQName);
// get the parent node and ensure that it is a container node
Node parentNode = getNodeNotNull(parentRef);
// get the child node
@@ -769,10 +769,10 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// this functionality is provided for free in getPath
getPaths(childNodeRef, false);
// Invoke policy behaviours
// Invoke policy behaviours
invokeOnCreateChildAssociation(assocRef);
invokeOnUpdateNode(parentRef);
invokeOnUpdateNode(parentRef);
return assoc.getChildAssocRef();
}
@@ -813,9 +813,9 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
deleteNode(primaryAssocRef.getChildRef());
}
// Invoke policy behaviours
invokeOnUpdateNode(parentRef);
// Invoke policy behaviours
invokeOnUpdateNode(parentRef);
// done
}
@@ -836,6 +836,31 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
return deleted;
}
public boolean removeSeconaryChildAssociation(ChildAssociationRef childAssocRef)
{
Node parentNode = getNodeNotNull(childAssocRef.getParentRef());
Node childNode = getNodeNotNull(childAssocRef.getChildRef());
QName typeQName = childAssocRef.getTypeQName();
QName qname = childAssocRef.getQName();
ChildAssoc assoc = nodeDaoService.getChildAssoc(parentNode, childNode, typeQName, qname);
if (assoc == null)
{
// No association exists
return false;
}
if (assoc.getIsPrimary())
{
throw new IllegalArgumentException(
"removeSeconaryChildAssociation can not be applied to a primary association: \n" +
" Child Assoc: " + assoc);
}
// Delete the secondary association
nodeDaoService.deleteChildAssoc(assoc, false);
invokeOnDeleteChildAssociation(childAssocRef);
// Done
return true;
}
/**
* Remove properties that should not be persisted as general properties. Where necessary, the
* properties are set on the node.
@@ -965,7 +990,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
Node node = getNodeNotNull(nodeRef);
// Invoke policy behaviours
invokeBeforeUpdateNode(nodeRef);
invokeBeforeUpdateNode(nodeRef);
// Do the set properties
Map<QName, Serializable> propertiesBefore = getPropertiesImpl(node);
@@ -973,8 +998,8 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
setChildUniqueName(node); // ensure uniqueness
// Invoke policy behaviours
invokeOnUpdateNode(nodeRef);
// Invoke policy behaviours
invokeOnUpdateNode(nodeRef);
invokeOnUpdateProperties(nodeRef, propertiesBefore, propertiesAfter);
}
@@ -1027,8 +1052,8 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
Assert.notNull(qname);
// Invoke policy behaviours
invokeBeforeUpdateNode(nodeRef);
invokeBeforeUpdateNode(nodeRef);
// get the node
Node node = getNodeNotNull(nodeRef);
@@ -1041,8 +1066,8 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
setChildUniqueName(node); // ensure uniqueness
}
// Invoke policy behaviours
invokeOnUpdateNode(nodeRef);
// Invoke policy behaviours
invokeOnUpdateNode(nodeRef);
invokeOnUpdateProperties(nodeRef, propertiesBefore, propertiesAfter);
}
@@ -1245,8 +1270,8 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
throws InvalidNodeRefException, AssociationExistsException
{
// Invoke policy behaviours
invokeBeforeUpdateNode(sourceRef);
invokeBeforeUpdateNode(sourceRef);
Node sourceNode = getNodeNotNull(sourceRef);
Node targetNode = getNodeNotNull(targetRef);
// see if it exists
@@ -1259,10 +1284,10 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
assoc = nodeDaoService.newNodeAssoc(sourceNode, targetNode, assocTypeQName);
AssociationRef assocRef = assoc.getNodeAssocRef();
// Invoke policy behaviours
invokeOnUpdateNode(sourceRef);
// Invoke policy behaviours
invokeOnUpdateNode(sourceRef);
invokeOnCreateAssociation(assocRef);
return assocRef;
}
@@ -1281,13 +1306,13 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
AssociationRef assocRef = assoc.getNodeAssocRef();
// Invoke policy behaviours
invokeBeforeUpdateNode(sourceRef);
invokeBeforeUpdateNode(sourceRef);
// delete it
nodeDaoService.deleteNodeAssoc(assoc);
// Invoke policy behaviours
invokeOnUpdateNode(sourceRef);
// Invoke policy behaviours
invokeOnUpdateNode(sourceRef);
invokeOnDeleteAssociation(assocRef);
}

View File

@@ -35,55 +35,55 @@ import org.alfresco.service.namespace.QName;
public class SingleNodeRefPolicyRuleTrigger extends RuleTriggerAbstractBase
{
private static final String ERR_POLICY_NAME_NOT_SET = "Unable to register rule trigger since policy name has not been set.";
private String policyNamespace = NamespaceService.ALFRESCO_URI;
private String policyName;
private boolean triggerParentRules = true;
public void setPolicyNamespace(String policyNamespace)
{
this.policyNamespace = policyNamespace;
}
public void setPolicyName(String policyName)
{
this.policyName = policyName;
}
public void setTriggerParentRules(boolean triggerParentRules)
{
this.triggerParentRules = triggerParentRules;
}
public void registerRuleTrigger()
{
if (policyName == null)
{
throw new RuleServiceException(ERR_POLICY_NAME_NOT_SET);
}
this.policyComponent.bindClassBehaviour(
QName.createQName(this.policyNamespace, this.policyName),
this,
new JavaBehaviour(this, "policyBehaviour"));
}
private static final String ERR_POLICY_NAME_NOT_SET = "Unable to register rule trigger since policy name has not been set.";
private String policyNamespace = NamespaceService.ALFRESCO_URI;
private String policyName;
private boolean triggerParentRules = true;
public void setPolicyNamespace(String policyNamespace)
{
this.policyNamespace = policyNamespace;
}
public void setPolicyName(String policyName)
{
this.policyName = policyName;
}
public void setTriggerParentRules(boolean triggerParentRules)
{
this.triggerParentRules = triggerParentRules;
}
public void registerRuleTrigger()
{
if (policyName == null)
{
throw new RuleServiceException(ERR_POLICY_NAME_NOT_SET);
}
this.policyComponent.bindClassBehaviour(
QName.createQName(this.policyNamespace, this.policyName),
this,
new JavaBehaviour(this, "policyBehaviour"));
}
public void policyBehaviour(NodeRef nodeRef)
{
if (triggerParentRules == true)
{
List<ChildAssociationRef> parentsAssocRefs = this.nodeService.getParentAssocs(nodeRef);
for (ChildAssociationRef parentAssocRef : parentsAssocRefs)
{
triggerRules(parentAssocRef.getParentRef(), nodeRef);
}
}
else
{
triggerRules(nodeRef, nodeRef);
}
}
public void policyBehaviour(NodeRef nodeRef)
{
if (triggerParentRules == true)
{
List<ChildAssociationRef> parentsAssocRefs = this.nodeService.getParentAssocs(nodeRef);
for (ChildAssociationRef parentAssocRef : parentsAssocRefs)
{
triggerRules(parentAssocRef.getParentRef(), nodeRef);
}
}
else
{
triggerRules(nodeRef, nodeRef);
}
}
}

View File

@@ -245,6 +245,14 @@ public class NodeServiceImpl implements NodeService, VersionModel
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
/**
* @throws UnsupportedOperationException always
*/
public boolean removeSeconaryChildAssociation(ChildAssociationRef childAssocRef)
{
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
/**
* @throws UnsupportedOperationException always
*/

View File

@@ -339,6 +339,16 @@ public interface NodeService
@Auditable(key = Auditable.Key.ARG_0 ,parameters = {"childAssocRef"})
public boolean removeChildAssociation(ChildAssociationRef childAssocRef);
/**
* Remove a specific secondary child association.
*
* @param childAssocRef the association to remove
* @return Returns <tt>true</tt> if the association existed, otherwise <tt>false</tt>.
* @throws IllegalArgumentException if the association is primary
*/
@Auditable(key = Auditable.Key.ARG_0 ,parameters = {"childAssocRef"})
public boolean removeSeconaryChildAssociation(ChildAssociationRef childAssocRef);
/**
* @param nodeRef
* @return Returns all properties keyed by their qualified name