Interface IAppDirectory

All Known Implementing Classes:
AppDirectory

public interface IAppDirectory
The virtual directory /app/<appID>/ of one application, as the server builds it and AppDirectoryHandler serves it (work order CC-PWA-V5A-APPDIR-ROUTE, design CC-DESIGN-APP-URL-V2 section 2.4): the generated application page per language, with the stamp of the directory and the time the stamp was first built.

An instance is immutable. The server holds one per application factory, built at the first request, so a hot deploy - which builds a new factory - discards it by construction; the handler never caches one. The pages are the generator's output, complete but for the three substitutions the handler makes per response: the client gate's appID marker, the Web Analytics line, and the registration of the application's Service Worker.

Beside the pages, the directory holds its generated files (work order CC-PWA-V5E-APPDIR-PWA, design section 2.2): the Service Worker sw.js and the offline page offline.html of every application, and the manifest per language (manifest-<lang>.webmanifest, or manifest.webmanifest without a language), the icons - any, maskable and monochrome in 192 and 512 px and the Apple touch icon - and the screenshots (screenshots/<name>) of an installable one (CC-PUSH-PWA-PAGES Set I). They are generated with the pages, so the stamp covers them, and the handler serves them as they are.

Author:
Christopher Mindus
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    A generated file of the directory: its media type, its bytes, and its max-age, zero for no-cache.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The max-age of an icon in seconds, one day (design 2.4): every other file of the directory is no-cache.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the canonical application ID of the directory: the ID the application was registered under, never an alias.
    getFile(String name, String lang)
    Gets a generated file of the directory by its name directly under the directory.
    Gets the application page for a language.
    Gets the stamp v of the directory: the first 16 hexadecimal digits of SHA-256 over the generated bytes of every file of the directory and the server's version and build.
    long
    Gets the time the stamp was first built, the Last-Modified of every file of the directory.
  • Field Details

    • ICON_MAX_AGE

      static final int ICON_MAX_AGE
      The max-age of an icon in seconds, one day (design 2.4): every other file of the directory is no-cache.
      See Also:
  • Method Details

    • getAppID

      String getAppID()
      Gets the canonical application ID of the directory: the ID the application was registered under, never an alias. The handler redirects an alias to it.
      Returns:
      The application ID, never null nor empty.
    • getStamp

      String getStamp()
      Gets the stamp v of the directory: the first 16 hexadecimal digits of SHA-256 over the generated bytes of every file of the directory and the server's version and build. Two directories with the same pages on the same build have the same stamp; one byte of difference gives another. It is the first half of every ETag the handler sends.
      Returns:
      The stamp, 16 lower-case hexadecimal digits.
    • getVersionTime

      long getVersionTime()
      Gets the time the stamp was first built, the Last-Modified of every file of the directory.
      Returns:
      The time in milliseconds since the Epoch, whole seconds.
    • getPage

      String getPage(String lang)
      Gets the application page for a language.
      Parameters:
      lang - The language code from the lang entry parameter, null or empty for the default language.
      Returns:
      The page, never null: the default language's page when the language is not one of the application's.
    • getFile

      default IAppDirectory.GeneratedFile getFile(String name, String lang)
      Gets a generated file of the directory by its name directly under the directory.
      Parameters:
      name - The name: sw.js, offline.html, manifest-<lang>.webmanifest (or manifest.webmanifest), one of the icon names, or screenshots/<file>.
      lang - The language code from the lang entry parameter, null or empty for the default language: it selects the language of a file that is served in several languages under one name - the offline page, whose answer for a language the application does not have is the default language's - and is ignored for the others.
      Returns:
      The file, or null when the directory holds none of that name: the manifest and the icons of an application without .iiziPWA, a manifest of another language, or a directory without generated files, which is what this default answers.