Class FileWebService

All Implemented Interfaces:
HttpUtil
Direct Known Subclasses:
AppWebService

public class FileWebService extends WebService
A file web service. This service is used for retrieving binary (or text) files from the storage, usually the standard web site files (HTML, CSS, JavaScript, etc). This web service only support HTTP GET requests.
Version:
1.0
  • Field Details

    • KEY_PATH

      public static final String KEY_PATH
      The dictionary key for the base storage path for files.
      See Also:
  • Constructor Details

    • FileWebService

      public FileWebService(String id, String type, Dict dict)
      Creates a new file web service from a serialized representation.
      Parameters:
      id - the object identifier
      type - the object type name
      dict - the serialized representation
  • Method Details

    • path

      public Path path()
      Returns the base storage path for file lookups.
      Overrides:
      path in class StorableObject
      Returns:
      the base storage path
    • methodsImpl

      protected String[] methodsImpl(Request request)
      Returns the HTTP methods implemented for the specified request. The OPTIONS or HEAD methods doesn't have to be added to the result (added automatically later).
      Specified by:
      methodsImpl in class WebService
      Parameters:
      request - the request to check
      Returns:
      the array of HTTP method names supported
      See Also:
    • doGet

      protected void doGet(Request request)
      Processes an HTTP GET request.
      Overrides:
      doGet in class WebService
      Parameters:
      request - the request to process
    • processFile

      protected void processFile(Request request, Path filePath, boolean exact)
      Processes a storage file retrieval request (if possible).
      Parameters:
      request - the request to process
      filePath - the storage path to the binary file
      exact - the exact path match flag
    • lookupPaths

      protected Stream<Path> lookupPaths(Path filePath, boolean exact)
      Returns an ordered stream of file lookup paths. For non-exact matches this includes all parent "404.html" and "index.html" paths.
      Parameters:
      filePath - the requested file path
      exact - the exact path match flag
      Returns:
      the stream of lookup paths