Added getContentReader and createContentWriter to AVMService. Also added convenience

getDirectoryListingArray() calls which return listings as arrays instead of Maps.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4377 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-11-16 19:53:42 +00:00
parent b5f3167443
commit 4287b291d4
6 changed files with 187 additions and 8 deletions

View File

@@ -41,6 +41,8 @@ import org.alfresco.service.cmr.avm.AVMWrongTypeException;
import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.alfresco.util.TempFileProvider;
@@ -105,6 +107,35 @@ public class AVMServiceImpl implements AVMService
return fAVMRepository.getOutputStream(path);
}
/**
* Get a content reader from a file node.
* @param version The version of the file.
* @param path The path to the file.
* @return A ContentReader.
*/
public ContentReader getContentReader(int version, String path)
{
if (path == null)
{
throw new AVMBadArgumentException("Null path.");
}
return fAVMRepository.getContentReader(version, path);
}
/**
* Get a ContentWriter to a file node.
* @param path The path to the file.
* @return A ContentWriter.
*/
public ContentWriter createContentWriter(String path)
{
if (path == null)
{
throw new AVMBadArgumentException("Null path.");
}
return fAVMRepository.createContentWriter(path);
}
/**
* Get a directory listing.
* @param version The version id to lookup.
@@ -137,6 +168,47 @@ public class AVMServiceImpl implements AVMService
return fAVMRepository.getListing(version, path, includeDeleted);
}
/**
* Get a directory listing as an Array of AVMNodeDescriptors.
* @param version The version to look under.
* @param path The path to the directory to be listed.
* @param includeDeleted Whether to include ghosts.
* @return An array of AVMNodeDescriptors.
*/
public AVMNodeDescriptor [] getDirectoryListingArray(int version, String path,
boolean includeDeleted)
{
Map<String, AVMNodeDescriptor> listing =
getDirectoryListing(version, path, includeDeleted);
AVMNodeDescriptor [] result = new AVMNodeDescriptor[listing.size()];
int off = 0;
for (AVMNodeDescriptor desc : listing.values())
{
result[off++] = desc;
}
return result;
}
/**
* Get a directory listing as an Array of node descriptors.
* @param dir The descriptor pointing at the directory to list.
* @param includeDeleted Whether to show ghosts.
* @return An array of AVMNodeDescriptors.
*/
public AVMNodeDescriptor [] getDirectoryListingArray(AVMNodeDescriptor dir,
boolean includeDeleted)
{
Map<String, AVMNodeDescriptor> listing =
getDirectoryListing(dir, includeDeleted);
AVMNodeDescriptor [] result = new AVMNodeDescriptor[listing.size()];
int off = 0;
for (AVMNodeDescriptor desc : listing.values())
{
result[off++] = desc;
}
return result;
}
/**
* Get a listing of all the directly contained children of a directory.
* @param dir The directory descriptor.