Package com.iizix.wsfile
Interface IWSFileProvider
- All Known Implementing Classes:
- WSFileProvider
public interface IWSFileProvider
The interface is used to provide files to the web server for various contexts:
- 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.
- Author:
- Christopher Mindus
- Method SummaryModifier and TypeMethodDescription- createDownloadInstance- (URL url, Object id, String description) Constructs an instance of a file to download.- void- downloadFiles- (IAppSessionGyro appGyro, IWSFileDownload[] files, Runnable completed) Downloads the collection of files.- getFileFromFileName- (String fileName) Gets a WSFile from a file name that is located inside the root of the provider.- getRoot()Gets the root directory.- getType()Returns the file type.Gets the URL path to the provider in the web server.- booleanChecks if the provider is disposed of.- reserveFile- (File file, String descr, Object id) Reserves an existing file on disk, i.e.
- Method Details- getTypeURNResourceType getType()Returns the file type.
- getRootGets the root directory.- Returns:
- The canonical root directory.
- Throws:
- IOException- If the root doesn't exist anymore or the provider is disposed of, or if the root doesn't exist and the directory cannot be created.
 
- createDownloadInstanceConstructs an instance of a file to download.- Parameters:
- url- The URL of the file to download.
- id- The ID used for database identification, Long or String,- nullwhen database is not used.- This value depends on the URNResourceType. The types are: - Long  :- URNResourceType.COMMON_DATABASE_PERSISTENT: Common database persistent files.
- String:- URNResourceType.APPLICATION_DATABASE_PERSISTENT: Application ID database persistent files.
- Long :- URNResourceType.GROUP_DATABASE_FILES: Group ID database persistent files.
- Long :- URNResourceType.USER_DATABASE_FILES: User ID database persistent files.
 
- description- Description of file, used to store in e.g. database, max 128 characters long.
- Throws:
- IllegalArgumentException- If the- descriptionis longer than 128 characters, or if the- idis of wrong class (not String or Long) depending on the- {@link URNResourceType}.
- NullPointerException- If- urlor- descriptionis- null, or that the- idis required to be specified for the- {@link URNResourceType}.
 
- downloadFilesDownloads the collection of files. Once all downloads a completed, the callback is invoked. If the application session is disposed of, the callback is not called.- Parameters:
- appGyro- The application session gyro, or null for system.
- files- The array of files to download. The results are placed in the respective instances.
- completed- Callback invoked upon completion of the downloads (with error or not).
 
- isDisposedboolean isDisposed()Checks if the provider is disposed of.- Returns:
- true if disposed, false otherwise.
 
- reserveFileIWSFile reserveFile- (File file, String descr, Object id) throws NotFoundException, IllegalArgumentException, IOException Reserves an existing file on disk, i.e. inside the root. If the file already is reserved, the previous WSFile instance is returned and no new reservation is done.- Parameters:
- file- The file.
- descr- The description.
- id- When a backing database is used, specify the user or group identifier as a- Long, the Application ID as a- String, or- nullwhen there is no special identifier, i.e. for global files.
- Returns:
- A new WSFile instance with a reserved name.
- Throws:
- NotFoundException- If the file doesn't exist.
- IllegalArgumentException- If the file parent is not this providers root directory, or if the ID does not match the database ID type (- Longor- String).
- IOException- For read errors of the file, or if the filename is not "compatible" with the database table.
 
- getURLPathString getURLPath()Gets the URL path to the provider in the web server.- Returns:
- The path on the web server, starting and ending with '/'.
 
- getFileFromFileNameGets a WSFile from a file name that is located inside the root of the provider.- Parameters:
- fileName- The file name to look up.
- Returns:
- The WSFile instance, or null if not found.