Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## fr.gouv.culture.sdx.repository
Class FSRepository

    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

All Implemented Interfaces:
  org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, Describable, Encodable, Identifiable, Localizable, org.apache.avalon.framework.logger.LogEnabled, Repository, Saveable, SdxObject, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.xml.sax.XMLizable

public class FSRepository
extends AbstractDatabaseBackedRepository

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 :

1. `baseDirectory`, the path to a base directory, can be relative or absolute, a non-existent directory will be created
2. `extent`, the number of directories to create within directories.
3. `depth`, the depth of the directories hierarchy to create.
4. `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 inherited from class 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

### FSRepository

    public FSRepository()

  Creates a repository.

  A super.getLog() must be set and then this repository must be configured and initialized.

See Also:
  `AbstractSdxObject.enableLogging(org.apache.avalon.framework.logger.Logger)`, `configure(org.apache.avalon.framework.configuration.Configuration)`, `init()`

Method Detail

### configure

    public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
                   throws org.apache.avalon.framework.configuration.ConfigurationException

  Configures this repository.

  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

  Specified by:
    `configure` in interface `org.apache.avalon.framework.configuration.Configurable`
  Overrides:
    `configure` in class `DatabaseBacked`
  Parameters:
    `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"/>

  Throws:
    `org.apache.avalon.framework.configuration.ConfigurationException`
  See Also:
    `we should link to this in the future when we have better documentation capabilities`

### init

    public void init()
              throws SDXException

  Creates the store (creates DB, base file location, etc.) if not already done.

  Specified by:
    `init` in interface `Repository`
  Overrides:
    `init` in class `DatabaseBacked`
  Throws:
    `SDXException`

### size

    public long size()
              throws SDXException

  Returns the number of documents within the store (SDX and attached documents).

  Throws:
    `SDXException`

### lists

    public void lists(org.xml.sax.ContentHandler hdl)
               throws SDXException

  Lists the content as SAX events. These SAX events represent a simple structure, one element per document, with a type attribute, and id attribute and may be an URL attribute. The elements are enclosed within a repository element, which has a type attribute and and id attribute. NOT YET IMPLEMENTED!

  Parameters:
    `hdl` - The SAX content handler to feed with events.
  Throws:
    `SDXException`

### add

    public void add(Document doc,
                    RepositoryConnection c)
             throws SDXException

  Adds a document.

  Specified by:
    `add` in interface `Repository`
  Overrides:
    `add` in class `AbstractDatabaseBackedRepository`
  Parameters:
    `doc` - The prepared document to add. //TODO : what means "prepared" ? -pb
    `c` - A connection to the store (not used).
  Throws:
    `SDXException`

### get

    public void get(Document doc,
                    java.io.OutputStream os,
                    RepositoryConnection c)
             throws SDXException

  Feeds a stream with a document.

  Specified by:
    `get` in interface `Repository`
  Overrides:
    `get` in class `AbstractDatabaseBackedRepository`
  Parameters:
    `doc` - The document to read.
    `os` - The output stream where to write.
    `c` - A connection to the repository.
  Throws:
    `SDXException`

### empty

    public void empty()
               throws SDXException

  Deletes all documents from the repository.

  Throws:
    `SDXException`

### delete

    public void delete(Document doc,
                       RepositoryConnection c)
                throws SDXException

  Deletes a document.

  Specified by:
    `delete` in interface `Repository`
  Overrides:
    `delete` in class `AbstractDatabaseBackedRepository`
  Parameters:
    `doc` - The document to delete, the only required field for the document is its "id".
  Throws:
    `SDXException`

### toSAX

    public void toSAX(ParsableDocument doc,
                      org.apache.cocoon.xml.XMLConsumer consumer,
                      RepositoryConnection conn)
               throws SDXException

  Retrieves a SDX document as SAX events.

  Specified by:
    `toSAX` in interface `Repository`
  Overrides:
    `toSAX` in class `AbstractDatabaseBackedRepository`
  Parameters:
    `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.
  Throws:
    `SDXException`

### openStream

    public java.io.InputStream openStream(Document doc,
                                          java.lang.String encoding,
                                          RepositoryConnection c)
                                   throws SDXException

  Opens a stream to read a document.

  Specified by:
    `openStream` in interface `Repository`
  Overrides:
    `openStream` in class `AbstractDatabaseBackedRepository`
  Parameters:
    `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.
  Returns:
    An input stream from which the serialized content of the document can be read.
  Throws:
    `SDXException`

### getConnection

    public RepositoryConnection getConnection()
                                       throws SDXException

  Gets a connection for manipulating store's content.

  Throws:
    `SDXException`

### initToSax

    protected boolean initToSax()

  Description copied from class: `AbstractSdxObject`
  Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML

  Overrides:
    `initToSax` in class `AbstractDatabaseBackedRepository`

### initVolatileObjectsToSax

    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

  Overrides:
    `initVolatileObjectsToSax` in class `AbstractDatabaseBackedRepository`

### backup

    public void backup(SaveParameters save_config)
                throws SDXException

  Save the repository

  Specified by:
    `backup` in interface `Saveable`
  Overrides:
    `backup` in class `AbstractDatabaseBackedRepository`
  Throws:
    `SDXException`
  See Also:
    `Saveable.backup(fr.gouv.culture.sdx.utils.save.SaveParameters)`

### restore

    public void restore(SaveParameters save_config)
                 throws SDXException

  Restore the repository

  Specified by:
    `restore` in interface `Saveable`
  Overrides:
    `restore` in class `AbstractDatabaseBackedRepository`
  Throws:
    `SDXException`
  See Also:
    `Saveable.restore(fr.gouv.culture.sdx.utils.save.SaveParameters)`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.