uk.ac.soton.itinnovation.registry.component.xml.db.xmldb
Class XmlDbAccessXmlDb

java.lang.Object
  extended by uk.ac.soton.itinnovation.registry.component.xml.db.XmlDbAccessAdapter<org.xmldb.api.modules.XMLResource>
      extended by uk.ac.soton.itinnovation.registry.component.xml.db.xmldb.XmlDbAccessXmlDb
All Implemented Interfaces:
PermissionManagement, XmlDbAccess<org.xmldb.api.modules.XMLResource>, Access

public class XmlDbAccessXmlDb
extends XmlDbAccessAdapter<org.xmldb.api.modules.XMLResource>
implements Access, XmlDbAccess<org.xmldb.api.modules.XMLResource>


Field Summary
 
Fields inherited from class uk.ac.soton.itinnovation.registry.component.xml.db.XmlDbAccessAdapter
cacheManagement, internalUsedQueries, logger
 
Method Summary
 boolean createCollection(String dir)
          Creates a collection specified by the directory name, if not already exists.
 ResultIterator<org.xmldb.api.modules.XMLResource> executePredefinedQuery(String name, ParameterValue... parameterValues)
          Execute predefined query.
 HashSet<String> getIdentifierByFile(String file)
          Checks identity of an inserted object.
 HashSet<String> getIdentifierByTemporyResource(String tempId, String dir)
           
 HashSet<String> getIdentifierByTemporyResource(org.xmldb.api.modules.XMLResource resource, String dir)
           
 HashSet<String> getIdentifierByXQuery(String xquery)
          This methods returns a set of document identifiers that correspond to the result of the xquery.
 String getIdentifierOfResource(org.xmldb.api.modules.XMLResource resource)
          Get identifier of specific resource.
 ArrayList<String> getIdentifiesByRelation(String id, String relation)
          Get referenced identifiers of a specified relationship based on the entity with specified id.
 ArrayList<String> getIdentifiesByRelation(org.xmldb.api.modules.XMLResource resource, String relation)
          Get referenced identifiers of a specified relationship based on a specified entity.
 String getLocalDirectoryName(String docId)
          Get the local name of the collection storing a specific entity.
 org.xmldb.api.base.Collection getOrCreateCollection(String dir)
          Get or create a database collection.
 ArrayList<String> getRelationships(String id)
          Get the provided relationships of an object specified by its identifier.
 ArrayList<String> getRelationships(org.xmldb.api.modules.XMLResource resource)
          Get the provided relationships of a persistent resource.
 ArrayList<org.xmldb.api.modules.XMLResource> getResourcesByRelation(String id, String relation)
          Get referenced objects of a specified relationship based on the entity with specified id.
 ArrayList<org.xmldb.api.modules.XMLResource> getResourcesByRelation(org.xmldb.api.modules.XMLResource resource, String relation)
          Get referenced objects of a specified relationship based on a specified entity.
protected  void initHook()
          Implementation of the init method in derived classes.
 void insertRelationship(String fromId, String fromConcept, String relationshipName, String toId, String toConcept)
          Stores a relationship with specific name between two documents specified by their ids.
protected  void loadPredefinedQueriesIntoCache(CacheManagement cacheManagement)
          Load the predefined queries into the registry cache management.
 org.xmldb.api.modules.XMLResource lookup(String docId)
          Lookup a specific XML resource by its document identifier.
 org.xmldb.api.modules.XMLResource lookup(String docId, String type)
          Lookup a specific XML resource by its document identifier and the directoryPath it belongs to.
 ResultIterator<org.xmldb.api.modules.XMLResource> lookupByDirectory(String dir)
          Returns documents (resources) that are stored in the specified directory.
 ArrayList<org.xmldb.api.modules.XMLResource> lookupByFile(String file)
           
 ArrayList<org.xmldb.api.modules.XMLResource> lookupByTemporaryResource(org.xmldb.api.modules.XMLResource resource, String dir)
           
 ResultIterator<org.xmldb.api.modules.XMLResource> query(org.xmldb.api.base.Collection collection, String xquery)
          Execute an xquery statement on the registry.
 ResultIterator<org.xmldb.api.modules.XMLResource> query(String xquery)
          Execute an xquery statement on the registry.
 void registerPredefinedQuery(String name, String query, String... parameterNames)
          Register a predefined query expression with the database.
 void removeAllDocumentsFromRegistry(String directoryPath)
          Removes all resources from the registry specified by the directory.
 void removeDocumentFromRegistry(String directoryPath, String id)
          Remove a resource (xml document) from a specified collection.
 void resetPredefinedQueries()
          Reset the predefined queries.
 void setPermission(String directoryPath, String str)
          Change the permissions of a specified directory.
 void setPermission(String directoryPath, String resourceName, String str)
          Change the permissions of a resource under the specified directory.
 String storeDocumentInRegistry(String directoryPath, Document content, String id)
          Stores a resource (dom) in the registry.
 String storeDocumentInRegistry(String directoryPath, File file, String id)
          Stores a resource (xml document) that is specified by a file.
 String storeDocumentInRegistry(String directoryPath, String filename, String id)
          Stores a resource (xml document) that is specified by a file.
 String storeDocumentInRegistry(String directoryPath, URI uri, String id)
          Stores a resource (xml document) that is specified by a URI.
 void storePredefinedQuery(String name, String query, String... parameterNames)
          Stores a predefined query in the database.
 String storeStringDocumentInRegistry(String directoryPath, String content, String id)
          Stores a resource (xml document) that is specified by a string.
 
