fr.gouv.culture.sdx.repository
Interface Repository

All Superinterfaces:
org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled
All Known Implementing Classes:
AbstractDatabaseBackedRepository, AbstractDataSourceComponentBackedRepository, AbstractRepository

public interface Repository
extends org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.configuration.Configurable

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 logger set, then configured and initialized.


Field Summary
static java.lang.String ATTRIBUTE_DEFAULT
          String representation of the "repository" attribute name "default".
static java.lang.String ATTRIBUTE_ID
          String representation of the "repository" attribute name "id" in our application.xconf config file.
static java.lang.String ATTRIBUTE_REF
          String representation of the 'repository' attribute named 'ref'.
static java.lang.String ATTRIBUTE_TYPE
          String representation of the 'repository' attribute named 'type'.
static java.lang.String CLASS_NAME_SUFFIX
          String representation of the repository class name suffix.
static java.lang.String ELEMENT_NAME_REPOSITORIES
          String representation of the element name "repositories".
static java.lang.String ELEMENT_NAME_REPOSITORY
          String representation of the element name "repository".
static java.lang.String PACKAGE_QUALNAME
          String representation of the repository package name (including trailing separator ".").
 
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.
 java.lang.String getId()
          Returns the repository's id.
 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
 void setProperties(java.util.Hashtable props)
          Sets the properties object for implementing classes.
 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 org.apache.avalon.framework.component.Composable
compose
 
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled
enableLogging
 
Methods inherited from interface org.apache.avalon.framework.configuration.Configurable
configure
 

Field Detail

ATTRIBUTE_ID

public static final java.lang.String ATTRIBUTE_ID
String representation of the "repository" attribute name "id" in our application.xconf config file.

See Also:
Constant Field Values

ELEMENT_NAME_REPOSITORIES

public static final java.lang.String ELEMENT_NAME_REPOSITORIES
String representation of the element name "repositories".

See Also:
Constant Field Values

ELEMENT_NAME_REPOSITORY

public static final java.lang.String ELEMENT_NAME_REPOSITORY
String representation of the element name "repository".

See Also:
Constant Field Values

ATTRIBUTE_DEFAULT

public static final java.lang.String ATTRIBUTE_DEFAULT
String representation of the "repository" attribute name "default".

See Also:
Constant Field Values

ATTRIBUTE_TYPE

public static final java.lang.String ATTRIBUTE_TYPE
String representation of the 'repository' attribute named 'type'.

See Also:
Constant Field Values

ATTRIBUTE_REF

public static final java.lang.String ATTRIBUTE_REF
String representation of the 'repository' attribute named 'ref'.

See Also:
Constant Field Values

PACKAGE_QUALNAME

public 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

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

See Also:
Constant Field Values
Method Detail

getId

public java.lang.String getId()
Returns the repository's id.


init

public void init()
          throws SDXException
Initializes the repository.

Throws:
SDXException

getConnection

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

Throws:
SDXException

releaseConnection

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

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

size

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

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

public 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

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.

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

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

public 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

public 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

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


setProperties

public void setProperties(java.util.Hashtable props)
Sets the properties object for implementing classes.

Parameters:
props - The properties object contain installation paths.

setIsDefault

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


optimize

public 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

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


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