fr.gouv.culture.sdx.oai
Class AbstractDocumentBaseOAIRepository

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.xml.AbstractXMLPipe
              extended by fr.gouv.culture.oai.OAIObjectImpl
                  extended by fr.gouv.culture.oai.AbstractOAIRepository
                      extended by fr.gouv.culture.sdx.oai.AbstractDocumentBaseOAIRepository
All Implemented Interfaces:
OAIObject, OAIRepository, DocumentBaseOAIRepository, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, 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.cocoon.xml.XMLPipe, org.apache.cocoon.xml.XMLProducer, org.apache.excalibur.xml.sax.XMLConsumer, org.apache.excalibur.xml.sax.XMLizable, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler
Direct Known Subclasses:
LuceneDocumentBaseOAIRepository

public abstract class AbstractDocumentBaseOAIRepository
extends AbstractOAIRepository
implements DocumentBaseOAIRepository

Abstract oai repository for DocumentBases providing common behaviors

TODORefactor: bring appropriate methods up from sub-classes


Nested Class Summary
 
Nested classes/interfaces inherited from interface fr.gouv.culture.sdx.oai.DocumentBaseOAIRepository
DocumentBaseOAIRepository.ConfigurationNode
 
Nested classes/interfaces inherited from interface fr.gouv.culture.oai.OAIObject
OAIObject.Node
 
Field Summary
protected  Database _database
          The database for this object
protected  org.apache.avalon.framework.context.DefaultContext context
          The framework's context.
protected  DocumentBase documentBase
          The underlying document base
protected  java.lang.String documentBaseId
          The document base's id
protected  java.lang.String externalIdPrefix
           
protected  java.lang.String id
           
protected  boolean isDefault
           
protected  org.apache.avalon.framework.service.ServiceManager manager
          The framework's service manager.
protected  int numRecordsPerResponse
          The number of records for before issuing a resumption tokent
static java.lang.String PARAMETER_NAME_SDX_FIELD
           
static java.lang.String PARAMETER_NAME_SET_NAME
           
static java.lang.String PARAMETER_NAME_SET_SPEC
           
protected  IDGenerator resumptionTokenIdGen
           
 
Fields inherited from class fr.gouv.culture.oai.AbstractOAIRepository
adminEmails, baseURL, compression, deletedRecord, description, earliestDatestamp, granularity, metadataFormats, protocolVersion, repositoryName
 
Fields inherited from class fr.gouv.culture.oai.OAIObjectImpl
_context, logger
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface fr.gouv.culture.oai.OAIObject
HTTP_HEADER_NAME_FROM, HTTP_HEADER_NAME_USER_AGENT, NUMBER_RECORDS_PER_RESPONSE, STRING_DATEFORMAT_GRANULARITY_DAY, STRING_DATEFORMAT_GRANULARITY_SECOND
 
Constructor Summary
AbstractDocumentBaseOAIRepository()
           
 
Method Summary
protected  java.lang.String buildExternalOaiId(OAIRequest request, java.lang.String docId)
          Deprecated. Since 2.4.0 use buildExternalOaiId(String) instead.
protected  java.lang.String buildExternalOaiId(java.lang.String docId)
          Builds an SDX/OAI identifier for a document This identifier is used to populate the identifier OAI element.
protected  java.lang.String buildUrlLocator(OAIRequest request, java.lang.String docId)
          Builds an URL locator for the document with the provided id
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
          Basic configuration
