Class ContentStreamer
- java.lang.Object
-
- org.alfresco.repo.web.scripts.content.ContentStreamer
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ResourceLoaderAware
public class ContentStreamer extends Object implements org.springframework.context.ResourceLoaderAware
Can be used when the binary data of a content property needs to be streamed back to the client as the result of executing a web script. These methods are taken from the StreamContent class so they can be reused by other webscripts.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.alfresco.service.cmr.repository.ContentService
contentService
protected org.alfresco.sync.repo.events.EventPublisher
eventPublisher
static String
KEY_ALLOW_BROWSER_TO_CACHE
static String
KEY_CACHE_DIRECTIVE
protected org.alfresco.service.cmr.repository.MimetypeService
mimetypeService
protected org.alfresco.service.cmr.repository.NodeService
nodeService
Servicesprotected org.springframework.core.io.ResourceLoader
resourceLoader
protected org.alfresco.service.cmr.site.SiteService
siteService
-
Constructor Summary
Constructors Constructor Description ContentStreamer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
filterNameForQuotedString(String s)
protected boolean
isValidQuotedStringHeaderParamChar(char c)
void
setAttachment(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, boolean attach, String attachFileName)
Set attachment headervoid
setContentService(org.alfresco.service.cmr.repository.ContentService contentService)
void
setEventPublisher(org.alfresco.sync.repo.events.EventPublisher eventPublisher)
void
setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
void
setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
void
setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
protected void
setResponseCache(org.springframework.extensions.webscripts.WebScriptResponse res, Date modified, String eTag, Map<String,Object> model)
Set the cache settings on the responsevoid
setSiteService(org.alfresco.service.cmr.site.SiteService siteService)
void
streamContent(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, File file, Long modifiedTime, boolean attach, String attachFileName, Map<String,Object> model)
Streams content back to client from a given File.protected void
streamContent(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, String resourcePath, boolean attach, String attachFileName, Map<String,Object> model)
Streams content back to client from a given resource path.void
streamContent(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, String resourcePath, boolean attach, Map<String,Object> model)
Streams content back to client from a given resource path.void
streamContent(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName propertyQName, boolean attach, String attachFileName, Map<String,Object> model)
Streams the content on a given node's content property to the response of the web script.void
streamContentImpl(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName propertyQName, boolean attach, Date modified, String eTag, String attachFileName, Map<String,Object> model)
Stream content implementation
-
-
-
Field Detail
-
KEY_ALLOW_BROWSER_TO_CACHE
public static final String KEY_ALLOW_BROWSER_TO_CACHE
- See Also:
- Constant Field Values
-
KEY_CACHE_DIRECTIVE
public static final String KEY_CACHE_DIRECTIVE
- See Also:
- Constant Field Values
-
nodeService
protected org.alfresco.service.cmr.repository.NodeService nodeService
Services
-
contentService
protected org.alfresco.service.cmr.repository.ContentService contentService
-
mimetypeService
protected org.alfresco.service.cmr.repository.MimetypeService mimetypeService
-
resourceLoader
protected org.springframework.core.io.ResourceLoader resourceLoader
-
eventPublisher
protected org.alfresco.sync.repo.events.EventPublisher eventPublisher
-
siteService
protected org.alfresco.service.cmr.site.SiteService siteService
-
-
Method Detail
-
setMimetypeService
public void setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
- Parameters:
mimetypeService
- MimetypeService
-
setNodeService
public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
- Parameters:
nodeService
- NodeService
-
setEventPublisher
public void setEventPublisher(org.alfresco.sync.repo.events.EventPublisher eventPublisher)
- Parameters:
eventPublisher
- EventPublisher
-
setSiteService
public void setSiteService(org.alfresco.service.cmr.site.SiteService siteService)
- Parameters:
siteService
- SiteService
-
setResourceLoader
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
- Specified by:
setResourceLoader
in interfaceorg.springframework.context.ResourceLoaderAware
-
setContentService
public void setContentService(org.alfresco.service.cmr.repository.ContentService contentService)
- Parameters:
contentService
- ContentService
-
streamContent
public void streamContent(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, File file, Long modifiedTime, boolean attach, String attachFileName, Map<String,Object> model) throws IOException
Streams content back to client from a given File.- Parameters:
req
- The requestres
- The responsefile
- The file whose content is to be streamed.modifiedTime
- The modified datetime to use for the streamed content. If null the file's timestamp will be used.attach
- Indicates whether the content should be streamed as an attachment or notattachFileName
- Optional file name to use when attach istrue
- Throws:
IOException
-
streamContent
public void streamContent(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName propertyQName, boolean attach, String attachFileName, Map<String,Object> model) throws IOException
Streams the content on a given node's content property to the response of the web script.- Parameters:
req
- Requestres
- ResponsenodeRef
- The node referencepropertyQName
- The content property nameattach
- Indicates whether the content should be streamed as an attachment or notattachFileName
- Optional file name to use when attach istrue
- Throws:
IOException
-
streamContent
public void streamContent(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, String resourcePath, boolean attach, Map<String,Object> model) throws IOException
Streams content back to client from a given resource path.- Parameters:
req
- The requestres
- The responseresourcePath
- The classpath resource path the content is required forattach
- Indicates whether the content should be streamed as an attachment or not- Throws:
IOException
-
streamContent
protected void streamContent(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, String resourcePath, boolean attach, String attachFileName, Map<String,Object> model) throws IOException
Streams content back to client from a given resource path.- Parameters:
req
- The requestres
- The responseresourcePath
- The classpath resource path the content is required for.attach
- Indicates whether the content should be streamed as an attachment or notattachFileName
- Optional file name to use when attach istrue
- Throws:
IOException
-
streamContentImpl
public void streamContentImpl(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName propertyQName, boolean attach, Date modified, String eTag, String attachFileName, Map<String,Object> model) throws IOException
Stream content implementation- Parameters:
req
- The requestres
- The responsereader
- The readernodeRef
- The content nodeRef if applicablepropertyQName
- The content property if applicableattach
- Indicates whether the content should be streamed as an attachment or notmodified
- Modified date of contenteTag
- ETag to useattachFileName
- Optional file name to use when attach istrue
- Throws:
IOException
-
setAttachment
public void setAttachment(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, boolean attach, String attachFileName)
Set attachment header- Parameters:
req
- WebScriptRequestres
- WebScriptResponseattach
- booleanattachFileName
- String
-
isValidQuotedStringHeaderParamChar
protected boolean isValidQuotedStringHeaderParamChar(char c)
-
-