mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added getPathsInStoreVersion() method to AVMService.
This returns all paths to a particular node in a particular store in a particular version. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6074 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -215,6 +215,14 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
|
||||
return fService.getAPath(desc);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.avm.AVMService#getPathsInStoreVersion(org.alfresco.service.cmr.avm.AVMNodeDescriptor, java.lang.String, int)
|
||||
*/
|
||||
public List<String> getPathsInStoreVersion(AVMNodeDescriptor desc, String store, int version)
|
||||
{
|
||||
return fService.getPathsInStoreVersion(desc, store, version);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.avm.AVMService#getAspects(int, java.lang.String)
|
||||
*/
|
||||
|
@@ -1558,6 +1558,18 @@ public class AVMRepository
|
||||
paths.add(new Pair<Integer, String>(version, makePath(components, storeName)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Alternate version.
|
||||
* @param components
|
||||
* @param storeName
|
||||
* @param paths
|
||||
*/
|
||||
private void addPath(List<String> components, String storeName,
|
||||
List<String> paths)
|
||||
{
|
||||
paths.add(makePath(components, storeName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for generating paths.
|
||||
* @param components The path components.
|
||||
@@ -2616,4 +2628,48 @@ public class AVMRepository
|
||||
fLookupCount.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getPathsInStoreVersion(AVMNodeDescriptor desc, String store, int version)
|
||||
{
|
||||
AVMNode node = fAVMNodeDAO.getByID(desc.getId());
|
||||
if (node == null)
|
||||
{
|
||||
throw new AVMNotFoundException("Not found: " + desc.getPath());
|
||||
}
|
||||
List<String> paths = new ArrayList<String>();
|
||||
List<String> components = new ArrayList<String>();
|
||||
recursiveGetStoreVersionPaths(store, node, version, components, paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the actual work.
|
||||
* @param node The current node.
|
||||
* @param components The currently accumulated path components.
|
||||
* @param paths The list to put full paths in.
|
||||
*/
|
||||
private void recursiveGetStoreVersionPaths(String storeName, AVMNode node, int version, List<String> components,
|
||||
List<String> paths)
|
||||
{
|
||||
if (node.getIsRoot())
|
||||
{
|
||||
VersionRoot versionRoot = fVersionRootDAO.getByRoot(node);
|
||||
if (versionRoot.getAvmStore().getName().equals(storeName) &&
|
||||
versionRoot.getVersionID() == version)
|
||||
{
|
||||
addPath(components, storeName, paths);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
List<ChildEntry> entries = fChildEntryDAO.getByChild(node);
|
||||
for (ChildEntry entry : entries)
|
||||
{
|
||||
String name = entry.getKey().getName();
|
||||
components.add(name);
|
||||
AVMNode parent = entry.getKey().getParent();
|
||||
recursiveGetStoreVersionPaths(storeName, parent, version, components, paths);
|
||||
components.remove(components.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -764,6 +764,18 @@ public class AVMServiceImpl implements AVMService
|
||||
return fAVMRepository.getPathsInStoreHead(desc, store);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.avm.AVMService#getPathsInStoreVersion(org.alfresco.service.cmr.avm.AVMNodeDescriptor, java.lang.String, int)
|
||||
*/
|
||||
public List<String> getPathsInStoreVersion(AVMNodeDescriptor desc, String store, int version)
|
||||
{
|
||||
if (desc == null || store == null || version < 1)
|
||||
{
|
||||
throw new AVMBadArgumentException("Illegal null argument or invalid version.");
|
||||
}
|
||||
return fAVMRepository.getPathsInStoreVersion(desc, store, version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge an AVMStore. Permanently delete everything that
|
||||
* is only referenced in that AVMStore.
|
||||
|
@@ -101,6 +101,45 @@ import org.alfresco.util.Pair;
|
||||
*/
|
||||
public class AVMServiceTest extends AVMServiceTestBase
|
||||
{
|
||||
/**
|
||||
* Test getStoreVersionRootPaths().
|
||||
*/
|
||||
public void testGetStoreVersionRootPaths()
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
AVMNodeDescriptor desc = fService.lookup(-1, "main:/a/b/c/foo");
|
||||
List<String> paths = fService.getPathsInStoreVersion(desc, "main", 1);
|
||||
assertEquals(1, paths.size());
|
||||
assertEquals("main:/a/b/c/foo", paths.get(0));
|
||||
fService.getFileOutputStream("main:/a/b/c/foo").close();
|
||||
fService.createSnapshot("main", null, null);
|
||||
fService.getFileOutputStream("main:/a/b/c/foo").close();
|
||||
fService.createSnapshot("main", null, null);
|
||||
fService.getFileOutputStream("main:/a/b/c/foo").close();
|
||||
fService.createSnapshot("main", null, null);
|
||||
fService.getFileOutputStream("main:/a/b/c/foo").close();
|
||||
fService.createSnapshot("main", null, null);
|
||||
fService.getFileOutputStream("main:/a/b/c/foo").close();
|
||||
fService.createSnapshot("main", null, null);
|
||||
fService.getFileOutputStream("main:/a/b/c/foo").close();
|
||||
fService.createSnapshot("main", null, null);
|
||||
fService.getFileOutputStream("main:/a/b/c/foo").close();
|
||||
fService.createSnapshot("main", null, null);
|
||||
fService.getFileOutputStream("main:/a/b/c/foo").close();
|
||||
fService.createSnapshot("main", null, null);
|
||||
paths = fService.getPathsInStoreVersion(desc, "main", 1);
|
||||
assertEquals(1, paths.size());
|
||||
assertEquals("main:/a/b/c/foo", paths.get(0));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimal testing of Locking Aware service.
|
||||
*/
|
||||
|
@@ -814,7 +814,15 @@ public interface AVMService
|
||||
*/
|
||||
public List<Pair<Integer, String>> getPathsInStoreHead(AVMNodeDescriptor desc, String store);
|
||||
|
||||
|
||||
/**
|
||||
* Get all paths to a given node in a single store in a single non-head version.
|
||||
* @param desc The node descriptor.
|
||||
* @param store The name of the store.
|
||||
* @param version The version.
|
||||
* @return A List of AVM paths.
|
||||
*/
|
||||
public List<String> getPathsInStoreVersion(AVMNodeDescriptor desc, String store, int version);
|
||||
|
||||
/**
|
||||
* Get the indirection path for a node in a layered context
|
||||
* whether that indirection path is primary or non-primary
|
||||
|
Reference in New Issue
Block a user