fr.gouv.culture.sdx.documentbase
Class AbstractDocumentBase

java.lang.Object
  extended byfr.gouv.culture.sdx.utils.SdxObjectImpl
      extended byfr.gouv.culture.sdx.utils.database.DatabaseBacked
          extended byfr.gouv.culture.sdx.documentbase.AbstractDocumentBase
All Implemented Interfaces:
org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, DocumentBase, org.apache.avalon.framework.logger.LogEnabled, SdxObject, Searchable, org.apache.cocoon.xml.XMLizable
Direct Known Subclasses:
SDXDocumentBase

public abstract class AbstractDocumentBase
extends DatabaseBacked
implements DocumentBase

an abstract document base class handling most common behaviors


Field Summary
protected  org.apache.avalon.framework.context.DefaultContext context
          The framework's context.
protected  java.lang.String DBELEM_ATTRIBUTE_DEFAULT
          The implied attribute stating whether the document base is to be used by default or not.
protected  java.lang.String DBELEM_ATTRIBUTE_KEEP_ORIGINAL
          The implied attribute stating whether original documents should be stored or not.
protected  Repository defaultRepository
          The default repository for this document base.
protected  java.lang.String ELEMENT_NAME_INDEX
          The element used to define the indexation pipelines.
static java.lang.String ELEMENT_NAME_OAI_HARVESTER
          The element used to define an oai harvester.
static java.lang.String ELEMENT_NAME_OAI_REPOSITORY
          The element used to define an oai repository.
protected  java.lang.String ELEMENT_NAME_PIPELINE
          The element used to define an indexation pipeline.
protected  Pipeline indexationPipeline
          The default indexation pipeline
static java.lang.String INTERNAL_FIELD_NAME_SDX_OAI_DELETED_RECORD
           
static java.lang.String INTERNAL_FIELD_NAME_SDXALL
          Internal field name for a *fixed* value field.
static java.lang.String INTERNAL_FIELD_NAME_SDXAPPID
          Internal field name for application id.
static java.lang.String INTERNAL_FIELD_NAME_SDXCONTENTLENGTH
          Internal field name for document length in bytes.
static java.lang.String INTERNAL_FIELD_NAME_SDXDBID
          Internal field name for document base id.
static java.lang.String INTERNAL_FIELD_NAME_SDXDOCID
          Internal field name for document ids
static java.lang.String INTERNAL_FIELD_NAME_SDXDOCTYPE
          Internal field name for document type.
static java.lang.String INTERNAL_FIELD_NAME_SDXMODDATE
          Internal field name for modification date.
static java.lang.String INTERNAL_FIELD_NAME_SDXREPOID
          Internal field name for repository id.
static java.lang.String INTERNAL_SDXALL_FIELD_VALUE
          Internal value for this field.
protected  boolean isDefault
          True if this document base is the default one in the application.
protected  java.util.Locale locale
          The locale for this document base (found either in the configuration file or by using Locale.getDefault()).
protected  OAIHarvester oaiHarv
          The oai harvester wrapper for this document base
protected  OAIRepository oaiRepo
          The oai repository wrapper for this document base
protected  java.lang.String PROPERTY_NAME_ATTACHED
          Internal fields for relationships between documents (kind of metadata required/proposed by SDX) //TODO : move them to a framework/application/relationship class ?
protected static java.lang.String PROPERTY_NAME_CONTENT_LENGTH
           
protected  java.lang.String PROPERTY_NAME_DOCTYPE
          A constant for the path property for the type of document, Binary, HTML, or XML.
protected static java.lang.String PROPERTY_NAME_MIMETYPE
          A constant for the path property for attached documents.
protected  java.lang.String PROPERTY_NAME_ORIGINAL
          Internal value for this field : an original document relationship.
protected  java.lang.String PROPERTY_NAME_PARENT
           
protected static java.lang.String PROPERTY_NAME_REPO
          A constant for the repository property in the database entities.
protected  java.lang.String PROPERTY_NAME_SUB
          Internal value for this field : a sub-document document relationship.
protected  java.util.Hashtable repoConnectionPool
          A pool of connections to the repositories.
protected  java.util.Hashtable repositories
          The repositories that are owned by this document base.
 
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, logger
 
Fields inherited from interface fr.gouv.culture.sdx.documentbase.DocumentBase
ATTRIBUTE_ID, ATTRIBUTE_TYPE, CLASS_NAME_SUFFIX, ELEMENT_NAME_DOCUMENT_BASE, ELEMENT_NAME_DOCUMENT_BASES, PACKAGE_QUALNAME
 
Constructor Summary
AbstractDocumentBase()
           
 
Method Summary
protected  void addOaiDeletedRecord(IndexableDocument doc)
           
