Package com.iizix.server.wsfile
Class WSFileProviderEngine
- java.lang.Object
- com.iizix.server.wsfile.WSFileProviderEngine
- All Implemented Interfaces:
IWSFileProviderServer
public class WSFileProviderEngine extends java.lang.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:
WSFile
,URNResourceType
Constructor Summary
Constructors Constructor Description WSFileProviderEngine(ServerSettings serverSettings)
Constructs a new engine.WSFileProviderEngine(java.io.File wsFileRootDir)
Constructs a new engine for the iiziGo Designer First-Time-Start dialog to assign a profile image.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Disposes of the engine and all the providers.WSFileProvider
getCreateFileProvider(URNResourceType type, java.lang.String descr, java.lang.String subject, java.lang.Object id, boolean doPersistFileNames, ServerSettings settings)
Gets or creates a new engine type file provider.java.io.File
getFileResourceFromExternalURL(java.lang.String target)
Gets the file resource for an external URL that starts with "/".
Constructor Detail
WSFileProviderEngine
public WSFileProviderEngine(ServerSettings serverSettings) throws java.io.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:
java.io.IOException
- If the root directory for the files cannot be created.
WSFileProviderEngine
public WSFileProviderEngine(java.io.File wsFileRootDir) throws java.io.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:
java.io.IOException
- If the root directory does not exist.
Method Detail
getCreateFileProvider
public WSFileProvider getCreateFileProvider(URNResourceType type, java.lang.String descr, java.lang.String subject, java.lang.Object id, boolean doPersistFileNames, ServerSettings settings) throws java.io.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 IDdoPersistFileNames
- 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:
java.io.IOException
- If the sub-directory for the file provider type cannot be created.java.lang.NullPointerException
- If thesubject
orid
is required but isnull
.java.lang.IllegalArgumentException
- If theid
is required but of wrong class type (Long or String).java.lang.IllegalStateException
- If the engine is disposed of.
getFileResourceFromExternalURL
public java.io.File getFileResourceFromExternalURL(java.lang.String target)
Gets the file resource for an external URL that starts with "/".- Specified by:
getFileResourceFromExternalURL
in interfaceIWSFileProviderServer
- 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.