Methods inherited from class uk.ac.soton.itinnovation.registry.component.xml.db.XmlDbAccessAdapter
getCacheManagement, init, loadRegistyDomainModelIntoCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initHook

protected final void initHook()
                       throws ExceptionInInitializerError
Description copied from class: XmlDbAccessAdapter
Implementation of the init method in derived classes.

Specified by:
initHook in class XmlDbAccessAdapter<org.xmldb.api.modules.XMLResource>
Throws:
ExceptionInInitializerError

createCollection

public final boolean createCollection(String dir)
                               throws DatabaseException
Description copied from interface: XmlDbAccess
Creates a collection specified by the directory name, if not already exists.

Specified by:
createCollection in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Parameters:
dir - dir has to start with an '/'
Returns:
true, if the collection is created, otherwise false.
Throws:
DatabaseException

getOrCreateCollection

public final org.xmldb.api.base.Collection getOrCreateCollection(String dir)
                                                          throws DatabaseException
Get or create a database collection.

Parameters:
dir -
Returns:
the new created collection.
Throws:
DatabaseException

storeDocumentInRegistry

public final String storeDocumentInRegistry(String directoryPath,
                                            String filename,
                                            String id)
                                     throws DatabaseException,
                                            IOException
Description copied from interface: XmlDbAccess
Stores a resource (xml document) that is specified by a file.

Specified by:
storeDocumentInRegistry in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Parameters:
directoryPath - concept under which the document is stored (beginning with '/')
id - identifier of the resource. If null then a new identifier will be generated.
Returns:
The id of the resource.
Throws:
DatabaseException
IOException

storeDocumentInRegistry

public final String storeDocumentInRegistry(String directoryPath,
                                            URI uri,
                                            String id)
                                     throws DatabaseException,
                                            IOException
Description copied from interface: XmlDbAccess
Stores a resource (xml document) that is specified by a URI.

Specified by:
storeDocumentInRegistry in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Parameters:
directoryPath - concept under which the document is stored (beginning with '/')
id - identifier of the resource. If null then a new identifier will be generated.
Returns:
The id of the resource.
Throws:
DatabaseException
IOException

storeDocumentInRegistry

public final String storeDocumentInRegistry(String directoryPath,
                                            File file,
                                            String id)
                                     throws DatabaseException,
                                            IOException
Description copied from interface: XmlDbAccess
Stores a resource (xml document) that is specified by a file.

Specified by:
storeDocumentInRegistry in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Parameters:
directoryPath - concept under which the document is stored (beginning with '/')
id - identifier of the resource. If null then a new identifier will be generated.
Returns:
The id of the resource.
Throws:
DatabaseException
IOException

storeStringDocumentInRegistry

public final String storeStringDocumentInRegistry(String directoryPath,
                                                  String content,
                                                  String id)
                                           throws DatabaseException,
                                                  IOException
Description copied from interface: XmlDbAccess
Stores a resource (xml document) that is specified by a string.

Specified by:
storeStringDocumentInRegistry in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Parameters:
directoryPath - concept under which the document is stored (beginning with '/')
content - xml content
id - identifier of the resource. If null then a new identifier will be generated.
Returns:
The id of the resource.
Throws:
DatabaseException
IOException

storeDocumentInRegistry

public final String storeDocumentInRegistry(String directoryPath,
                                            Document content,
                                            String id)
                                     throws DatabaseException,
                                            IOException
Description copied from interface: XmlDbAccess
Stores a resource (dom) in the registry.

Specified by:
storeDocumentInRegistry in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Returns:
the id of the resource in the registry
Throws:
DatabaseException
IOException

removeDocumentFromRegistry

public final void removeDocumentFromRegistry(String directoryPath,
                                             String id)
                                      throws DatabaseException
