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 URLRepository

    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

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 URLRepository
extends AbstractDatabaseBackedRepository

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 :

1. `base`, http url, local file url, relative path to the directory which contains this file, it must already exist

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
`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

### URLRepository

    public URLRepository()

  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

### releaseConnection

    public void releaseConnection(RepositoryConnection c)
                           throws SDXException

  Releases a previously opened connection.

  Specified by:
    `releaseConnection` in interface `Repository`
  Overrides:
    `releaseConnection` in class `AbstractDatabaseBackedRepository`
  Parameters:
    `c` - The connection to release.
  Throws:
    `SDXException`

### getConnection

    public RepositoryConnection getConnection()
                                       throws SDXException

  Gets a connection for manipulating store's content.

  Throws:
    `SDXException`

### 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 (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.

  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 = "URL" sdx:id = "myRepoId" base = "http url, local file url, relative path to the directory which contains this file"/>

  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) 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 repository (all kind of documents).

  Throws:
    `SDXException`

### size

    public long size(int type)
              throws SDXException

  Returns the number of documents of specified type within the store.

  Parameters:
    `type` - The type of document, muse be defined in fr.gouv.culture.sdx.documents.Document constants.
  Throws:
    `SDXException`

### lists

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

  Lists the repository content as SAX events.

  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.

  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 to the repository.

  Specified by:
    `add` in interface `Repository`
  Overrides:
    `add` in class `AbstractDatabaseBackedRepository`
  Parameters:
    `doc` - The document to add.
    `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.
    `c` - The connection to the repository.
  Throws:
    `SDXException`

### toSAX

    public void toSAX(ParsableDocument doc,
                      org.apache.cocoon.xml.XMLConsumer consumer,
                      RepositoryConnection c)
               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);

    `c` - A connection to the repository.
  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`

### 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`

### optimize

    public void optimize()
                  throws SDXException

  Description copied from interface: `Repository`
  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.

  Specified by:
    `optimize` in interface `Repository`
  Overrides:
    `optimize` in class `AbstractDatabaseBackedRepository`
  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.