Fairly complete test coverage of basic sanity type operations: createFile, createDirectory,

createBranch, createLayeredDirectory, createLayeredFile, rename, delete, read, write, snapshot,
listDirectory.  Rename, createLayeredDirectory, createBranch all tested across repositories also. 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@2940 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-05-22 19:03:46 +00:00
parent 11037b2451
commit bd0752eb4a
11 changed files with 342 additions and 47 deletions

View File

@@ -9,12 +9,13 @@
<property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="current_session_context_class">thread</property> <property name="current_session_context_class">thread</property>
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="show_sql">true</property> <property name="show_sql">false</property>
<property name="connection.isolation">2</property> <property name="connection.isolation">2</property>
<property name="c3po.min_size">5</property> <property name="c3po.min_size">5</property>
<property name="c3po.max_size">20</property> <property name="c3po.max_size">20</property>
<property name="c3po.timeout">900</property> <property name="c3po.timeout">900</property>
<property name="c3po.max_statements">50</property> <property name="c3po.max_statements">50</property>
<!-- <property name="cache.use_query_cache">true</property> -->
<mapping resource="org/alfresco/repo/avm/hibernate/AVM.hbm.xml"/> <mapping resource="org/alfresco/repo/avm/hibernate/AVM.hbm.xml"/>
</session-factory> </session-factory>
</hibernate-configuration> </hibernate-configuration>

View File