protected  void configureAdminEmails(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures (sets) the adminEmails class-field from a configuration object
protected  void configureBaseURL(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures (sets) the baseURL class-field from a configuration object
protected  void configureDatabase(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures (sets) the database class-field from a configuration object
protected  void configureDefault(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures the default flag : true if this OAI repository is the default one, false or null if not.
protected  void configureDescription(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures (sets) the description class-field from a configuration object
protected  void configureExternalIdPrefix(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures (sets) the external OAI id prefix from a configuration object.
protected  void configureId(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures the id of this OAI repository
protected  void configureResumptionTokenIDGenerator(org.apache.avalon.framework.configuration.Configuration configuration)
           
protected  java.lang.String createResumptionToken(OAIRequest request)
          Builds a resumption token for a request and the database entity to store needed informations.
protected  java.lang.String deriveInternalSdxId(OAIRequest request, java.lang.String fullOaiId)
          Deprecated. Since SDX 2.4.0, use deriveInternalSdxId(String) instead.
protected  java.lang.String deriveInternalSdxId(java.lang.String fullOaiId)
          Retrieves an internal SDX identifier from a full OAI identifier
 java.lang.String getId()
          Returns the identifier for this OAI repository as a String.
protected  java.lang.String getRepositoryId()
          Returns the internal identifier for this OAI repository.
 java.lang.String getResumptionTokenCursor(java.lang.String resumptionToken)
          Returns the cursor index of the provided resumption token
protected  java.lang.String getResumptionTokenProperty(java.lang.String resumptionToken, java.lang.String propertyName)
          Returns a property value for provided resumption token
 boolean isDefault()
          Returns the default flag value
 void service(org.apache.avalon.framework.service.ServiceManager serviceManager)
           
 void setDefault()
           
 void unsetDefault()
           
 
Methods inherited from class fr.gouv.culture.oai.AbstractOAIRepository
endVerbEvent, getAdminEmails, getBaseURL, getCompression, getDeletedRecord, getDescription, getEarliestDatestamp, getGranularity, getGranularity, getProtocolVersion, getRepositoryName, identify, sendNoSetHierarchyError, sendResumptionToken, sendResumptionToken, sendResumptionToken, sendResumptionTokensNotSupportedError, startVerbEvent, toSAX, verifyGranularity, verifyParameters
 
Methods inherited from class fr.gouv.culture.oai.OAIObjectImpl
contextualize, enableLogging, endElement, getContext, sendElement, sendElementContent, startElement
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDocument, endDTD, endElement, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
recycle, setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
getLogger, setupLogger, setupLogger, setupLogger
 
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.oai.OAIRepository
addDeletedRecord, getAdminEmails, getBaseURL, getCompression, getDeletedRecord, getDescription, getEarliestDatestamp, getGranularity, getProtocolVersion, getRecord, getRepositoryName, getResumptionToken, identify, listIdentifiers, listMetadataFormats, listRecords, listSets, purgeDeletedRecords, removeDeletedRecord, verifyParameters
 
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.excalibur.xml.sax.XMLizable
toSAX
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

manager

protected org.apache.avalon.framework.service.ServiceManager manager
The framework's service manager.


context

protected org.apache.avalon.framework.context.DefaultContext context
The framework's context.


documentBase

protected DocumentBase documentBase
The underlying document base


_database

protected Database _database
The database for this object


documentBaseId

protected java.lang.String documentBaseId
The document base's id


numRecordsPerResponse

protected int numRecordsPerResponse
The number of records for before issuing a resumption tokent


resumptionTokenIdGen

protected IDGenerator resumptionTokenIdGen

externalIdPrefix

protected java.lang.String externalIdPrefix

id

protected java.lang.String id

isDefault

protected boolean isDefault

PARAMETER_NAME_SDX_FIELD

public static final java.lang.String PARAMETER_NAME_SDX_FIELD
See Also:
Constant Field Values

PARAMETER_NAME_SET_NAME

public static final java.lang.String PARAMETER_NAME_SET_NAME
See Also:
Constant Field Values

PARAMETER_NAME_SET_SPEC

public static final java.lang.String PARAMETER_NAME_SET_SPEC
See Also:
Constant Field Values
Constructor Detail

AbstractDocumentBaseOAIRepository

public AbstractDocumentBaseOAIRepository()
Method Detail

service

public void service(org.apache.avalon.framework.service.ServiceManager serviceManager)
             throws org.apache.avalon.framework.service.ServiceException
Specified by:
service in interface org.apache.avalon.framework.service.Serviceable
Throws:
org.apache.avalon.framework.service.ServiceException

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Basic configuration

Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureId

protected void configureId(org.apache.avalon.framework.configuration.Configuration configuration)
                    throws org.apache.avalon.framework.configuration.ConfigurationException
Configures the id of this OAI repository

Parameters:
configuration -
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureDefault

protected void configureDefault(org.apache.avalon.framework.configuration.Configuration configuration)
                         throws org.apache.avalon.framework.configuration.ConfigurationException
Configures the default flag : true if this OAI repository is the default one, false or null if not.

Parameters:
configuration -
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

setDefault

public void setDefault()

unsetDefault

public void unsetDefault()

isDefault

public boolean isDefault()
Returns the default flag value

Returns:
true if this OAI repository is the default one; false if not.

configureExternalIdPrefix

protected void configureExternalIdPrefix(org.apache.avalon.framework.configuration.Configuration configuration)
                                  throws org.apache.avalon.framework.configuration.ConfigurationException
Configures (sets) the external OAI id prefix from a configuration object.

The prefix can be passed throught the configuration attribute:

<oai-repository oai-id-prefix="my.external.oai.id.prefix"
If the configuration element does not contain an oai-id-prefix attribute, the prefix is based on the pattern: sdx:{baseURL}
For example: sdx:www.sdx.org: for the baseURL = http://www.sdx.org/

Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureResumptionTokenIDGenerator

protected void configureResumptionTokenIDGenerator(org.apache.avalon.framework.configuration.Configuration configuration)
                                            throws org.apache.avalon.framework.configuration.ConfigurationException
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureBaseURL

protected void configureBaseURL(org.apache.avalon.framework.configuration.Configuration configuration)
                         throws org.apache.avalon.framework.configuration.ConfigurationException
Configures (sets) the baseURL class-field from a configuration object

Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureDescription

protected void configureDescription(org.apache.avalon.framework.configuration.Configuration configuration)
                             throws org.apache.avalon.framework.configuration.ConfigurationException
Configures (sets) the description class-field from a configuration object

Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureAdminEmails

protected void configureAdminEmails(org.apache.avalon.framework.configuration.Configuration configuration)
                             throws org.apache.avalon.framework.configuration.ConfigurationException
Configures (sets) the adminEmails class-field from a configuration object

Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureDatabase

protected void configureDatabase(org.apache.avalon.framework.configuration.Configuration configuration)
                          throws org.apache.avalon.framework.configuration.ConfigurationException
Configures (sets) the database class-field from a configuration object

Throws:
org.apache.avalon.framework.configuration.ConfigurationException

getRepositoryId

protected java.lang.String getRepositoryId()
Returns the internal identifier for this OAI repository.

Returns the internal identifier for this OAI repository. It's build on the pattern : sdx_oai_r_{document base id}_{OAI repo id}.
It's used, among other, to configure the SQL database, ie the table name.

Returns:

getId

public java.lang.String getId()
Returns the identifier for this OAI repository as a String.

Returns:
The identifier: default if it's the default OAI repository, the id if not.
See Also:
ID configuration

buildExternalOaiId

protected java.lang.String buildExternalOaiId(OAIRequest request,
                                              java.lang.String docId)
Deprecated. Since 2.4.0 use buildExternalOaiId(String) instead.

Builds an SDX/OAI identifier for a document

This identifier is used to populate the identifier OAI element. For example, the one wich is returned by the "ListIdentifiers" verb.

Parameters:
request - The request from which the url will be used for id construction
docId - The sdx document identifier
See Also:
Deconstruction of id's built with this method

buildExternalOaiId

protected java.lang.String buildExternalOaiId(java.lang.String docId)
Builds an SDX/OAI identifier for a document

This identifier is used to populate the identifier OAI element. For example, the one wich is returned by the "ListIdentifiers" verb.

Parameters:
request - The request from which the url will be used for id construction
docId - The sdx document identifier
See Also:
Deconstruction of id's built with this method, The configuration of the prefix

deriveInternalSdxId

protected java.lang.String deriveInternalSdxId(OAIRequest request,
                                               java.lang.String fullOaiId)
Deprecated. Since SDX 2.4.0, use deriveInternalSdxId(String) instead.

Retrieves an internal SDX identifier from a full OAI identifier

Parameters:
request - The request from which the url will be used for id construction
fullOaiId - The OAI record identifier
See Also:
Construction of id's passed as the fullOaiId argument

deriveInternalSdxId

protected java.lang.String deriveInternalSdxId(java.lang.String fullOaiId)
Retrieves an internal SDX identifier from a full OAI identifier

Parameters:
request - The request from which the url will be used for id construction
fullOaiId - The OAI record identifier
See Also:
construction of id's passed as the fullOaiId argument

buildUrlLocator

protected java.lang.String buildUrlLocator(OAIRequest request,
                                           java.lang.String docId)
Builds an URL locator for the document with the provided id

Parameters:
request - The request
docId - The id of the document for which to build the locator TODORemove: this is tightly coupled to the external sdx/sdx/sitemap.xmap

createResumptionToken

protected java.lang.String createResumptionToken(OAIRequest request)
                                          throws SDXException
Builds a resumption token for a request and the database entity to store needed informations.

Parameters:
request - The request
Returns:
newResumptionToken The next resumptionToken
Throws:
SDXException

getResumptionTokenCursor

public java.lang.String getResumptionTokenCursor(java.lang.String resumptionToken)
Returns the cursor index of the provided resumption token

Parameters:
resumptionToken -

getResumptionTokenProperty

protected java.lang.String getResumptionTokenProperty(java.lang.String resumptionToken,
                                                      java.lang.String propertyName)
Returns a property value for provided resumption token

Parameters:
resumptionToken - The resumption token in question
propertyName - The property name for which a value is desired


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