|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fr.gouv.culture.sdx.utils.AbstractSdxObject fr.gouv.culture.sdx.utils.database.DatabaseBacked fr.gouv.culture.sdx.repository.AbstractDatabaseBackedRepository fr.gouv.culture.sdx.repository.URLRepository
public class URLRepository
Implements a repository where url's are referenced.
There are two main concerns with this repository : (1) how to retrieve efficiently a document from it's id and (2) how to access the referenced urls.
For the first concern, we use a simplified SDX database to keep track of ids and their references.
For the second concern, one can give some parameters to help reference the urls. These parameters are :
base
, http url, local file url, relative path
to the directory which contains this file, it must already exist
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface fr.gouv.culture.sdx.repository.Repository |
---|
Repository.ConfigurationNode |
Field Summary |
---|
Fields inherited from class fr.gouv.culture.sdx.repository.AbstractDatabaseBackedRepository |
---|
isDefault |
Fields inherited from class fr.gouv.culture.sdx.utils.database.DatabaseBacked |
---|
_database, CLASS_NAME_SUFFIX, DATABASE_DIR_NAME, databaseConf, dbLocation, dbPath, DEFAULT_DATABASE_TYPE |
Fields inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject |
---|
_configuration, _context, _description, _encoding, _id, _locale, _logger, _manager, _xmlizable_objects, _xmlLang, isToSaxInitialized |
Fields inherited from interface fr.gouv.culture.sdx.repository.Repository |
---|
CLASS_NAME_SUFFIX, PACKAGE_QUALNAME |
Fields inherited from interface fr.gouv.culture.sdx.utils.Encodable |
---|
DEFAULT_ENCODING |
Fields inherited from interface fr.gouv.culture.sdx.utils.save.Saveable |
---|
ALL_SAVE_ATTRIB, PATH_ATTRIB, SAVE_DIRECTORY_PARAM |
Constructor Summary | |
---|---|
URLRepository()
Creates a repository. |
Method Summary | |
---|---|
void |
add(Document doc,
RepositoryConnection c)
Adds a document to the repository. |
void |
backup(SaveParameters save_config)
Save the repository |
void |
configure(org.apache.avalon.framework.configuration.Configuration configuration)
Configures this repository. |
void |
delete(Document doc,
RepositoryConnection c)
Deletes a document. |
void |
empty()
Deletes all documents from the repository. |
void |
get(Document doc,
java.io.OutputStream os,
RepositoryConnection c)
Feeds a stream with a document. |
RepositoryConnection |
getConnection()
Gets a connection for manipulating store's content. |
void |
init()
Creates the store (creates DB) if not already done. |
protected boolean |
initToSax()
Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML |
protected void |
initVolatileObjectsToSax()
Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML Some objects need to be refresh each time a toSAX is called |
void |
lists(org.xml.sax.ContentHandler hdl)
Lists the repository content as SAX events. |
java.io.InputStream |
openStream(Document doc,
java.lang.String encoding,
RepositoryConnection c)
Opens a stream to read a document. |
void |
optimize()
Utility method for repository maintenance, normally used to optimize indices of Lucene based repositories It is the responsibility of the Repository to ensure that unnecessary optimizations are not performed when this method is called. |
void |
releaseConnection(RepositoryConnection c)
Releases a previously opened connection. |
void |
restore(SaveParameters save_config)
Restore the repository |
long |
size()
Returns the number of documents within the repository (all kind of documents). |
long |
size(int type)
Returns the number of documents of specified type within the store. |
void |
toSAX(ParsableDocument doc,
org.apache.cocoon.xml.XMLConsumer consumer,
RepositoryConnection c)
Retrieves a SDX document as SAX events. |
Methods inherited from class fr.gouv.culture.sdx.repository.AbstractDatabaseBackedRepository |
---|
checkConnection, checkEncoding, exists, getClassNameSuffix, isDefault, loadBaseConfiguration, setIsDefault |
Methods inherited from class fr.gouv.culture.sdx.utils.database.DatabaseBacked |
---|
configure, getDatabase |
Methods inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject |
---|
configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, service, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, toSAX, verifyConfigurationResources |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface fr.gouv.culture.sdx.utils.SdxObject |
---|
getLog |
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled |
---|
enableLogging |
Methods inherited from interface org.apache.avalon.framework.context.Contextualizable |
---|
contextualize |
Methods inherited from interface org.apache.avalon.framework.service.Serviceable |
---|
service |
Methods inherited from interface fr.gouv.culture.sdx.utils.Identifiable |
---|
getId, setId |
Methods inherited from interface fr.gouv.culture.sdx.utils.Describable |
---|
getDescription, setDescription |
Methods inherited from interface fr.gouv.culture.sdx.utils.Encodable |
---|
getEncoding, setEncoding |
Methods inherited from interface fr.gouv.culture.sdx.utils.Localizable |
---|
getLocale, getXmlLang, setLocale, setXmlLang |
Methods inherited from interface org.apache.excalibur.xml.sax.XMLizable |
---|
toSAX |
Constructor Detail |
---|
public URLRepository()
A super.getLog() must be set and then this repository must be configured and initialized.
AbstractSdxObject.enableLogging(org.apache.avalon.framework.logger.Logger)
,
configure(org.apache.avalon.framework.configuration.Configuration)
,
init()
Method Detail |
---|
public void releaseConnection(RepositoryConnection c) throws SDXException
releaseConnection
in interface Repository
releaseConnection
in class AbstractDatabaseBackedRepository
c
- The connection to release.
SDXException
public RepositoryConnection getConnection() throws SDXException
SDXException
public void configure(org.apache.avalon.framework.configuration.Configuration configuration) throws org.apache.avalon.framework.configuration.ConfigurationException
In addition to the parameters needed in the base configuration handled by the parent class, the following parameters are allowed : a base (optional) useful if documents exist in one directory; links to the documents will be made relative to this base, this facilitates the portability of a repository to other machines.
configure
in interface org.apache.avalon.framework.configuration.Configurable
configure
in class DatabaseBacked
configuration
- The configuration for this repository (based on a xml file).
Sample configuration entry:
<sdx:repository sdx:type = "URL" sdx:id = "myRepoId" base = "http url, local file url, relative path to the directory which contains this file"/>
org.apache.avalon.framework.configuration.ConfigurationException
we should link to this in the future when we have better documentation capabilities
public void init() throws SDXException
init
in interface Repository
init
in class DatabaseBacked
SDXException
public long size() throws SDXException
SDXException
public long size(int type) throws SDXException
type
- The type of document, muse be defined in fr.gouv.culture.sdx.documents.Document constants.
SDXException
public void lists(org.xml.sax.ContentHandler hdl) throws SDXException
The exact structure is still to be defined, but it should be very simple, with only one element per document and a few properties as attributes.
hdl
- The SAX content handler to feed with events.
SDXException
public void add(Document doc, RepositoryConnection c) throws SDXException
add
in interface Repository
add
in class AbstractDatabaseBackedRepository
doc
- The document to add.c
- A connection to the repository.
SDXException
public void empty() throws SDXException
SDXException
public void delete(Document doc, RepositoryConnection c) throws SDXException
delete
in interface Repository
delete
in class AbstractDatabaseBackedRepository
doc
- The document to delete.c
- The connection to the repository.
SDXException
public void toSAX(ParsableDocument doc, org.apache.cocoon.xml.XMLConsumer consumer, RepositoryConnection c) throws SDXException
toSAX
in interface Repository
toSAX
in class AbstractDatabaseBackedRepository
doc
- A ParsableDocument, ie XMLDocument or HTMLDocument.consumer
- A SAX content handler to feed with events.
The wrapped contentHandler for including events within an XSP page contentHandler should be created using IncludeXMLConsumer stripper = new IncludeXMLConsumer(xspContentHandler);
c
- A connection to the repository.
SDXException
public java.io.InputStream openStream(Document doc, java.lang.String encoding, RepositoryConnection c) throws SDXException
openStream
in interface Repository
openStream
in class AbstractDatabaseBackedRepository
doc
- The document to read.encoding
- The encoding to use for serialization of XML content (may be null
).
If null
or invalid we use a default.
TODOImplement: use of encoding currently not implemented , will do soon.
c
- A connection to the repository.
SDXException
public void get(Document doc, java.io.OutputStream os, RepositoryConnection c) throws SDXException
get
in interface Repository
get
in class AbstractDatabaseBackedRepository
doc
- The document to read.os
- The output stream where to write.c
- A connection to the repository.
SDXException
public void optimize() throws SDXException
Repository
optimize
in interface Repository
optimize
in class AbstractDatabaseBackedRepository
SDXException
protected boolean initToSax()
AbstractSdxObject
initToSax
in class AbstractDatabaseBackedRepository
protected void initVolatileObjectsToSax()
initVolatileObjectsToSax
in class AbstractDatabaseBackedRepository
public void backup(SaveParameters save_config) throws SDXException
backup
in interface Saveable
backup
in class AbstractDatabaseBackedRepository
SDXException
Saveable.backup(fr.gouv.culture.sdx.utils.save.SaveParameters)
public void restore(SaveParameters save_config) throws SDXException
restore
in interface Saveable
restore
in class AbstractDatabaseBackedRepository
SDXException
Saveable.restore(fr.gouv.culture.sdx.utils.save.SaveParameters)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |