fr.gouv.culture.sdx.repository
Class AbstractDataSourceComponentBackedRepository

java.lang.Object
  extended by fr.gouv.culture.sdx.utils.AbstractSdxObject
      extended by fr.gouv.culture.sdx.utils.rdbms.JDBC
          extended by fr.gouv.culture.sdx.utils.rdbms.DataSourceComponentBacked
              extended by fr.gouv.culture.sdx.repository.AbstractDataSourceComponentBackedRepository
All Implemented Interfaces:
Repository, Describable, Encodable, Identifiable, Localizable, Saveable, SdxObject, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.xml.sax.XMLizable
Direct Known Subclasses:
JDBCRepository

public abstract class AbstractDataSourceComponentBackedRepository
extends DataSourceComponentBacked
implements Repository


Nested Class Summary
 
Nested classes/interfaces inherited from class fr.gouv.culture.sdx.utils.rdbms.JDBC
JDBC.QueryExecutor, JDBC.Template
 
Nested classes/interfaces inherited from interface fr.gouv.culture.sdx.repository.Repository
Repository.ConfigurationNode
 
Field Summary
protected static java.lang.String FIELD_ID
          Constant for a field name in a table
protected  boolean isDefault
          True if this is a default repository for an application.
protected  int PARAM_INDEX_FIELD_ID
           
 
Fields inherited from class fr.gouv.culture.sdx.utils.rdbms.DataSourceComponentBacked
ATTRIBUTE_DSI, dbSelector, dsi
 
Fields inherited from class fr.gouv.culture.sdx.utils.rdbms.JDBC
tableName
 
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
AbstractDataSourceComponentBackedRepository()
           
 
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
 boolean exists(java.lang.String id, RepositoryConnection conn)
           
 void get(Document doc, java.io.OutputStream os, RepositoryConnection c)
          Does param checks for subclasses
protected  java.lang.String getClassNameSuffix()
          Sub classes should element this method to return their class name suffix for SAX output
protected  java.lang.String getDocumentGetQuery()
          Returns an SQL query that could select a document using its id.
 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 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.rdbms.DataSourceComponentBacked
configure, finalize, getDataSourceComponent, releaseDataSourceComponent, service
 
Methods inherited from class fr.gouv.culture.sdx.utils.rdbms.JDBC
createTable, getTableCreationQuery, getTableName, handleUnsupportedTokens, initVolatileObjectsToSax
 
Methods inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject
configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, initToSax, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, toSAX, verifyConfigurationResources
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fr.gouv.culture.sdx.repository.Repository
empty, getConnection, init, lists, releaseConnection, size
 
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

isDefault

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


FIELD_ID

protected static final java.lang.String FIELD_ID
Constant for a field name in a table

See Also:
Constant Field Values

PARAM_INDEX_FIELD_ID

protected final int PARAM_INDEX_FIELD_ID
See Also:
Constant Field Values
Constructor Detail

AbstractDataSourceComponentBackedRepository

public AbstractDataSourceComponentBackedRepository()
Method Detail

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.
configuration - The configuration for this repository (based on a xml file).

Sample configuration entry:

<sdx:repository sdx:type = "FS" sdx:id = "myRepoId" baseDirectory = "baseDirName" 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

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

getDocumentGetQuery

protected java.lang.String getDocumentGetQuery()
Returns an SQL query that could select a document using its id.

This query should have one parameter for the id.

Returns:
The query.

exists

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

getClassNameSuffix

protected java.lang.String getClassNameSuffix()
Description copied from class: AbstractSdxObject
Sub classes should element this method to return their class name suffix for SAX output

Specified by:
getClassNameSuffix in class AbstractSdxObject


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