|
|||||||||
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.FSRepository
public class FSRepository
Implements a repository where files are stored in the server's filesystem.
There are two main concerns with this repository : (1) how to retrieve efficiently a document from it's id and (2) how to place files within the filesystem.
For the first concern, we use a simplified SDX database to keep track of ids and their location.
For the second concern, one must give some parameters to help SDX build a directory structure. These parameters are :
baseDirectory
, the path to a base directory, can be relative or absolute, a non-existent directory will be created
extent
, the number of directories to create within
directories.
depth
, the depth of the directories hierarchy to create.
size
, the number of documents to store within a directory before
creating a new one.TODO?:size is currently not used, but should it be?-rbp
A filesystem repository is always managed by SDX. Documents should not be altered from the outside. From a base directory, SDX will create all the structure it needs.
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 | |
---|---|
FSRepository()
Creates a repository. |
Method Summary | |
---|---|
void |
add(Document doc,
RepositoryConnection c)
Adds a document. |
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, base file location, etc.) 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 content as SAX events. |
java.io.InputStream |
openStream(Document doc,
java.lang.String encoding,
RepositoryConnection c)
Opens a stream to read a document. |
void |
restore(SaveParameters save_config)
Restore the repository |
long |
size()
Returns the number of documents within the store (SDX and attached documents). |
void |
toSAX(ParsableDocument doc,
org.apache.cocoon.xml.XMLConsumer consumer,
RepositoryConnection conn)
Retrieves a SDX document as SAX events. |
Methods inherited from class fr.gouv.culture.sdx.repository.AbstractDatabaseBackedRepository |
---|
checkConnection, checkEncoding, exists, getClassNameSuffix, isDefault, loadBaseConfiguration, optimize, releaseConnection, 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 FSRepository()
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 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 directory (required) for storage of data, the number of directories per directory (extent, optional, default is 100), the depth of the directory structure (depth, optional, default is 3) and the maximum number of documents per directory.TODO?:size(the latter) is currently not used, but should it be?-rbp
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 = "FS" sdx:id = "myRepoId" baseDirectory = "baseDirPath" depth = "2" extent = "50"/>
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 void lists(org.xml.sax.ContentHandler hdl) throws SDXException
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 prepared document to add. //TODO : what means "prepared" ? -pbc
- A connection to the store (not used).
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 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, the only required field for the document is its "id".
SDXException
public void toSAX(ParsableDocument doc, org.apache.cocoon.xml.XMLConsumer consumer, RepositoryConnection conn) 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);
conn
- A connection to the store.
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 RepositoryConnection getConnection() throws SDXException
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 |