Aspects on AVM nodes are copied on write. Also missing configuration change

from last checkin.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3699 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-09-05 18:22:40 +00:00
parent 1fd96d13d5
commit fff09ab01d
7 changed files with 44 additions and 3 deletions

View File

@@ -213,6 +213,9 @@
<entry key="avm"><ref bean="avmNodeService"/></entry> <entry key="avm"><ref bean="avmNodeService"/></entry>
</map> </map>
</property> </property>
<property name="defaultNodeService">
<ref bean="dbNodeService"/>
</property>
</bean> </bean>
<bean id="nodeDaoServiceImpl" class="org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl"> <bean id="nodeDaoServiceImpl" class="org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl">

View File

@@ -310,6 +310,24 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
} }
} }
/**
* Copy all aspects from another node.
* @param other The other node.
*/
protected void copyAspects(AVMNode other)
{
List<AVMAspectName> aspects =
AVMContext.fgInstance.fAVMAspectNameDAO.get(other);
for (AVMAspectName name : aspects)
{
AVMAspectName newName =
new AVMAspectNameImpl();
newName.setName(name.getName());
newName.setNode(this);
AVMContext.fgInstance.fAVMAspectNameDAO.save(newName);
}
}
/** /**
* Set a property on a node. Overwrite it if it exists. * Set a property on a node. Overwrite it if it exists.
* @param name The name of the property. * @param name The name of the property.

View File

@@ -2220,7 +2220,9 @@ public class AVMServiceTest extends AVMServiceTestBase
assertFalse(fService.hasAspect(-1, "main:/a/b/c/foo", ContentModel.ASPECT_AUTHOR)); assertFalse(fService.hasAspect(-1, "main:/a/b/c/foo", ContentModel.ASPECT_AUTHOR));
fService.removeAspect("main:/a/b/c/foo", ContentModel.ASPECT_TITLED); fService.removeAspect("main:/a/b/c/foo", ContentModel.ASPECT_TITLED);
fService.createSnapshot("main"); fService.createSnapshot("main");
fService.getFileOutputStream("main:/a/b/c/foo").close();
assertFalse(fService.hasAspect(-1, "main:/a/b/c/foo", ContentModel.ASPECT_TITLED)); assertFalse(fService.hasAspect(-1, "main:/a/b/c/foo", ContentModel.ASPECT_TITLED));
assertTrue(fService.hasAspect(-1, "main:/a/b/c/foo", ContentModel.ASPECT_AUDITABLE));
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -114,6 +114,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
} }
AVMContext.fgInstance.fAVMNodeDAO.flush(); AVMContext.fgInstance.fAVMNodeDAO.flush();
copyProperties(other); copyProperties(other);
copyAspects(other);
} }
/** /**
@@ -147,6 +148,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
} }
AVMContext.fgInstance.fAVMNodeDAO.flush(); AVMContext.fgInstance.fAVMNodeDAO.flush();
copyProperties(other); copyProperties(other);
copyAspects(other);
} }
/** /**
@@ -170,6 +172,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush(); AVMContext.fgInstance.fAVMNodeDAO.flush();
copyProperties(dir); copyProperties(dir);
copyAspects(dir);
} }
/** /**

View File

@@ -54,6 +54,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush(); AVMContext.fgInstance.fAVMNodeDAO.flush();
copyProperties(other); copyProperties(other);
copyAspects(other);
} }
/** /**
@@ -83,10 +84,12 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
{ {
throw new AVMException("Unbacked layered file node."); throw new AVMException("Unbacked layered file node.");
} }
// TODO This doesn't look quite right.
PlainFileNodeImpl newMe = new PlainFileNodeImpl(lPath.getAVMStore(), PlainFileNodeImpl newMe = new PlainFileNodeImpl(lPath.getAVMStore(),
getBasicAttributes(), getBasicAttributes(),
getContentData(lPath), getContentData(lPath),
getProperties()); indirect.getProperties(),
AVMContext.fgInstance.fAVMAspectNameDAO.get(indirect));
newMe.setAncestor(this); newMe.setAncestor(this);
return newMe; return newMe;
} }

View File

@@ -73,6 +73,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
} }
AVMContext.fgInstance.fAVMNodeDAO.flush(); AVMContext.fgInstance.fAVMNodeDAO.flush();
copyProperties(other); copyProperties(other);
copyAspects(other);
} }
/** /**

View File

@@ -17,6 +17,7 @@
package org.alfresco.repo.avm; package org.alfresco.repo.avm;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.alfresco.repo.domain.PropertyValue; import org.alfresco.repo.domain.PropertyValue;
@@ -90,6 +91,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush(); AVMContext.fgInstance.fAVMNodeDAO.flush();
copyProperties(other); copyProperties(other);
copyAspects(other);
} }
/** /**
@@ -102,14 +104,23 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
public PlainFileNodeImpl(AVMStore store, public PlainFileNodeImpl(AVMStore store,
BasicAttributes attrs, BasicAttributes attrs,
ContentData content, ContentData content,
Map<QName, PropertyValue> props) Map<QName, PropertyValue> props,
List<AVMAspectName> aspects)
{ {
super(store.getAVMRepository().issueID(), store); super(store.getAVMRepository().issueID(), store);
setContentData(content); setContentData(content);
setBasicAttributes(attrs); setBasicAttributes(attrs);
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush(); AVMContext.fgInstance.fAVMNodeDAO.flush();
this.setProperties(props); setProperties(props);
for (AVMAspectName name : aspects)
{
AVMAspectName newName =
new AVMAspectNameImpl();
newName.setName(name.getName());
newName.setNode(this);
AVMContext.fgInstance.fAVMAspectNameDAO.save(newName);
}
} }
/** /**