Class WSFileProviderEngine

java.lang.Object
com.iizix.server.wsfile.WSFileProviderEngine
All Implemented Interfaces:
IWSFileProviderServer

public class WSFileProviderEngine extends Object implements IWSFileProviderServer
Engine to handle file providing for external web server files, typically images and other client resources that are fetched from the web server.

The file contexts are:

  • Server session,
  • Per application (and version),
  • Per user (all sessions),
  • Per application session (on user basis),
  • Per client session.

The server places these files in subdirectories in the file provider directory configured for the server (default "wsfiles" in ServerSettings.DEFAULT_FILE_PROVIDER_ROOT).

Author:
Christopher Mindus
See Also:
  • Constructor Details

    • WSFileProviderEngine

      public WSFileProviderEngine(ServerSettings serverSettings) throws IOException
      Constructs a new engine. This constructor is intended to be used by the IIZI framework and not instantiated elsewhere.
      Parameters:
      serverSettings - The server settings.
      Throws:
      IOException - If the root directory for the files cannot be created.
    • WSFileProviderEngine

      public WSFileProviderEngine(File wsFileRootDir) throws IOException
      Constructs a new engine for the iiziGo Designer First-Time-Start dialog to assign a profile image. This constructor is intended to be used by the IIZI framework and not instantiated elsewhere.
      Parameters:
      wsFileRootDir - The web server provider files root directory.
      Throws:
      IOException - If the root directory does not exist.
  • Method Details

    • getCreateFileProvider

      public WSFileProvider getCreateFileProvider(URNResourceType type, String descr, String subject, Object id, boolean doPersistFileNames, ServerSettings settings) throws IOException
      Gets or creates a new engine type file provider. Depending on the engine type, just one may be created for a particular subject.
      Parameters:
      type - The engine type.
      descr - The description used for logging (ignored for single WSFileType's)
      subject - The subject when multiple file providers is supported, null (or ignored) for single types.
      id - The ID used when storing in a database: a Long or String value, Long for User ID, Group ID, String for Application ID
      doPersistFileNames - Flag to use the real file name for client caching purposes. Otherwise a unique file name is always generated.
      settings - The server settings.
      Returns:
      The file provider.
      Throws:
      IOException - If the sub-directory for the file provider type cannot be created.
      NullPointerException - If the subject or id is required but is null.
      IllegalArgumentException - If the id is required but of wrong class type (Long or String).
      IllegalStateException - If the engine is disposed of.
    • getFileResourceFromExternalURL

      public File getFileResourceFromExternalURL(String target)
      Gets the file resource for an external URL that starts with "/".
      Specified by:
      getFileResourceFromExternalURL in interface IWSFileProviderServer
      Parameters:
      target - The target request.
      Returns:
      The file target, or null if it is not found.
    • dispose

      public void dispose()
      Disposes of the engine and all the providers.