org.progeeks.repository
Class Repository

java.lang.Object
  extended by org.progeeks.repository.Repository

public class Repository
extends java.lang.Object

Implementation of a content repository that uses the file system to provide access to documents that are checked in to the repository. An instance of this class is thread safe and may be shared among any number of threads.

Version:
$Revision: 1.8 $
Author:
Paul Wisneskey

Nested Class Summary
protected static class Repository.ListPropertyTypeRenderer
          Renderer for writing list property types to XML in a format that they can be read back in with (utilizing the constructed bean handler).
protected static class Repository.MetaClassCache
          Class the provides a cache of meta-classes that have been seen by the repository.
protected static class Repository.MetaClassPropertyTypeRenderer
          Renderer for writing metaclass property types to XML as deferred property types.
protected static class Repository.PropertyInfoRenderer
          Renderer for writing property info objects to XML.
protected  class Repository.ReadLockedItem
          Repository item implementation for items that are locked for reading only.
protected  class Repository.WriteLockedItem
          Repository item implementation for items that are locked for reading and writing.
 
Constructor Summary
Repository()
           
 
Method Summary
 RepositoryItem addItem(MetaObject metaData)
          Adds an item to the repository, assigning it an id and saving its supplied meta-data.
 void close()
          Close the repository, release the lock on it.
 void deleteItem(RepositoryItem item)
          Deletes the given item from the repository.
 void deleteItem(java.lang.String itemId)
          Deletes the item corresponding to the itemId
protected  java.io.File generateItemDataFile(java.io.File itemDir, java.lang.String itemId)
          Determines the file that the data for an item will be stored in.
protected  java.io.File generateItemDirectory(java.lang.String itemId)
          Returns the directory in the repository where the item should be stored.
protected  java.io.File generateItemMetaDataFile(java.io.File itemDir, java.lang.String itemId)
          Determines the file that the meta data for an item will be stored in.
 RepositoryItem getItem(java.lang.String itemId)
          Returns a repository item handle for the item with the given id and the item will be locked for reading.
 RepositoryItem getItem(java.lang.String itemId, boolean writeLock)
          Returns a repository item handle for the item with the given id, optionally locked for writing.
 LockManager getLockManager()
          Returns the lock manager implementation being used.
protected  java.lang.String getNextItemId()
          Returns an id string for the next item to be added to the repository.
 java.io.File getRepositoryDir()
          Returns the repository directory.
 boolean getUseMetaClassCache()
          Returns the flag indicating if the meta-classes should be cached in the repository.
 void open()
          Open the repository, creating it if necessary.
protected  MetaObject readItemMetaData(java.lang.String itemId)
          Reads and returns the meta-data information for the given item.
 void releaseLock(Lock lock)
          Release the supplied repository item lock.
protected  void repositoryOpenCheck()
          Checks to see if the repository is open, throwing an exception if it is not.
 void setLockManager(LockManager lockManager)
          Sets the lock manager implementation to use.
 void setRepositoryDir(java.io.File repositoryDir)
          Sets the repository directory (i.e. root directory for the repository).
 void setUseMetaClassCache(boolean useMetaClassCache)
          Sets the flag indicating if meta-classes should be cached in the repository.
 java.lang.String toString()
          Returns a string summary of the object.
protected  void writeItemMetaData(java.lang.String itemId, MetaObject metaData)
          Writes the given meta-data information to the repository for the specified item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Repository

public Repository()
Method Detail

setRepositoryDir

public void setRepositoryDir(java.io.File repositoryDir)
Sets the repository directory (i.e. root directory for the repository).


getRepositoryDir

public java.io.File getRepositoryDir()
Returns the repository directory.


setLockManager

public void setLockManager(LockManager lockManager)
Sets the lock manager implementation to use.


getLockManager

public LockManager getLockManager()
Returns the lock manager implementation being used.


setUseMetaClassCache

public void setUseMetaClassCache(boolean useMetaClassCache)
Sets the flag indicating if meta-classes should be cached in the repository. It is up to the caller to determine if the meta-class cache is appropriate to use for their locking manager implementation.


getUseMetaClassCache

public boolean getUseMetaClassCache()
Returns the flag indicating if the meta-classes should be cached in the repository.


open

public void open()
Open the repository, creating it if necessary.


close

public void close()
Close the repository, release the lock on it. It is up to caller to ensure no items are still locked or in use.


getItem

public RepositoryItem getItem(java.lang.String itemId,
                              boolean writeLock)
Returns a repository item handle for the item with the given id, optionally locked for writing. By default the item will be locked for reading. If the desired lock type can not be obtained, a repository lock exception will be thrown.


getItem

public RepositoryItem getItem(java.lang.String itemId)
Returns a repository item handle for the item with the given id and the item will be locked for reading.


addItem

public RepositoryItem addItem(MetaObject metaData)
Adds an item to the repository, assigning it an id and saving its supplied meta-data. The returned repository item is write locked and should be used to write the item's actualy data before it is released.


deleteItem

public void deleteItem(RepositoryItem item)
Deletes the given item from the repository.


deleteItem

public void deleteItem(java.lang.String itemId)
Deletes the item corresponding to the itemId

Parameters:
itemId -

releaseLock

public void releaseLock(Lock lock)
Release the supplied repository item lock.


toString

public java.lang.String toString()
Returns a string summary of the object.

Overrides:
toString in class java.lang.Object

repositoryOpenCheck

protected void repositoryOpenCheck()
Checks to see if the repository is open, throwing an exception if it is not.


getNextItemId

protected java.lang.String getNextItemId()
Returns an id string for the next item to be added to the repository.


generateItemDirectory

protected java.io.File generateItemDirectory(java.lang.String itemId)
Returns the directory in the repository where the item should be stored. Directory is calculated based on the item id in a manner designed to spread out the files even across multiple subdirectories in a consistent manner.


generateItemMetaDataFile

protected java.io.File generateItemMetaDataFile(java.io.File itemDir,
                                                java.lang.String itemId)
Determines the file that the meta data for an item will be stored in. The file is constructed from the item's directory and item id.


generateItemDataFile

protected java.io.File generateItemDataFile(java.io.File itemDir,
                                            java.lang.String itemId)
Determines the file that the data for an item will be stored in. The file is constructed from the item's directory and item id.


readItemMetaData

protected MetaObject readItemMetaData(java.lang.String itemId)
Reads and returns the meta-data information for the given item.


writeItemMetaData

protected void writeItemMetaData(java.lang.String itemId,
                                 MetaObject metaData)
Writes the given meta-data information to the repository for the specified item.



Copyright © 2002-2003 Paul Speed. All Rights Reserved.