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.ContentServicecontentServiceprotected org.alfresco.sync.repo.events.EventPublishereventPublisherstatic StringKEY_ALLOW_BROWSER_TO_CACHEstatic StringKEY_CACHE_DIRECTIVEprotected org.alfresco.service.cmr.repository.MimetypeServicemimetypeServiceprotected org.alfresco.service.cmr.repository.NodeServicenodeServiceServicesprotected org.springframework.core.io.ResourceLoaderresourceLoaderprotected org.alfresco.service.cmr.site.SiteServicesiteService
-
Constructor Summary
Constructors Constructor Description ContentStreamer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringfilterNameForQuotedString(String s)protected booleanisValidQuotedStringHeaderParamChar(char c)voidsetAttachment(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, boolean attach, String attachFileName)Set attachment headervoidsetContentService(org.alfresco.service.cmr.repository.ContentService contentService)voidsetEventPublisher(org.alfresco.sync.repo.events.EventPublisher eventPublisher)voidsetMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)voidsetNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)voidsetResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)protected voidsetResponseCache(org.springframework.extensions.webscripts.WebScriptResponse res, Date modified, String eTag, Map<String,Object> model)Set the cache settings on the responsevoidsetSiteService(org.alfresco.service.cmr.site.SiteService siteService)voidstreamContent(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 voidstreamContent(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.voidstreamContent(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.voidstreamContent(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.voidstreamContentImpl(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:
setResourceLoaderin 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 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, org.alfresco.service.cmr.repository.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, 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 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
-
isValidQuotedStringHeaderParamChar
protected boolean isValidQuotedStringHeaderParamChar(char c)
-
-