Class FileServlet

java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.openremote.container.web.file.AbstractFileServlet
org.openremote.container.web.file.FileServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class FileServlet extends AbstractFileServlet
See Also:
  • Field Details

    • DEFAULT_EXPIRE_SECONDS

      public static final long DEFAULT_EXPIRE_SECONDS
      See Also:
    • EXPIRES_SECONDS_CACHE_JS

      public static final long EXPIRES_SECONDS_CACHE_JS
      See Also:
    • devMode

      protected final boolean devMode
    • base

      protected final File base
    • unsecuredIndex

      protected final File unsecuredIndex
    • requiredRoles

      protected final String[] requiredRoles
    • mimeTypes

      protected final Map<String,String> mimeTypes
    • mimeTypesExpireSeconds

      protected final Map<String,Integer> mimeTypesExpireSeconds
    • alreadyZippedExtensions

      protected final String[] alreadyZippedExtensions
  • Constructor Details

  • Method Details

    • isSecured

      public boolean isSecured()
    • service

      protected void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
      Overrides:
      service in class javax.servlet.http.HttpServlet
      Throws:
      javax.servlet.ServletException
      IOException
    • getFile

      protected File getFile(javax.servlet.http.HttpServletRequest request) throws AbstractFileServlet.RedirectException
      Description copied from class: AbstractFileServlet
      Returns the file associated with the given HTTP servlet request. If this method throws IllegalArgumentException, then the servlet will return a HTTP 400 error. If this method returns null, or if File.isFile() returns false, then the servlet will invoke AbstractFileServlet.handleFileNotFound(HttpServletRequest, HttpServletResponse).
      Specified by:
      getFile in class AbstractFileServlet
      Parameters:
      request - The involved HTTP servlet request.
      Returns:
      The file associated with the given HTTP servlet request.
      Throws:
      AbstractFileServlet.RedirectException
    • getExpireTime

      protected long getExpireTime(javax.servlet.http.HttpServletRequest request, File file)
      Description copied from class: AbstractFileServlet
      Returns how long the resource may be cached by the client before it expires, in seconds.

      The default implementation returns 30 days in seconds.

      Overrides:
      getExpireTime in class AbstractFileServlet
      Parameters:
      request - The involved HTTP servlet request.
      file - The involved file.
      Returns:
      The client cache expire time in seconds (not milliseconds!).
    • getContentType

      protected String getContentType(javax.servlet.http.HttpServletRequest request, File file)
      Description copied from class: AbstractFileServlet
      Returns the content type associated with the given HTTP servlet request and file.

      The default implementation delegates File.getName() to ServletContext.getMimeType(String) with a fallback default value of application/octet-stream.

      Overrides:
      getContentType in class AbstractFileServlet
      Parameters:
      request - The involved HTTP servlet request.
      file - The involved file.
      Returns:
      The content type associated with the given HTTP servlet request and file.
    • setContentHeaders

      protected String setContentHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, AbstractFileServlet.Resource resource, List<AbstractFileServlet.Range> ranges)
      Description copied from class: AbstractFileServlet
      Set content headers.
      Overrides:
      setContentHeaders in class AbstractFileServlet
    • getExtension

      protected String getExtension(String fileName)