org.fcrepo.server.journal
Class JournalReader

java.lang.Object
  extended by org.fcrepo.server.journal.xmlhelpers.AbstractXmlReader
      extended by org.fcrepo.server.journal.JournalReader
All Implemented Interfaces:
JournalConstants
Direct Known Subclasses:
MultiFileJournalReader, SingleFileJournalReader

public abstract class JournalReader
extends AbstractXmlReader
implements JournalConstants

The abstract base for all JournalReader classes.

Each child class is responsible for providing an XMLEventReader that is positioned at the beginning of a JournalEntry tag. This class will read the entry and leave the XMLEventReader positioned after the corresponding closing tag.

Author:
Jim Blake

Field Summary
protected  Map<String,String> parameters
           
protected  JournalRecoveryLog recoveryLog
           
protected  String role
           
protected  ServerInterface server
           
 
Fields inherited from interface org.fcrepo.server.journal.JournalConstants
ARGUMENT_NAME_ALT_IDS, ARGUMENT_NAME_CHECKSUM, ARGUMENT_NAME_CHECKSUM_TYPE, ARGUMENT_NAME_CONTEXT, ARGUMENT_NAME_CONTROL_GROUP, ARGUMENT_NAME_DATATYPE, ARGUMENT_NAME_DISSEMINATOR_ID, ARGUMENT_NAME_DISSEMINATOR_LABEL, ARGUMENT_NAME_DISSEMINATOR_STATE, ARGUMENT_NAME_DS_CONTENT, ARGUMENT_NAME_DS_ID, ARGUMENT_NAME_DS_LABEL, ARGUMENT_NAME_DS_LOCATION, ARGUMENT_NAME_DS_STATE, ARGUMENT_NAME_ENCODING, ARGUMENT_NAME_END_DATE, ARGUMENT_NAME_FORCE, ARGUMENT_NAME_FORMAT, ARGUMENT_NAME_FORMAT_URI, ARGUMENT_NAME_IN, ARGUMENT_NAME_IS_LITERAL, ARGUMENT_NAME_LABEL, ARGUMENT_NAME_LAST_MODIFIED_DATE, ARGUMENT_NAME_LOCATION, ARGUMENT_NAME_LOG_MESSAGE, ARGUMENT_NAME_MIME_TYPE, ARGUMENT_NAME_NAMESPACE, ARGUMENT_NAME_NEW_PID, ARGUMENT_NAME_NUM_PIDS, ARGUMENT_NAME_OBJECT, ARGUMENT_NAME_OWNERID, ARGUMENT_NAME_PID, ARGUMENT_NAME_RELATIONSHIP, ARGUMENT_NAME_SERIALIZATION, ARGUMENT_NAME_START_DATE, ARGUMENT_NAME_STATE, ARGUMENT_NAME_VERSION_DATE, ARGUMENT_NAME_VERSIONABLE, ARGUMENT_TYPE_BINDING_MAP, ARGUMENT_TYPE_BOOLEAN, ARGUMENT_TYPE_DATE, ARGUMENT_TYPE_INTEGER, ARGUMENT_TYPE_NULL, ARGUMENT_TYPE_STREAM, ARGUMENT_TYPE_STRING, ARGUMENT_TYPE_STRINGARRAY, CONTEXT_MAPNAME_ACTION, CONTEXT_MAPNAME_ENVIRONMENT, CONTEXT_MAPNAME_RECOVERY, CONTEXT_MAPNAME_RESOURCE, CONTEXT_MAPNAME_SUBJECT, DEFAULT_AGE_LIMIT, DEFAULT_FILENAME_PREFIX, DEFAULT_SIZE_LIMIT, DOCUMENT_ENCODING, DOCUMENT_VERSION, FORMAT_JOURNAL_FILENAME_TIMESTAMP, METHOD_ADD_DATASTREAM, METHOD_ADD_DISSEMINATOR, METHOD_ADD_RELATIONSHIP, METHOD_GET_NEXT_PID, METHOD_INGEST, METHOD_MODIFY_DATASTREAM_BY_REFERENCE, METHOD_MODIFY_DATASTREAM_BY_VALUE, METHOD_MODIFY_DISSEMINATOR, METHOD_MODIFY_OBJECT, METHOD_PURGE_DATASTREAM, METHOD_PURGE_DISSEMINATOR, METHOD_PURGE_OBJECT, METHOD_PURGE_RELATIONSHIP, METHOD_PUT_TEMP_STREAM, METHOD_SET_DATASTREAM_STATE, METHOD_SET_DATASTREAM_VERSIONABLE, METHOD_SET_DISSEMINATOR_STATE, PARAMETER_IGNORE_HASH, PARAMETER_JOURNAL_FILE_AGE_LIMIT, PARAMETER_JOURNAL_FILE_SIZE_LIMIT, PARAMETER_JOURNAL_FILENAME_PREFIX, PARAMETER_JOURNAL_MODE, PARAMETER_JOURNAL_READER_CLASSNAME, PARAMETER_JOURNAL_RECOVERY_LOG_CLASSNAME, PARAMETER_JOURNAL_WRITER_CLASSNAME, PARAMETER_RECOVERY_LOG_FILENAME, PARAMETER_RECOVERY_LOG_LEVEL, PASSWORD_CIPHER_TYPE, QNAME_ATTR_BIND_KEY_NAME, QNAME_ATTR_BIND_LABEL, QNAME_ATTR_CLIENT_IP, QNAME_ATTR_DATASTREAM_ID, QNAME_ATTR_DS_BIND_MAP_ID, QNAME_ATTR_DS_BIND_MAP_LABEL, QNAME_ATTR_DS_BIND_MECHANISM_PID, QNAME_ATTR_LOGIN_ID, QNAME_ATTR_METHOD, QNAME_ATTR_NAME, QNAME_ATTR_PASSWORD_TYPE, QNAME_ATTR_REPOSITORY_HASH, QNAME_ATTR_SEQ_NO, QNAME_ATTR_STATE, QNAME_ATTR_TIMESTAMP, QNAME_ATTR_TYPE, QNAME_ATTR_USERID, QNAME_TAG_ARGUMENT, QNAME_TAG_ARRAYELEMENT, QNAME_TAG_CONTEXT, QNAME_TAG_DS_BINDING, QNAME_TAG_DS_BINDING_MAP, QNAME_TAG_JOURNAL, QNAME_TAG_JOURNAL_ENTRY, QNAME_TAG_MULTI_VALUE_MAP, QNAME_TAG_MULTI_VALUE_MAP_KEY, QNAME_TAG_MULTI_VALUE_MAP_VALUE, QNAME_TAG_NOOP, QNAME_TAG_NOW, QNAME_TAG_PASSWORD, SYSTEM_PROPERTY_PREFIX, TIMESTAMP_FORMAT, VALUE_FALSE, VALUE_JOURNAL_MODE_NORMAL, VALUE_JOURNAL_MODE_RECOVER, VALUE_RECOVERY_LOG_LEVEL_HIGH, VALUE_RECOVERY_LOG_LEVEL_LOW, VALUE_RECOVERY_LOG_LEVEL_MEDIUM, VALUE_TRUE
 
