mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/DEV/V3.3-BUG-FIX to HEAD:
24001: Merged BRANCHES/DEV/BELARUS/V3.3-2010_11_10 to BRANCHES/DEV/V3.3-BUG-FIX: 23971: ALF-1948: Deleting a freshly created file doesn't remove it from a user sandbox - also minor formatting & extra tests 24007: Merged BRANCHES/DEV/BELARUS/V3.3-2010_11_10 to BRANCHES/DEV/V3.3-BUG-FIX: 23971: ALF-1948: (commit mergeinfo !) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@24896 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,6 +28,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -927,6 +928,115 @@ public class AVMServiceLocalTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public void testDeleteLD3() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
fService.createStore("mainB");
|
||||
fService.createStore("mainB--layer");
|
||||
fService.createDirectory("mainB:/", "a");
|
||||
fService.createSnapshot("mainB", null, null);
|
||||
|
||||
SortedMap<String, AVMNodeDescriptor> directoryListing = fService.getDirectoryListing(-1, "mainB:/a");
|
||||
assertTrue(directoryListing.isEmpty());
|
||||
|
||||
fService.createLayeredDirectory("mainB:/a", "mainB--layer:/", "a");
|
||||
|
||||
fService.createFile("mainB--layer:/a", "testfile.txt");
|
||||
fService.createDirectory("mainB--layer:/a", "testfolder");
|
||||
fService.createSnapshot("mainB--layer", null, null);
|
||||
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "mainB--layer:/a", -1, "mainB:/a", null);
|
||||
assertEquals(2, diffs.size());
|
||||
assertEquals("[mainB--layer:/a/testfile.txt[-1] > mainB:/a/testfile.txt[-1], mainB--layer:/a/testfolder[-1] > mainB:/a/testfolder[-1]]", diffs.toString());
|
||||
|
||||
// ALF-1948
|
||||
fService.removeNode("mainB--layer:/a", "testfile.txt");
|
||||
fService.createSnapshot("mainB--layer", null, null);
|
||||
diffs = fSyncService.compare(-1, "mainB--layer:/a", -1, "mainB:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[mainB--layer:/a/testfolder[-1] > mainB:/a/testfolder[-1]]", diffs.toString());
|
||||
|
||||
fService.removeNode("mainB--layer:/a", "testfolder");
|
||||
fService.createSnapshot("mainB--layer", null, null);
|
||||
diffs = fSyncService.compare(-1, "mainB--layer:/a", -1, "mainB:/a", null);
|
||||
assertEquals(0, diffs.size());
|
||||
|
||||
directoryListing = fService.getDirectoryListing(-1, "mainB--layer:/a");
|
||||
assertTrue(directoryListing.isEmpty());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService.purgeStore("mainB");
|
||||
fService.purgeStore("mainB--layer");
|
||||
}
|
||||
}
|
||||
|
||||
public void testDeleteLD4() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.debug("created 2 stores: main, layer");
|
||||
|
||||
fService.createDirectory("main:/", "a");
|
||||
|
||||
fService.createLayeredDirectory("main:/a", "layer:/", "a");
|
||||
|
||||
logger.debug("created layered dir: layer:/a -> main:/a");
|
||||
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "layer:/a", -1, "main:/a", null);
|
||||
assertEquals(0, diffs.size());
|
||||
|
||||
fService.createStore("layer2");
|
||||
|
||||
logger.debug("created store: layer2");
|
||||
|
||||
fService.createLayeredDirectory("layer:/a", "layer2:/", "a");
|
||||
|
||||
logger.debug("created layered dir: layer2:/a -> layer:/a");
|
||||
|
||||
OutputStream o = fService.createFile("layer2:/a", "foo");
|
||||
PrintStream out = new PrintStream(o);
|
||||
out.println("I am layer2:/a/foo");
|
||||
out.close();
|
||||
|
||||
diffs = fSyncService.compare(-1, "layer2:/a", -1, "layer:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[layer2:/a/foo[-1] > layer:/a/foo[-1]]", diffs.toString());
|
||||
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
|
||||
diffs = fSyncService.compare(-1, "layer2:/a", -1, "layer:/a", null);
|
||||
assertEquals(0, diffs.size());
|
||||
|
||||
diffs = fSyncService.compare(-1, "layer:/a", -1, "main:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[layer:/a/foo[-1] > main:/a/foo[-1]]", diffs.toString());
|
||||
|
||||
// ALF-1948
|
||||
fService.removeNode("layer:/a", "foo");
|
||||
|
||||
logger.debug("remove file in layer: layer:/a/foo");
|
||||
|
||||
diffs = fSyncService.compare(-1, "layer:/a", -1, "main:/a", null);
|
||||
assertEquals(0, diffs.size());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (fService.getStore("layer2") != null) { fService.purgeStore("layer2"); }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test bulk update (using layered directory).
|
||||
*/
|
||||
@@ -3511,6 +3621,122 @@ public class AVMServiceLocalTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
// ALF-1948
|
||||
public void testDeleteLD5() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
fService.createStore("mainB");
|
||||
fService.createStore("mainB--layer");
|
||||
fService.createDirectory("mainB:/", "a");
|
||||
fService.createSnapshot("mainB", null, null);
|
||||
|
||||
SortedMap<String, AVMNodeDescriptor> directoryListing = fService.getDirectoryListing(-1, "mainB:/a");
|
||||
assertTrue(directoryListing.isEmpty());
|
||||
|
||||
fService.createLayeredDirectory("mainB:/a", "mainB--layer:/", "a");
|
||||
|
||||
fService.createFile("mainB--layer:/a", "testfile.txt");
|
||||
fService.createDirectory("mainB--layer:/a", "testfolder");
|
||||
fService.createSnapshot("mainB--layer", null, null);
|
||||
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "mainB--layer:/a", -1, "mainB:/a", null);
|
||||
assertEquals(2, diffs.size());
|
||||
assertEquals("[mainB--layer:/a/testfile.txt[-1] > mainB:/a/testfile.txt[-1], mainB--layer:/a/testfolder[-1] > mainB:/a/testfolder[-1]]", diffs.toString());
|
||||
|
||||
fService.removeNode("mainB--layer:/a", "testfile.txt");
|
||||
fService.createSnapshot("mainB--layer", null, null);
|
||||
diffs = fSyncService.compare(-1, "mainB--layer:/a", -1, "mainB:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[mainB--layer:/a/testfolder[-1] > mainB:/a/testfolder[-1]]", diffs.toString());
|
||||
|
||||
fService.removeNode("mainB--layer:/a", "testfolder");
|
||||
fService.createSnapshot("mainB--layer", null, null);
|
||||
diffs = fSyncService.compare(-1, "mainB--layer:/a", -1, "mainB:/a", null);
|
||||
assertEquals(0, diffs.size());
|
||||
|
||||
directoryListing = fService.getDirectoryListing(-1, "mainB--layer:/a");
|
||||
assertTrue(directoryListing.isEmpty());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService.purgeStore("mainB");
|
||||
fService.purgeStore("mainB--layer");
|
||||
}
|
||||
}
|
||||
|
||||
// ALF-1948
|
||||
public void testDeleteLD6() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
fService.createStore("mainB");
|
||||
fService.createStore("mainB--layer");
|
||||
fService.createDirectory("mainB:/", "a");
|
||||
fService.createSnapshot("mainB", null, null);
|
||||
|
||||
SortedMap<String, AVMNodeDescriptor> directoryListing = fService.getDirectoryListing(-1, "mainB:/a");
|
||||
assertTrue(directoryListing.isEmpty());
|
||||
|
||||
fService.createLayeredDirectory("mainB:/a", "mainB--layer:/", "a");
|
||||
|
||||
performDeletion(100);
|
||||
fSyncService.resetLayer("mainB--layer:/a");
|
||||
performDeletion(500);
|
||||
fSyncService.resetLayer("mainB--layer:/a");
|
||||
performDeletion(500);
|
||||
fSyncService.resetLayer("mainB--layer:/a");
|
||||
performDeletion(1000);
|
||||
fSyncService.resetLayer("mainB--layer:/a");
|
||||
performDeletion(2000);
|
||||
fSyncService.resetLayer("mainB--layer:/a");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService.purgeStore("mainB");
|
||||
fService.purgeStore("mainB--layer");
|
||||
}
|
||||
}
|
||||
|
||||
private void performDeletion(int objectsAmount)
|
||||
{
|
||||
SortedMap<String, AVMNodeDescriptor> directoryListing;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
for (int i = 0; i < objectsAmount; i++)
|
||||
{
|
||||
String commonPart = "-" + timestamp + "-" + i;
|
||||
fService.createFile("mainB--layer:/a", ("testfile" + commonPart + ".txt"));
|
||||
fService.createDirectory("mainB--layer:/a", ("testfolder" + commonPart));
|
||||
}
|
||||
fService.createSnapshot("mainB--layer", null, null);
|
||||
|
||||
List<AVMDifference> compare = fSyncService.compare(-1, "mainB:/a", -1, "mainB--layer:/a", null);
|
||||
assertEquals(2 * objectsAmount, compare.size());
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
for (int i = 0; i < objectsAmount; i++)
|
||||
{
|
||||
String commonPart = "-" + timestamp + "-" + i;
|
||||
fService.removeNode("mainB--layer:/a", ("testfile" + commonPart + ".txt"));
|
||||
fService.removeNode("mainB--layer:/a", ("testfolder" + commonPart));
|
||||
}
|
||||
fService.createSnapshot("mainB--layer", null, null);
|
||||
logger.info("Time spent on deletion of " + compare.size() + " objects is " + (System.currentTimeMillis() - time));
|
||||
|
||||
directoryListing = fService.getDirectoryListing(-1, "mainB--layer:/a");
|
||||
assertTrue(directoryListing.isEmpty());
|
||||
}
|
||||
|
||||
protected void recursiveContents(String path)
|
||||
{
|
||||
String contentsStr = recursiveContents(path, -1, true);
|
||||
|
@@ -25,6 +25,7 @@ import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.alfresco.repo.avm.util.AVMUtil;
|
||||
import org.alfresco.repo.domain.permissions.Acl;
|
||||
import org.alfresco.repo.security.permissions.ACLCopyMode;
|
||||
import org.alfresco.repo.security.permissions.ACLType;
|
||||
@@ -798,6 +799,16 @@ public class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements Layer
|
||||
return;
|
||||
}
|
||||
AVMDAOs.Instance().fChildEntryDAO.delete(entry);
|
||||
|
||||
Lookup lookup = AVMRepository.GetInstance().lookup(-1, AVMUtil.extendAVMPath(lPath.getRepresentedPath(), name), true);
|
||||
|
||||
if (((AVMNodeType.PLAIN_FILE == child.getType()) ||
|
||||
(AVMNodeType.LAYERED_DIRECTORY == child.getType()) ||
|
||||
(AVMNodeType.PLAIN_DIRECTORY == child.getType())) &&
|
||||
((lookup == null) || (lookup.getIndirectionPath() == null)) && (lookupChild(lPath, name, true) == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -224,7 +224,7 @@ public class AssetServiceImplTest extends AbstractWCMServiceImplTest
|
||||
// try to get assets (including deleted)
|
||||
|
||||
myFolder1Asset = assetService.getAsset(sbStoreId, -1, path+"/myFolder1", true);
|
||||
checkAssetInfo(myFolder1Asset, "myFolder1", path+"/myFolder1", USER_ONE, false, true, true, false, null); // TODO - unlike admin (testSimple)
|
||||
assertNull(myFolder1Asset);
|
||||
|
||||
myFile1Asset = assetService.getAsset(sbStoreId, -1, path+"/myFile1", true);
|
||||
assertNull(myFile1Asset);
|
||||
@@ -348,7 +348,7 @@ public class AssetServiceImplTest extends AbstractWCMServiceImplTest
|
||||
// try to get assets (including deleted)
|
||||
|
||||
myFolder1Asset = assetService.getAssetWebApp(sbStoreId, myWebApp1, "/myFolder1", true);
|
||||
checkAssetInfo(myFolder1Asset, "myFolder1", path+"/myFolder1", USER_ONE, false, true, true, false, null); // TODO - unlike admin (testSimple)
|
||||
assertNull(myFolder1Asset);
|
||||
|
||||
myFile1Asset = assetService.getAssetWebApp(sbStoreId, myWebApp1, "/myFile1", true);
|
||||
assertNull(myFile1Asset);
|
||||
@@ -669,7 +669,8 @@ public class AssetServiceImplTest extends AbstractWCMServiceImplTest
|
||||
// submit the changes
|
||||
sbService.submitWebApp(sbStoreId, defaultWebApp, "some updates by "+user, null);
|
||||
|
||||
pollForSnapshotCount(stagingStoreId, snapCnt+1);
|
||||
snapCnt += (canUpdateExisting || canDeleteExisting) ? (1):(0);
|
||||
pollForSnapshotCount(stagingStoreId, snapCnt);
|
||||
}
|
||||
|
||||
public void testRenameFile()
|
||||
@@ -1347,4 +1348,42 @@ public class AssetServiceImplTest extends AbstractWCMServiceImplTest
|
||||
expectedStageCnt++;
|
||||
}
|
||||
}
|
||||
|
||||
// ALF-1948
|
||||
public void testDeleteFile() throws Exception
|
||||
{
|
||||
WebProjectInfo wpInfo = wpService.createWebProject(TEST_WEBPROJ_DNS + "-import", TEST_WEBPROJ_NAME + "-import", TEST_WEBPROJ_TITLE, TEST_WEBPROJ_DESCRIPTION,
|
||||
TEST_WEBPROJ_DEFAULT_WEBAPP, TEST_WEBPROJ_DONT_USE_AS_TEMPLATE, null);
|
||||
|
||||
String defaultWebApp = wpInfo.getDefaultWebApp();
|
||||
|
||||
SandboxInfo stagingInfo = sbService.getStagingSandbox(wpInfo.getStoreId());
|
||||
String stagingStoreId = stagingInfo.getSandboxId();
|
||||
|
||||
SandboxInfo sbInfo = sbService.getAuthorSandbox(wpInfo.getStoreId());
|
||||
String sbStoreId = sbInfo.getSandboxId();
|
||||
|
||||
String path = sbInfo.getSandboxRootPath() + "/" + defaultWebApp;
|
||||
|
||||
assetService.createFile(sbStoreId, path, "testfile.txt", null);
|
||||
assetService.createFolder(sbStoreId, path, "testfolder", null);
|
||||
|
||||
List<AssetInfo> listAssets = assetService.listAssets(stagingStoreId, path, true);
|
||||
assertEquals(0, listAssets.size());
|
||||
|
||||
listAssets = assetService.listAssets(sbStoreId, path, true);
|
||||
assertEquals(2, listAssets.size());
|
||||
|
||||
int validAmount = listAssets.size() - 1;
|
||||
for (AssetInfo asset : listAssets)
|
||||
{
|
||||
assetService.deleteAsset(asset);
|
||||
List<AssetInfo> tempAssetsList = assetService.listAssets(sbStoreId, path, true);
|
||||
assertNotNull(tempAssetsList);
|
||||
assertEquals(validAmount--, tempAssetsList.size());
|
||||
}
|
||||
|
||||
List<AssetInfo> listChanged = sbService.listChanged(sbStoreId, path, true);
|
||||
assertEquals(0, listChanged.size());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user