protected  void configurePipeline(org.apache.avalon.framework.configuration.Configuration configuration)
           
 void contextualize(org.apache.avalon.framework.context.Context context)
          Contextualize this class.
protected  DatabaseEntity createEntityForDocMetaData(Document doc, Repository repository, java.lang.String[] parentDocId)
           
 void delete(Document doc, org.xml.sax.ContentHandler handler)
          Deletes a document and any attached document(s) if not used by any other document(s).
protected  void deletePhysicalDocument(Document doc, Repository repo, org.xml.sax.ContentHandler handler)
          This method does a special delete.
 Repository getDefaultRepository()
          Returns the default repository for this document base.
 java.io.InputStream getDocument(Document doc)
          Does param checks for subclasses
 void getDocument(Document doc, java.io.OutputStream os)
          Does param checks for subclasses
 void getDocument(ParsableDocument doc, org.apache.cocoon.xml.XMLConsumer consumer)
          Does param checks for subclasses
 java.lang.String getId()
          Returns the document base id.
 Pipeline getIndexationPipeline()
          Returns the default indexation pipeline used for indexation in this document base.
 java.lang.String getMimeType(Document doc)
          Supplies the mimeType for the the document if it exists otherwise the binary document default mimetype is returned
 OAIHarvester getOAIHarvester()
          Gets the AbstractDocumentBaseOAIHarvester for the documentbase if one exists
 OAIRepository getOAIRepository()
          Gets the OAIRepository for the documentbase if one exists
protected  RepositoryConnection getPooledRepositoryConnection(java.lang.String repoId)
           
 Repository getRepository(java.lang.String id)
          Gets a repository in this document base.
 boolean isDefault()
          Returns true if this document base is the default in the application.
protected  void optimizeDatabase()
           
protected  void optimizeRepositories()
          This method should be called before releasePooledRepositoryConnections(); so we have something to optimize.
protected  void releasePooledRepositoryConnections()
           
protected  void removeOaiDeletedRecord(IndexableDocument doc)
           
 void setId(java.lang.String id)
          Sets the document base id.
 void toSAX(org.xml.sax.ContentHandler hdl)
          Feeds a SAX content handler with information about this document base.
 
Methods inherited from class fr.gouv.culture.sdx.utils.database.DatabaseBacked
compose, configure, getDatabase, init, setProperties
 
Methods inherited from class fr.gouv.culture.sdx.utils.SdxObjectImpl
enableLogging, 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.documentbase.DocumentBase
creationDate, delete, getDocument, index, index, init, lastModificationDate, setProperties
 
Methods inherited from interface org.apache.avalon.framework.configuration.Configurable
configure
 
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled
enableLogging
 
Methods inherited from interface org.apache.avalon.framework.component.Composable
compose
 
Methods inherited from interface fr.gouv.culture.sdx.search.Searchable
getIndex
 

Field Detail

context

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


isDefault

protected boolean isDefault
True if this document base is the default one in the application.


indexationPipeline

protected Pipeline indexationPipeline
The default indexation pipeline


repositories

protected java.util.Hashtable repositories
The repositories that are owned by this document base.


defaultRepository

protected Repository defaultRepository
The default repository for this document base.


oaiRepo

protected OAIRepository oaiRepo
The oai repository wrapper for this document base


oaiHarv

protected OAIHarvester oaiHarv
The oai harvester wrapper for this document base


locale

protected java.util.Locale locale
The locale for this document base (found either in the configuration file or by using Locale.getDefault()).


repoConnectionPool

protected java.util.Hashtable repoConnectionPool
A pool of connections to the repositories.


PROPERTY_NAME_ATTACHED

protected final java.lang.String PROPERTY_NAME_ATTACHED
Internal fields for relationships between documents (kind of metadata required/proposed by SDX) //TODO : move them to a framework/application/relationship class ? -pb /** Internal value for this field : an attached document relationship.

See Also:
Constant Field Values

PROPERTY_NAME_ORIGINAL

protected final java.lang.String PROPERTY_NAME_ORIGINAL
Internal value for this field : an original document relationship.

See Also:
Constant Field Values

PROPERTY_NAME_SUB

protected final java.lang.String PROPERTY_NAME_SUB
Internal value for this field : a sub-document document relationship.

See Also:
Constant Field Values

PROPERTY_NAME_PARENT

protected final java.lang.String PROPERTY_NAME_PARENT
See Also:
Constant Field Values

DBELEM_ATTRIBUTE_DEFAULT

protected final java.lang.String DBELEM_ATTRIBUTE_DEFAULT
The implied attribute stating whether the document base is to be used by default or not.

See Also:
Constant Field Values

DBELEM_ATTRIBUTE_KEEP_ORIGINAL

protected final java.lang.String DBELEM_ATTRIBUTE_KEEP_ORIGINAL
The implied attribute stating whether original documents should be stored or not.

See Also:
Constant Field Values

ELEMENT_NAME_INDEX

protected final java.lang.String ELEMENT_NAME_INDEX
The element used to define the indexation pipelines.

See Also:
Constant Field Values

ELEMENT_NAME_PIPELINE

protected final java.lang.String ELEMENT_NAME_PIPELINE
The element used to define an indexation pipeline.

See Also:
Constant Field Values

ELEMENT_NAME_OAI_REPOSITORY

public static final java.lang.String ELEMENT_NAME_OAI_REPOSITORY
The element used to define an oai repository.

See Also:
Constant Field Values

ELEMENT_NAME_OAI_HARVESTER

public static final java.lang.String ELEMENT_NAME_OAI_HARVESTER
The element used to define an oai harvester.

See Also:
Constant Field Values

PROPERTY_NAME_REPO

protected static final java.lang.String PROPERTY_NAME_REPO
A constant for the repository property in the database entities.

See Also:
Constant Field Values

PROPERTY_NAME_MIMETYPE

protected static final java.lang.String PROPERTY_NAME_MIMETYPE
A constant for the path property for attached documents.

See Also:
Constant Field Values

PROPERTY_NAME_CONTENT_LENGTH

protected static final java.lang.String PROPERTY_NAME_CONTENT_LENGTH
See Also:
Constant Field Values

PROPERTY_NAME_DOCTYPE

protected final java.lang.String PROPERTY_NAME_DOCTYPE
A constant for the path property for the type of document, Binary, HTML, or XML.

See Also:
Constant Field Values

INTERNAL_FIELD_NAME_SDXDOCID

public static final java.lang.String INTERNAL_FIELD_NAME_SDXDOCID
Internal field name for document ids

See Also:
Constant Field Values

INTERNAL_FIELD_NAME_SDXALL

public static final java.lang.String INTERNAL_FIELD_NAME_SDXALL
Internal field name for a *fixed* value field. This field can serve several purposes : 1) permit a search that is able to retrieve all the documents (no 'SELECT *' in Lucene), 2) act as a hack that permits to allow creation of binary queries when user wants only to provide an unary one

See Also:
Constant Field Values

INTERNAL_SDXALL_FIELD_VALUE

public static final java.lang.String INTERNAL_SDXALL_FIELD_VALUE
Internal value for this field.

See Also:
Constant Field Values

INTERNAL_FIELD_NAME_SDXAPPID

public static final java.lang.String INTERNAL_FIELD_NAME_SDXAPPID
Internal field name for application id.

See Also:
Constant Field Values

INTERNAL_FIELD_NAME_SDXDBID

public static final java.lang.String INTERNAL_FIELD_NAME_SDXDBID
Internal field name for document base id.

See Also:
Constant Field Values

INTERNAL_FIELD_NAME_SDXREPOID

public static final java.lang.String INTERNAL_FIELD_NAME_SDXREPOID
Internal field name for repository id.

See Also:
Constant Field Values

INTERNAL_FIELD_NAME_SDXDOCTYPE

public static final java.lang.String INTERNAL_FIELD_NAME_SDXDOCTYPE
Internal field name for document type.

See Also:
Constant Field Values

INTERNAL_FIELD_NAME_SDXMODDATE

public static final java.lang.String INTERNAL_FIELD_NAME_SDXMODDATE
Internal field name for modification date.

See Also:
Constant Field Values

INTERNAL_FIELD_NAME_SDXCONTENTLENGTH

public static final java.lang.String INTERNAL_FIELD_NAME_SDXCONTENTLENGTH
Internal field name for document length in bytes.

See Also:
Constant Field Values

INTERNAL_FIELD_NAME_SDX_OAI_DELETED_RECORD

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

AbstractDocumentBase

public AbstractDocumentBase()
Method Detail

contextualize

public void contextualize(org.apache.avalon.framework.context.Context context)
                   throws org.apache.avalon.framework.context.ContextException
Contextualize this class.

Specified by:
contextualize in interface org.apache.avalon.framework.context.Contextualizable
Parameters:
context - The context provided by Cocoon.
Throws:
org.apache.avalon.framework.context.ContextException

setId

public void setId(java.lang.String id)
           throws SDXException
Sets the document base id.

Specified by:
setId in interface DocumentBase
Overrides:
setId in class DatabaseBacked
Parameters:
id - The id (shoud not be null).
Throws:
SDXException

getId

public java.lang.String getId()
Returns the document base id.

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

isDefault

public boolean isDefault()
Returns true if this document base is the default in the application.

Specified by:
isDefault in interface DocumentBase

getIndexationPipeline

public Pipeline getIndexationPipeline()
Returns the default indexation pipeline used for indexation in this document base.

Specified by:
getIndexationPipeline in interface DocumentBase

getMimeType

public java.lang.String getMimeType(Document doc)
                             throws SDXException
Supplies the mimeType for the the document if it exists otherwise the binary document default mimetype is returned

Specified by:
getMimeType in interface DocumentBase
Parameters:
doc - The document.
Throws:
SDXException

configurePipeline

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

getDocument

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

Specified by:
getDocument in interface DocumentBase
Parameters:
doc -
consumer -
Throws:
SDXException

getDocument

public void getDocument(Document doc,
                        java.io.OutputStream os)
                 throws SDXException
Does param checks for subclasses

Specified by:
getDocument in interface DocumentBase
Parameters:
doc -
os -
Throws:
SDXException

getDocument

public java.io.InputStream getDocument(Document doc)
                                throws SDXException
Does param checks for subclasses

Specified by:
getDocument in interface DocumentBase
Parameters:
doc -
Returns:
Throws:
SDXException

getDefaultRepository

public Repository getDefaultRepository()
Returns the default repository for this document base.

Specified by:
getDefaultRepository in interface DocumentBase
Returns:
The default repository object.

getRepository

public Repository getRepository(java.lang.String id)
                         throws SDXException
Gets a repository in this document base.

Specified by:
getRepository in interface DocumentBase
Parameters:
id - The repository's id, if null for the default repository is returned
Returns:
The repository object
Throws:
SDXException

getOAIRepository

public OAIRepository getOAIRepository()
Description copied from interface: DocumentBase
Gets the OAIRepository for the documentbase if one exists

Specified by:
getOAIRepository in interface DocumentBase
Returns:

getOAIHarvester

public OAIHarvester getOAIHarvester()
Description copied from interface: DocumentBase
Gets the AbstractDocumentBaseOAIHarvester for the documentbase if one exists

Specified by:
getOAIHarvester in interface DocumentBase
Returns:

toSAX

public void toSAX(org.xml.sax.ContentHandler hdl)
           throws org.xml.sax.SAXException,
                  org.apache.cocoon.ProcessingException
Feeds a SAX content handler with information about this document base. NOT IMPLEMENTED YET!

Specified by:
toSAX in interface org.apache.cocoon.xml.XMLizable
Parameters:
hdl - A SAX content handler to feed with events.
Throws:
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

addOaiDeletedRecord

protected void addOaiDeletedRecord(IndexableDocument doc)
                            throws SDXException
Throws:
SDXException

removeOaiDeletedRecord

protected void removeOaiDeletedRecord(IndexableDocument doc)
                               throws SDXException
Throws:
SDXException

optimizeDatabase

protected void optimizeDatabase()
                         throws SDXException
Throws:
SDXException

optimizeRepositories

protected void optimizeRepositories()
                             throws SDXException
This method should be called before releasePooledRepositoryConnections(); so we have something to optimize.

Throws:
SDXException

releasePooledRepositoryConnections

protected void releasePooledRepositoryConnections()
                                           throws SDXException
Throws:
SDXException

getPooledRepositoryConnection

protected RepositoryConnection getPooledRepositoryConnection(java.lang.String repoId)
                                                      throws SDXException
Throws:
SDXException

createEntityForDocMetaData

protected DatabaseEntity createEntityForDocMetaData(Document doc,
                                                    Repository repository,
                                                    java.lang.String[] parentDocId)
                                             throws SDXException
Throws:
SDXException

delete

public void delete(Document doc,
                   org.xml.sax.ContentHandler handler)
            throws SDXException,
                   org.xml.sax.SAXException,
                   org.apache.cocoon.ProcessingException
Deletes a document and any attached document(s) if not used by any other document(s).

Specified by:
delete in interface DocumentBase
Parameters:
doc - The document to delete. * @param handler A content handler to feed with information.
handler - The SAX events consumer that receives informations about the deletion process.
Throws:
SDXException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

deletePhysicalDocument

protected void deletePhysicalDocument(Document doc,
                                      Repository repo,
                                      org.xml.sax.ContentHandler handler)
                               throws SDXException,
                                      org.xml.sax.SAXException,
                                      org.apache.cocoon.ProcessingException
This method does a special delete. Only the document and it's lookup information are deleted any relations will remain

Parameters:
doc -
handler -
Throws:
SDXException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException


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