Class StaticResourceServlet

java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.opencastproject.fsresources.StaticResourceServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class StaticResourceServlet extends javax.servlet.http.HttpServlet
Serves static content from a configured path on the filesystem. In production systems, this should be replaced with apache httpd or another web server optimized for serving static content.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    No-arg constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    activate(org.osgi.service.component.ComponentContext cc)
    OSGI Activation callback
    void
    addStaticFileAuthorization(org.opencastproject.security.api.StaticFileAuthorization authorization)
     
    protected void
    copy(File f, javax.servlet.ServletOutputStream out, Iterator<StaticResourceServlet.Range> ranges, String contentType)
     
    protected IOException
    copyRange(InputStream istream, javax.servlet.ServletOutputStream ostream, long start, long end)
    Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception).
    protected void
    doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
    protected void
    doHead(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
     
    parseRange(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse response, String eTag, long lastModified, long fileLength)
    Parse the range header.
    void
    removeStaticFileAuthorization(org.opencastproject.security.api.StaticFileAuthorization authorization)
     

    Methods inherited from class javax.servlet.http.HttpServlet

    doDelete, doOptions, doPost, doPut, doTrace, getLastModified, service, service

    Methods inherited from class javax.servlet.GenericServlet

    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • StaticResourceServlet

      public StaticResourceServlet()
      No-arg constructor
  • Method Details

    • addStaticFileAuthorization

      public void addStaticFileAuthorization(org.opencastproject.security.api.StaticFileAuthorization authorization)
    • removeStaticFileAuthorization

      public void removeStaticFileAuthorization(org.opencastproject.security.api.StaticFileAuthorization authorization)
    • activate

      public void activate(org.osgi.service.component.ComponentContext cc)
      OSGI Activation callback
      Parameters:
      cc - the component context
    • doGet

      protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException
      Overrides:
      doGet in class javax.servlet.http.HttpServlet
      Throws:
      IOException
      See Also:
      • HttpServlet.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    • doHead

      protected void doHead(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException
      Overrides:
      doHead in class javax.servlet.http.HttpServlet
      Throws:
      IOException
    • copy

      protected void copy(File f, javax.servlet.ServletOutputStream out, Iterator<StaticResourceServlet.Range> ranges, String contentType) throws IOException
      Throws:
      IOException
    • parseRange

      protected ArrayList<StaticResourceServlet.Range> parseRange(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse response, String eTag, long lastModified, long fileLength) throws IOException
      Parse the range header.
      Parameters:
      req - The servlet request we are processing
      response - The servlet response we are creating
      Returns:
      Vector of ranges
      Throws:
      IOException
    • copyRange

      protected IOException copyRange(InputStream istream, javax.servlet.ServletOutputStream ostream, long start, long end)
      Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception).
      Parameters:
      istream - The input stream to read from
      ostream - The output stream to write to
      start - Start of the range which will be copied
      end - End of the range which will be copied
      Returns:
      Exception which occurred during processing