org.apache.lenya.ac.file
Class FileItemManager

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.lenya.ac.file.FileItemManager
All Implemented Interfaces:
org.apache.avalon.framework.logger.LogEnabled, org.apache.lenya.ac.ItemManager
Direct Known Subclasses:
FileGroupManager, FileIPRangeManager, FileRoleManager, FileUserManager

public abstract class FileItemManager
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements org.apache.lenya.ac.ItemManager

Abstract superclass for classes that manage items loaded from configuration files.


Nested Class Summary
static class FileItemManager.DirectoryChangeNotifier
          Helper class to observe a directory for changes.
 
Constructor Summary
protected FileItemManager(org.apache.lenya.ac.AccreditableManager accreditableManager)
          Create a new ItemManager.
 
Method Summary
 void add(org.apache.lenya.ac.Item item)
          Add an Item to this manager
 void addItemManagerListener(org.apache.lenya.ac.ItemManagerListener listener)
          Attaches an item manager listener to this item manager.
 void configure(java.io.File _configurationDirectory)
          Configures the item manager.
 boolean contains(org.apache.lenya.ac.Item item)
          Returns if the ItemManager contains an object.
 org.apache.lenya.ac.AccreditableManager getAccreditableManager()
           
 java.io.File getConfigurationDirectory()
          Get the directory where the items are located.
protected  java.io.FileFilter getFileFilter()
          Get a file filter which filters for files containing items.
 org.apache.lenya.ac.Item getItem(java.lang.String id)
          Returns an item for a given ID.
protected  org.apache.avalon.framework.configuration.Configuration getItemConfiguration(java.io.File file)
          Loads teh configuration of an item from a file.
 org.apache.lenya.ac.Item[] getItems()
          get all items
protected abstract  java.lang.String getSuffix()
          Returns the file extension to be used.
protected  org.apache.lenya.ac.Item loadItem(java.io.File file)
          Loads an item from a file.
protected  void loadItems()
          Reloads the items if an item was changed / added / removed.
protected  void notifyAdded(org.apache.lenya.ac.Item item)
          Notifies the listeners that an item was added.
protected  void notifyRemoved(org.apache.lenya.ac.Item item)
          Notifies the listeners that an item was removed.
 void remove(org.apache.lenya.ac.Item item)
          Remove an item from this manager
protected  void removeItem(java.io.File file)
           
 void removeItemManagerListener(org.apache.lenya.ac.ItemManagerListener listener)
          Removes an item manager listener from this item manager.
 void update(org.apache.lenya.ac.Item newItem)
          Update an item.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileItemManager

protected FileItemManager(org.apache.lenya.ac.AccreditableManager accreditableManager)
Create a new ItemManager.

Parameters:
accreditableManager - The AccreditableManager.
Method Detail

configure

public void configure(java.io.File _configurationDirectory)
               throws org.apache.lenya.ac.AccessControlException
Configures the item manager.

Parameters:
_configurationDirectory - where the items are fetched from
Throws:
org.apache.lenya.ac.AccessControlException - if the item manager cannot be instantiated

loadItems

protected void loadItems()
                  throws org.apache.lenya.ac.AccessControlException
Reloads the items if an item was changed / added / removed.

Throws:
org.apache.lenya.ac.AccessControlException - when something went wrong.

loadItem

protected org.apache.lenya.ac.Item loadItem(java.io.File file)
                                     throws org.apache.lenya.ac.AccessControlException
Loads an item from a file.

Parameters:
file - The file.
Returns:
An item.
Throws:
org.apache.lenya.ac.AccessControlException - when something went wrong.

getItemConfiguration

protected org.apache.avalon.framework.configuration.Configuration getItemConfiguration(java.io.File file)
                                                                                throws org.apache.lenya.ac.AccessControlException
Loads teh configuration of an item from a file.

Parameters:
file - The file.
Returns:
A configuration.
Throws:
org.apache.lenya.ac.AccessControlException - when something went wrong.

removeItem

protected void removeItem(java.io.File file)

getItem

public org.apache.lenya.ac.Item getItem(java.lang.String id)
Returns an item for a given ID.

Parameters:
id - The id.
Returns:
An item.

getItems

public org.apache.lenya.ac.Item[] getItems()
get all items

Returns:
an array of items

add

public void add(org.apache.lenya.ac.Item item)
         throws org.apache.lenya.ac.AccessControlException
Add an Item to this manager

Parameters:
item - to be added
Throws:
org.apache.lenya.ac.AccessControlException - when the notification threw this exception.

remove

public void remove(org.apache.lenya.ac.Item item)
            throws org.apache.lenya.ac.AccessControlException
Remove an item from this manager

Parameters:
item - to be removed
Throws:
org.apache.lenya.ac.AccessControlException - when the notification threw this exception.

update

public void update(org.apache.lenya.ac.Item newItem)
            throws org.apache.lenya.ac.AccessControlException
Update an item.

Parameters:
newItem - The new version of the item.
Throws:
org.apache.lenya.ac.AccessControlException - when the notification threw this exception.

contains

public boolean contains(org.apache.lenya.ac.Item item)
Returns if the ItemManager contains an object.

Parameters:
item - The object.
Returns:
A boolean value.

getConfigurationDirectory

public java.io.File getConfigurationDirectory()
Get the directory where the items are located.

Returns:
a File

getFileFilter

protected java.io.FileFilter getFileFilter()
Get a file filter which filters for files containing items.

Returns:
a FileFilter

getSuffix

protected abstract java.lang.String getSuffix()
Returns the file extension to be used.

Returns:
A string.

addItemManagerListener

public void addItemManagerListener(org.apache.lenya.ac.ItemManagerListener listener)
Attaches an item manager listener to this item manager.

Specified by:
addItemManagerListener in interface org.apache.lenya.ac.ItemManager
Parameters:
listener - An item manager listener.

removeItemManagerListener

public void removeItemManagerListener(org.apache.lenya.ac.ItemManagerListener listener)
Removes an item manager listener from this item manager.

Specified by:
removeItemManagerListener in interface org.apache.lenya.ac.ItemManager
Parameters:
listener - An item manager listener.

notifyAdded

protected void notifyAdded(org.apache.lenya.ac.Item item)
                    throws org.apache.lenya.ac.AccessControlException
Notifies the listeners that an item was added.

Parameters:
item - The item that was added.
Throws:
org.apache.lenya.ac.AccessControlException - if an error occurs.

notifyRemoved

protected void notifyRemoved(org.apache.lenya.ac.Item item)
                      throws org.apache.lenya.ac.AccessControlException
Notifies the listeners that an item was removed.

Parameters:
item - The item that was removed.
Throws:
org.apache.lenya.ac.AccessControlException - if an error occurs.

getAccreditableManager

public org.apache.lenya.ac.AccreditableManager getAccreditableManager()
Specified by:
getAccreditableManager in interface org.apache.lenya.ac.ItemManager


Copyright © $ Apache Software Foundation. All Rights Reserved.