mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
This brings the AVM implementation to the 'it compiles so it should work"
state. It's hooked up to nothing right now. First will be a basic test harness for it, then... git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@2891 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
</id>
|
||||
<discriminator column="class_type" type="string" length="20"></discriminator>
|
||||
<version column="vers" name="vers" type="long"></version>
|
||||
<many-to-one name="basicAttributes" column="basic_attrs"
|
||||
class="BasicAttributesBeanImpl" unique="true" cascade="all">
|
||||
</many-to-one>
|
||||
<many-to-one name="ancestor" column="ancestor_id"
|
||||
class="AVMNodeBeanImpl">
|
||||
</many-to-one>
|
||||
@@ -95,4 +98,17 @@
|
||||
</subclass>
|
||||
</subclass>
|
||||
</class>
|
||||
<class name="BasicAttributesBeanImpl" proxy="BasicAttributesBean"
|
||||
lazy="true" optimistic-lock="version" table="basic_attributes">
|
||||
<id name="id" type="long">
|
||||
<generator class="native"></generator>
|
||||
</id>
|
||||
<version column="vers" name="vers" type="long"></version>
|
||||
<property name="creator" type="string" not-null="true"></property>
|
||||
<property name="owner" type="string" not-null="true"></property>
|
||||
<property name="lastModifier" type="string" not-null="true"></property>
|
||||
<property name="createDate" type="long" not-null="true"></property>
|
||||
<property name="modDate" type="long" not-null="true"></property>
|
||||
<property name="accessDate" type="long" not-null="true"></property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
|
@@ -131,4 +131,16 @@ public interface AVMNodeBean
|
||||
* @return The version.
|
||||
*/
|
||||
public long getVers();
|
||||
|
||||
/**
|
||||
* Set the basic attributes.
|
||||
* @param attrs The attributes to set.
|
||||
*/
|
||||
public void setBasicAttributes(BasicAttributesBean attrs);
|
||||
|
||||
/**
|
||||
* Get the basic attributes.
|
||||
* @return The attributes.
|
||||
*/
|
||||
public BasicAttributesBean getBasicAttributes();
|
||||
}
|
@@ -58,6 +58,11 @@ public class AVMNodeBeanImpl implements AVMNodeBean
|
||||
*/
|
||||
private RepositoryBean fRepository;
|
||||
|
||||
/**
|
||||
* The BasicAttributes.
|
||||
*/
|
||||
private BasicAttributesBean fBasicAttributes;
|
||||
|
||||
/**
|
||||
* Whether this node is new (and should therefore not be COWed).
|
||||
*/
|
||||
@@ -91,7 +96,8 @@ public class AVMNodeBeanImpl implements AVMNodeBean
|
||||
AVMNodeBean ancestor,
|
||||
AVMNodeBean mergedFrom,
|
||||
DirectoryNodeBean parent,
|
||||
RepositoryBean repository)
|
||||
RepositoryBean repository,
|
||||
BasicAttributesBean attrs)
|
||||
{
|
||||
fID = id;
|
||||
fVersionID = versionID;
|
||||
@@ -101,6 +107,7 @@ public class AVMNodeBeanImpl implements AVMNodeBean
|
||||
fParent = parent;
|
||||
fRepository = repository;
|
||||
fIsNew = true;
|
||||
fBasicAttributes = attrs;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -272,4 +279,20 @@ public class AVMNodeBeanImpl implements AVMNodeBean
|
||||
{
|
||||
fVers = vers;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.AVMNodeBean#getBasicAttributes()
|
||||
*/
|
||||
public BasicAttributesBean getBasicAttributes()
|
||||
{
|
||||
return fBasicAttributes;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.AVMNodeBean#setBasicAttributes(org.alfresco.repo.avm.hibernate.BasicAttributesBean)
|
||||
*/
|
||||
public void setBasicAttributes(BasicAttributesBean attrs)
|
||||
{
|
||||
fBasicAttributes = attrs;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.alfresco.repo.avm.hibernate;
|
||||
|
||||
/**
|
||||
* Ownership, timestamps, later perhaps ACLs
|
||||
* @author britt
|
||||
*/
|
||||
public interface BasicAttributesBean
|
||||
{
|
||||
/**
|
||||
* Set the id.
|
||||
* @param id
|
||||
*/
|
||||
public void setId(Long id);
|
||||
|
||||
/**
|
||||
* Get the id.
|
||||
* @return The id.
|
||||
*/
|
||||
public Long getId();
|
||||
|
||||
/**
|
||||
* Set the version (for concurrency control.)
|
||||
*/
|
||||
public void setVers(long vers);
|
||||
|
||||
/**
|
||||
* Get the version (for concurrency control.)
|
||||
*/
|
||||
public long getVers();
|
||||
|
||||
/**
|
||||
* Set the creator of the node.
|
||||
* @param creator The creator to set.
|
||||
*/
|
||||
public void setCreator(String creator);
|
||||
|
||||
/**
|
||||
* Get the creator of the node.
|
||||
* @return The creator.
|
||||
*/
|
||||
public String getCreator();
|
||||
|
||||
/**
|
||||
* Set the owner of the node.
|
||||
* @param owner The owner to set.
|
||||
*/
|
||||
public void setOwner(String owner);
|
||||
|
||||
/**
|
||||
* Get the owner of the node.
|
||||
* @return The owner.
|
||||
*/
|
||||
public String getOwner();
|
||||
|
||||
/**
|
||||
* Set the last modifier of the node.
|
||||
* @param lastModifier
|
||||
*/
|
||||
public void setLastModifier(String lastModifier);
|
||||
|
||||
/**
|
||||
* Get the last modifier of the node.
|
||||
* @return The last modifier.
|
||||
*/
|
||||
public String getLastModifier();
|
||||
|
||||
/**
|
||||
* Set the create date.
|
||||
* @param createDate The date to set.
|
||||
*/
|
||||
public void setCreateDate(long createDate);
|
||||
|
||||
/**
|
||||
* Get the create date.
|
||||
* @return The create date.
|
||||
*/
|
||||
public long getCreateDate();
|
||||
|
||||
/**
|
||||
* Set the modification date.
|
||||
* @param modDate The date to set.
|
||||
*/
|
||||
public void setModDate(long modDate);
|
||||
|
||||
/**
|
||||
* Get the modification date.
|
||||
* @return The modification date.
|
||||
*/
|
||||
public long getModDate();
|
||||
|
||||
/**
|
||||
* Set the access date of the node.
|
||||
* @param accessDate The access date.
|
||||
*/
|
||||
public void setAccessDate(long accessDate);
|
||||
|
||||
/**
|
||||
* Get the access date of the node.
|
||||
* @return The access date.
|
||||
*/
|
||||
public long getAccessDate();
|
||||
}
|
@@ -0,0 +1,225 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.alfresco.repo.avm.hibernate;
|
||||
|
||||
/**
|
||||
* Implementation of the BasicAttributesBean.
|
||||
* @author britt
|
||||
*
|
||||
*/
|
||||
public class BasicAttributesBeanImpl implements BasicAttributesBean
|
||||
{
|
||||
/**
|
||||
* The id.
|
||||
*/
|
||||
private Long fID;
|
||||
|
||||
/**
|
||||
* The version for concurrency control.
|
||||
*/
|
||||
private long fVers;
|
||||
|
||||
/**
|
||||
* The creator.
|
||||
*/
|
||||
private String fCreator;
|
||||
|
||||
/**
|
||||
* The owner.
|
||||
*/
|
||||
private String fOwner;
|
||||
|
||||
/**
|
||||
* The last modifier.
|
||||
*/
|
||||
private String fLastModifier;
|
||||
|
||||
/**
|
||||
* The creation date.
|
||||
*/
|
||||
private long fCreateDate;
|
||||
|
||||
/**
|
||||
* The modification date.
|
||||
*/
|
||||
private long fModDate;
|
||||
|
||||
/**
|
||||
* The access date.
|
||||
*/
|
||||
private long fAccessDate;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#getId()
|
||||
*/
|
||||
public Long getId()
|
||||
{
|
||||
return fID;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#setId(java.lang.Long)
|
||||
*/
|
||||
public void setId(Long id)
|
||||
{
|
||||
fID = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public BasicAttributesBeanImpl()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A Copy constructor.
|
||||
* @param other
|
||||
*/
|
||||
public BasicAttributesBeanImpl(BasicAttributesBean other)
|
||||
{
|
||||
fCreator = other.getCreator();
|
||||
fOwner = other.getOwner();
|
||||
fLastModifier = other.getLastModifier();
|
||||
fCreateDate = other.getCreateDate();
|
||||
fModDate = other.getModDate();
|
||||
fAccessDate = other.getAccessDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill in the blanks constructor.
|
||||
* @param creator
|
||||
* @param owner
|
||||
* @param modifier
|
||||
* @param createDate
|
||||
* @param modDate
|
||||
* @param accessDate
|
||||
*/
|
||||
public BasicAttributesBeanImpl(String creator,
|
||||
String owner,
|
||||
String modifier,
|
||||
long createDate,
|
||||
long modDate,
|
||||
long accessDate)
|
||||
{
|
||||
fCreator = creator;
|
||||
fOwner = owner;
|
||||
fLastModifier = modifier;
|
||||
fCreateDate = createDate;
|
||||
fModDate = modDate;
|
||||
fAccessDate = accessDate;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#getVers()
|
||||
*/
|
||||
public long getVers()
|
||||
{
|
||||
return fVers;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#setVers(long)
|
||||
*/
|
||||
public void setVers(long vers)
|
||||
{
|
||||
fVers = vers;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#setCreator(java.lang.String)
|
||||
*/
|
||||
public void setCreator(String creator)
|
||||
{
|
||||
fCreator = creator;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#getCreator()
|
||||
*/
|
||||
public String getCreator()
|
||||
{
|
||||
return fCreator;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#setOwner(java.lang.String)
|
||||
*/
|
||||
public void setOwner(String owner)
|
||||
{
|
||||
fOwner = owner;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#getOwner()
|
||||
*/
|
||||
public String getOwner()
|
||||
{
|
||||
return fOwner;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#setLastModifier(java.lang.String)
|
||||
*/
|
||||
public void setLastModifier(String lastModifier)
|
||||
{
|
||||
fLastModifier = lastModifier;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#getLastModifier()
|
||||
*/
|
||||
public String getLastModifier()
|
||||
{
|
||||
return fLastModifier;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#setCreateDate(long)
|
||||
*/
|
||||
public void setCreateDate(long createDate)
|
||||
{
|
||||
fCreateDate = createDate;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#getCreateDate()
|
||||
*/
|
||||
public long getCreateDate()
|
||||
{
|
||||
return fCreateDate;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#setModDate(long)
|
||||
*/
|
||||
public void setModDate(long modDate)
|
||||
{
|
||||
fModDate = modDate;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#getModDate()
|
||||
*/
|
||||
public long getModDate()
|
||||
{
|
||||
return fModDate;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#setAccessDate(long)
|
||||
*/
|
||||
public void setAccessDate(long accessDate)
|
||||
{
|
||||
fAccessDate = accessDate;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.hibernate.BasicAttributesBean#getAccessDate()
|
||||
*/
|
||||
public long getAccessDate()
|
||||
{
|
||||
return fAccessDate;
|
||||
}
|
||||
}
|
@@ -46,8 +46,9 @@ public class DirectoryNodeBeanImpl extends AVMNodeBeanImpl implements DirectoryN
|
||||
AVMNodeBean ancestor,
|
||||
AVMNodeBean mergedFrom,
|
||||
DirectoryNodeBean parent,
|
||||
RepositoryBean repository)
|
||||
RepositoryBean repository,
|
||||
BasicAttributesBean attrs)
|
||||
{
|
||||
super(id, versionID, branchID, ancestor, mergedFrom, parent, repository);
|
||||
super(id, versionID, branchID, ancestor, mergedFrom, parent, repository, attrs);
|
||||
}
|
||||
}
|
||||
|
@@ -47,8 +47,9 @@ public class FileNodeBeanImpl extends AVMNodeBeanImpl implements FileNodeBean
|
||||
AVMNodeBean ancestor,
|
||||
AVMNodeBean mergedFrom,
|
||||
DirectoryNodeBean parent,
|
||||
RepositoryBean repository)
|
||||
RepositoryBean repository,
|
||||
BasicAttributesBean attrs)
|
||||
{
|
||||
super(id, versionID, branchID, ancestor, mergedFrom, parent, repository);
|
||||
super(id, versionID, branchID, ancestor, mergedFrom, parent, repository, attrs);
|
||||
}
|
||||
}
|
||||
|
@@ -81,10 +81,11 @@ public class LayeredDirectoryNodeBeanImpl extends DirectoryNodeBeanImpl implemen
|
||||
AVMNodeBean mergedFrom,
|
||||
DirectoryNodeBean parent,
|
||||
RepositoryBean repository,
|
||||
BasicAttributesBean attrs,
|
||||
long layerID,
|
||||
String indirection)
|
||||
{
|
||||
super(id, versionID, branchID, ancestor, mergedFrom, parent, repository);
|
||||
super(id, versionID, branchID, ancestor, mergedFrom, parent, repository, attrs);
|
||||
fLayerID = layerID;
|
||||
fIndirection = indirection;
|
||||
fAdded = new HashMap<String, DirectoryEntry>();
|
||||
|
@@ -54,9 +54,10 @@ public class LayeredFileNodeBeanImpl extends FileNodeBeanImpl implements
|
||||
AVMNodeBean mergedFrom,
|
||||
DirectoryNodeBean parent,
|
||||
RepositoryBean repository,
|
||||
BasicAttributesBean attrs,
|
||||
String indirection)
|
||||
{
|
||||
super(id, versionID, branchID, ancestor, mergedFrom, parent, repository);
|
||||
super(id, versionID, branchID, ancestor, mergedFrom, parent, repository, attrs);
|
||||
fIndirection = indirection;
|
||||
}
|
||||
|
||||
|
@@ -61,9 +61,10 @@ public class PlainDirectoryNodeBeanImpl extends DirectoryNodeBeanImpl implements
|
||||
AVMNodeBean mergedFrom,
|
||||
DirectoryNodeBean parent,
|
||||
RepositoryBean repository,
|
||||
BasicAttributesBean attrs,
|
||||
boolean isRoot)
|
||||
{
|
||||
super(id, versionID, branchID, ancestor, mergedFrom, parent, repository);
|
||||
super(id, versionID, branchID, ancestor, mergedFrom, parent, repository, attrs);
|
||||
fChildren = new HashMap<String, DirectoryEntry>();
|
||||
fIsRoot = isRoot;
|
||||
}
|
||||
|
@@ -54,9 +54,10 @@ public class PlainFileNodeBeanImpl extends FileNodeBeanImpl implements PlainFile
|
||||
AVMNodeBean mergedFrom,
|
||||
DirectoryNodeBean parent,
|
||||
RepositoryBean repository,
|
||||
BasicAttributesBean attrs,
|
||||
ContentBean content)
|
||||
{
|
||||
super(id, versionID, branchID, ancestor, mergedFrom, parent, repository);
|
||||
super(id, versionID, branchID, ancestor, mergedFrom, parent, repository, attrs);
|
||||
fContent = content;
|
||||
}
|
||||
|
||||
|
@@ -80,7 +80,15 @@ public class TestPopulate extends TestCase
|
||||
Issuer contentIssuer = new Issuer("content", 0);
|
||||
Issuer repositoryIssuer = new Issuer("repository", 0);
|
||||
// Make the initial root directory.
|
||||
PlainDirectoryNodeBean root =
|
||||
long time = System.currentTimeMillis();
|
||||
BasicAttributesBean attrs = new BasicAttributesBeanImpl("britt",
|
||||
"britt",
|
||||
"britt",
|
||||
time,
|
||||
time,
|
||||
time);
|
||||
session.save(attrs);
|
||||
PlainDirectoryNodeBean root =
|
||||
new PlainDirectoryNodeBeanImpl(nodeIssuer.issue(),
|
||||
0,
|
||||
0,
|
||||
@@ -88,6 +96,7 @@ public class TestPopulate extends TestCase
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
attrs,
|
||||
true);
|
||||
// Make a new repository.
|
||||
RepositoryBean rep =
|
||||
@@ -112,11 +121,19 @@ public class TestPopulate extends TestCase
|
||||
// Now read some things back, and modify some stuff.
|
||||
Issuer nodeIssuer = (Issuer)session.get(Issuer.class, "node");
|
||||
Issuer contentIssuer = (Issuer)session.get(Issuer.class, "content");
|
||||
RepositoryBean rep = (RepositoryBean)session.get(RepositoryBeanImpl.class, 0L);
|
||||
RepositoryBean rep = (RepositoryBean)session.get(RepositoryBeanImpl.class, "main");
|
||||
long version = rep.getNextVersionID();
|
||||
rep.setNextVersionID(version + 1);
|
||||
assertTrue(rep != null);
|
||||
PlainDirectoryNodeBean root = (PlainDirectoryNodeBean)rep.getRoot();
|
||||
long time = System.currentTimeMillis();
|
||||
BasicAttributesBean attrs = new BasicAttributesBeanImpl("britt",
|
||||
"britt",
|
||||
"britt",
|
||||
time,
|
||||
time,
|
||||
time);
|
||||
session.save(attrs);
|
||||
PlainDirectoryNodeBean newRoot = new PlainDirectoryNodeBeanImpl(nodeIssuer.issue(),
|
||||
version,
|
||||
0L,
|
||||
@@ -124,8 +141,11 @@ public class TestPopulate extends TestCase
|
||||
null,
|
||||
null,
|
||||
rep,
|
||||
attrs,
|
||||
true);
|
||||
ContentBean content = new ContentBeanImpl(contentIssuer.issue());
|
||||
attrs = new BasicAttributesBeanImpl(attrs);
|
||||
session.save(attrs);
|
||||
PlainFileNodeBean file = new PlainFileNodeBeanImpl(nodeIssuer.issue(),
|
||||
version,
|
||||
0L,
|
||||
@@ -133,6 +153,7 @@ public class TestPopulate extends TestCase
|
||||
null,
|
||||
newRoot,
|
||||
rep,
|
||||
attrs,
|
||||
content);
|
||||
content.setRefCount(content.getRefCount() + 1);
|
||||
newRoot.getChildren().put("foo", new DirectoryEntry(AVMNodeType.PLAIN_FILE, file));
|
||||
@@ -141,6 +162,8 @@ public class TestPopulate extends TestCase
|
||||
content = new ContentBeanImpl(contentIssuer.issue());
|
||||
content.setRefCount(content.getRefCount() + 1);
|
||||
file.setIsNew(false);
|
||||
attrs = new BasicAttributesBeanImpl(attrs);
|
||||
session.save(attrs);
|
||||
file = new PlainFileNodeBeanImpl(nodeIssuer.issue(),
|
||||
version,
|
||||
0L,
|
||||
@@ -148,6 +171,7 @@ public class TestPopulate extends TestCase
|
||||
null,
|
||||
newRoot,
|
||||
rep,
|
||||
attrs,
|
||||
content);
|
||||
session.save(content);
|
||||
file.setIsNew(false);
|
||||
@@ -187,11 +211,11 @@ public class TestPopulate extends TestCase
|
||||
{
|
||||
public void perform(Session session)
|
||||
{
|
||||
RepositoryBean rep = (RepositoryBean)session.get(RepositoryBeanImpl.class, 0L);
|
||||
RepositoryBean rep = (RepositoryBean)session.get(RepositoryBeanImpl.class, "main");
|
||||
PlainDirectoryNodeBean root = (PlainDirectoryNodeBean)rep.getRoot();
|
||||
PlainDirectoryNodeBean prev = (PlainDirectoryNodeBean)root.getAncestor();
|
||||
rep.getRoots().remove(rep.getRoot().getId());
|
||||
rep.setRoot(prev);
|
||||
rep.getRoots().remove(1);
|
||||
for (String name : root.getChildren().keySet())
|
||||
{
|
||||
AVMNodeBean child = root.getChildren().get(name).getChild();
|
||||
|
Reference in New Issue
Block a user