mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added the opacity bit to layered directories, and a method to set it. The opacity
status is returned in AVMNodeDescriptors now. Basic test added. Also restored a bunch of commented out checks in a number of tests. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3257 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -100,6 +100,11 @@ public class AVMNodeDescriptor
|
||||
* The length, if this is a file or -1 otherwise.
|
||||
*/
|
||||
private long fLength;
|
||||
|
||||
/**
|
||||
* The opacity for layered directories.
|
||||
*/
|
||||
private boolean fOpacity;
|
||||
|
||||
/**
|
||||
* Make one up.
|
||||
@@ -132,6 +137,7 @@ public class AVMNodeDescriptor
|
||||
String indirection,
|
||||
boolean isPrimary,
|
||||
long layerID,
|
||||
boolean opacity,
|
||||
long length)
|
||||
{
|
||||
fPath = path;
|
||||
@@ -149,6 +155,7 @@ public class AVMNodeDescriptor
|
||||
fIsPrimary = isPrimary;
|
||||
fLayerID = layerID;
|
||||
fLength = length;
|
||||
fOpacity = opacity;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,7 +363,15 @@ public class AVMNodeDescriptor
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the opacity
|
||||
*/
|
||||
public boolean getOpacity()
|
||||
{
|
||||
return fOpacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a debuggable string representation of this.
|
||||
* @return A string representation of this.
|
||||
|
@@ -270,4 +270,11 @@ public interface AVMService
|
||||
* @return A List of ancestors starting with the most recent.
|
||||
*/
|
||||
public List<AVMNodeDescriptor> getHistory(AVMNodeDescriptor desc, int count);
|
||||
|
||||
/**
|
||||
* Set the opacity of a layered directory. An opaque layered directory
|
||||
* hides the contents of its indirection.
|
||||
* @param path The path to the layered directory.
|
||||
*/
|
||||
public void setOpacity(String path, boolean opacity);
|
||||
}
|
||||
|
@@ -860,4 +860,28 @@ public class AVMServiceImpl implements AVMService
|
||||
fTransaction.perform(doit, false);
|
||||
return doit.history;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the opacity of a layered directory. An opaque layer hides what
|
||||
* its indirection points to.
|
||||
* @param path The path to the layered directory.
|
||||
* @param opacity True is opaque false is not.
|
||||
*/
|
||||
public void setOpacity(final String path, final boolean opacity)
|
||||
{
|
||||
if (path == null)
|
||||
{
|
||||
throw new AVMBadArgumentException("Null path.");
|
||||
}
|
||||
class HTxnCallback implements HibernateTxnCallback
|
||||
{
|
||||
public void perform(Session session)
|
||||
{
|
||||
fSuperRepository.setSession(session);
|
||||
fSuperRepository.setOpacity(path, opacity);
|
||||
}
|
||||
}
|
||||
HTxnCallback doit = new HTxnCallback();
|
||||
fTransaction.perform(doit, false);
|
||||
}
|
||||
}
|
||||
|
@@ -70,16 +70,19 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/b should contain fao and bar
|
||||
listing = fService.getDirectoryListing(-1, "main:/layer/b");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("bar", listing.get(0).getName());
|
||||
// assertEquals("foo", listing.get(1).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("bar", list.get(0));
|
||||
assertEquals("foo", list.get(1));
|
||||
// /a/b should contain foo.
|
||||
listing = fService.getDirectoryListing(-1, "main:/a/b");
|
||||
assertEquals(1, listing.size());
|
||||
// assertEquals("foo", listing.get(0).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("foo", list.get(0));
|
||||
// /a/c should contain bar.
|
||||
listing = fService.getDirectoryListing(-1, "main:/a/c");
|
||||
// assertEquals(1, listing.size());
|
||||
// assertEquals("bar", listing.get(0).getName());
|
||||
assertEquals(1, listing.size());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("bar", list.get(0));
|
||||
// Now make a file in /a/b
|
||||
fService.createFile("main:/a/b", "baz").close();
|
||||
fService.createSnapshot("main");
|
||||
@@ -88,15 +91,17 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /a/b should contain baz and foo.
|
||||
listing = fService.getDirectoryListing(-1, "main:/a/b");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("baz", listing.get(0).getName());
|
||||
// assertEquals("foo", listing.get(1).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("baz", list.get(0));
|
||||
assertEquals("foo", list.get(1));
|
||||
// /layer/b should contain foo, bar, and baz.
|
||||
listing = fService.getDirectoryListing(-1, "main:/layer/b");
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
assertEquals(3, listing.size());
|
||||
// assertEquals("bar", listing.get(0).getName());
|
||||
// assertEquals("baz", listing.get(1).getName());
|
||||
// assertEquals("foo", listing.get(2).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("bar", list.get(0));
|
||||
assertEquals("baz", list.get(1));
|
||||
assertEquals("foo", list.get(2));
|
||||
// Remove baz from /layer/b
|
||||
fService.removeNode("main:/layer/b", "baz");
|
||||
fService.createSnapshot("main");
|
||||
@@ -106,13 +111,15 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/b should have bar and foo.
|
||||
listing = fService.getDirectoryListing(-1, "main:/layer/b");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("bar", listing.get(0).getName());
|
||||
// assertEquals("foo", listing.get(1).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("bar", list.get(0));
|
||||
assertEquals("foo", list.get(1));
|
||||
// /a/b should contain baz and foo as before.
|
||||
listing = fService.getDirectoryListing(-1, "main:/a/b");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("baz", listing.get(0).getName());
|
||||
// assertEquals("foo", listing.get(1).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("baz", list.get(0));
|
||||
assertEquals("foo", list.get(1));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -163,8 +170,9 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/d should no contain baz and figs.
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/layer/d");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("baz", listing.get(0).getName());
|
||||
// assertEquals("figs", listing.get(1).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("baz", list.get(0));
|
||||
assertEquals("figs", list.get(1));
|
||||
for (String val : history.values())
|
||||
{
|
||||
System.out.println(val);
|
||||
@@ -219,8 +227,9 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/d should now contain baz and figs.
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/layer/d");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("baz", listing.get(0).getName());
|
||||
// assertEquals("figs", listing.get(1).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("baz", list.get(0));
|
||||
assertEquals("figs", list.get(1));
|
||||
// Rename /layer/d to /layer/e and uncover /layer/d
|
||||
fService.rename("main:/layer", "d", "main:/layer", "e");
|
||||
fService.uncover("main:/layer", "d");
|
||||
@@ -230,11 +239,13 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/d contains figs.
|
||||
listing = fService.getDirectoryListing(-1, "main:/layer/d");
|
||||
assertEquals(1, listing.size());
|
||||
// assertEquals("figs", listing.get(0).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("figs", list.get(0));
|
||||
// /layer/e contains baz.
|
||||
listing = fService.getDirectoryListing(-1, "main:/layer/e");
|
||||
assertEquals(1, listing.size());
|
||||
// assertEquals("baz", listing.get(0).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("baz", list.get(0));
|
||||
for (String val : history.values())
|
||||
{
|
||||
System.out.println(val);
|
||||
@@ -283,9 +294,10 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /b should have foo and bar and baz.
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/b");
|
||||
assertEquals(3, listing.size());
|
||||
// assertEquals("bar", listing.get(0).getName());
|
||||
// assertEquals("baz", listing.get(1).getName());
|
||||
// assertEquals("foo", listing.get(2).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("bar", list.get(0));
|
||||
assertEquals("baz", list.get(1));
|
||||
assertEquals("foo", list.get(2));
|
||||
// Add something to /a and it will show up in /layer.
|
||||
fService.createFile("main:/a", "figs").close();
|
||||
fService.createSnapshot("main");
|
||||
@@ -293,8 +305,9 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
checkHistory(history, "main");
|
||||
// /layer should have figs in it.
|
||||
listing = fService.getDirectoryListing(-1, "main:/layer");
|
||||
// assertEquals(1, listing.size());
|
||||
// assertEquals("figs", listing.get(0).getName());
|
||||
assertEquals(1, listing.size());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("figs", list.get(0));
|
||||
for (String val : history.values())
|
||||
{
|
||||
System.out.println(val);
|
||||
@@ -403,8 +416,9 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/under/e should contain bow and f.
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/layer/under/e");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("bow", listing.get(0).getName());
|
||||
// assertEquals("f", listing.get(1).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("bow", list.get(0));
|
||||
assertEquals("f", list.get(1));
|
||||
// Put a new set of dirs in to be made into a layering under d.
|
||||
fService.createDirectory("main:/", "g");
|
||||
fService.createDirectory("main:/g", "h");
|
||||
@@ -444,8 +458,9 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/under/gover/h/i shows both moo and cow.
|
||||
listing = fService.getDirectoryListing(-1, "main:/layer/under/gover/h/i");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("cow", listing.get(0).getName());
|
||||
// assertEquals("moo", listing.get(1).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("cow", list.get(0));
|
||||
assertEquals("moo", list.get(1));
|
||||
// Rename /layer/under/gover to /layer/b/gover and see what happens.
|
||||
fService.rename("main:/layer/under", "gover", "main:/layer/b", "gover");
|
||||
fService.createSnapshot("main");
|
||||
@@ -454,7 +469,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// moo should be in /layer/b/gover/h/i
|
||||
listing = fService.getDirectoryListing(-1, "main:/layer/b/gover/h/i");
|
||||
assertEquals(1, listing.size());
|
||||
// assertEquals("moo", listing.get(0).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("moo", list.get(0));
|
||||
// Add a new file to /layer/b/gover/h/i
|
||||
fService.createFile("main:/layer/b/gover/h/i", "oink").close();
|
||||
fService.createSnapshot("main");
|
||||
@@ -463,8 +479,9 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/b/gover/h/i should contain moo, oink.
|
||||
listing = fService.getDirectoryListing(-1, "main:/layer/b/gover/h/i");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("moo", listing.get(0).getName());
|
||||
// assertEquals("oink", listing.get(1).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("moo", list.get(0));
|
||||
assertEquals("oink", list.get(1));
|
||||
for (String val : history.values())
|
||||
{
|
||||
System.out.println(val);
|
||||
@@ -969,7 +986,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
fService.createSnapshot("main");
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/a");
|
||||
assertEquals(1, listing.size());
|
||||
// assertEquals("b", listing.get(0).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("b", list.get(0));
|
||||
fService.createLayeredDirectory("main:/a", "main:/", "c");
|
||||
fService.createLayeredDirectory("main:/c", "main:/", "d");
|
||||
fService.createFile("main:/d/b", "foo.txt").close();
|
||||
@@ -977,23 +995,27 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
listing = fService.getDirectoryListing(-1, "main:/d/b");
|
||||
assertEquals(1, listing.size());
|
||||
// assertEquals("foo.txt", listing.get(0).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("foo.txt", list.get(0));
|
||||
fService.createFile("main:/c/b", "bar.txt").close();
|
||||
fService.createSnapshot("main");
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
listing = fService.getDirectoryListing(-1, "main:/c/b");
|
||||
assertEquals(1, listing.size());
|
||||
// assertEquals("bar.txt", listing.get(0).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("bar.txt", list.get(0));
|
||||
listing = fService.getDirectoryListing(-1, "main:/d/b");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("bar.txt", listing.get(0).getName());
|
||||
// assertEquals("foo.txt", listing.get(1).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("bar.txt", list.get(0));
|
||||
assertEquals("foo.txt", list.get(1));
|
||||
fService.rename("main:/", "c", "main:/", "e");
|
||||
fService.createSnapshot("main");
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
listing = fService.getDirectoryListing(-1, "main:/d/b");
|
||||
// assertEquals(1, listing.size());
|
||||
// assertEquals("foo.txt", listing.get(0).getName());
|
||||
assertEquals(1, listing.size());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("foo.txt", list.get(0));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -1088,28 +1110,32 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /g/b/c/d should contain foo and bar.
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/g/b/c/d");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("bar", listing.get(0).getName());
|
||||
// assertEquals("foo", listing.get(1).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("bar", list.get(0));
|
||||
assertEquals("foo", list.get(1));
|
||||
// /f/b/c/d should contain just bar.
|
||||
listing = fService.getDirectoryListing(-1, "main:/f/b/c/d");
|
||||
assertEquals(1, listing.size());
|
||||
// assertEquals("bar", listing.get(0).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("bar", list.get(0));
|
||||
// Now do something in the bottom layer.
|
||||
fService.createFile("main:/a/b/c", "baz").close();
|
||||
fService.createSnapshot("main");
|
||||
// /e/b/c should contain baz and d
|
||||
listing = fService.getDirectoryListing(-1, "main:/e/b/c");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("baz", listing.get(0).getName());
|
||||
// assertEquals("d", listing.get(1).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("baz", list.get(0));
|
||||
assertEquals("d", list.get(1));
|
||||
// Now add something in the e layer.
|
||||
fService.createFile("main:/e/b/c/d", "bing").close();
|
||||
fService.createSnapshot("main");
|
||||
// /f/b/c/d should now contain bar and bing.
|
||||
listing = fService.getDirectoryListing(-1, "main:/f/b/c/d");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("bar", listing.get(0).getName());
|
||||
// assertEquals("bing", listing.get(1).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("bar", list.get(0));
|
||||
assertEquals("bing", list.get(1));
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -1144,16 +1170,18 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer should contain b and moved
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/layer");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("b", listing.get(0).getName());
|
||||
// assertEquals("moved", listing.get(1).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("b", list.get(0));
|
||||
assertEquals("moved", list.get(1));
|
||||
// Now rename moved back to d.
|
||||
fService.rename("main:/layer", "moved", "main:/layer", "d");
|
||||
fService.createSnapshot("main");
|
||||
// /layer should contain b and d.
|
||||
listing = fService.getDirectoryListing(-1, "main:/layer");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("b", listing.get(0).getName());
|
||||
// assertEquals("d", listing.get(1).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("b", list.get(0));
|
||||
assertEquals("d", list.get(1));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -1252,9 +1280,10 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer2/c should contain foo bar and baz.
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/layer2/c");
|
||||
assertEquals(3, listing.size());
|
||||
// assertEquals("bar", listing.get(0).getName());
|
||||
// assertEquals("baz", listing.get(1).getName());
|
||||
// assertEquals("foo", listing.get(2).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("bar", list.get(0));
|
||||
assertEquals("baz", list.get(1));
|
||||
assertEquals("foo", list.get(2));
|
||||
for (String val : history.values())
|
||||
{
|
||||
System.out.println(val);
|
||||
@@ -1291,7 +1320,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/b/c should contain e.
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/layer/b/c");
|
||||
assertEquals(1, listing.size());
|
||||
// assertEquals("e", listing.get(0).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("e", list.get(0));
|
||||
// Rename /layer/b/c to /layer/c
|
||||
fService.rename("main:/layer/b", "c", "main:/layer", "c");
|
||||
fService.createSnapshot("main");
|
||||
@@ -1314,8 +1344,9 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer2/c should have baz and e in it.
|
||||
listing = fService.getDirectoryListing(-1, "main:/layer2/c");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("baz", listing.get(0).getName());
|
||||
// assertEquals("e", listing.get(1).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("baz", list.get(0));
|
||||
assertEquals("e", list.get(1));
|
||||
for (String val : history.values())
|
||||
{
|
||||
System.out.println(val);
|
||||
@@ -1431,8 +1462,9 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/b/branch/e/f should contain moo and cow.
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/layer/b/branch/e/f");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("cow", listing.get(0).getName());
|
||||
// assertEquals("moo", listing.get(1).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("cow", list.get(0));
|
||||
assertEquals("moo", list.get(1));
|
||||
for (String val : history.values())
|
||||
{
|
||||
System.out.println(val);
|
||||
@@ -1487,8 +1519,9 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/b/branch/e/f should contain moo and cow.
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/layer/b/d/e/f");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("cow", listing.get(0).getName());
|
||||
// assertEquals("moo", listing.get(1).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("cow", list.get(0));
|
||||
assertEquals("moo", list.get(1));
|
||||
for (String val : history.values())
|
||||
{
|
||||
System.out.println(val);
|
||||
@@ -1546,8 +1579,9 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/b/c/fover/g/h/iover/j/k should contain pismo and foo.
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/layer/b/c/fover/g/h/iover/j/k");
|
||||
assertEquals(2, listing.size());
|
||||
// assertEquals("foo", listing.get(0).getName());
|
||||
// assertEquals("pismo", listing.get(1).getName());
|
||||
List<String> list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("foo", list.get(0));
|
||||
assertEquals("pismo", list.get(1));
|
||||
// Make a file in /flayer/g/h/iover/j/k
|
||||
fService.createFile("main:/flayer/g/h/iover/j/k", "zuma").close();
|
||||
fService.createSnapshot("main");
|
||||
@@ -1556,9 +1590,10 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// /layer/b/c/fover/g/h/iover/j/k should contain foo, pismo, and zuma.
|
||||
listing = fService.getDirectoryListing(-1, "main:/layer/b/c/fover/g/h/iover/j/k");
|
||||
assertEquals(3, listing.size());
|
||||
// assertEquals("foo", listing.get(0).getName());
|
||||
// assertEquals("pismo", listing.get(1).getName());
|
||||
// assertEquals("zuma", listing.get(2).getName());
|
||||
list = new ArrayList<String>(listing.keySet());
|
||||
assertEquals("foo", list.get(0));
|
||||
assertEquals("pismo", list.get(1));
|
||||
assertEquals("zuma", list.get(2));
|
||||
for (String val : history.values())
|
||||
{
|
||||
System.out.println(val);
|
||||
@@ -1837,7 +1872,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
/**
|
||||
* Test repository functions.
|
||||
*/
|
||||
public void testRepsitory()
|
||||
public void testRepository()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1863,4 +1898,53 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test opacity and manipulations.
|
||||
*/
|
||||
public void testOpacity()
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createLayeredDirectory("main:/a", "main:/", "layer");
|
||||
fService.createSnapshot("main");
|
||||
fService.createFile("main:/layer/b/c", "baz").close();
|
||||
fService.createFile("main:/layer/b/c", "fig").close();
|
||||
fService.createSnapshot("main");
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/layer/b/c");
|
||||
assertEquals(4, listing.size());
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
// Setting the opacity of layer to true will make no difference to what we see through
|
||||
// main:/layer/b/c.
|
||||
fService.setOpacity("main:/layer", true);
|
||||
fService.createSnapshot("main");
|
||||
assertTrue(fService.lookup(-1, "main:/layer").getOpacity());
|
||||
assertEquals(4, fService.getDirectoryListing(-1, "main:/layer/b/c").size());
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
// If main:/layer/b/c is opaque, however, we'll only see two items in it.
|
||||
fService.setOpacity("main:/layer", false);
|
||||
fService.setOpacity("main:/layer/b/c", true);
|
||||
fService.createSnapshot("main");
|
||||
assertFalse(fService.lookup(-1, "main:/layer").getOpacity());
|
||||
assertTrue(fService.lookup(-1, "main:/layer/b/c").getOpacity());
|
||||
assertEquals(2, fService.getDirectoryListing(-1, "main:/layer/b/c").size());
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
// Gratuitous test of retarget.
|
||||
fService.retargetLayeredDirectory("main:/layer", "main:/d");
|
||||
fService.setOpacity("main:/layer/b/c", false);
|
||||
fService.createSnapshot("main");
|
||||
assertFalse(fService.lookup(-1, "main:/layer/b/c").getOpacity());
|
||||
assertEquals(2, fService.getDirectoryListing(-1, "main:/layer/b/c").size());
|
||||
// This is just testing that opacity setting works on latent
|
||||
// layered directories.
|
||||
fService.setOpacity("main:/layer/e/f", true);
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -77,4 +77,17 @@ interface LayeredDirectoryNode extends DirectoryNode, Layered
|
||||
* @return All deleted children.
|
||||
*/
|
||||
public List<DeletedChild> getDeleted();
|
||||
|
||||
/**
|
||||
* Set the opacity of this.
|
||||
* @param opacity Whether this should be opaque, i.e. not see the things it
|
||||
* in its indirection.
|
||||
*/
|
||||
public void setOpacity(boolean opacity);
|
||||
|
||||
/**
|
||||
* Get the opacity of this.
|
||||
* @return The opacity.
|
||||
*/
|
||||
public boolean getOpacity();
|
||||
}
|
@@ -52,7 +52,12 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
* Whether this is a primary indirection node.
|
||||
*/
|
||||
private boolean fPrimaryIndirection;
|
||||
|
||||
|
||||
/**
|
||||
* Whether this is opaque.
|
||||
*/
|
||||
private boolean fOpacity;
|
||||
|
||||
/**
|
||||
* Default constructor. Called by Hibernate.
|
||||
*/
|
||||
@@ -71,6 +76,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
fLayerID = -1;
|
||||
fIndirection = indirection;
|
||||
fPrimaryIndirection = true;
|
||||
fOpacity = false;
|
||||
repos.getSuperRepository().getSession().save(this);
|
||||
}
|
||||
|
||||
@@ -88,6 +94,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
fIndirection = other.getUnderlying();
|
||||
fPrimaryIndirection = other.getPrimaryIndirection();
|
||||
fLayerID = -1;
|
||||
fOpacity = false;
|
||||
sess.save(this);
|
||||
for (ChildEntry child : other.getChildren())
|
||||
{
|
||||
@@ -121,6 +128,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
fIndirection = null;
|
||||
fPrimaryIndirection = false;
|
||||
fLayerID = -1;
|
||||
fOpacity = false;
|
||||
Session sess = repos.getSuperRepository().getSession();
|
||||
sess.save(this);
|
||||
if (copyContents)
|
||||
@@ -152,6 +160,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
fIndirection = srcLookup.getIndirectionPath() + "/" + name;
|
||||
fPrimaryIndirection = true;
|
||||
fLayerID = -1;
|
||||
fOpacity = false;
|
||||
repo.getSuperRepository().getSession().save(this);
|
||||
}
|
||||
|
||||
@@ -297,21 +306,28 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
{
|
||||
// Get the base listing from the thing we indirect to.
|
||||
Map<String, AVMNode> baseListing = null;
|
||||
try
|
||||
if (fOpacity)
|
||||
{
|
||||
Lookup lookup = SuperRepository.GetInstance().lookupDirectory(-1, getUnderlying(lPath));
|
||||
DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode();
|
||||
baseListing = dir.getListing(lookup);
|
||||
}
|
||||
catch (AVMException re)
|
||||
{
|
||||
if (re instanceof AVMCycleException)
|
||||
{
|
||||
throw re;
|
||||
}
|
||||
// It's OK for an indirection to dangle.
|
||||
baseListing = new HashMap<String, AVMNode>();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Lookup lookup = SuperRepository.GetInstance().lookupDirectory(-1, getUnderlying(lPath));
|
||||
DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode();
|
||||
baseListing = dir.getListing(lookup);
|
||||
}
|
||||
catch (AVMException re)
|
||||
{
|
||||
if (re instanceof AVMCycleException)
|
||||
{
|
||||
throw re;
|
||||
}
|
||||
// It's OK for an indirection to dangle.
|
||||
baseListing = new HashMap<String, AVMNode>();
|
||||
}
|
||||
}
|
||||
// Filter the base listing by taking out anything in the deleted Set.
|
||||
Map<String, AVMNode> listing = new TreeMap<String, AVMNode>();
|
||||
for (String name : baseListing.keySet())
|
||||
@@ -341,25 +357,30 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
throw new AVMBadArgumentException("Illegal null argument.");
|
||||
}
|
||||
Map<String, AVMNodeDescriptor> baseListing = new TreeMap<String, AVMNodeDescriptor>();
|
||||
try
|
||||
// If we are not opaque, get the underlying base listing.
|
||||
if (!fOpacity)
|
||||
{
|
||||
Lookup lookup = SuperRepository.GetInstance().lookupDirectory(-1, dir.getIndirection());
|
||||
DirectoryNode dirNode = (DirectoryNode)lookup.getCurrentNode();
|
||||
Map<String, AVMNode> listing = dirNode.getListing(lookup);
|
||||
for (String name : listing.keySet())
|
||||
try
|
||||
{
|
||||
baseListing.put(name,
|
||||
listing.get(name).getDescriptor(dir.getPath(), name,
|
||||
lookup.getCurrentIndirection()));
|
||||
}
|
||||
}
|
||||
catch (AVMException e)
|
||||
{
|
||||
if (e instanceof AVMCycleException)
|
||||
{
|
||||
throw e;
|
||||
Lookup lookup = SuperRepository.GetInstance().lookupDirectory(-1, dir.getIndirection());
|
||||
DirectoryNode dirNode = (DirectoryNode)lookup.getCurrentNode();
|
||||
Map<String, AVMNode> listing = dirNode.getListing(lookup);
|
||||
for (String name : listing.keySet())
|
||||
{
|
||||
baseListing.put(name,
|
||||
listing.get(name).getDescriptor(dir.getPath(), name,
|
||||
lookup.getCurrentIndirection()));
|
||||
}
|
||||
}
|
||||
catch (AVMException e)
|
||||
{
|
||||
if (e instanceof AVMCycleException)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove anything deleted in this layer.
|
||||
List<DeletedChild> deleted = getDeleted();
|
||||
for (DeletedChild child : deleted)
|
||||
{
|
||||
@@ -397,6 +418,11 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
{
|
||||
return AVMNodeUnwrapper.Unwrap(entry.getChild());
|
||||
}
|
||||
// Don't check our underlying directory if we are opaque.
|
||||
if (fOpacity)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// Not here so check our indirection.
|
||||
try
|
||||
{
|
||||
@@ -437,6 +463,11 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
name,
|
||||
mine.getIndirection());
|
||||
}
|
||||
// If we are opaque don't check underneath.
|
||||
if (fOpacity)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
Lookup lookup = SuperRepository.GetInstance().lookupDirectory(-1, mine.getIndirection());
|
||||
@@ -568,6 +599,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
getUnderlying(lPath),
|
||||
fPrimaryIndirection,
|
||||
fLayerID,
|
||||
fOpacity,
|
||||
-1);
|
||||
}
|
||||
|
||||
@@ -595,6 +627,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
getUnderlying(lPath),
|
||||
fPrimaryIndirection,
|
||||
fLayerID,
|
||||
fOpacity,
|
||||
-1);
|
||||
}
|
||||
|
||||
@@ -633,6 +666,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
indirection,
|
||||
fPrimaryIndirection,
|
||||
fLayerID,
|
||||
fOpacity,
|
||||
-1);
|
||||
}
|
||||
|
||||
@@ -687,4 +721,23 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
public void setIsRoot(boolean isRoot)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the opacity of this.
|
||||
* @return The opacity.
|
||||
*/
|
||||
public boolean getOpacity()
|
||||
{
|
||||
return fOpacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the opacity of this, ie, whether it blocks things normally
|
||||
* seen through its indirection.
|
||||
* @param opacity
|
||||
*/
|
||||
public void setOpacity(boolean opacity)
|
||||
{
|
||||
fOpacity = opacity;
|
||||
}
|
||||
}
|
||||
|
@@ -172,6 +172,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
|
||||
getUnderlying(lPath),
|
||||
false,
|
||||
-1,
|
||||
false,
|
||||
0);
|
||||
}
|
||||
|
||||
@@ -198,6 +199,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
|
||||
getUnderlying(lPath),
|
||||
false,
|
||||
-1,
|
||||
false,
|
||||
0);
|
||||
}
|
||||
|
||||
@@ -226,6 +228,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
|
||||
fIndirection,
|
||||
false,
|
||||
-1,
|
||||
false,
|
||||
0);
|
||||
}
|
||||
|
||||
|
@@ -294,6 +294,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
|
||||
null,
|
||||
false,
|
||||
-1,
|
||||
false,
|
||||
-1);
|
||||
}
|
||||
|
||||
@@ -320,6 +321,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
|
||||
null,
|
||||
false,
|
||||
-1,
|
||||
false,
|
||||
-1);
|
||||
}
|
||||
|
||||
@@ -348,6 +350,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
|
||||
null,
|
||||
false,
|
||||
-1,
|
||||
false,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
|
@@ -162,6 +162,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
|
||||
null,
|
||||
false,
|
||||
-1,
|
||||
false,
|
||||
getContentForRead().getLength());
|
||||
}
|
||||
|
||||
@@ -188,6 +189,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
|
||||
null,
|
||||
false,
|
||||
-1,
|
||||
false,
|
||||
getContentForRead().getLength());
|
||||
}
|
||||
|
||||
@@ -216,6 +218,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
|
||||
null,
|
||||
false,
|
||||
-1,
|
||||
false,
|
||||
getContentForRead().getLength());
|
||||
}
|
||||
|
||||
|
@@ -245,4 +245,12 @@ interface Repository
|
||||
* @return The descriptor.
|
||||
*/
|
||||
public RepositoryDescriptor getDescriptor();
|
||||
|
||||
/**
|
||||
* Set the opacity of a layered directory. An opaque directory hides
|
||||
* what is pointed at by its indirection.
|
||||
* @param path The path to the layered directory.
|
||||
* @param opacity True is opaque; false is not.
|
||||
*/
|
||||
public void setOpacity(String path, boolean opacity);
|
||||
}
|
@@ -835,4 +835,21 @@ class RepositoryImpl implements Repository, Serializable
|
||||
{
|
||||
return new RepositoryDescriptor(fName, fCreator, fCreateDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the opacity of a layered directory. An opaque directory hides
|
||||
* what is pointed at by its indirection.
|
||||
* @param path The path to the layered directory.
|
||||
* @param opacity True is opaque; false is not.
|
||||
*/
|
||||
public void setOpacity(String path, boolean opacity)
|
||||
{
|
||||
Lookup lPath = lookup(-1, path, true);
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
if (!(node instanceof LayeredDirectoryNode))
|
||||
{
|
||||
throw new AVMWrongTypeException("Not a LayeredDirectoryNode.");
|
||||
}
|
||||
((LayeredDirectoryNode)node).setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
|
@@ -868,6 +868,20 @@ class SuperRepository
|
||||
return history;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the opacity of a layered directory. An opaque directory hides
|
||||
* the things it points to via indirection.
|
||||
* @param path The path to the layered directory.
|
||||
* @param opacity True is opaque; false is not.
|
||||
*/
|
||||
public void setOpacity(String path, boolean opacity)
|
||||
{
|
||||
fLookupCount.set(1);
|
||||
String[] pathParts = SplitPath(path);
|
||||
Repository rep = getRepositoryByName(pathParts[0], true);
|
||||
rep.setOpacity(pathParts[1], opacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the RepositoryDescriptor for a Repository.
|
||||
* @param name The name of the Repository.
|
||||
|
@@ -62,18 +62,12 @@
|
||||
container (false). -->
|
||||
<property name="primaryIndirection"
|
||||
column="primary_indirection" type="boolean"/>
|
||||
<property name="opacity" column="opacity" type="boolean"/>
|
||||
<!-- Map of names to DirectoryEntries. -->
|
||||
</subclass>
|
||||
<!-- Just plain directories. -->
|
||||
<subclass name="PlainDirectoryNodeImpl"
|
||||
discriminator-value="plaindirectory" proxy="PlainDirectoryNode" lazy="true">
|
||||
<!-- For reference count based garbage collection of purged nodes
|
||||
to work we need to specially mark the root directory of
|
||||
a Repository as special so that its absence of parents will
|
||||
not cause it to be vacuumed away. TODO: for ease of queries,
|
||||
this probably wants to be in the base class. -->
|
||||
<!-- 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. -->
|
||||
</subclass>
|
||||
</subclass>
|
||||
<!-- There are two kinds of files, plain and symlinky. -->
|
||||
|
Reference in New Issue
Block a user