fr.gouv.culture.sdx.repository
Class AbstractDatabaseBackedRepository

java.lang.Object
  extended byfr.gouv.culture.sdx.utils.SdxObjectImpl
      extended byfr.gouv.culture.sdx.utils.database.DatabaseBacked
          extended byfr.gouv.culture.sdx.repository.AbstractDatabaseBackedRepository
All Implemented Interfaces:
org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, Repository, SdxObject
Direct Known Subclasses:
FSRepository, URLRepository

public abstract class AbstractDatabaseBackedRepository
extends DatabaseBacked
implements Repository

A basic implementation of a repository. This is a copy of the AbstractRepository class, BUT inherits the functionality of the DatabaseBacked class.

This abstract implementation handles the logger, the id and null operations for connections.


Field Summary
protected  java.lang.String DEFAULT_ENCODING
          The default encoding
protected  boolean isDefault
          True if this is a default repository for an application.
protected  org.apache.avalon.framework.logger.Logger logger
          Avalon logger to write information.
 
Fields inherited from class fr.gouv.culture.sdx.utils.database.DatabaseBacked
_manager, ATTRIBUTE_ID, CLASS_NAME_SUFFIX, database, DATABASE_DIR_NAME, databaseConf, dbLocation, dbPath, DEFAULT_DATABASE_TYPE, ELEMENT_NAME_DATABASE, id, PACKAGE_QUALNAME, props
 
Fields inherited from class fr.gouv.culture.sdx.utils.SdxObjectImpl
encoding
 
Fields inherited from interface fr.gouv.culture.sdx.repository.Repository
ATTRIBUTE_DEFAULT, ATTRIBUTE_ID, ATTRIBUTE_REF, ATTRIBUTE_TYPE, CLASS_NAME_SUFFIX, ELEMENT_NAME_REPOSITORIES, ELEMENT_NAME_REPOSITORY, PACKAGE_QUALNAME
 
Constructor Summary
AbstractDatabaseBackedRepository()
           
 
Method Summary
 void add(Document doc, RepositoryConnection c)
          Does param checks for subclasses
 void checkConnection(RepositoryConnection c)
           
protected  java.lang.String checkEncoding(java.lang.String encoding)
          Verifies an encoding string, if not supported by JVM default is used, UTF-8.
 void delete(Document doc, RepositoryConnection c)
          Does param checks for subclasses
 void enableLogging(org.apache.avalon.framework.logger.Logger logger)
          Sets the logger.
 boolean exists(java.lang.String id, RepositoryConnection conn)
           
 void get(Document doc, java.io.OutputStream os, RepositoryConnection c)
          Does param checks for subclasses
 java.lang.String getId()
          Returns the identifier for this repository within an application.
 boolean isDefault()
          Returns whether it is a default repository for an application.
protected  void loadBaseConfiguration(org.apache.avalon.framework.configuration.Configuration configuration)
          Loads base configuration common to all repositories.
 java.io.InputStream openStream(Document doc, java.lang.String encoding, RepositoryConnection c)
          Does param checks for subclasses
 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 isDefault flag for the repository
 void toSAX(ParsableDocument doc, org.apache.cocoon.xml.XMLConsumer consumer, RepositoryConnection c)
          Does param checks for subclasses
 
Methods inherited from class fr.gouv.culture.sdx.utils.database.DatabaseBacked
compose, configure, getDatabase, init, setId, setProperties
 
Methods inherited from class fr.gouv.culture.sdx.utils.SdxObjectImpl
getChildLogger, setEncoding
 
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.repository.Repository
empty, getConnection, init, lists, setProperties, size
 
Methods inherited from interface org.apache.avalon.framework.component.Composable
compose
 
Methods inherited from interface org.apache.avalon.framework.configuration.Configurable
configure
 

Field Detail

logger

protected org.apache.avalon.framework.logger.Logger logger
Avalon logger to write information.


isDefault

protected boolean isDefault
True if this is a default repository for an application.


DEFAULT_ENCODING

protected final java.lang.String DEFAULT_ENCODING
The default encoding

See Also:
Constant Field Values
Constructor Detail

AbstractDatabaseBackedRepository

public AbstractDatabaseBackedRepository()
Method Detail

enableLogging

public void enableLogging(org.apache.avalon.framework.logger.Logger logger)
Sets the logger.

Specified by:
enableLogging in interface org.apache.avalon.framework.logger.LogEnabled
Overrides:
enableLogging in class SdxObjectImpl
Parameters:
logger - The logger to use.

getId

public java.lang.String getId()
Returns the identifier for this repository within an application.

Specified by:
getId in interface Repository
Overrides:
getId in class DatabaseBacked

loadBaseConfiguration

protected void loadBaseConfiguration(org.apache.avalon.framework.configuration.Configuration configuration)
                              throws org.apache.avalon.framework.configuration.ConfigurationException
Loads base configuration common to all repositories.

Parameters:
configuration - The configuration object The parameter required are an id for the repository, an optional attribute indicating if the repository is the default within a document base is also handled but the default if not specified will be false.
Throws:
org.apache.avalon.framework.configuration.ConfigurationException
See Also:
we should link to this in the future when we have better documentation capabilities

releaseConnection

public void releaseConnection(RepositoryConnection c)
                       throws SDXException
Releases a previously opened connection. This does nothing in this abstract class.

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

isDefault

public boolean isDefault()
Description copied from interface: Repository
Returns whether it is a default repository for an application.

Specified by:
isDefault in interface Repository

delete

public void delete(Document doc,
                   RepositoryConnection c)
            throws SDXException
Does param checks for subclasses

Specified by:
delete in interface Repository
Parameters:
doc - The document to delete.
Throws:
SDXException

add

public void add(Document doc,
                RepositoryConnection c)
         throws SDXException
Does param checks for subclasses

Specified by:
add in interface Repository
Parameters:
doc - The document to add.
c - A connection to the repository.
Throws:
SDXException

openStream

public java.io.InputStream openStream(Document doc,
                                      java.lang.String encoding,
                                      RepositoryConnection c)
                               throws SDXException
Does param checks for subclasses

Specified by:
openStream in interface Repository
Parameters:
doc - The document to read.
encoding - Should be null as not verified here, but in subClasses with checkEncoding() method.
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
Does param checks for subclasses

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

toSAX

public void toSAX(ParsableDocument doc,
                  org.apache.cocoon.xml.XMLConsumer consumer,
                  RepositoryConnection c)
           throws SDXException
Does param checks for subclasses

Specified by:
toSAX in interface Repository
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

setIsDefault

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

Specified by:
setIsDefault in interface Repository

checkEncoding

protected java.lang.String checkEncoding(java.lang.String encoding)
                                  throws SDXException
Verifies an encoding string, if not supported by JVM default is used, UTF-8.

Parameters:
encoding -
Returns:
Throws:
SDXException

checkConnection

public void checkConnection(RepositoryConnection c)
                     throws SDXException
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
Throws:
SDXException

exists

public boolean exists(java.lang.String id,
                      RepositoryConnection conn)
Specified by:
exists in interface Repository


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