org.fcrepo.server.journal
Class JournalWriter

java.lang.Object
  extended by org.fcrepo.server.journal.xmlhelpers.AbstractXmlWriter
      extended by org.fcrepo.server.journal.JournalWriter
All Implemented Interfaces:
JournalConstants
Direct Known Subclasses:
MulticastJournalWriter, MultiFileJournalWriter, SingleFileJournalWriter

public abstract class JournalWriter
extends AbstractXmlWriter

The abstract base for all JournalWriter classes.

Each child class is responsible for providing an XMLEventWriter that will receive the JournalEntry tag. This class will format a JournalEntry object into XML and add it to the XMLEventWriter.

Note that the writing of an entry is necessarily a three step process, consisting of

  1. calling prepareToWriteJournalEntry(),
  2. invoking the management method,
  3. calling writeJournalEntry(CreatorJournalEntry)
Several factors combine to require this sequence.

Author:
Jim Blake

Field Summary
protected  Map<String,String> parameters
           
protected  String role
           
protected  ServerInterface server
           
static Object SYNCHRONIZER
          A single object on which to synchronize all writing operations.
 
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 JournalWriter(Map<String,String> parameters, String role, ServerInterface server)
          Concrete sub-classes must implement this constructor.
 
Method Summary
static JournalWriter getInstance(Map<String,String> parameters, String role, ServerInterface server)
          Create an instance of the proper JournalWriter child class, as determined by the server parameters.
abstract  void prepareToWriteJournalEntry()
          Concrete sub-classes should insure that a message transport is ready, and call {@link #writeDocumentHeader(XMLEventWriter) if needed.
abstract  void shutdown()
           
protected  void writeDocumentHeader(XMLEventWriter writer)
          Subclasses should call this method to initialize a new Journal file.
protected  void writeDocumentHeader(XMLEventWriter writer, String repositoryHash, Date currentDate)
          Subclasses should call this method to initialize a new Journal file, if they already know the repository hash and the current date.
protected  void writeDocumentTrailer(XMLEventWriter writer)
          Subclasses should call this method to close a Journal file.
abstract  void writeJournalEntry(CreatorJournalEntry journalEntry)
          Concrete sub-classes should provide an XMLEventWriter, and call #writeJournalEntry(XMLEventWriter), after which, they should probably flush the XMLEventWriter.
protected  void writeJournalEntry(CreatorJournalEntry journalEntry, XMLEventWriter writer)
          Format a JournalEntry object and write a JournalEntry tag to the journal.
 
Methods inherited from class org.fcrepo.server.journal.xmlhelpers.AbstractXmlWriter
putAttribute, putAttributeIfNotNull, putCharacters, putEndDocument, putEndTag, putStartDocument, putStartTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYNCHRONIZER

public static final Object SYNCHRONIZER
A single object on which to synchronize all writing operations. The most obvious use is in CreatorJournalEntry to be sure that Management methods are single-threaded. A less obvious, but necessary use is to synchronize the timeout on JournalFiles, so a file is not closed in the middle of an operation.


role

protected final String role

parameters

protected final Map<String,String> parameters

server

protected final ServerInterface server
Constructor Detail

JournalWriter

protected JournalWriter(Map<String,String> parameters,
                        String role,
                        ServerInterface server)
Concrete sub-classes must implement this constructor.

Method Detail

getInstance

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

Throws:
JournalException

shutdown

public abstract void shutdown()
                       throws JournalException
Throws:
JournalException

prepareToWriteJournalEntry

public abstract void prepareToWriteJournalEntry()
                                         throws JournalException
Concrete sub-classes should insure that a message transport is ready, and call #writeDocumentHeader(XMLEventWriter) if needed. This method is called separately from {@link #writeJournalEntry(CreatorJournalEntry)}, so we can obtain the repository hash before the Management method is invoked.

Throws:
JournalException

writeJournalEntry

public abstract void writeJournalEntry(CreatorJournalEntry journalEntry)
                                throws JournalException
Concrete sub-classes should provide an XMLEventWriter, and call #writeJournalEntry(XMLEventWriter), after which, they should probably flush the XMLEventWriter. This method is called after the Management method is invoked, since the Management method may modify the context object in the journal entry.

Throws:
JournalException

writeDocumentHeader

protected void writeDocumentHeader(XMLEventWriter writer)
                            throws JournalException
Subclasses should call this method to initialize a new Journal file.

Throws:
JournalException

writeDocumentHeader

protected void writeDocumentHeader(XMLEventWriter writer,
                                   String repositoryHash,
                                   Date currentDate)
                            throws JournalException
Subclasses should call this method to initialize a new Journal file, if they already know the repository hash and the current date.

Throws:
JournalException

writeDocumentTrailer

protected void writeDocumentTrailer(XMLEventWriter writer)
                             throws JournalException
Subclasses should call this method to close a Journal file.

Throws:
JournalException

writeJournalEntry

protected void writeJournalEntry(CreatorJournalEntry journalEntry,
                                 XMLEventWriter writer)
                          throws JournalException
Format a JournalEntry object and write a JournalEntry tag to the journal.

Throws:
JournalException


Copyright © 2012 DuraSpace. All Rights Reserved.