@@ -17,6 +17,8 @@
package org.alfresco.repo.avm; package org.alfresco.repo.avm;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -25,6 +27,7 @@ import java.util.Set;
import org.alfresco.repo.avm.hibernate.HibernateHelper; import org.alfresco.repo.avm.hibernate.HibernateHelper;
import org.alfresco.repo.avm.impl.AVMServiceImpl; import org.alfresco.repo.avm.impl.AVMServiceImpl;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.stat.Statistics;
import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.hbm2ddl.SchemaExport;
import junit.framework.TestCase; import junit.framework.TestCase;
@@ -40,6 +43,11 @@ public class AVMServiceTest extends TestCase
*/ */
private AVMService fService; private AVMService fService;
/**
* The start time of actual work for a test.
*/
private long fStartTime;
/* (non-Javadoc) /* (non-Javadoc)
* @see junit.framework.TestCase#setUp() * @see junit.framework.TestCase#setUp()
*/ */
@@ -47,11 +55,13 @@ public class AVMServiceTest extends TestCase
protected void setUp() throws Exception protected void setUp() throws Exception
{ {
Configuration cfg = HibernateHelper.GetConfiguration(); Configuration cfg = HibernateHelper.GetConfiguration();
HibernateHelper.GetSessionFactory().getStatistics().setStatisticsEnabled(true);
SchemaExport se = new SchemaExport(cfg); SchemaExport se = new SchemaExport(cfg);
se.drop(false, true); se.drop(false, true);
AVMServiceImpl service = new AVMServiceImpl(); AVMServiceImpl service = new AVMServiceImpl();
service.setStorage("storage"); service.setStorage("storage");
service.init(true); service.init(true);
fStartTime = System.currentTimeMillis();
fService = service; fService = service;
} }
@@ -61,6 +71,11 @@ public class AVMServiceTest extends TestCase
@Override @Override
protected void tearDown() throws Exception protected void tearDown() throws Exception
{ {
long now = System.currentTimeMillis();
System.out.println("Timing: " + (now - fStartTime) + "ms");
Statistics stats = HibernateHelper.GetSessionFactory().getStatistics();
stats.logSummary();
stats.clear();
HibernateHelper.Reset(); HibernateHelper.Reset();
} }
@@ -98,13 +113,13 @@ public class AVMServiceTest extends TestCase
try try
{ {
testCreateDirectory(); testCreateDirectory();
fService.createFile("main:testdir", "testfile"); fService.createFile("main:/testdir", "testfile");
fService.createFile("main:/", "testfile2"); fService.createFile("main:/", "testfile2");
fService.createSnapshot("main"); fService.createSnapshot("main");
PrintStream out = new PrintStream(fService.getFileOutputStream("main:testdir/testfile")); PrintStream out = new PrintStream(fService.getFileOutputStream("main:/testdir/testfile"));
out.println("This is testdir/testfile"); out.println("This is testdir/testfile");
out.close(); out.close();
out = new PrintStream(fService.getFileOutputStream("main:testfile2")); out = new PrintStream(fService.getFileOutputStream("main:/testfile2"));
out.println("This is testfile2"); out.println("This is testfile2");
out.close(); out.close();
fService.createSnapshot("main"); fService.createSnapshot("main");
@@ -114,6 +129,15 @@ public class AVMServiceTest extends TestCase
System.out.println("V:" + version); System.out.println("V:" + version);
System.out.println(recursiveList("main", version)); System.out.println(recursiveList("main", version));
} }
BufferedReader reader =
new BufferedReader(new InputStreamReader(fService.getFileInputStream(-1, "main:/testdir/testfile")));
String line = reader.readLine();
assertEquals("This is testdir/testfile", line);
reader.close();
reader =
new BufferedReader(new InputStreamReader(fService.getFileInputStream(-1, "main:/testfile2")));
line = reader.readLine();
assertEquals("This is testfile2", line);
} }
catch (Exception e) catch (Exception e)
{ {
@@ -130,7 +154,7 @@ public class AVMServiceTest extends TestCase
try try
{ {
setupBasicTree(); setupBasicTree();
fService.createBranch(-1, "main:a", "main:d/e", "abranch"); fService.createBranch(-1, "main:/a", "main:/d/e", "abranch");
fService.createSnapshot("main"); fService.createSnapshot("main");
Set<Integer> versions = fService.getRepositoryVersions("main"); Set<Integer> versions = fService.getRepositoryVersions("main");
for (Integer version : versions) for (Integer version : versions)
@@ -138,8 +162,10 @@ public class AVMServiceTest extends TestCase
System.out.println("V:" + version); System.out.println("V:" + version);
System.out.println(recursiveList("main", version)); System.out.println(recursiveList("main", version));
} }
List<FolderEntry> original = fService.getDirectoryListing(-1, "main:a"); String original = recursiveList("main:/a", -1, 0);
List<FolderEntry> branch = fService.getDirectoryListing(-1, "main:d/e/abranch"); original = original.substring(original.indexOf('\n'));
String branch = recursiveList("main:/d/e/abranch", -1, 0);
branch = branch.substring(branch.indexOf('\n'));
assertEquals(original, branch); assertEquals(original, branch);
} }
catch (Exception e) catch (Exception e)
@@ -157,12 +183,226 @@ public class AVMServiceTest extends TestCase
try try
{ {
setupBasicTree(); setupBasicTree();
fService.createLayeredDirectory("main:a", "main:d/e", "alayer"); fService.createLayeredDirectory("main:/a", "main:/d/e", "alayer");
fService.createSnapshot("main"); fService.createSnapshot("main");
System.out.println(recursiveList("main", -1)); System.out.println(recursiveList("main", -1));
List<FolderEntry> original = fService.getDirectoryListing(-1, "main:a"); assertEquals("main:/a", fService.getIndirectionPath(-1, "main:/d/e/alayer"));
List<FolderEntry> layer = fService.getDirectoryListing(-1, "main:d/e/alayer"); String original = recursiveList("main:/a", -1, 0);
original = original.substring(original.indexOf('\n'));
String layer = recursiveList("main:/d/e/alayer", -1, 0);
layer = original.substring(original.indexOf('\n'));
assertEquals(original, layer); assertEquals(original, layer);
PrintStream out = new PrintStream(fService.getFileOutputStream("main:/d/e/alayer/b/c/foo"));
out.println("I am main:/d/e/alayer/b/c/foo");
out.close();
fService.createSnapshot("main");
BufferedReader reader =
new BufferedReader(new InputStreamReader(fService.getFileInputStream(-1, "main:/a/b/c/foo")));
String line = reader.readLine();
reader.close();
assertEquals("I am main:/a/b/c/foo", line);
System.out.println(recursiveList("main", -1));
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
/**
* Test creating a layered file.
*/
public void testCreateLayeredFile()
{
try
{
setupBasicTree();
fService.createLayeredFile("main:/a/b/c/foo", "main:/d", "lfoo");
fService.createSnapshot("main");
System.out.println(recursiveList("main", -1));
assertEquals("main:/a/b/c/foo", fService.getIndirectionPath(-1, "main:/d/lfoo"));
BufferedReader reader =
new BufferedReader(new InputStreamReader(fService.getFileInputStream(-1, "main:/d/lfoo")));
String line = reader.readLine();
reader.close();
assertEquals("I am main:/a/b/c/foo", line);
PrintStream out = new PrintStream(fService.getFileOutputStream("main:/d/lfoo"));
out.println("I am main:/d/lfoo");
out.close();
fService.createSnapshot("main");
System.out.println(recursiveList("main", -1));
reader =
new BufferedReader(new InputStreamReader(fService.getFileInputStream(-1, "main:/a/b/c/foo")));
line = reader.readLine();
reader.close();
assertEquals("I am main:/a/b/c/foo", line);
reader =
new BufferedReader(new InputStreamReader(fService.getFileInputStream(-1, "main:/d/lfoo")));
line = reader.readLine();
reader.close();
assertEquals("I am main:/d/lfoo", line);
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
/**
* Test rename.
*/
public void testRename()
{
try
{
setupBasicTree();
fService.rename("main:/a", "b", "main:/d/e", "brenamed");
fService.createSnapshot("main");
System.out.println(recursiveList("main", -1));
String original = recursiveList("main:/a/b", 0, 0);
original = original.substring(original.indexOf('\n'));
String renamed = recursiveList("main:/d/e/brenamed", 1, 0);
renamed = renamed.substring(renamed.indexOf('\n'));
assertEquals(original, renamed);
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
/**
* Test remove.
*/
public void testRemove()
{
try
{
setupBasicTree();
System.out.println(recursiveList("main", -1));
fService.removeNode("main:/a/b/c", "foo");
fService.createSnapshot("main");
System.out.println(recursiveList("main", -1));
List<FolderEntry> l = fService.getDirectoryListing(-1, "main:/a/b/c");
assertEquals(1, l.size());
fService.removeNode("main:/d", "e");
fService.createSnapshot("main");
System.out.println(recursiveList("main", -1));
l = fService.getDirectoryListing(-1, "main:/d");
assertEquals(0, l.size());
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
/**
* Test branching from one repository to another.
*/
public void testBranchAcross()
{
try
{
setupBasicTree();
fService.createRepository("second");
fService.createBranch(-1, "main:/", "second:/", "main");
fService.createSnapshot("second");
System.out.println(recursiveList("second", -1));
String original = recursiveList("main:/", -1, 0);
original = original.substring(original.indexOf('\n'));
String branch = recursiveList("second:/main", -1, 0);
branch = branch.substring(branch.indexOf('\n'));
assertEquals(original, branch);
// Now make sure nothing happens to the branched from place,
// if the branch is modified.
PrintStream out =
new PrintStream(fService.getFileOutputStream("second:/main/a/b/c/foo"));
out.println("I am second:/main/a/b/c/foo");
out.close();
fService.createSnapshot("second");
System.out.println(recursiveList("second", -1));
BufferedReader reader =
new BufferedReader(new InputStreamReader(fService.getFileInputStream(-1, "main:/a/b/c/foo")));
String line = reader.readLine();
reader.close();
assertEquals("I am main:/a/b/c/foo", line);
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
/**
* Test creating a layer across repositories.
*/
public void testLayerAcross()
{
try
{
setupBasicTree();
fService.createRepository("second");
fService.createLayeredDirectory("main:/", "second:/", "main");
fService.createSnapshot("second");
System.out.println(recursiveList("second", -1));
String original = recursiveList("main:/", -1, 0);
original = original.substring(original.indexOf('\n'));
String layer = recursiveList("second:/main", -1, 0);
layer = layer.substring(layer.indexOf('\n'));
assertEquals(original, layer);
// Now make sure that a copy on write will occur and
// that the underlying stuff doesn't get changed.
PrintStream out = new PrintStream(fService.getFileOutputStream("second:/main/a/b/c/foo"));
out.println("I am second:/main/a/b/c/foo");
out.close();
fService.createSnapshot("second");
System.out.println(recursiveList("second", -1));
BufferedReader reader =
new BufferedReader(new InputStreamReader(fService.getFileInputStream(-1, "second:/main/a/b/c/foo")));
String line = reader.readLine();
reader.close();
assertEquals("I am second:/main/a/b/c/foo", line);
reader =
new BufferedReader(new InputStreamReader(fService.getFileInputStream(-1, "main:/a/b/c/foo")));
line = reader.readLine();
reader.close();
assertEquals("I am main:/a/b/c/foo", line);
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
/**
* Test rename across repositories.
*/
public void testRenameAcross()
{
try
{
setupBasicTree();
fService.createRepository("second");
fService.rename("main:/a/b", "c", "second:/", "cmoved");
ArrayList<String> toSnapshot = new ArrayList<String>();
toSnapshot.add("main");
toSnapshot.add("second");
System.out.println(recursiveList("main", -1));
System.out.println(recursiveList("second", -1));
// Check that the moved thing has identical contents to the thing it
// was moved from.
String original = recursiveList("main:/a/b/c", 0, 0);
original = original.substring(original.indexOf('\n'));
String moved = recursiveList("second:/cmoved", -1, 0);
moved = moved.substring(moved.indexOf('\n'));
assertEquals(original, moved);
} }
catch (Exception e) catch (Exception e)
{ {
@@ -194,7 +434,7 @@ public class AVMServiceTest extends TestCase
{ {
builder.append(' '); builder.append(' ');
} }
builder.append(path); builder.append(path.substring(path.lastIndexOf('/') + 1));
builder.append(' '); builder.append(' ');
Lookup lookup = fService.lookup(version, path); Lookup lookup = fService.lookup(version, path);
AVMNode node = lookup.getCurrentNode(); AVMNode node = lookup.getCurrentNode();
@@ -202,7 +442,7 @@ public class AVMServiceTest extends TestCase
builder.append('\n'); builder.append('\n');
if (node instanceof DirectoryNode) if (node instanceof DirectoryNode)
{ {
String basename = path.endsWith("/") ? path.substring(0, path.length() - 1) : path + "/"; String basename = path.endsWith("/") ? path : path + "/";
List<FolderEntry> listing = fService.getDirectoryListing(version, path); List<FolderEntry> listing = fService.getDirectoryListing(version, path);
for (FolderEntry entry : listing) for (FolderEntry entry : listing)
{ {
@@ -218,18 +458,18 @@ public class AVMServiceTest extends TestCase
private void setupBasicTree() private void setupBasicTree()
{ {
fService.createDirectory("main:/", "a"); fService.createDirectory("main:/", "a");
fService.createDirectory("main:a", "b"); fService.createDirectory("main:/a", "b");
fService.createDirectory("main:a/b", "c"); fService.createDirectory("main:/a/b", "c");
fService.createDirectory("main:/", "d"); fService.createDirectory("main:/", "d");
fService.createDirectory("main:d", "e"); fService.createDirectory("main:/d", "e");
fService.createDirectory("main:d/e", "f"); fService.createDirectory("main:/d/e", "f");
fService.createFile("main:a/b/c", "foo"); fService.createFile("main:/a/b/c", "foo");
PrintStream out = new PrintStream(fService.getFileOutputStream("main:a/b/c/foo")); PrintStream out = new PrintStream(fService.getFileOutputStream("main:/a/b/c/foo"));
out.println("I am main:a/b/c/foo"); out.println("I am main:/a/b/c/foo");
out.close(); out.close();
fService.createFile("main:a/b/c", "bar"); fService.createFile("main:/a/b/c", "bar");
out = new PrintStream(fService.getFileOutputStream("main:a/b/c/bar")); out = new PrintStream(fService.getFileOutputStream("main:/a/b/c/bar"));
out.println("I am main:a/b/c/bar"); out.println("I am main:/a/b/c/bar");
out.close(); out.close();
ArrayList<String> toSnapshot = new ArrayList<String>(); ArrayList<String> toSnapshot = new ArrayList<String>();
toSnapshot.add("main"); toSnapshot.add("main");

View File

@@ -18,6 +18,7 @@
package org.alfresco.repo.avm; package org.alfresco.repo.avm;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
@@ -71,7 +72,7 @@ public class LayeredDirectoryNode extends DirectoryNode implements Layered
time); time);
fData = new LayeredDirectoryNodeBeanImpl(repos.getSuperRepository().issueID(), fData = new LayeredDirectoryNodeBeanImpl(repos.getSuperRepository().issueID(),
-1, -1,
-1, 0,
null, null,
null, null,
null, null,
@@ -102,7 +103,7 @@ public class LayeredDirectoryNode extends DirectoryNode implements Layered
attrs.setLastModifier("britt"); attrs.setLastModifier("britt");
fData = new LayeredDirectoryNodeBeanImpl(repos.getSuperRepository().issueID(), fData = new LayeredDirectoryNodeBeanImpl(repos.getSuperRepository().issueID(),
-1, -1,
-1, 0,
null, null,
null, null,
null, null,
@@ -112,8 +113,8 @@ public class LayeredDirectoryNode extends DirectoryNode implements Layered
thatBean.getPrimaryIndirection(), thatBean.getPrimaryIndirection(),
other.getUnderlying()); other.getUnderlying());
setDataBean(fData); setDataBean(fData);
fData.setAdded(thatBean.getAdded()); fData.setAdded(new HashMap<String, DirectoryEntry>(thatBean.getAdded()));
fData.setDeleted(thatBean.getDeleted()); fData.setDeleted(new HashSet<String>(thatBean.getDeleted()));
// fData.setPrimaryIndirection(thatBean.getPrimaryIndirection()); // fData.setPrimaryIndirection(thatBean.getPrimaryIndirection());
repos.getSuperRepository().getSession().save(fData); repos.getSuperRepository().getSession().save(fData);
} }
@@ -135,7 +136,7 @@ public class LayeredDirectoryNode extends DirectoryNode implements Layered
attrs.setLastModifier("britt"); attrs.setLastModifier("britt");
fData = new LayeredDirectoryNodeBeanImpl(repos.getSuperRepository().issueID(), fData = new LayeredDirectoryNodeBeanImpl(repos.getSuperRepository().issueID(),
-1, -1,
-1, 0,
null, null,
null, null,
null, null,
@@ -174,7 +175,7 @@ public class LayeredDirectoryNode extends DirectoryNode implements Layered
attrs.setLastModifier("britt"); attrs.setLastModifier("britt");
fData = new LayeredDirectoryNodeBeanImpl(repo.getSuperRepository().issueID(), fData = new LayeredDirectoryNodeBeanImpl(repo.getSuperRepository().issueID(),
-1, -1,
-1, 0,
null, null,
null, null,
null, null,

View File

@@ -62,7 +62,7 @@ public class LayeredFileNode extends FileNode implements Layered
fData = fData =
new LayeredFileNodeBeanImpl(repo.getSuperRepository().issueID(), new LayeredFileNodeBeanImpl(repo.getSuperRepository().issueID(),
-1, -1,
-1L, 0L,
null, null,
null, null,
null, null,
@@ -99,7 +99,7 @@ public class LayeredFileNode extends FileNode implements Layered
fData = fData =
new LayeredFileNodeBeanImpl(repos.getSuperRepository().issueID(), new LayeredFileNodeBeanImpl(repos.getSuperRepository().issueID(),
-1, -1,
-1L, 0L,
null, null,
null, null,
null, null,
@@ -126,7 +126,7 @@ public class LayeredFileNode extends FileNode implements Layered
time); time);
fData = new LayeredFileNodeBeanImpl(repo.getSuperRepository().issueID(), fData = new LayeredFileNodeBeanImpl(repo.getSuperRepository().issueID(),
-1, -1,
-1L, 0L,
null, null,
null, null,
null, null,
@@ -151,10 +151,16 @@ public class LayeredFileNode extends FileNode implements Layered
*/ */
public AVMNode possiblyCopy(Lookup lPath) public AVMNode possiblyCopy(Lookup lPath)
{ {
// LayeredFileNodes are always copied. Lookup lookup = lPath.getRepository().getSuperRepository().lookup(-1, fData.getIndirection());
// TODO This is busted. Need to set the PlainFileNode contents AVMNode indirect = lookup.getCurrentNode();
// to share with underlying file node. if (!(indirect instanceof FileNode))
PlainFileNode newMe = new PlainFileNode(lPath.getRepository()); {
throw new AlfrescoRuntimeException("Unbacked layered file node.");
}
// This is a mildly dirty trick. We use getContentForRead so as not to startle
// the ultimate destination content into copying itself prematurely.
FileContent content = ((FileNode)indirect).getContentForRead(-1, lPath.getRepository());
PlainFileNode newMe = new PlainFileNode(content, lPath.getRepository(), fData.getBasicAttributes());
newMe.setAncestor(this); newMe.setAncestor(this);
return newMe; return newMe;
} }

View File

@@ -120,7 +120,15 @@ public class Lookup
} }
else else
{ {
comp.setIndirection(fComponents.get(fPosition).getIndirection() + "/" + name); String parentIndirection = fComponents.get(fPosition).getIndirection();
if (parentIndirection.endsWith("/"))
{
comp.setIndirection(parentIndirection + name);
}
else
{
comp.setIndirection(parentIndirection + "/" + name);
}
} }
fLayeredYet = true; fLayeredYet = true;
// Record the first layer seen. // Record the first layer seen.
@@ -278,7 +286,6 @@ public class Lookup
public String getCurrentIndirection() public String getCurrentIndirection()
{ {
String value = fComponents.get(fPosition).getIndirection(); String value = fComponents.get(fPosition).getIndirection();
System.err.println(value);
return value; return value;
} }

View File

@@ -96,7 +96,7 @@ public class PlainDirectoryNode extends DirectoryNode
attrs.setLastModifier("britt"); attrs.setLastModifier("britt");
fData = new PlainDirectoryNodeBeanImpl(repos.getSuperRepository().issueID(), fData = new PlainDirectoryNodeBeanImpl(repos.getSuperRepository().issueID(),
-1, -1,
-1, 0,
null, null,
null, null,
null, null,

View File

@@ -60,7 +60,7 @@ public class PlainFileNode extends FileNode
time); time);
fData = new PlainFileNodeBeanImpl(repos.getSuperRepository().issueID(), fData = new PlainFileNodeBeanImpl(repos.getSuperRepository().issueID(),
-1, -1,
-1, 0,
null, null,
null, null,
null, null,
@@ -92,7 +92,7 @@ public class PlainFileNode extends FileNode
attrs.setLastModifier("britt"); attrs.setLastModifier("britt");
fData = new PlainFileNodeBeanImpl(repos.getSuperRepository().issueID(), fData = new PlainFileNodeBeanImpl(repos.getSuperRepository().issueID(),
-1, -1,
-1, 0,
null, null,
null, null,
null, null,
@@ -104,6 +104,39 @@ public class PlainFileNode extends FileNode
setDataBean(fData); setDataBean(fData);
} }
/**
* Constructor that takes a FileContent to share.
* @param content The FileContent to share.
* @param repos The Repository.
*/
public PlainFileNode(FileContent content,
Repository repos,
BasicAttributesBean oAttrs)
{
// Setup sensible BasicAttributes.
long time = System.currentTimeMillis();
// TODO Figure out how to get user from context.
BasicAttributesBean attrs = new BasicAttributesBeanImpl(oAttrs);
attrs.setCreateDate(time);
attrs.setModDate(time);
attrs.setAccessDate(time);
attrs.setCreator("britt");
attrs.setLastModifier("britt");
fData = new PlainFileNodeBeanImpl(repos.getSuperRepository().issueID(),
-1,
0,
null,
null,
null,
repos.getDataBean(),
attrs,
content.getDataBean());
repos.getSuperRepository().getSession().save(fData);
fData.getContent().setRefCount(fData.getContent().getRefCount() + 1);
setDataBean(fData);
}
/** /**
* Copy on write logic. * Copy on write logic.
* @param lPath The lookup path. * @param lPath The lookup path.

View File

@@ -75,6 +75,7 @@
column="primary_indirection" type="boolean" /> column="primary_indirection" type="boolean" />
<!-- Map of names to DirectoryEntries. --> <!-- Map of names to DirectoryEntries. -->
<map name="added" cascade="all"> <map name="added" cascade="all">
<cache usage="read-write"/>
<key column="directory_id" /> <key column="directory_id" />
<map-key type="string" column="name" /> <map-key type="string" column="name" />
<!-- A DirectoryEntry is a (node)type AVMNode reference pair. <!-- A DirectoryEntry is a (node)type AVMNode reference pair.
@@ -92,6 +93,7 @@
hidden) in this layer. --> hidden) in this layer. -->
<set name="deleted" table="deleted_children" <set name="deleted" table="deleted_children"
fetch="join" cascade="all"> fetch="join" cascade="all">
<cache usage="read-write"/>
<key column="directory_id" /> <key column="directory_id" />
<element type="string" column="name" /> <element type="string" column="name" />
</set> </set>
@@ -108,14 +110,15 @@
<!-- A map of names to DirectoryEntries. In the AVM world, it makes sense <!-- A map of names to DirectoryEntries. In the AVM world, it makes sense
that nodes don't know there own names, only their containers do. --> that nodes don't know there own names, only their containers do. -->
<map name="children" cascade="all"> <map name="children" cascade="all">
<cache usage="read-write"/>
<key column="directory_id" /> <key column="directory_id" />
<map-key type="string" column="name" /> <map-key type="string" column="name" />
<composite-element <composite-element
class="org.alfresco.repo.avm.hibernate.DirectoryEntry"> class="DirectoryEntry">
<property name="type" type="int" <property name="type" type="int"
not-null="true" column="type_code" /> not-null="true" column="type_code" />
<many-to-one name="child" <many-to-one name="child"
class="org.alfresco.repo.avm.hibernate.AVMNodeBeanImpl" class="AVMNodeBeanImpl"
not-null="true" cascade="save-update"> not-null="true" cascade="save-update">
</many-to-one> </many-to-one>
</composite-element> </composite-element>
@@ -186,6 +189,7 @@
<!-- In addition to the current root directory, a Repository maintains a set <!-- In addition to the current root directory, a Repository maintains a set
of versioned root directories. --> of versioned root directories. -->
<map name="roots" table="repository_roots"> <map name="roots" table="repository_roots">
<cache usage="read-write"/>
<key column="repository_id"/> <key column="repository_id"/>
<map-key type="int" column="version_id"/> <map-key type="int" column="version_id"/>
<many-to-many class="DirectoryNodeBeanImpl" <many-to-many class="DirectoryNodeBeanImpl"
@@ -194,6 +198,7 @@
<!-- NewNodes keeps track of those nodes created since the last <!-- NewNodes keeps track of those nodes created since the last
'snapshot' operation. --> 'snapshot' operation. -->
<set table="new_nodes" name="newNodes" cascade="all"> <set table="new_nodes" name="newNodes" cascade="all">
<cache usage="read-write"/>
<key column="repository_id"/> <key column="repository_id"/>
<many-to-many class="AVMNodeBeanImpl" <many-to-many class="AVMNodeBeanImpl"
column="new_node_id"/> column="new_node_id"/>

View File

@@ -17,8 +17,6 @@
package org.alfresco.repo.avm.hibernate; package org.alfresco.repo.avm.hibernate;
import org.alfresco.repo.avm.AVMNodeType;
/** /**
* This holds Directory Entries in directories. * This holds Directory Entries in directories.
* @author britt * @author britt

View File

@@ -244,7 +244,7 @@ public class RepositoryImpl implements Repository
// TODO Reexamine decision to not check validity of srcPath. // TODO Reexamine decision to not check validity of srcPath.
LayeredFileNode newFile = LayeredFileNode newFile =
new LayeredFileNode(srcPath, this); new LayeredFileNode(srcPath, this);
dir.addChild(dstPath, newFile, lPath); dir.addChild(name, newFile, lPath);
newFile.setVersion(getLatestVersion() + 1); newFile.setVersion(getLatestVersion() + 1);
setNew(newFile); setNew(newFile);
} }
@@ -408,6 +408,10 @@ public class RepositoryImpl implements Repository
{ {
throw new AlfrescoRuntimeException("Invalid path: " + path); throw new AlfrescoRuntimeException("Invalid path: " + path);
} }
if (path.length() > 1)
{
path = path.substring(1);
}
String[] pathElements = path.split("/"); String[] pathElements = path.split("/");
// Grab the root node to start the lookup. // Grab the root node to start the lookup.
DirectoryNode dir = null; DirectoryNode dir = null;

View File

@@ -217,7 +217,7 @@ public class SuperRepositoryImpl implements SuperRepository
} }
pathParts = SplitPath(dstPath); pathParts = SplitPath(dstPath);
Repository dstRepo = getRepositoryByName(pathParts[0]); Repository dstRepo = getRepositoryByName(pathParts[0]);
Lookup dPath = dstRepo.lookupDirectory(-1, dstPath); Lookup dPath = dstRepo.lookupDirectory(-1, pathParts[1]);
DirectoryNode dstDir = (DirectoryNode)dPath.getCurrentNode(); DirectoryNode dstDir = (DirectoryNode)dPath.getCurrentNode();
AVMNode dstNode = dstDir.lookupChild(dPath, dstName, -1); AVMNode dstNode = dstDir.lookupChild(dPath, dstName, -1);
if (dstNode != null) if (dstNode != null)