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 java.lang.Object implements org.springframework.context.ResourceLoaderAwareCan 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 java.lang.StringKEY_ALLOW_BROWSER_TO_CACHEstatic java.lang.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 java.lang.StringfilterNameForQuotedString(java.lang.String s)protected booleanisValidQuotedStringHeaderParamChar(char c)voidsetAttachment(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, boolean attach, java.lang.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, java.util.Date modified, java.lang.String eTag, java.util.Map<java.lang.String,java.lang.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, java.io.File file, java.lang.Long modifiedTime, boolean attach, java.lang.String attachFileName, java.util.Map<java.lang.String,java.lang.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, java.lang.String resourcePath, boolean attach, java.lang.String attachFileName, java.util.Map<java.lang.String,java.lang.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, java.lang.String resourcePath, boolean attach, java.util.Map<java.lang.String,java.lang.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, java.lang.String attachFileName, java.util.Map<java.lang.String,java.lang.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, java.util.Date modified, java.lang.String eTag, java.lang.String attachFileName, java.util.Map<java.lang.String,java.lang.Object> model)Stream content implementation
-
-
-
Field Detail
-
KEY_ALLOW_BROWSER_TO_CACHE
public static final java.lang.String KEY_ALLOW_BROWSER_TO_CACHE
- See Also:
- Constant Field Values
-
KEY_CACHE_DIRECTIVE
public static final java.lang.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, java.io.File file, java.lang.Long modifiedTime, boolean attach, java.lang.String attachFileName, java.util.Map<java.lang.String,java.lang.Object> model) throws java.io.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:
java.io.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, java.lang.String attachFileName, java.util.Map<java.lang.String,java.lang.Object> model) throws java.io.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:
java.io.IOException
-
streamContent
public void streamContent(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, java.lang.String resourcePath, boolean attach, java.util.Map<java.lang.String,java.lang.Object> model) throws java.io.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:
java.io.IOException
-
streamContent
protected void streamContent(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, java.lang.String resourcePath, boolean attach, java.lang.String attachFileName, java.util.Map<java.lang.String,java.lang.Object> model) throws java.io.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:
java.io.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, java.util.Date modified, java.lang.String eTag, java.lang.String attachFileName, java.util.Map<java.lang.String,java.lang.Object> model) throws java.io.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:
java.io.IOException
-
setAttachment
public void setAttachment(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, boolean attach, java.lang.String attachFileName)Set attachment header- Parameters:
req- WebScriptRequestres- WebScriptResponseattach- booleanattachFileName- String
-
filterNameForQuotedString
protected java.lang.String filterNameForQuotedString(java.lang.String s)
-
isValidQuotedStringHeaderParamChar
protected boolean isValidQuotedStringHeaderParamChar(char c)
-
setResponseCache
protected void setResponseCache(org.springframework.extensions.webscripts.WebScriptResponse res, java.util.Date modified, java.lang.String eTag, java.util.Map<java.lang.String,java.lang.Object> model)Set the cache settings on the response- Parameters:
res- WebScriptResponsemodified- DateeTag- String
-
-