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:
Britt Park
2007-06-22 22:10:05 +00:00
parent 54d7208f7b
commit 7e9c7b505c
5 changed files with 124 additions and 1 deletions

View File

@@ -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);
}
}
}