Added accessors for node history. Added those to console.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3135 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-06-18 15:32:45 +00:00
parent 6fff182633
commit c892c5a4b5
8 changed files with 180 additions and 16 deletions

View File

@@ -20,6 +20,7 @@ package org.alfresco.repo.avm;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -508,6 +509,28 @@ class SuperRepository
return repo.getInputStream(version, pathParts[1]);
}
/**
* Get an InputStream from a given version of a file.
* @param desc The node descriptor.
* @return The InputStream.
*/
public InputStream getInputStream(AVMNodeDescriptor desc)
{
fLookupCount.set(1);
AVMNode node = (AVMNode)fSession.get().get(AVMNodeImpl.class, desc.getId());
if (node == null)
{
throw new AVMNotFoundException("Not found.");
}
if (node.getType() != AVMNodeType.PLAIN_FILE &&
node.getType() != AVMNodeType.LAYERED_FILE)
{
throw new AVMWrongTypeException("Not a file.");
}
FileNode file = (FileNode)node;
return file.getContentForRead().getInputStream(SuperRepository.GetInstance());
}
/**
* Get a listing of a directory.
* @param version The version to look under.
@@ -780,6 +803,36 @@ class SuperRepository
rep.retargetLayeredDirectory(pathParts[1], target);
}
/**
* Get the history chain for a node.
* @param desc The node to get history of.
* @param count The maximum number of ancestors to traverse. Negative means all.
* @return A List of ancestors.
*/
public List<AVMNodeDescriptor> getHistory(AVMNodeDescriptor desc, int count)
{
AVMNode node = (AVMNode)fSession.get().get(AVMNodeImpl.class, desc.getId());
if (node == null)
{
throw new AVMNotFoundException("Not found.");
}
if (count < 0)
{
count = Integer.MAX_VALUE;
}
List<AVMNodeDescriptor> history = new ArrayList<AVMNodeDescriptor>();
for (int i = 0; i < count; i++)
{
node = node.getAncestor();
if (node == null)
{
break;
}
history.add(node.getDescriptor("UNKNOWN", "UNKNOWN", "UNKNOWN"));
}
return history;
}
/**
* Get the single instance of SuperRepository.
* @return