Description copied from interface: XmlDbAccess
Remove a resource (xml document) from a specified collection.

Specified by:
removeDocumentFromRegistry in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Parameters:
directoryPath - directory under which the document is stored (beginning with '/')
Throws:
DatabaseException

removeAllDocumentsFromRegistry

public final void removeAllDocumentsFromRegistry(String directoryPath)
                                          throws DatabaseException
Description copied from interface: XmlDbAccess
Removes all resources from the registry specified by the directory.

Specified by:
removeAllDocumentsFromRegistry in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

insertRelationship

public final void insertRelationship(String fromId,
                                     String fromConcept,
                                     String relationshipName,
                                     String toId,
                                     String toConcept)
                              throws DatabaseException
Description copied from interface: XmlDbAccess
Stores a relationship with specific name between two documents specified by their ids.

Specified by:
insertRelationship in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

getRelationships

public final ArrayList<String> getRelationships(String id)
                                         throws DatabaseException
Description copied from interface: XmlDbAccess
Get the provided relationships of an object specified by its identifier.

Specified by:
getRelationships in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

getRelationships

public final ArrayList<String> getRelationships(org.xmldb.api.modules.XMLResource resource)
                                         throws DatabaseException
Description copied from interface: XmlDbAccess
Get the provided relationships of a persistent resource.

Specified by:
getRelationships in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

getIdentifiesByRelation

public final ArrayList<String> getIdentifiesByRelation(String id,
                                                       String relation)
                                                throws DatabaseException
Description copied from interface: XmlDbAccess
Get referenced identifiers of a specified relationship based on the entity with specified id.

Specified by:
getIdentifiesByRelation in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

getIdentifiesByRelation

public final ArrayList<String> getIdentifiesByRelation(org.xmldb.api.modules.XMLResource resource,
                                                       String relation)
                                                throws DatabaseException
Description copied from interface: XmlDbAccess
Get referenced identifiers of a specified relationship based on a specified entity.

Specified by:
getIdentifiesByRelation in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

getResourcesByRelation

public final ArrayList<org.xmldb.api.modules.XMLResource> getResourcesByRelation(String id,
                                                                                 String relation)
                                                                          throws DatabaseException
Description copied from interface: XmlDbAccess
Get referenced objects of a specified relationship based on the entity with specified id.

Specified by:
getResourcesByRelation in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

getResourcesByRelation

public final ArrayList<org.xmldb.api.modules.XMLResource> getResourcesByRelation(org.xmldb.api.modules.XMLResource resource,
                                                                                 String relation)
                                                                          throws DatabaseException
Description copied from interface: XmlDbAccess
Get referenced objects of a specified relationship based on a specified entity.

Specified by:
getResourcesByRelation in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

executePredefinedQuery

public final ResultIterator<org.xmldb.api.modules.XMLResource> executePredefinedQuery(String name,
                                                                                      ParameterValue... parameterValues)
                                                                               throws DatabaseException
Description copied from interface: XmlDbAccess
Execute predefined query.

Specified by:
executePredefinedQuery in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Parameters:
name - name under with the query is stored.
Throws:
DatabaseException

getLocalDirectoryName

public final String getLocalDirectoryName(String docId)
                                   throws DatabaseException,
                                          AccessException
Description copied from interface: XmlDbAccess
Get the local name of the collection storing a specific entity.

Specified by:
getLocalDirectoryName in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException
AccessException

lookup

public final org.xmldb.api.modules.XMLResource lookup(String docId)
                                               throws DatabaseException
Description copied from interface: XmlDbAccess
Lookup a specific XML resource by its document identifier.

Specified by:
lookup in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Returns:
xml resource of null if it is not found
Throws:
DatabaseException

lookup

public final org.xmldb.api.modules.XMLResource lookup(String docId,
                                                      String type)
                                               throws DatabaseException
Description copied from interface: XmlDbAccess
Lookup a specific XML resource by its document identifier and the directoryPath it belongs to.

Specified by:
lookup in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
type - (begins with '/')
Returns:
xml resource or null if it is not found
Throws:
DatabaseException

lookupByFile

public final ArrayList<org.xmldb.api.modules.XMLResource> lookupByFile(String file)
                                                                throws DatabaseException,
                                                                       IOException
Specified by:
lookupByFile in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException
IOException

lookupByTemporaryResource

public final ArrayList<org.xmldb.api.modules.XMLResource> lookupByTemporaryResource(org.xmldb.api.modules.XMLResource resource,
                                                                                    String dir)
                                                                             throws DatabaseException
Specified by:
lookupByTemporaryResource in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

lookupByDirectory

public final ResultIterator<org.xmldb.api.modules.XMLResource> lookupByDirectory(String dir)
                                                                          throws DatabaseException
