Class StreamContent

  • All Implemented Interfaces:
    org.springframework.extensions.webscripts.WebScript
    Direct Known Subclasses:
    ContentGet, ContentInfo, NodeContentGet, StreamACP, StreamJMXDump, WorkflowInstanceDiagramGet

    public class StreamContent
    extends org.springframework.extensions.webscripts.AbstractWebScript
    Web script 'type' that can be used when the binary data of a content property needs to be streamed back to the client as the result of executing the web script. Many of these methods have been moved into the ContentStreamer class so they can be reused by other webscripts.
    Author:
    Roy Wetherall
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.springframework.extensions.webscripts.AbstractWebScript

        org.springframework.extensions.webscripts.AbstractWebScript.ScriptDetails
    • Constructor Summary

      Constructors 
      Constructor Description
      StreamContent()  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected org.alfresco.repo.web.scripts.content.StreamContent.ObjectReference createObjectReferenceFromUrl​(Map<String,​String> args, Map<String,​String> templateArgs)  
      void execute​(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res)  
      protected Map<String,​Object> executeImpl​(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.Status status)
      Deprecated. 
      protected Map<String,​Object> executeImpl​(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.Status status, org.springframework.extensions.webscripts.Cache cache)
      Execute custom Java logic
      protected Map<String,​Object> executeImpl​(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptStatus status)
      Deprecated. 
      protected void renderFormatTemplate​(String format, Map<String,​Object> model, Writer writer)
      Render a template (of given format) to the Web Script Response
      protected void setAttachment​(org.springframework.extensions.webscripts.WebScriptResponse res, boolean attach, String attachFileName)
      Set attachment header
      void setDelegate​(ContentStreamer delegate)  
      void setMimetypeService​(MimetypeService mimetypeService)  
      void setNodeService​(NodeService nodeService)  
      void setPermissionService​(PermissionService permissionService)  
      void setRepository​(Repository repository)  
      protected void streamContent​(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, File file)
      Streams content back to client from a given File.
      protected void streamContent​(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, File file, 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, NodeRef nodeRef, 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.
      protected 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)
      Stream content implementation
      • Methods inherited from class org.springframework.extensions.webscripts.AbstractWebScript

        addModuleBundleToCache, checkModuleBundleCache, createArgs, createArgsM, createHeaders, createHeadersM, createScriptParameters, createStatusException, createTemplateParameters, executeScript, getContainer, getDescription, getExecuteScript, getResources, getStatusTemplate, init, renderString, renderString, renderTemplate, sendStatus, setURLModelFactory, toString
    • Constructor Detail

      • StreamContent

        public StreamContent()
    • Method Detail

      • setMimetypeService

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

        public void setPermissionService​(PermissionService permissionService)
        Parameters:
        permissionService - PermissionService
      • setNodeService

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

        public void setDelegate​(ContentStreamer delegate)
        Parameters:
        delegate - ContentStreamer
      • setRepository

        public void setRepository​(Repository repository)
        Parameters:
        repository - Repository
      • execute

        public void execute​(org.springframework.extensions.webscripts.WebScriptRequest req,
                            org.springframework.extensions.webscripts.WebScriptResponse res)
                     throws IOException
        Throws:
        IOException
        See Also:
        WebScript.execute(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.WebScriptResponse)
      • setAttachment

        protected void setAttachment​(org.springframework.extensions.webscripts.WebScriptResponse res,
                                     boolean attach,
                                     String attachFileName)
        Set attachment header
        Parameters:
        res - WebScriptResponse
        attach - boolean
        attachFileName - String
      • streamContent

        protected void streamContent​(org.springframework.extensions.webscripts.WebScriptRequest req,
                                     org.springframework.extensions.webscripts.WebScriptResponse res,
                                     File file)
                              throws IOException
        Streams content back to client from a given File. The Last-Modified header will reflect the given file's modification timestamp.
        Parameters:
        req - The request
        res - The response
        file - The file whose content is to be streamed.
        Throws:
        IOException
      • streamContent

        protected void streamContent​(org.springframework.extensions.webscripts.WebScriptRequest req,
                                     org.springframework.extensions.webscripts.WebScriptResponse res,
                                     File file,
                                     boolean attach,
                                     String attachFileName,
                                     Map<String,​Object> model)
                              throws IOException
        Streams content back to client from a given File. The Last-Modified header will reflect the given file's modification timestamp.
        Parameters:
        req - The request
        res - The response
        file - The file whose content is to be streamed.
        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

        protected 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
      • streamContentImpl

        protected 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
      • executeImpl

        protected Map<String,​Object> executeImpl​(org.springframework.extensions.webscripts.WebScriptRequest req,
                                                       org.springframework.extensions.webscripts.WebScriptStatus status)
        Deprecated.
        Execute custom Java logic
        Parameters:
        req - Web Script request
        status - Web Script status
        Returns:
        custom service model
      • executeImpl

        protected Map<String,​Object> executeImpl​(org.springframework.extensions.webscripts.WebScriptRequest req,
                                                       org.springframework.extensions.webscripts.Status status)
        Deprecated.
        Execute custom Java logic
        Parameters:
        req - Web Script request
        status - Web Script status
        Returns:
        custom service model
      • executeImpl

        protected Map<String,​Object> executeImpl​(org.springframework.extensions.webscripts.WebScriptRequest req,
                                                       org.springframework.extensions.webscripts.Status status,
                                                       org.springframework.extensions.webscripts.Cache cache)
        Execute custom Java logic
        Parameters:
        req - Web Script request
        status - Web Script status
        cache - Web Script cache
        Returns:
        custom service model
      • renderFormatTemplate

        protected final void renderFormatTemplate​(String format,
                                                  Map<String,​Object> model,
                                                  Writer writer)
        Render a template (of given format) to the Web Script Response
        Parameters:
        format - template format (null, default format)
        model - data model to render
        writer - where to output
      • createObjectReferenceFromUrl

        protected org.alfresco.repo.web.scripts.content.StreamContent.ObjectReference createObjectReferenceFromUrl​(Map<String,​String> args,
                                                                                                                   Map<String,​String> templateArgs)