Class 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 Detail

      • nodeService

        protected NodeService nodeService
        Services
      • resourceLoader

        protected org.springframework.core.io.ResourceLoader resourceLoader
      • eventPublisher

        protected org.alfresco.repo.events.EventPublisher eventPublisher
    • Constructor Detail

      • ContentStreamer

        public ContentStreamer()
    • Method Detail

      • setMimetypeService

        public void setMimetypeService​(MimetypeService mimetypeService)
        Parameters:
        mimetypeService - MimetypeService
      • setNodeService

        public void setNodeService​(NodeService nodeService)
        Parameters:
        nodeService - NodeService
      • setEventPublisher

        public void setEventPublisher​(org.alfresco.repo.events.EventPublisher eventPublisher)
        Parameters:
        eventPublisher - EventPublisher
      • setSiteService

        public void setSiteService​(SiteService siteService)
        Parameters:
        siteService - SiteService
      • setResourceLoader

        public void setResourceLoader​(org.springframework.core.io.ResourceLoader resourceLoader)
        Specified by:
        setResourceLoader in interface org.springframework.context.ResourceLoaderAware
      • setContentService

        public void setContentService​(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 request
        res - The response
        file - 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 not
        attachFileName - Optional file name to use when attach is true
        Throws:
        IOException
      • streamContent

        public void streamContent​(org.springframework.extensions.webscripts.WebScriptRequest req,
                                  org.springframework.extensions.webscripts.WebScriptResponse res,
                                  NodeRef nodeRef,
                                  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 - Request
        res - Response
        nodeRef - The node reference
        propertyQName - The content property name
        attach - Indicates whether the content should be streamed as an attachment or not
        attachFileName - Optional file name to use when attach is true
        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 request
        res - The response
        resourcePath - The classpath resource path the content is required for
        attach - 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 request
        res - The response
        resourcePath - The classpath resource path the content is required for.
        attach - Indicates whether the content should be streamed as an attachment or not
        attachFileName - Optional file name to use when attach is true
        Throws:
        IOException
      • streamContentImpl

        public void streamContentImpl​(org.springframework.extensions.webscripts.WebScriptRequest req,
                                      org.springframework.extensions.webscripts.WebScriptResponse res,
                                      ContentReader reader,
                                      NodeRef nodeRef,
                                      QName propertyQName,
                                      boolean attach,
                                      Date modified,
                                      String eTag,
                                      String attachFileName,
                                      Map<String,​Object> model)
                               throws IOException
        Stream content implementation
        Parameters:
        req - The request
        res - The response
        reader - The reader
        nodeRef - The content nodeRef if applicable
        propertyQName - The content property if applicable
        attach - Indicates whether the content should be streamed as an attachment or not
        modified - Modified date of content
        eTag - ETag to use
        attachFileName - Optional file name to use when attach is true
        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 - WebScriptRequest
        res - WebScriptResponse
        attach - boolean
        attachFileName - String
      • filterNameForQuotedString

        protected String filterNameForQuotedString​(String s)
      • 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 - WebScriptResponse
        modified - Date
        eTag - String