|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.ogsadai.dataresource.FilesDataResourceAccessor
A data resource accessor that provides access to file system data resources.
The configuration file is named dataResourceConfig.xml
and is assumed to reside in the configuration files directory for
the data service resource that owns this data resource accessor.
Field Summary | |
private static java.lang.String |
COPYRIGHT_NOTICE
|
private static DAILogger |
LOG
|
private static java.lang.String |
MAIN_CONFIG_FILE_NAME
|
private java.io.File |
mDirectory
|
private Property[] |
mProperties
|
private java.lang.String |
mResourceName
|
Constructor Summary | |
FilesDataResourceAccessor()
|
Method Summary | |
boolean |
canReadFile(java.lang.String userCredential,
java.io.File file)
Determines whether the user is allowed to read the specified file or directory. |
boolean |
canWriteFile(java.lang.String userCredential,
java.io.File file)
Determines whether the user is allowed to write the specified file or directory. |
private org.w3c.dom.Document |
getConfigAsDOM(java.lang.String name,
java.io.File dir)
Reads the data resource accessor configuration file and converts it to DOM. |
private java.io.File |
getDirectory(java.lang.String name,
java.lang.String path)
Returns the directory corresponding to the given path. |
java.io.File |
getHomeDirectory(java.lang.String userCredential)
Gets the file data resource directory for a specified user. |
private Property[] |
getMetaData(java.lang.String name,
org.w3c.dom.Document configDoc)
Extract meta data from the data resource accessor configuration and convert to properties. |
Property[] |
getProperties()
Gets the resource properties associated with the data resource accessor. |
private java.lang.String |
getRootDirectory(org.w3c.dom.Document configDoc)
Returns the root directory of the file data resource. |
void |
restoreFromConfig(java.io.File directory)
Configures the data resource accessor by reading any relevant configuration files in the given directory. |
void |
setResourceName(java.lang.String resourceName)
Sets the name of the resource. |
void |
validateReadFile(java.lang.String userCredential,
java.io.File file)
Determines whether the user is allowed to read the specified file or directory. |
void |
validateWriteFile(java.lang.String userCredential,
java.io.File file)
Determines whether the user is allowed to write the specified file or directory. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.String COPYRIGHT_NOTICE
private static DAILogger LOG
private static final java.lang.String MAIN_CONFIG_FILE_NAME
private Property[] mProperties
private java.lang.String mResourceName
private java.io.File mDirectory
Constructor Detail |
public FilesDataResourceAccessor()
Method Detail |
public void setResourceName(java.lang.String resourceName)
DataResourceAccessor
setResourceName
in interface DataResourceAccessor
resourceName
- Name of the data service resource which will use this data
resource accessor to mediate access to a data resource.public void restoreFromConfig(java.io.File directory) throws DataResourceAccessorConfigException, DataResourceAccessorMetaDataException, DataResourceAccessorSetupException, java.lang.IllegalArgumentException
PersistInFiles
If a data service resource is being constructed by reading
from a configuration file this method will be called once
immediately after the setName
method is called.
The data resource accessor should read its configuration from
the files in the given directory of the data service resource
which uses it.
Data resource accessors are free to add, amend or delete files
in the given directory at any time throughout their lifetime.
The exception to this rule is the
dataResourceClassConfig.xml
file which must be
left unaltered since this specifies the data resource accessor
class name.
restoreFromConfig
in interface PersistInFiles
directory
- Directory containing the data service resource configuration files.
This includes the data resource accessor configuration files.
java.lang.IllegalArgumentException
- if the directory
argument
is null
or is not a directory.
DataResourceAccessorSetupException
- if an error occurs when setting up the data resource accessor after
having read the configuration files.
DataResourceAccessorConfigException
- if an error occurs reading the configuration files.
DataResourceAccessorMetaDataException
- if an error occurs when constructing data resource accessor meta
data properties.private org.w3c.dom.Document getConfigAsDOM(java.lang.String name, java.io.File dir) throws DataResourceAccessorConfigException
name
- Data service resource name.dir
- Data service resource configuration files directory.
DataResourceAccessorConfigException
- if there is an
error in reading the configuration file.private Property[] getMetaData(java.lang.String name, org.w3c.dom.Document configDoc) throws DataResourceAccessorMetaDataException
name
- Data service resource name.configDoc
- Data resource accessor configuration document.
DataResourceAccessorMetaDataException
- if an error
occurs when constructing data resource accessor meta data
properties.private java.lang.String getRootDirectory(org.w3c.dom.Document configDoc)
configDoc
- Data resource accessor configuration document.
private java.io.File getDirectory(java.lang.String name, java.lang.String path) throws DataResourceAccessorSetupException
name
- Data service resource name.path
- Top-level path name.
DataResourceAccessorSetupException
- if the directory
does not exist is not a directory.public Property[] getProperties()
DataResourceAccessor
This method should be called once after the
readConfig
method has been called but before any
other methods are called.
getProperties
in interface DataResourceAccessor
public java.io.File getHomeDirectory(java.lang.String userCredential) throws DataResourceAuthorizationException, FilesResourceUseException, AuthorizationExecutionException
FileAccessProvider
getHomeDirectory
in interface FileAccessProvider
userCredential
- Credentials specifying a user.
DataResourceAuthorizationException
- if the user is not
permitted any access to any part of the file data resource.
AuthorizationExecutionException
- if there is a problem
when authorizing the request.
FilesResourceUseException
- if there is a problem in
using the resource.public boolean canReadFile(java.lang.String userCredential, java.io.File file) throws FilesResourceUseException
FileAccessProvider
canReadFile
in interface FileAccessProvider
userCredential
- Credentials of the specified user.file
- File or directory. The file need not currently exist.
true
if the user may attempt to read this
file or directory, false
otherwise.
FilesResourceUseException
- if there is a problem in
using the resource.public void validateReadFile(java.lang.String userCredential, java.io.File file) throws DataResourceAuthorizationException, FilesResourceUseException, AuthorizationExecutionException
FileAccessProvider
validateReadFile
in interface FileAccessProvider
userCredential
- Credentials of the specified user.file
- File or directory. The file need not currently exist.
FilesResourceUseException
- if there is a problem in
using the resource.
AuthorizationExecutionException
- if there is a problem
when authorizing the request.
DataResourceAuthorizationException
- if the user is not
permitted any access to any part of the file data resource.public boolean canWriteFile(java.lang.String userCredential, java.io.File file) throws FilesResourceUseException
FileAccessProvider
canWriteFile
in interface FileAccessProvider
userCredential
- Credentials of the specified user.file
- File or directory. The file need not currently exist.
true
if the user may attempt to write this
file or directory, false
otherwise.
FilesResourceUseException
- if there is a problem in
using the resource.public void validateWriteFile(java.lang.String userCredential, java.io.File file) throws DataResourceAuthorizationException, FilesResourceUseException, AuthorizationExecutionException
FileAccessProvider
validateWriteFile
in interface FileAccessProvider
userCredential
- Credentials of the specified user.file
- File or directory. The file need not currently exist.
FilesResourceUseException
- if there is a problem in
using the resource.
AuthorizationExecutionException
- if there is a problem
when authorizing the request.
DataResourceAuthorizationException
- if the user is not
permitted any access to any part of the file data resource.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |