mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
This makes AVMNodeService policy aware.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3619 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -63,13 +63,16 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- AVMNodeService -->
|
<!-- AVMNodeService -->
|
||||||
<bean id="avmNodeService" class="org.alfresco.repo.avm.AVMNodeService">
|
<bean id="avmNodeService" class="org.alfresco.repo.avm.AVMNodeService" init-method="init">
|
||||||
<property name="dictionaryService">
|
<property name="dictionaryService">
|
||||||
<ref bean="dictionaryService"/>
|
<ref bean="dictionaryService"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="avmService">
|
<property name="avmService">
|
||||||
<ref bean="AVMService"/>
|
<ref bean="AVMService"/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="policyComponent">
|
||||||
|
<ref bean="policyComponent"/>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Handles policy callbacks to ensure that node hierarchy gets indexed -->
|
<!-- Handles policy callbacks to ensure that node hierarchy gets indexed -->
|
||||||
|
@@ -19,6 +19,7 @@ package org.alfresco.repo.avm;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -30,12 +31,12 @@ import java.util.SortedMap;
|
|||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.domain.PropertyValue;
|
import org.alfresco.repo.domain.PropertyValue;
|
||||||
import org.alfresco.repo.node.AbstractNodeServiceImpl;
|
import org.alfresco.repo.node.AbstractNodeServiceImpl;
|
||||||
import org.alfresco.service.Auditable;
|
|
||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
|
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
|
||||||
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
|
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.AssociationExistsException;
|
import org.alfresco.service.cmr.repository.AssociationExistsException;
|
||||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
@@ -111,9 +112,14 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
public StoreRef createStore(String protocol, String identifier) throws StoreExistsException
|
public StoreRef createStore(String protocol, String identifier) throws StoreExistsException
|
||||||
{
|
{
|
||||||
StoreRef result = new StoreRef(StoreRef.PROTOCOL_AVM, identifier);
|
StoreRef result = new StoreRef(StoreRef.PROTOCOL_AVM, identifier);
|
||||||
|
invokeBeforeCreateStore(ContentModel.TYPE_STOREROOT, result);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fAVMService.createAVMStore(identifier);
|
fAVMService.createAVMStore(identifier);
|
||||||
|
NodeRef rootRef = getRootNode(result);
|
||||||
|
addAspect(rootRef, ContentModel.ASPECT_ROOT,
|
||||||
|
Collections.<QName, Serializable>emptyMap());
|
||||||
|
invokeOnCreateStore(rootRef);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
catch (AVMExistsException e)
|
catch (AVMExistsException e)
|
||||||
@@ -247,6 +253,11 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
throw new InvalidNodeRefException("Read only store.", parentRef);
|
throw new InvalidNodeRefException("Read only store.", parentRef);
|
||||||
}
|
}
|
||||||
String avmPath = (String)avmVersionPath[1];
|
String avmPath = (String)avmVersionPath[1];
|
||||||
|
// Invoke policy behavior.
|
||||||
|
invokeBeforeUpdateNode(parentRef);
|
||||||
|
invokeBeforeCreateNode(parentRef, assocTypeQName, assocQName, nodeTypeQName);
|
||||||
|
// Look up the type definition in the dictionary.
|
||||||
|
TypeDefinition nodeTypeDef = dictionaryService.getType(nodeTypeQName);
|
||||||
// Do the creates for supported types, or error out.
|
// Do the creates for supported types, or error out.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -262,6 +273,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
{
|
{
|
||||||
throw new InvalidTypeException("Invalid node type for AVM.", nodeTypeQName);
|
throw new InvalidTypeException("Invalid node type for AVM.", nodeTypeQName);
|
||||||
}
|
}
|
||||||
|
addDefaultPropertyValues(nodeTypeDef, properties);
|
||||||
|
// TODO Add default aspects to the child..
|
||||||
}
|
}
|
||||||
catch (AVMNotFoundException e)
|
catch (AVMNotFoundException e)
|
||||||
{
|
{
|
||||||
@@ -273,7 +286,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
}
|
}
|
||||||
String newAVMPath = AVMNodeConverter.ExtendAVMPath(avmPath, nodeName);
|
String newAVMPath = AVMNodeConverter.ExtendAVMPath(avmPath, nodeName);
|
||||||
NodeRef childRef = AVMNodeConverter.ToNodeRef(-1, newAVMPath);
|
NodeRef childRef = AVMNodeConverter.ToNodeRef(-1, newAVMPath);
|
||||||
// TODO Q? Is properties ever null?
|
addDefaultPropertyValues(nodeTypeDef, properties);
|
||||||
|
addDefaultAspects(nodeTypeDef, newAVMPath, properties);
|
||||||
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>();
|
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>();
|
||||||
for (QName qname : properties.keySet())
|
for (QName qname : properties.keySet())
|
||||||
{
|
{
|
||||||
@@ -284,13 +298,18 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
props.put(qname, new PropertyValue(null, properties.get(qname)));
|
props.put(qname, new PropertyValue(null, properties.get(qname)));
|
||||||
}
|
}
|
||||||
fAVMService.setNodeProperties(newAVMPath, props);
|
fAVMService.setNodeProperties(newAVMPath, props);
|
||||||
return
|
ChildAssociationRef ref =
|
||||||
new ChildAssociationRef(assocTypeQName,
|
new ChildAssociationRef(assocTypeQName,
|
||||||
parentRef,
|
parentRef,
|
||||||
assocQName,
|
assocQName,
|
||||||
childRef,
|
childRef,
|
||||||
true,
|
true,
|
||||||
-1);
|
-1);
|
||||||
|
invokeOnCreateNode(ref);
|
||||||
|
invokeOnUpdateNode(parentRef);
|
||||||
|
// TODO invokeOnUpdateProperties
|
||||||
|
|
||||||
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -357,12 +376,14 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
}
|
}
|
||||||
String dstParent = (String)dst[1];
|
String dstParent = (String)dst[1];
|
||||||
String dstName = assocQName.getLocalName();
|
String dstName = assocQName.getLocalName();
|
||||||
|
// TODO Invoke policy behavior. Not quite sure how to translate this.
|
||||||
// Actually perform the rename and return a pseudo
|
// Actually perform the rename and return a pseudo
|
||||||
// ChildAssociationRef.
|
// ChildAssociationRef.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fAVMService.rename(srcParent, srcName, dstParent, dstName);
|
fAVMService.rename(srcParent, srcName, dstParent, dstName);
|
||||||
String dstPath = AVMNodeConverter.ExtendAVMPath(dstParent, dstName);
|
String dstPath = AVMNodeConverter.ExtendAVMPath(dstParent, dstName);
|
||||||
|
// TODO Invoke policy behaviors. Not sure how to translate that.
|
||||||
return new ChildAssociationRef(assocTypeQName,
|
return new ChildAssociationRef(assocTypeQName,
|
||||||
newParentRef,
|
newParentRef,
|
||||||
assocQName,
|
assocQName,
|
||||||
@@ -479,6 +500,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
throw new InvalidAspectException("The aspect is invalid: " + aspectTypeQName,
|
throw new InvalidAspectException("The aspect is invalid: " + aspectTypeQName,
|
||||||
aspectTypeQName);
|
aspectTypeQName);
|
||||||
}
|
}
|
||||||
|
// Invoke policy behaviors.
|
||||||
|
invokeBeforeUpdateNode(nodeRef);
|
||||||
|
invokeBeforeAddAspect(nodeRef, aspectTypeQName);
|
||||||
// Crack the nodeRef.
|
// Crack the nodeRef.
|
||||||
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
||||||
int version = (Integer)avmVersionPath[0];
|
int version = (Integer)avmVersionPath[0];
|
||||||
@@ -508,6 +532,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
fAVMService.addAspect(avmPath, aspectTypeQName);
|
fAVMService.addAspect(avmPath, aspectTypeQName);
|
||||||
|
// Invoke policy behaviors.
|
||||||
|
invokeOnUpdateNode(nodeRef);
|
||||||
|
invokeOnAddAspect(nodeRef, aspectTypeQName);
|
||||||
}
|
}
|
||||||
catch (AVMNotFoundException e)
|
catch (AVMNotFoundException e)
|
||||||
{
|
{
|
||||||
@@ -524,13 +551,16 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
private void addDefaultAspects(ClassDefinition classDef, String path,
|
private void addDefaultAspects(ClassDefinition classDef, String path,
|
||||||
Map<QName, Serializable> properties)
|
Map<QName, Serializable> properties)
|
||||||
{
|
{
|
||||||
|
NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, path);
|
||||||
// Get mandatory aspects.
|
// Get mandatory aspects.
|
||||||
List<AspectDefinition> defaultAspectDefs = classDef.getDefaultAspects();
|
List<AspectDefinition> defaultAspectDefs = classDef.getDefaultAspects();
|
||||||
// add all the aspects (and there dependent aspects recursively).
|
// add all the aspects (and there dependent aspects recursively).
|
||||||
for (AspectDefinition def : defaultAspectDefs)
|
for (AspectDefinition def : defaultAspectDefs)
|
||||||
{
|
{
|
||||||
|
invokeBeforeAddAspect(nodeRef, def.getName());
|
||||||
fAVMService.addAspect(path, def.getName());
|
fAVMService.addAspect(path, def.getName());
|
||||||
addDefaultPropertyValues(def, properties);
|
addDefaultPropertyValues(def, properties);
|
||||||
|
invokeOnAddAspect(nodeRef, def.getName());
|
||||||
// recurse
|
// recurse
|
||||||
addDefaultAspects(def, path, properties);
|
addDefaultAspects(def, path, properties);
|
||||||
}
|
}
|
||||||
@@ -548,6 +578,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
public void removeAspect(NodeRef nodeRef, QName aspectTypeQName)
|
public void removeAspect(NodeRef nodeRef, QName aspectTypeQName)
|
||||||
throws InvalidNodeRefException, InvalidAspectException
|
throws InvalidNodeRefException, InvalidAspectException
|
||||||
{
|
{
|
||||||
|
// Invoke policy behaviors.
|
||||||
|
invokeBeforeUpdateNode(nodeRef);
|
||||||
|
invokeBeforeRemoveAspect(nodeRef, aspectTypeQName);
|
||||||
AspectDefinition def = dictionaryService.getAspect(aspectTypeQName);
|
AspectDefinition def = dictionaryService.getAspect(aspectTypeQName);
|
||||||
if (def == null)
|
if (def == null)
|
||||||
{
|
{
|
||||||
@@ -576,6 +609,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
fAVMService.deleteNodeProperty(path, propertyName);
|
fAVMService.deleteNodeProperty(path, propertyName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Invoke policy behaviors.
|
||||||
|
invokeOnUpdateNode(nodeRef);
|
||||||
|
invokeOnRemoveAspect(nodeRef, aspectTypeQName);
|
||||||
}
|
}
|
||||||
catch (AVMNotFoundException e)
|
catch (AVMNotFoundException e)
|
||||||
{
|
{
|
||||||
@@ -673,6 +709,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
*/
|
*/
|
||||||
public void deleteNode(NodeRef nodeRef) throws InvalidNodeRefException
|
public void deleteNode(NodeRef nodeRef) throws InvalidNodeRefException
|
||||||
{
|
{
|
||||||
|
// Invoke policy behaviors.
|
||||||
|
invokeBeforeDeleteNode(nodeRef);
|
||||||
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
||||||
if ((Integer)avmVersionPath[0] != -1)
|
if ((Integer)avmVersionPath[0] != -1)
|
||||||
{
|
{
|
||||||
@@ -686,6 +724,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
fAVMService.removeNode(avmPathBase[0], avmPathBase[1]);
|
fAVMService.removeNode(avmPathBase[0], avmPathBase[1]);
|
||||||
|
// Invoke policy behaviors.
|
||||||
|
// TODO invokeOnDeleteNode() Need to fake up ChildAssocRef.
|
||||||
}
|
}
|
||||||
catch (AVMNotFoundException e)
|
catch (AVMNotFoundException e)
|
||||||
{
|
{
|
||||||
@@ -726,6 +766,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
*/
|
*/
|
||||||
public void removeChild(NodeRef parentRef, NodeRef childRef) throws InvalidNodeRefException
|
public void removeChild(NodeRef parentRef, NodeRef childRef) throws InvalidNodeRefException
|
||||||
{
|
{
|
||||||
|
// Invoke policy behaviors.
|
||||||
|
// TODO Have to fake up ChildAssocRef.
|
||||||
Object [] parentVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef);
|
Object [] parentVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef);
|
||||||
if ((Integer)parentVersionPath[0] >= 0)
|
if ((Integer)parentVersionPath[0] >= 0)
|
||||||
{
|
{
|
||||||
@@ -746,6 +788,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
fAVMService.removeNode(childPathBase[0], childPathBase[1]);
|
fAVMService.removeNode(childPathBase[0], childPathBase[1]);
|
||||||
|
// Invoke policy behaviors.
|
||||||
|
// TODO Need to fake up ChildAssocRef.
|
||||||
}
|
}
|
||||||
catch (AVMNotFoundException e)
|
catch (AVMNotFoundException e)
|
||||||
{
|
{
|
||||||
@@ -918,6 +962,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Invoke policy behaviors.
|
||||||
|
invokeBeforeUpdateNode(nodeRef);
|
||||||
fAVMService.deleteNodeProperties((String)avmVersionPath[1]);
|
fAVMService.deleteNodeProperties((String)avmVersionPath[1]);
|
||||||
Map<QName, PropertyValue> values = new HashMap<QName, PropertyValue>();
|
Map<QName, PropertyValue> values = new HashMap<QName, PropertyValue>();
|
||||||
for (QName qName : properties.keySet())
|
for (QName qName : properties.keySet())
|
||||||
@@ -931,6 +977,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
values.put(qName, new PropertyValue(null, properties.get(qName)));
|
values.put(qName, new PropertyValue(null, properties.get(qName)));
|
||||||
}
|
}
|
||||||
fAVMService.setNodeProperties((String)avmVersionPath[1], values);
|
fAVMService.setNodeProperties((String)avmVersionPath[1], values);
|
||||||
|
// Invoke policy behaviors.
|
||||||
|
invokeOnUpdateNode(nodeRef);
|
||||||
}
|
}
|
||||||
catch (AVMNotFoundException e)
|
catch (AVMNotFoundException e)
|
||||||
{
|
{
|
||||||
@@ -979,6 +1027,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
*/
|
*/
|
||||||
public void setProperty(NodeRef nodeRef, QName qname, Serializable value) throws InvalidNodeRefException
|
public void setProperty(NodeRef nodeRef, QName qname, Serializable value) throws InvalidNodeRefException
|
||||||
{
|
{
|
||||||
|
// Invoke policy behaviors.
|
||||||
|
invokeBeforeUpdateNode(nodeRef);
|
||||||
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
||||||
// TODO Just until we can set built in properties on AVM Nodes.
|
// TODO Just until we can set built in properties on AVM Nodes.
|
||||||
if (isBuiltInProperty(qname))
|
if (isBuiltInProperty(qname))
|
||||||
@@ -995,6 +1045,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
fAVMService.setNodeProperty((String)avmVersionPath[1], qname, new PropertyValue(null, value));
|
fAVMService.setNodeProperty((String)avmVersionPath[1], qname, new PropertyValue(null, value));
|
||||||
|
// Invoke policy behaviors.
|
||||||
|
invokeOnUpdateNode(nodeRef);
|
||||||
}
|
}
|
||||||
catch (AVMNotFoundException e)
|
catch (AVMNotFoundException e)
|
||||||
{
|
{
|
||||||
@@ -1291,8 +1343,6 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
String [] splitPath = AVMNodeConverter.SplitBase(currPath);
|
String [] splitPath = AVMNodeConverter.SplitBase(currPath);
|
||||||
String parentPath = splitPath[0];
|
String parentPath = splitPath[0];
|
||||||
String name = splitPath[1];
|
String name = splitPath[1];
|
||||||
// TODO Remove when understood.
|
|
||||||
fgLogger.error("parentpath = " + parentPath);
|
|
||||||
ChildAssociationRef caRef =
|
ChildAssociationRef caRef =
|
||||||
new ChildAssociationRef(ContentModel.ASSOC_CONTAINS,
|
new ChildAssociationRef(ContentModel.ASSOC_CONTAINS,
|
||||||
AVMNodeConverter.ToNodeRef(version, parentPath),
|
AVMNodeConverter.ToNodeRef(version, parentPath),
|
||||||
@@ -1308,8 +1358,6 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
AVMNodeConverter.ToNodeRef(version,
|
AVMNodeConverter.ToNodeRef(version,
|
||||||
currPath));
|
currPath));
|
||||||
path.prepend(new Path.ChildAssocElement(caRef));
|
path.prepend(new Path.ChildAssocElement(caRef));
|
||||||
// TODO Get rid of this when you figure this out.
|
|
||||||
fgLogger.error(path);
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user