Constructor Summary
protected JournalReader(Map<String,String> parameters, String role, JournalRecoveryLog recoveryLog, ServerInterface server)
          Concrete sub-classes must implement this constructor.
 
Method Summary
protected  void checkRepositoryHash(String hash)
          Compare the repository hash from the journal file with the current hash obtained from the server.
static JournalReader getInstance(Map<String,String> parameters, String role, JournalRecoveryLog recoveryLog, ServerInterface server)
          Create an instance of the proper JournalReader child class, as determined by the server parameters.
abstract  ConsumerJournalEntry readJournalEntry()
          Concrete sub-classes should insure that their XMLEventReader is positioned at the beginning of a JournalEntry, and call readJournalEntry(XMLEventReader).
protected  ConsumerJournalEntry readJournalEntry(XMLEventReader reader)
          Read a JournalEntry from the journal, to produce a ConsumerJournalEntry instance.
abstract  void shutdown()
          Concrete sub-classes should probably synchronize this method, since it can be called either from the JournalConsumerThread or from the Server.
 
Methods inherited from class org.fcrepo.server.journal.xmlhelpers.AbstractXmlReader
advancePastWhitespace, getNotCharactersException, getNotEndTagException, getNotNextMemberOrEndOfGroupException, getNotStartTagException, getOptionalAttributeValue, getRequiredAttributeValue, isEndTagEvent, isStartTagEvent, readCharactersUntilEndTag, readStartTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parameters

protected final Map<String,String> parameters

role

protected final String role

recoveryLog

protected final JournalRecoveryLog recoveryLog

server

protected final ServerInterface server
Constructor Detail

JournalReader

protected JournalReader(Map<String,String> parameters,
                        String role,
                        JournalRecoveryLog recoveryLog,
                        ServerInterface server)
                 throws JournalException
Concrete sub-classes must implement this constructor.

Throws:
JournalException
Method Detail

getInstance

public static JournalReader getInstance(Map<String,String> parameters,
                                        String role,
                                        JournalRecoveryLog recoveryLog,
                                        ServerInterface server)
                                 throws ModuleInitializationException
Create an instance of the proper JournalReader child class, as determined by the server parameters.

Throws:
ModuleInitializationException

shutdown

public abstract void shutdown()
                       throws JournalException
Concrete sub-classes should probably synchronize this method, since it can be called either from the JournalConsumerThread or from the Server.

Throws:
JournalException

readJournalEntry

public abstract ConsumerJournalEntry readJournalEntry()
                                               throws JournalException,
                                                      XMLStreamException
Concrete sub-classes should insure that their XMLEventReader is positioned at the beginning of a JournalEntry, and call readJournalEntry(XMLEventReader). It is likely that this method should be synchronized also, since it could be called from JournalConsumerThread when the server calls shutdown()

Throws:
JournalException
XMLStreamException

checkRepositoryHash

protected void checkRepositoryHash(String hash)
                            throws JournalException
Compare the repository hash from the journal file with the current hash obtained from the server. If they do not match, either throw an exception or simply log it, depending on the parameters. This method must not be called before the server has completed initialization. That's the only way we can be confident that the DOManager is present, and ready to create the repository has that we will compare to.

Throws:
JournalException

readJournalEntry

protected ConsumerJournalEntry readJournalEntry(XMLEventReader reader)
                                         throws JournalException,
                                                XMLStreamException
Read a JournalEntry from the journal, to produce a ConsumerJournalEntry instance. Concrete sub-classes should insure that the XMLEventReader is positioned at the beginning of a JournalEntry before calling this method.

Throws:
JournalException
XMLStreamException


Copyright © 2012 DuraSpace. All Rights Reserved.