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
FieldsModifier and TypeFieldDescriptionprotected ContentService
protected org.alfresco.sync.repo.events.EventPublisher
static final String
static final String
protected MimetypeService
protected NodeService
Servicesprotected org.springframework.core.io.ResourceLoader
protected SiteService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
protected boolean
void
setAttachment
(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, boolean attach, String attachFileName) Set attachment headervoid
setContentService
(ContentService contentService) void
setEventPublisher
(org.alfresco.sync.repo.events.EventPublisher eventPublisher) void
setMimetypeService
(MimetypeService mimetypeService) void
setNodeService
(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
(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, 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, ContentReader reader, NodeRef nodeRef, org.alfresco.service.namespace.QName propertyQName, boolean attach, Date modified, String eTag, String attachFileName, Map<String, Object> model) Stream content implementation
-
Field Details
-
KEY_ALLOW_BROWSER_TO_CACHE
- See Also:
-
KEY_CACHE_DIRECTIVE
- See Also:
-
nodeService
Services -
contentService
-
mimetypeService
-
resourceLoader
protected org.springframework.core.io.ResourceLoader resourceLoader -
eventPublisher
protected org.alfresco.sync.repo.events.EventPublisher eventPublisher -
siteService
-
-
Constructor Details
-
ContentStreamer
public ContentStreamer()
-
-
Method Details
-
setMimetypeService
- Parameters:
mimetypeService
- MimetypeService
-
setNodeService
- Parameters:
nodeService
- NodeService
-
setEventPublisher
public void setEventPublisher(org.alfresco.sync.repo.events.EventPublisher eventPublisher) - Parameters:
eventPublisher
- EventPublisher
-
setSiteService
- Parameters:
siteService
- SiteService
-
setResourceLoader
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) - Specified by:
setResourceLoader
in interfaceorg.springframework.context.ResourceLoaderAware
-
setContentService
- 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 IOExceptionStreams 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, NodeRef nodeRef, org.alfresco.service.namespace.QName propertyQName, boolean attach, String attachFileName, Map<String, Object> model) throws IOExceptionStreams 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 IOExceptionStreams 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 IOExceptionStreams 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, ContentReader reader, NodeRef nodeRef, org.alfresco.service.namespace.QName propertyQName, boolean attach, Date modified, String eTag, String attachFileName, Map<String, Object> model) throws IOExceptionStream 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
-
filterNameForQuotedString
-
isValidQuotedStringHeaderParamChar
protected boolean isValidQuotedStringHeaderParamChar(char c) -
setResponseCache
protected void setResponseCache(org.springframework.extensions.webscripts.WebScriptResponse res, Date modified, String eTag, Map<String, Object> model) Set the cache settings on the response- Parameters:
res
- WebScriptResponsemodified
- DateeTag
- String
-