|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.ogsadai.dataresource.XMLDBDataResourceAccessor
A data resource accessor that provides access to XMLDB 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.lang.String |
mCollectionURI
|
private java.lang.String |
mDriverClassName
|
private Property[] |
mProperties
|
private java.lang.String |
mResourceName
|
private RoleMapper |
mRoleMapper
|
Constructor Summary | |
XMLDBDataResourceAccessor()
|
Method Summary | |
private java.lang.String |
getAndLoadDriverClassName(org.w3c.dom.Document configDoc)
Returns the name of the XMLDB driver class and loads the class and registers it with the XMLDB database manager. |
java.lang.String |
getBaseCollectionURI()
Return the URI of the base collection. |
protected org.xmldb.api.base.Collection |
getCollection(java.lang.String collectionURI,
java.lang.String user,
java.lang.String password)
Obtains a collection from the database. |
private Property |
getCollectionSchema(java.lang.String name,
org.w3c.dom.Document configDoc)
Extract collection schema meta data from the data resource accessor configuration and converts to a property. |
private java.lang.String |
getCollectionURI(org.w3c.dom.Document configDoc)
Returns the URI of the database. |
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 Property[] |
getMetaData(java.lang.String name,
org.w3c.dom.Document configDoc)
Extract meta data from the data resource accessor configuration and convert to properties. |
private Property |
getProductInfo(org.w3c.dom.Document configDoc)
Extract product meta data from the data resource accessor configuration and convert to property. |
Property[] |
getProperties()
Gets the resource properties associated with the data resource accessor. |
private Property[] |
getProperties(Property productInfo,
Property collectionSchema,
Property[] metaData)
Gets data resource accessor properties - formed from aggregation of all meta data properties. |
private RoleMapper |
getRoleMapper(org.w3c.dom.Document configDoc)
Extracts the role mapper implementation class, creates an instance of it and initialises it with a role map file. |
org.xmldb.api.base.Collection |
getXMLDBCollection(java.lang.String userCredentials)
Returns an open collection for the base collection of a data resource. |
org.xmldb.api.base.Collection |
getXMLDBCollection(java.lang.String subCollection,
java.lang.String userCredentials)
Returns an open collection for the specified sub-collection of a data resource. |
void |
releaseXMLDBCollection(org.xmldb.api.base.Collection collection)
Releases a previously obtained XMLB collection. |
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. |
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 java.lang.String mResourceName
private Property[] mProperties
private RoleMapper mRoleMapper
private java.lang.String mDriverClassName
private java.lang.String mCollectionURI
Constructor Detail |
public XMLDBDataResourceAccessor()
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 getProductInfo(org.w3c.dom.Document configDoc)
configDoc
- Data resource accessor configuration document.
null
if none.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 Property[] getProperties(Property productInfo, Property collectionSchema, Property[] metaData)
productInfo
- Product meta data property.collectionSchema
- Collection schema property.metaData
- Other meta data properties.
private Property getCollectionSchema(java.lang.String name, org.w3c.dom.Document configDoc) throws DataResourceAccessorMetaDataException
Extracts a collection schema meta data extractor class from
the value of a callback
attribute of
a collectionSchema
child element of
metaData
. From this a dynamic property is
constructed. The dynamic property callback callsback in turn to
this class.
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 RoleMapper getRoleMapper(org.w3c.dom.Document configDoc) throws RoleMapperCreationException, RoleMapConfigurationException
The information is held within the roleMap
element
of a data resource accessor configuration file.
configDoc
- Data resource accessor configuration document.
RoleMapperCreationException
- if the role mapper cannot
be created.
RoleMapConfigurationException
- if the role mapper cannot
be configured with a role map file.private java.lang.String getAndLoadDriverClassName(org.w3c.dom.Document configDoc) throws DAIClassNotFoundException, DAIClassCreateException, DAIClassMissingInterfaceException, XMLDBRegistrationException
configDoc
- Data resource accessor configuration document.
DAIClassNotFoundException
- if the driver class cannot be
loaded.
DAIClassCreateException
- if an instance of the driver
cannot be created.
DAIClassMissingInterfaceException
- if the driver class
does not implement interfaces required by the XMLDB driver
manager.
throws XMLDBRegistrationException if the driver instance cannot
be registered with the XMLDB driver manager.
XMLDBRegistrationException
private java.lang.String getCollectionURI(org.w3c.dom.Document configDoc)
configDoc
- Data resource accessor configuration document.
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.lang.String getBaseCollectionURI()
XMLDBCollectionProvider
getBaseCollectionURI
in interface XMLDBCollectionProvider
public org.xmldb.api.base.Collection getXMLDBCollection(java.lang.String userCredentials) throws DataResourceAuthorizationException, XMLDBCollectionUseException, AuthorizationExecutionException
XMLDBCollectionProvider
The specified user credential may be used to authorize access to the data resource.
getXMLDBCollection
in interface XMLDBCollectionProvider
userCredentials
- Credentials specifing a user.
XMLDBCollectionUseException
- if there is a problem in
using the data resource.
AuthorizationExecutionException
- if there is a problem
encountered during the authorization.
DataResourceAuthorizationException
- if the user is not
authorized to access the collection.public org.xmldb.api.base.Collection getXMLDBCollection(java.lang.String subCollection, java.lang.String userCredentials) throws DataResourceAuthorizationException, XMLDBUnknownSubCollectionException, XMLDBCollectionUseException, AuthorizationExecutionException
XMLDBCollectionProvider
The specified user credential may be used to authorize access to the data resource.
getXMLDBCollection
in interface XMLDBCollectionProvider
subCollection
- The path to the sub-collection relative to the data
resource's base collection. This should not begin with a
"/". The "/" is added automatically to the base collection
URI when the full collection URI is composed. For example,
if the base collection is db
and the
sub-collection is test/addresses
then an open
collection for /db/test/addresses
will be
returned. If this is null
then the
base collection is returned.userCredentials
- Credentials specifing a user.
AuthorizationExecutionException
- if there is a problem
encountered during the authorization.
XMLDBUnknownSubCollectionException
- if the
sub-collection is unknown.
XMLDBCollectionUseException
- if there is a problem in
using the data resource.
DataResourceAuthorizationException
- if the user is not
authorized to access the collection or sub-collection.public void releaseXMLDBCollection(org.xmldb.api.base.Collection collection) throws XMLDBCollectionUseException
XMLDBCollectionProvider
Once a collection is finished with it should be passed back to this method. This allows collection pooling to be performed under the surface.
releaseXMLDBCollection
in interface XMLDBCollectionProvider
collection
- XMLDB collection to release. If the collection is
null
or already released then nothing is done.
XMLDBCollectionUseException
- if there is a problem in
closing the collection.protected org.xmldb.api.base.Collection getCollection(java.lang.String collectionURI, java.lang.String user, java.lang.String password) throws XMLDBCollectionUseException
collectionURI
- URI of the database collection.user
- User name used to access databasepassword
- Password used to access database.
null
if there is no
such collection.
XMLDBCollectionUseException
- if the collection cannot
be accessed.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |