fr.gouv.culture.sdx.documentbase
Class SDXDocumentBase

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
              extended byfr.gouv.culture.sdx.documentbase.SDXDocumentBase
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:
LuceneDocumentBase

public abstract class SDXDocumentBase
extends AbstractDocumentBase

an abstract document base class handling SDX based configurations


Field Summary
protected static java.lang.String[] _documentAdditionStatus
           
protected static int DOC_ADD_STATUS_ADDED
           
protected static int DOC_ADD_STATUS_FAILURE
           
protected static int DOC_ADD_STATUS_IGNORED
           
protected static int DOC_ADD_STATUS_REFRESHED
           
protected static int DOC_ADD_STATUS_REPLACED
           
protected  java.lang.String DOC_URL
           
static java.lang.String DOCUMENTBASE_DIR_PATH
          String representation for a key in the Properties object : document base's directory location.
protected  boolean keepOriginalDocuments
          Whether the original documents should be stored or not.
protected static java.lang.String SDX_DATABASE_FORMAT
           
protected static java.lang.String SDX_DATABASE_VERSION
           
protected static java.lang.String SDX_DATABASE_VERSION_2_3
           
protected  java.lang.String SDX_DATE
           
protected  java.lang.String SDX_DATE_MILLISECONDS
           
protected  java.lang.String SDX_ISO8601_DATE
           
protected  java.lang.String SDX_USER
           
 
Fields inherited from class fr.gouv.culture.sdx.documentbase.AbstractDocumentBase
context, DBELEM_ATTRIBUTE_DEFAULT, DBELEM_ATTRIBUTE_KEEP_ORIGINAL, defaultRepository, ELEMENT_NAME_INDEX, ELEMENT_NAME_OAI_HARVESTER, ELEMENT_NAME_OAI_REPOSITORY, ELEMENT_NAME_PIPELINE, indexationPipeline, INTERNAL_FIELD_NAME_SDX_OAI_DELETED_RECORD, INTERNAL_FIELD_NAME_SDXALL, INTERNAL_FIELD_NAME_SDXAPPID, INTERNAL_FIELD_NAME_SDXCONTENTLENGTH, INTERNAL_FIELD_NAME_SDXDBID, INTERNAL_FIELD_NAME_SDXDOCID, INTERNAL_FIELD_NAME_SDXDOCTYPE, INTERNAL_FIELD_NAME_SDXMODDATE, INTERNAL_FIELD_NAME_SDXREPOID, INTERNAL_SDXALL_FIELD_VALUE, isDefault, locale, oaiHarv, oaiRepo, PROPERTY_NAME_ATTACHED, PROPERTY_NAME_CONTENT_LENGTH, PROPERTY_NAME_DOCTYPE, PROPERTY_NAME_MIMETYPE, PROPERTY_NAME_ORIGINAL, PROPERTY_NAME_PARENT, PROPERTY_NAME_REPO, PROPERTY_NAME_SUB, repoConnectionPool, repositories
 
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
SDXDocumentBase()
           
 
Method Summary
protected  void add(boolean batchIndex, Document originalDoc, Repository repository, RepositoryConnection conn, IndexParameters params, boolean isIndexable, boolean isPrimary, java.lang.String relation, java.lang.String parentId, org.xml.sax.ContentHandler handler, java.lang.String attachedDocId)
           
protected abstract  void addToSearchIndex(java.lang.Object indexationDoc, boolean batchIndex)
          Add a document to the underlying search index
protected abstract  void compactSearchIndex()
           
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
           
protected abstract  void configureDocumentBase(org.apache.avalon.framework.configuration.Configuration configuration)
           
protected  void configureIdGenerator(org.apache.avalon.framework.configuration.Configuration configuration)
           
 void configureOAIComponents(org.apache.avalon.framework.configuration.Configuration configuration)
           
protected abstract  void configureOAIHarvester(org.apache.avalon.framework.configuration.Configuration configuration)
           
protected abstract  void configureOAIRepository(org.apache.avalon.framework.configuration.Configuration configuration)
           
protected  void configureRepositories(org.apache.avalon.framework.configuration.Configuration configuration)
           
 void delete(Document[] docs, org.xml.sax.ContentHandler handler)
          Deletes an array of documents and any attached document(s) if not used by any other document(s).
protected  void delete(Document doc, boolean isIndexable, boolean isPrimary, boolean isShared, java.lang.String relation, org.xml.sax.ContentHandler handler)
          Deletes a document and any attached document(s) if not used by any other document(s).
protected abstract  void deleteFromSearchIndex(java.lang.String id)
           
protected  void deleteIndexableDocumentComponents(IndexableDocument doc, org.xml.sax.ContentHandler handler)
          Deletes all secondary document and search index components
protected  void deleteRelationsToMastersFromDatabase(Document doc)
           
 java.io.InputStream getDocument(Document doc)
          Provides the requested SDX document as an InputStream
 void getDocument(Document doc, java.io.OutputStream os)
          Supplies the provided output stream with the requested document
 void getDocument(ParsableDocument doc, org.apache.cocoon.xml.XMLConsumer consumer)
          Gets a SDX document as SAX events.
 void getDocument(ParsableDocument doc, org.apache.cocoon.xml.XMLConsumer consumer, boolean docTypeKnown)
          Gets a SDX document as SAX events.
protected abstract  java.lang.Object getIndexationDocument(IndexableDocument doc, java.lang.String storeDocId, java.lang.String repoId, IndexParameters params)
           
 java.lang.String[] getOwners(java.lang.String relationType, java.lang.String docId, org.xml.sax.ContentHandler handler)
          Retrieves all parent documents containing the relationType/docId entry
 java.lang.String[] getRelated(java.lang.String docId, java.lang.String relationType, org.xml.sax.ContentHandler handler)
          Retrieves the related documents (sub, attached, original) of the parent document for the relationType provided
protected  org.apache.avalon.framework.configuration.Configuration[] getRepositoryConfigurationList(org.apache.avalon.framework.configuration.Configuration configuration)
           
protected  Repository getRepositoryForDocument(Document doc)
          Gets the repository object in which a document resides, document should not be null and have a valid id, use Utilities.checkDocument before calling this method
protected  Repository getRepositoryForStorage(Document doc, Repository defaultRepo)
          This method retrieves a repository id from a document object and then does a lookup for the corresponding repository object.
protected  int handleParameters(Document doc, Repository repo, IndexParameters params, boolean isIndexable, boolean isPrimary, java.lang.String relation, org.xml.sax.ContentHandler handler)
           
 void index(IndexableDocument[] docs, Repository repository, IndexParameters params, org.xml.sax.ContentHandler handler)
          Adds some documents.
 void index(IndexableDocument doc, Repository repository, IndexParameters params, org.xml.sax.ContentHandler handler)
          Adds a document.
protected  void index(IndexableDocument doc, Repository repository, RepositoryConnection conn, IndexParameters params, org.xml.sax.ContentHandler handler, boolean batchIndex)
          Adds a document from an array of documents using the same connection.
 void init()
          Initializes the document base.
protected  void loadBaseConfiguration(org.apache.avalon.framework.configuration.Configuration configuration)
           
protected  void rollbackIndexation(IndexableDocument doc, org.xml.sax.ContentHandler handler)
           
protected  IndexParameters setBaseParameters(IndexParameters params)
          Set's the default pipeline parameters and ensures the params have a pipeline
 
Methods inherited from class fr.gouv.culture.sdx.documentbase.AbstractDocumentBase
addOaiDeletedRecord, configurePipeline, contextualize, createEntityForDocMetaData, delete, deletePhysicalDocument, getDefaultRepository, getId, getIndexationPipeline, getMimeType, getOAIHarvester, getOAIRepository, getPooledRepositoryConnection, getRepository, isDefault, optimizeDatabase, optimizeRepositories, releasePooledRepositoryConnections, removeOaiDeletedRecord, setId, toSAX
 
Methods inherited from class fr.gouv.culture.sdx.utils.database.DatabaseBacked
compose, getDatabase, 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, lastModificationDate, setProperties
 
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

DOCUMENTBASE_DIR_PATH

public static final java.lang.String DOCUMENTBASE_DIR_PATH
String representation for a key in the Properties object : document base's directory location.

See Also:
Constant Field Values

keepOriginalDocuments

protected boolean keepOriginalDocuments
Whether the original documents should be stored or not.


DOC_URL

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

SDX_USER

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

SDX_DATE

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

SDX_ISO8601_DATE

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

SDX_DATE_MILLISECONDS

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

_documentAdditionStatus

protected static final java.lang.String[] _documentAdditionStatus

DOC_ADD_STATUS_FAILURE

protected static final int DOC_ADD_STATUS_FAILURE
See Also:
Constant Field Values

DOC_ADD_STATUS_IGNORED

protected static final int DOC_ADD_STATUS_IGNORED
See Also:
Constant Field Values

DOC_ADD_STATUS_ADDED

protected static final int DOC_ADD_STATUS_ADDED
See Also:
Constant Field Values

DOC_ADD_STATUS_REFRESHED

protected static final int DOC_ADD_STATUS_REFRESHED
See Also:
Constant Field Values

DOC_ADD_STATUS_REPLACED

protected static final int DOC_ADD_STATUS_REPLACED
See Also:
Constant Field Values

SDX_DATABASE_FORMAT

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

SDX_DATABASE_VERSION

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

SDX_DATABASE_VERSION_2_3

protected static final java.lang.String SDX_DATABASE_VERSION_2_3
See Also:
Constant Field Values
Constructor Detail

SDXDocumentBase

public SDXDocumentBase()
Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Overrides:
configure in class DatabaseBacked
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

loadBaseConfiguration

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

getRepositoryConfigurationList

protected org.apache.avalon.framework.configuration.Configuration[] getRepositoryConfigurationList(org.apache.avalon.framework.configuration.Configuration configuration)
                                                                                            throws org.apache.avalon.framework.configuration.ConfigurationException
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureRepositories

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

configureOAIComponents

public void configureOAIComponents(org.apache.avalon.framework.configuration.Configuration configuration)
                            throws org.apache.avalon.framework.configuration.ConfigurationException
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureIdGenerator

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

configureDocumentBase

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

deleteFromSearchIndex

protected abstract void deleteFromSearchIndex(java.lang.String id)
                                       throws SDXException
Throws:
SDXException

configureOAIRepository

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

configureOAIHarvester

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

getIndexationDocument

protected abstract java.lang.Object getIndexationDocument(IndexableDocument doc,
                                                          java.lang.String storeDocId,
                                                          java.lang.String repoId,
                                                          IndexParameters params)
                                                   throws SDXException
Throws:
SDXException

addToSearchIndex

protected abstract void addToSearchIndex(java.lang.Object indexationDoc,
                                         boolean batchIndex)
                                  throws SDXException
Add a document to the underlying search index

Parameters:
indexationDoc - The document object for the specific search implementation (lucene, or other)
batchIndex - parameter to indicate wheter a batch indexation pass is taking place so that optimization is done at the end of the batch
Throws:
SDXException

compactSearchIndex

protected abstract void compactSearchIndex()
                                    throws SDXException
Throws:
SDXException

getDocument

public void getDocument(ParsableDocument doc,
                        org.apache.cocoon.xml.XMLConsumer consumer)
                 throws SDXException
Gets a SDX document as SAX events.

Specified by:
getDocument in interface DocumentBase
Overrides:
getDocument in class AbstractDocumentBase
Parameters:
doc - A ParsableDocument, ie XMLDocument or HTMLDocument.
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);

Throws:
SDXException

getDocument

public void getDocument(ParsableDocument doc,
                        org.apache.cocoon.xml.XMLConsumer consumer,
                        boolean docTypeKnown)
                 throws SDXException
Gets a SDX document as SAX events.

Parameters:
doc - A Document, ie XMLDocument or HTMLDocument, we discern the type from the document lookup.
consumer - A SAX content handler to feed with events.
docTypeKnown - If the type of the ParsableDocument desired is unknown, ie. XML or HTML, allows users to build one or the other type of document and still retrieve a document

The wrapped contentHandler for including events within an XSP page contentHandler should be created using IncludeXMLConsumer stripper = new IncludeXMLConsumer(xspContentHandler);

Throws:
SDXException

getDocument

public void getDocument(Document doc,
                        java.io.OutputStream os)
                 throws SDXException
Supplies the provided output stream with the requested document

Specified by:
getDocument in interface DocumentBase
Overrides:
getDocument in class AbstractDocumentBase
Parameters:
doc - The document.
os - The output stream.
Throws:
SDXException

getDocument

public java.io.InputStream getDocument(Document doc)
                                throws SDXException
Provides the requested SDX document as an InputStream

Specified by:
getDocument in interface DocumentBase
Overrides:
getDocument in class AbstractDocumentBase
Parameters:
doc - The document.
Returns:
An input stream.
Throws:
SDXException

getRepositoryForStorage

protected Repository getRepositoryForStorage(Document doc,
                                             Repository defaultRepo)
                                      throws SDXException
This method retrieves a repository id from a document object and then does a lookup for the corresponding repository object.

Parameters:
doc - Document with desired repository storage id
defaultRepo - Default repo to utilize if none found
Returns:
Throws:
SDXException

getRepositoryForDocument

protected Repository getRepositoryForDocument(Document doc)
                                       throws SDXException
Gets the repository object in which a document resides, document should not be null and have a valid id, use Utilities.checkDocument before calling this method

Throws:
SDXException

delete

protected void delete(Document doc,
                      boolean isIndexable,
                      boolean isPrimary,
                      boolean isShared,
                      java.lang.String relation,
                      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).

Parameters:
doc - The document to delete.
Throws:
SDXException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

deleteIndexableDocumentComponents

protected void deleteIndexableDocumentComponents(IndexableDocument doc,
                                                 org.xml.sax.ContentHandler handler)
                                          throws SDXException,
                                                 org.apache.cocoon.ProcessingException,
                                                 org.xml.sax.SAXException
Deletes all secondary document and search index components

Parameters:
doc - The parent document
Throws:
SDXException
org.apache.cocoon.ProcessingException
org.xml.sax.SAXException

delete

public void delete(Document[] docs,
                   org.xml.sax.ContentHandler handler)
            throws SDXException,
                   org.xml.sax.SAXException,
                   org.apache.cocoon.ProcessingException
Deletes an array of documents and any attached document(s) if not used by any other document(s).

Parameters:
docs - The documents to delete.
handler - A content handler to feed with information.
Throws:
SDXException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

index

public void index(IndexableDocument doc,
                  Repository repository,
                  IndexParameters params,
                  org.xml.sax.ContentHandler handler)
           throws SDXException,
                  org.xml.sax.SAXException,
                  org.apache.cocoon.ProcessingException
Adds a document.

Parameters:
doc - The document to add.
repository - The repository where to store the document.
params - The parameters for this adding action.
handler - A content handler where to send information about the process (may be null), currently we don't use it, but maybe in the future. TODO : what kind of "informations" ? -pb
Throws:
SDXException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

rollbackIndexation

protected void rollbackIndexation(IndexableDocument doc,
                                  org.xml.sax.ContentHandler handler)
                           throws SDXException,
                                  org.xml.sax.SAXException,
                                  org.apache.cocoon.ProcessingException
Throws:
SDXException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

getOwners

public java.lang.String[] getOwners(java.lang.String relationType,
                                    java.lang.String docId,
                                    org.xml.sax.ContentHandler handler)
                             throws SDXException,
                                    org.xml.sax.SAXException
Retrieves all parent documents containing the relationType/docId entry

Parameters:
relationType - The relation type (sub, attached, original)
docId - The secondary document id
handler - Then handler to feed with events
Returns:
Throws:
SDXException
org.xml.sax.SAXException

getRelated

public java.lang.String[] getRelated(java.lang.String docId,
                                     java.lang.String relationType,
                                     org.xml.sax.ContentHandler handler)
                              throws SDXException,
                                     org.xml.sax.SAXException
Retrieves the related documents (sub, attached, original) of the parent document for the relationType provided

Parameters:
docId - The parent document id
relationType - The relation type (sub, attached, original)
handler - The handler to feed with events
Returns:
Throws:
SDXException
org.xml.sax.SAXException

deleteRelationsToMastersFromDatabase

protected void deleteRelationsToMastersFromDatabase(Document doc)
                                             throws SDXException
Throws:
SDXException

handleParameters

protected int handleParameters(Document doc,
                               Repository repo,
                               IndexParameters params,
                               boolean isIndexable,
                               boolean isPrimary,
                               java.lang.String relation,
                               org.xml.sax.ContentHandler handler)
                        throws SDXException,
                               org.xml.sax.SAXException,
                               org.apache.cocoon.ProcessingException
Throws:
SDXException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

setBaseParameters

protected IndexParameters setBaseParameters(IndexParameters params)
Set's the default pipeline parameters and ensures the params have a pipeline

Parameters:
params - The params object provided by the user at indexation time

index

public void index(IndexableDocument[] docs,
                  Repository repository,
                  IndexParameters params,
                  org.xml.sax.ContentHandler handler)
           throws SDXException,
                  org.xml.sax.SAXException,
                  org.apache.cocoon.ProcessingException
Adds some documents.

Parameters:
docs - The documents to add.
repository - The repository where to store the documents. If null is passed, the default repository will be used.
params - The parameters for this adding action.
handler - A content handler where to send information about the process (may be null) TODO : what kind of "informations" ? -pb
Throws:
SDXException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

index

protected void index(IndexableDocument doc,
                     Repository repository,
                     RepositoryConnection conn,
                     IndexParameters params,
                     org.xml.sax.ContentHandler handler,
                     boolean batchIndex)
              throws SDXException,
                     org.xml.sax.SAXException,
                     org.apache.cocoon.ProcessingException
Adds a document from an array of documents using the same connection.

Parameters:
doc - The document to add.
repository - The repository where to store the document.
conn - The repository's connection, we want to use only one connection for all the documents
params - The parameters for this adding action.
handler - A content handler where to send information about the process (may be null), currently we don't use it, but maybe in the future. TODO : what kind of "informations" ? -pb
Throws:
SDXException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

add

protected void add(boolean batchIndex,
                   Document originalDoc,
                   Repository repository,
                   RepositoryConnection conn,
                   IndexParameters params,
                   boolean isIndexable,
                   boolean isPrimary,
                   java.lang.String relation,
                   java.lang.String parentId,
                   org.xml.sax.ContentHandler handler,
                   java.lang.String attachedDocId)
            throws SDXException,
                   org.xml.sax.SAXException,
                   org.apache.cocoon.ProcessingException
Parameters:
originalDoc - The document to add
repository - The repository to use
conn - The repository connection to use
params - The document addition parameters
handler - The content handler to feed with events
isIndexable - is the document indexable
isPrimary - is the document a primary or secondary document
batchIndex - is this a batch index
Throws:
SDXException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

init

public void init()
          throws SDXException
Description copied from interface: DocumentBase
Initializes the document base.

This method must be called after the logger has been set and the configuration done.

Specified by:
init in interface DocumentBase
Overrides:
init in class DatabaseBacked
Throws:
SDXException


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