mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added variants to getPaths, which get all HEAD paths for
a node or all HEAD paths for a node in a given store. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3977 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -932,12 +932,58 @@ public class AVMRepository
|
|||||||
public List<Pair<Integer, String>> getPaths(AVMNodeDescriptor desc)
|
public List<Pair<Integer, String>> getPaths(AVMNodeDescriptor desc)
|
||||||
{
|
{
|
||||||
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(desc.getId());
|
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(desc.getId());
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
throw new AVMNotFoundException("Not found: " + desc.getPath());
|
||||||
|
}
|
||||||
List<Pair<Integer, String>> paths = new ArrayList<Pair<Integer, String>>();
|
List<Pair<Integer, String>> paths = new ArrayList<Pair<Integer, String>>();
|
||||||
List<String> components = new ArrayList<String>();
|
List<String> components = new ArrayList<String>();
|
||||||
recursiveGetPaths(node, components, paths);
|
recursiveGetPaths(node, components, paths);
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all paths for a node reachable by HEAD.
|
||||||
|
* @param desc The node descriptor.
|
||||||
|
* @return A List of all the version, path Pairs that match.
|
||||||
|
*/
|
||||||
|
public List<Pair<Integer, String>> getHeadPaths(AVMNodeDescriptor desc)
|
||||||
|
{
|
||||||
|
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(desc.getId());
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
throw new AVMNotFoundException("Not found: " + desc.getPath());
|
||||||
|
}
|
||||||
|
List<Pair<Integer, String>> paths = new ArrayList<Pair<Integer, String>>();
|
||||||
|
List<String> components = new ArrayList<String>();
|
||||||
|
recursiveGetHeadPaths(node, components, paths);
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Pair<Integer, String>> getPathsInStoreHead(AVMNodeDescriptor desc, String store)
|
||||||
|
{
|
||||||
|
AVMStore st = getAVMStoreByName(store);
|
||||||
|
if (st == null)
|
||||||
|
{
|
||||||
|
throw new AVMNotFoundException("Store not found: " + store);
|
||||||
|
}
|
||||||
|
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(desc.getId());
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
throw new AVMNotFoundException("Not found: " + desc.getPath());
|
||||||
|
}
|
||||||
|
List<Pair<Integer, String>> paths = new ArrayList<Pair<Integer, String>>();
|
||||||
|
List<String> components = new ArrayList<String>();
|
||||||
|
recursiveGetPathsInStoreHead(node, components, paths, st.getRoot(), store);
|
||||||
|
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 recursiveGetPaths(AVMNode node, List<String> components,
|
private void recursiveGetPaths(AVMNode node, List<String> components,
|
||||||
List<Pair<Integer, String>> paths)
|
List<Pair<Integer, String>> paths)
|
||||||
{
|
{
|
||||||
@@ -966,7 +1012,63 @@ public class AVMRepository
|
|||||||
components.remove(components.size() - 1);
|
components.remove(components.size() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 recursiveGetHeadPaths(AVMNode node, List<String> components,
|
||||||
|
List<Pair<Integer, String>> paths)
|
||||||
|
{
|
||||||
|
if (node.getIsRoot())
|
||||||
|
{
|
||||||
|
AVMStore store = AVMContext.fgInstance.fAVMStoreDAO.getByRoot(node);
|
||||||
|
if (store != null)
|
||||||
|
{
|
||||||
|
addPath(components, -1, store.getName(), paths);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<ChildEntry> entries = AVMContext.fgInstance.fChildEntryDAO.getByChild(node);
|
||||||
|
for (ChildEntry entry : entries)
|
||||||
|
{
|
||||||
|
String name = entry.getName();
|
||||||
|
components.add(name);
|
||||||
|
AVMNode parent = entry.getParent();
|
||||||
|
recursiveGetHeadPaths(parent, components, paths);
|
||||||
|
components.remove(components.size() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 recursiveGetPathsInStoreHead(AVMNode node, List<String> components,
|
||||||
|
List<Pair<Integer, String>> paths, DirectoryNode root,
|
||||||
|
String storeName)
|
||||||
|
{
|
||||||
|
if (node.equals(root))
|
||||||
|
{
|
||||||
|
addPath(components, -1, storeName, paths);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<ChildEntry> entries = AVMContext.fgInstance.fChildEntryDAO.getByChild(node);
|
||||||
|
for (ChildEntry entry : entries)
|
||||||
|
{
|
||||||
|
String name = entry.getName();
|
||||||
|
components.add(name);
|
||||||
|
AVMNode parent = entry.getParent();
|
||||||
|
recursiveGetHeadPaths(parent, components, paths);
|
||||||
|
components.remove(components.size() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a path to the list.
|
* Add a path to the list.
|
||||||
* @param components The path name components.
|
* @param components The path name components.
|
||||||
|
@@ -582,6 +582,34 @@ public class AVMServiceImpl implements AVMService
|
|||||||
return fAVMRepository.getPaths(desc);
|
return fAVMRepository.getPaths(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all paths that a given node has that are in the head version.
|
||||||
|
* @param desc The node descriptor to get paths for.
|
||||||
|
* @return A List of version, path Pairs.
|
||||||
|
*/
|
||||||
|
public List<Pair<Integer, String>> getHeadPaths(AVMNodeDescriptor desc)
|
||||||
|
{
|
||||||
|
if (desc == null)
|
||||||
|
{
|
||||||
|
throw new AVMBadArgumentException("Descriptor is null.");
|
||||||
|
}
|
||||||
|
return fAVMRepository.getHeadPaths(desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all paths to a node starting at the HEAD version of a store.
|
||||||
|
* @param desc The node descriptor.
|
||||||
|
* @param store The store.
|
||||||
|
* @return A List of all paths meeting the criteria.
|
||||||
|
*/
|
||||||
|
public List<Pair<Integer, String>> getPathsInStoreHead(AVMNodeDescriptor desc, String store)
|
||||||
|
{
|
||||||
|
if (desc == null || store == null)
|
||||||
|
{
|
||||||
|
throw new AVMBadArgumentException("Illegal null argument.");
|
||||||
|
}
|
||||||
|
return fAVMRepository.getPathsInStoreHead(desc, store);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purge an AVMStore. Permanently delete everything that
|
* Purge an AVMStore. Permanently delete everything that
|
||||||
|
@@ -81,6 +81,18 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
{
|
{
|
||||||
System.out.println(path.getFirst() + " " + path.getSecond());
|
System.out.println(path.getFirst() + " " + path.getSecond());
|
||||||
}
|
}
|
||||||
|
paths = fService.getHeadPaths(fService.lookup(-1, "main:/a/b/c/foo"));
|
||||||
|
System.out.println("------------------------------");
|
||||||
|
for (Pair<Integer, String> path : paths)
|
||||||
|
{
|
||||||
|
System.out.println(path.getFirst() + " " + path.getSecond());
|
||||||
|
}
|
||||||
|
paths = fService.getPathsInStoreHead(fService.lookup(-1, "main:/a/b/c/foo"), "main");
|
||||||
|
System.out.println("------------------------------");
|
||||||
|
for (Pair<Integer, String> path : paths)
|
||||||
|
{
|
||||||
|
System.out.println(path.getFirst() + " " + path.getSecond());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@@ -415,6 +415,21 @@ public interface AVMService
|
|||||||
*/
|
*/
|
||||||
public List<Pair<Integer, String>> getPaths(AVMNodeDescriptor desc);
|
public List<Pair<Integer, String>> getPaths(AVMNodeDescriptor desc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all paths that a given node has that are in the head version.
|
||||||
|
* @param desc The node descriptor to get paths for.
|
||||||
|
* @return A List of version, path Pairs.
|
||||||
|
*/
|
||||||
|
public List<Pair<Integer, String>> getHeadPaths(AVMNodeDescriptor desc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all paths to a node starting at the HEAD version of a store.
|
||||||
|
* @param desc The node descriptor.
|
||||||
|
* @param store The store.
|
||||||
|
* @return A List of all paths meeting the criteria.
|
||||||
|
*/
|
||||||
|
public List<Pair<Integer, String>> getPathsInStoreHead(AVMNodeDescriptor desc, String store);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the indirection path for a node in a layered context.
|
* Get the indirection path for a node in a layered context.
|
||||||
* @param version The version number to get.
|
* @param version The version number to get.
|
||||||
|
Reference in New Issue
Block a user