fr.gouv.culture.sdx.repository
Interface Repository

All Superinterfaces:
org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, Describable, Encodable, Identifiable, Localizable, org.apache.avalon.framework.logger.LogEnabled, Saveable, SdxObject, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.xml.sax.XMLizable
All Known Implementing Classes:
AbstractDatabaseBackedRepository, AbstractDataSourceComponentBackedRepository, AbstractRepository, FSRepository, HSQLRepository, JDBCRepository, MSSQLRepository, MYSQLRepository, ORACLERepository, POSTGRESQLRepository, URLRepository

public interface Repository
extends SdxObject, Saveable

A generic storage location for SDX documents.

When SDX indexes a document, it must make it available, for example send it as a stream or as SAX events. A repository is responsible for sending the document's contents and, possibly, to store it.

A repository can be read-only or not. TODO?: i think we have removed this option?-rbp If it is, documents can't be stored, they can only be retrieved. There are two main interests for read-only repositories : (1) to implement an SDX application on a read-only media such as a CD-ROM, the indexing may have been done before ; (2) for URL repositories, where the document can be distant and not writable.

A repository must be able to find a document only with the document's id. The manner in which it keeps track of these ids is implementation specific.

A repository must also manage a connection, even if it doesn't use it. A connection may be used to speed up batch operations.

To be usable, a repository object must created, a super.getLog() set, then configured and initialized.


Nested Class Summary
static interface Repository.ConfigurationNode
           
 
Field Summary
static java.lang.String CLASS_NAME_SUFFIX
          String representation of the repository class name suffix.
static java.lang.String PACKAGE_QUALNAME
          String representation of the repository package name (including trailing separator ".").
 
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
 
Method Summary
 void add(Document doc, RepositoryConnection c)
          Adds a document to the repository.
 void delete(Document doc, RepositoryConnection c)
          Deletes a document.
 void empty()
          Deletes all documents from the repository.
 boolean exists(java.lang.String id, RepositoryConnection conn)
           
 void get(Document doc, java.io.OutputStream os, RepositoryConnection c)
          Feeds a stream with a document.
 RepositoryConnection getConnection()
          Returns a connection to the repository.
 void init()
          Initializes the repository.
 boolean isDefault()
          Returns whether it is a default repository for an application.
 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 setIsDefault(boolean b)
          Sets the default flag for the repository
 long size()
          Returns the number of documents within the repository.
 void toSAX(ParsableDocument doc, org.apache.cocoon.xml.XMLConsumer consumer, RepositoryConnection c)
          Retrieves a SDX document as SAX events.
 
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 org.apache.avalon.framework.configuration.Configurable
configure
 
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
 
Methods inherited from interface fr.gouv.culture.sdx.utils.save.Saveable
backup, restore
 

Field Detail

PACKAGE_QUALNAME

static final java.lang.String PACKAGE_QUALNAME
String representation of the repository package name (including trailing separator ".").

See Also:
Constant Field Values

CLASS_NAME_SUFFIX

static final java.lang.String CLASS_NAME_SUFFIX
String representation of the repository class name suffix.

See Also:
Constant Field Values
Method Detail

init

void init()
          throws SDXException
Initializes the repository.

Throws:
SDXException

getConnection

RepositoryConnection getConnection()
                                   throws SDXException
Returns a connection to the repository.

Throws:
SDXException

releaseConnection

void releaseConnection(RepositoryConnection c)
                       throws SDXException
Releases a previously opened connection

Parameters:
c - The connection to release.
Throws:
SDXException

size

long size()
          throws SDXException
Returns the number of documents within the repository.

Throws:
SDXException

lists

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

void add(Document doc,
         RepositoryConnection c)
         throws SDXException
Adds a document to the repository.

Parameters:
doc - The document to add.
c - A connection to the repository.
Throws:
SDXException

empty

void empty()
           throws SDXException
Deletes all documents from the repository.

Throws:
SDXException

delete

void delete(Document doc,
            RepositoryConnection c)
            throws SDXException
Deletes a document.

Parameters:
doc - The document to delete.
Throws:
SDXException

toSAX

void toSAX(ParsableDocument doc,
           org.apache.cocoon.xml.XMLConsumer consumer,
           RepositoryConnection c)
           throws SDXException
Retrieves a SDX document as SAX events.

Parameters:
doc - The document.
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

java.io.InputStream openStream(Document doc,
                               java.lang.String encoding,
                               RepositoryConnection c)
                               throws SDXException
Opens a stream to read a document.

Parameters:
doc - The document to read.
encoding - The encoding to use for serialization of XML content (may be null).
c - A connection to the repository.
Returns:
An input stream from which the serialized content of the document can be read.
Throws:
SDXException

get

void get(Document doc,
         java.io.OutputStream os,
         RepositoryConnection c)
         throws SDXException
Feeds a stream with a document.

Parameters:
doc - The document to read.
os - The output stream where to write.
c - A connection to the repository.
Throws:
SDXException

isDefault

boolean isDefault()
Returns whether it is a default repository for an application.


setIsDefault

void setIsDefault(boolean b)
Sets the default flag for the repository


optimize

void optimize()
              throws SDXException
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.

Throws:
SDXException

exists

boolean exists(java.lang.String id,
               RepositoryConnection conn)


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