org.tigris.eyebrowse
Class MailingListArchive

java.lang.Object
  |
  +--org.tigris.eyebrowse.MailingListArchive
All Implemented Interfaces:
org.tigris.eyebrowse.util.IFileRotate

public class MailingListArchive
extends java.lang.Object
implements org.tigris.eyebrowse.util.IFileRotate

Business object which encapsulates database and mbox data, and provides an API to list operations. Currently used most by the the classes in the org.tigris.eyerowse.programs package.

Since:
1.1
Author:
Michael Salmon, Daniel Rall

Constructor Summary
MailingListArchive()
          Needed for loading of this class as an IFileRotate implementation.
MailingListArchive(EyebrowseDb.ListInfo list)
           
MailingListArchive(java.lang.String name)
          Creates a new instance with the specified name.
MailingListArchive(java.lang.String name, java.lang.String description, java.lang.String filePath, java.lang.String indexDirPath)
          Creates a new instance with the specified attributes.
 
Method Summary
 void addIndex()
          Adds the index already set for this object.
 void addIndex(java.lang.String indexDirPath)
          Adds the index directory at indexDirPath for this list.
 void addList()
           
 void addListFile()
          Adds the list file set for this object.
 void addListFile(java.lang.String filePath)
           
 void deleteList()
          removes all database entries for this list finds list by name
 void deleteListAndFiles()
          removes the list and all the list files, use with caution!
 void deleteOnlyIndex()
          removes only the index record for this list finds list by name
 java.lang.String getActiveListFilePath()
          Returns the path to the active mbox file for this list.
protected  org.tigris.eyebrowse.util.IFileRotate getFileRotator()
          Gets the configured IFileRotate implementation keyed by the org.tigris.eyebrowse.fileRotator property, caching an instance if one doesn't already exist.
 int getID()
          returns the ID that was set by the constructor, if it wasnt set at instantiation time then it's gotten from the database
 java.lang.String getLastListFilePath()
          Returns the path to the last file for list by ID or null if there is none for the list.
 java.lang.String getName()
          Returns the name of this list.
 boolean hasConsistentData()
          Diagnositc routine which checks the database for consistency against the active list file.
 void rotateActiveListFile()
          Rotates the active mbox file for this list according to the algorithm provided by the configured IFileRotate implementation's rotateFile() method.
 java.lang.String rotateFile(MailingListArchive archive)
          Eyebrowse's default implementation of the IFileRotate interface.
 void setDescription(java.lang.String description)
           
 void setFilePath(java.lang.String filePath)
           
 void setID(int id)
           
 void setIndexDirPath(java.lang.String indexDirPath)
           
 void updateDescription()
           
 void updateDescription(java.lang.String description)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailingListArchive

public MailingListArchive()
Needed for loading of this class as an IFileRotate implementation.

MailingListArchive

public MailingListArchive(java.lang.String name)
Creates a new instance with the specified name.

MailingListArchive

public MailingListArchive(java.lang.String name,
                          java.lang.String description,
                          java.lang.String filePath,
                          java.lang.String indexDirPath)
Creates a new instance with the specified attributes.
Parameters:
name - The list name.
description - The list description.
filePath - The path to the active list data file.
indexDirPath - The path to the index directory.

MailingListArchive

public MailingListArchive(EyebrowseDb.ListInfo list)
See Also:
MailingListArchive(String, String, String, String)
Method Detail

setDescription

public void setDescription(java.lang.String description)

setID

public void setID(int id)

setFilePath

public void setFilePath(java.lang.String filePath)

setIndexDirPath

public void setIndexDirPath(java.lang.String indexDirPath)

addList

public void addList()
             throws EyebrowseException

addListFile

public void addListFile(java.lang.String filePath)
                 throws EyebrowseException
Parameters:
filePath - The file path.
See Also:
addListFile()

addListFile

public void addListFile()
                 throws EyebrowseException
Adds the list file set for this object.

addIndex

public void addIndex(java.lang.String indexDirPath)
              throws EyebrowseException,
                     IndexerException
Adds the index directory at indexDirPath for this list.
Parameters:
indexDirPath - The path to the index directory to add.
See Also:
addIndex()

addIndex

public void addIndex()
              throws EyebrowseException,
                     IndexerException
Adds the index already set for this object.

deleteList

public void deleteList()
                throws EyebrowseException
removes all database entries for this list finds list by name

deleteListAndFiles

public void deleteListAndFiles()
                        throws EyebrowseException
removes the list and all the list files, use with caution!

deleteOnlyIndex

public void deleteOnlyIndex()
                     throws EyebrowseException
removes only the index record for this list finds list by name

getID

public int getID()
          throws EyebrowseException
returns the ID that was set by the constructor, if it wasnt set at instantiation time then it's gotten from the database

getName

public java.lang.String getName()
Returns the name of this list.

getActiveListFilePath

public java.lang.String getActiveListFilePath()
                                       throws EyebrowseException
Returns the path to the active mbox file for this list. TODO: Cache active list file path.
Returns:
The path to the active mbox file.

rotateActiveListFile

public final void rotateActiveListFile()
                                throws EyebrowseException
Rotates the active mbox file for this list according to the algorithm provided by the configured IFileRotate implementation's rotateFile() method. Logs rotation status.
Returns:
The new file name.
Throws:
EyebrowseException - Couldn't rotate the mbox.
See Also:
rotateFile(MailingListArchive), IFileRotate

rotateFile

public java.lang.String rotateFile(MailingListArchive archive)
                            throws EyebrowseException

Eyebrowse's default implementation of the IFileRotate interface. Rotates the active mbox file for this list, creating a new mbox for the current month (if it doesn't already exist and the file is writable), producing a date-stamped file name corresponding to the current month (using the date format yyyyMM).

The configured IFileRotate implementation is called by the rotateActiveListFile() method.

Specified by:
rotateFile in interface org.tigris.eyebrowse.util.IFileRotate
Parameters:
archive - List archive to rotate -- the class loaded default implementation won't have the necessary identifying information. Quite possibly a reference to ourself.
Returns:
The active file name.
See Also:
rotateActiveListFile(), IFileRotate

getFileRotator

protected org.tigris.eyebrowse.util.IFileRotate getFileRotator()
                                                        throws EyebrowseException
Gets the configured IFileRotate implementation keyed by the org.tigris.eyebrowse.fileRotator property, caching an instance if one doesn't already exist.

getLastListFilePath

public java.lang.String getLastListFilePath()
                                     throws EyebrowseException
Returns the path to the last file for list by ID or null if there is none for the list.

updateDescription

public void updateDescription()
                       throws EyebrowseException

updateDescription

public void updateDescription(java.lang.String description)
                       throws EyebrowseException

hasConsistentData

public boolean hasConsistentData()
                          throws EyebrowseException
Diagnositc routine which checks the database for consistency against the active list file. Consistency is determined by the following criteria:
  1. Existence of active mbox file (in database)
  2. Existence of active mbox file (on file system)
  3. Matching file size between database and file system
  4. Matching number of messages between database and file system
Returns:
Whether consistent.
Throws:
EyebrowseException - Error checking consistency.


Copyright © 2000 Quiotix Corp. All Rights Reserved.