Description copied from interface: XmlDbAccess
Returns documents (resources) that are stored in the specified directory.

Specified by:
lookupByDirectory in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

getIdentifierByFile

public final HashSet<String> getIdentifierByFile(String file)
                                          throws DatabaseException,
                                                 IOException
Description copied from interface: XmlDbAccess
Checks identity of an inserted object. Remark: order of childs is important, i.e. exact matching (==) and not equals

Specified by:
getIdentifierByFile in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException
IOException

getIdentifierByTemporyResource

public HashSet<String> getIdentifierByTemporyResource(String tempId,
                                                      String dir)
                                               throws DatabaseException
Specified by:
getIdentifierByTemporyResource in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Parameters:
tempId - identifier of temporal resource
dir - search directory
Throws:
DatabaseException

getIdentifierByTemporyResource

public HashSet<String> getIdentifierByTemporyResource(org.xmldb.api.modules.XMLResource resource,
                                                      String dir)
                                               throws DatabaseException
Specified by:
getIdentifierByTemporyResource in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
dir - search directory
Throws:
DatabaseException

getIdentifierOfResource

public final String getIdentifierOfResource(org.xmldb.api.modules.XMLResource resource)
                                     throws DatabaseException
Description copied from interface: XmlDbAccess
Get identifier of specific resource.

Specified by:
getIdentifierOfResource in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

getIdentifierByXQuery

public final HashSet<String> getIdentifierByXQuery(String xquery)
                                            throws DatabaseException
Description copied from interface: XmlDbAccess
This methods returns a set of document identifiers that correspond to the result of the xquery.

Specified by:
getIdentifierByXQuery in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

query

public ResultIterator<org.xmldb.api.modules.XMLResource> query(String xquery)
                                                        throws DatabaseException
Description copied from interface: XmlDbAccess
Execute an xquery statement on the registry.

Specified by:
query in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

query

public final ResultIterator<org.xmldb.api.modules.XMLResource> query(org.xmldb.api.base.Collection collection,
                                                                     String xquery)
                                                              throws DatabaseException
Execute an xquery statement on the registry.

Parameters:
collection - query runs over the specified collection.
xquery -
Throws:
DatabaseException

storePredefinedQuery

public final void storePredefinedQuery(String name,
                                       String query,
                                       String... parameterNames)
                                throws DatabaseException
Description copied from interface: XmlDbAccess
Stores a predefined query in the database. The name must be unique. If this name is already used, the content will be overwritten.

Specified by:
storePredefinedQuery in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Parameters:
name - name of the query
query - xquery expression
parameterNames - parameters used in the query
Throws:
DatabaseException

registerPredefinedQuery

public final void registerPredefinedQuery(String name,
                                          String query,
                                          String... parameterNames)
                                   throws DatabaseException
Description copied from interface: XmlDbAccess
Register a predefined query expression with the database.

Specified by:
registerPredefinedQuery in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>
Throws:
DatabaseException

resetPredefinedQueries

public void resetPredefinedQueries()
Description copied from interface: XmlDbAccess
Reset the predefined queries.

Specified by:
resetPredefinedQueries in interface XmlDbAccess<org.xmldb.api.modules.XMLResource>

loadPredefinedQueriesIntoCache

protected void loadPredefinedQueriesIntoCache(CacheManagement cacheManagement)
Description copied from class: XmlDbAccessAdapter
Load the predefined queries into the registry cache management.

Specified by:
loadPredefinedQueriesIntoCache in class XmlDbAccessAdapter<org.xmldb.api.modules.XMLResource>

setPermission

public void setPermission(String directoryPath,
                          String resourceName,
                          String str)
                   throws PermissionManagementException
Description copied from interface: PermissionManagement
Change the permissions of a resource under the specified directory. Set permissions using a string. The string has the following syntax: [user|group|other]=[+|-][read|write|update] For example, to set read and write permissions for the group, but not for others: group=+read,+write,other=-read,-write The new settings are or'ed with the existing settings.

Specified by:
setPermission in interface PermissionManagement
Throws:
PermissionManagementException

setPermission

public void setPermission(String directoryPath,
                          String str)
                   throws PermissionManagementException
Description copied from interface: PermissionManagement
Change the permissions of a specified directory. Set permissions using a string. The string has the following syntax: [user|group|other]=[+|-][read|write|update] For example, to set read and write permissions for the group, but not for others: group=+read,+write,other=-read,-write The new settings are or'ed with the existing settings.

Specified by:
setPermission in interface PermissionManagement
Throws:
PermissionManagementException


Copyright © 2001-2007 University of Southampton IT Innovation Centre. All Rights Reserved.