mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added a method to AVMService and its dependent services to get an InputStream
directly from a node descriptor. It's a minor optimization for a few use scenarios. It's also convenient for accessing content of historical file versions directly. Another CLT, to list the versions of a store. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4496 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,6 +27,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
||||
@@ -41,6 +42,7 @@ 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.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
@@ -75,6 +77,11 @@ public class AVMRepository
|
||||
*/
|
||||
private Issuer fLayerIssuer;
|
||||
|
||||
/**
|
||||
* Reference to the ContentStoreImpl
|
||||
*/
|
||||
private ContentStore fContentStore;
|
||||
|
||||
/**
|
||||
* The Lookup Cache instance.
|
||||
*/
|
||||
@@ -107,6 +114,14 @@ public class AVMRepository
|
||||
fLayerIssuer = layerIssuer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ContentService.
|
||||
*/
|
||||
public void setContentStore(ContentStore store)
|
||||
{
|
||||
fContentStore = store;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Lookup Cache instance.
|
||||
* @param cache The instance to set.
|
||||
@@ -798,6 +813,23 @@ public class AVMRepository
|
||||
}
|
||||
}
|
||||
|
||||
public InputStream getInputStream(AVMNodeDescriptor desc)
|
||||
{
|
||||
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(desc.getId());
|
||||
if (!(node instanceof FileNode))
|
||||
{
|
||||
throw new AVMWrongTypeException(desc + " is not a File.");
|
||||
}
|
||||
FileNode file = (FileNode)node;
|
||||
ContentData data = file.getContentData(null);
|
||||
if (data == null)
|
||||
{
|
||||
throw new AVMException(desc + " has no content.");
|
||||
}
|
||||
ContentReader reader = fContentStore.getReader(data.getContentUrl());
|
||||
return reader.getContentInputStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a listing of a directory.
|
||||
* @param version The version to look under.
|
||||
|
Reference in New Issue
Block a user