| java.lang.Object org.sakaiproject.util.BaseXmlFileStorage
BaseXmlFileStorage | public class BaseXmlFileStorage (Code) | |
BaseXmlFileStorage is a class that stores Resources (of some type) in an XML file
backed memory store, provides locked access, and generally implements a service's
"storage" class. The service's storage class can extend this to provide covers to
turn Resource and Edit into something more type specific to the service.
|
Inner Class :protected class Container | |
Method Summary | |
public void | cancelContainer(Edit edit) Cancel the changes and release the locked container. | public void | cancelResource(String container, Edit edit) Cancel the changes and release the lock. | protected String | caseId(String id) Fix the case of resource ids to support case insensitive ids if enabled
Parameters: The - id to fix. | public boolean | checkContainer(String ref) Check if a container by this id exists.
Parameters: ref - The container reference. | public boolean | checkResource(String container, String id) Check if a resource by this id exists.
Parameters: container - The container id. Parameters: id - The id. | public void | close() Close. | public void | commitContainer(Edit edit) Commit the changes and release the locked container. | public void | commitResource(String container, Edit edit) Commit the changes and release the lock. | public int | countAllResources(String container) Count all entries.
Parameters: container - The container id. | protected Document | createDocument() | public Edit | editContainer(String ref) Return a lock on the container with this id, or null if a lock cannot be made.
Parameters: ref - The container reference. | public Edit | editResource(String container, String id) Return a lock on the entry with this id, or null if a lock cannot be made.
Parameters: container - The container id. Parameters: id - The id. | protected void | finalize() Clean up. | protected void | flush() | public List | getAllContainers() Get a list of all containers. | public List | getAllResources(String container) Get all entries.
Parameters: container - The container id. | public List | getAllResources(String container, int first, int last) Get all entries within a range sorted by id.
Parameters: container - The container id. Parameters: first - The first position. Parameters: last - The last position. | public Entity | getContainer(String ref) Get the container with this id, or null if not found.
Parameters: ref - The container reference. | public List | getContainerIdsMatching(String context) Access a list of container ids that match (start with) the root.
Parameters: context - The reference root to match. | public Entity | getResource(String container, String id) Get the entry with this id, or null if not found.
Parameters: container - The container id. Parameters: id - The id. | public List | getResources(String container, Time afterDate, int limitedToLatest, String draftsForId, boolean pubViewOnly) Get resources filtered by date and count and drafts, in descending (latest first) order
Parameters: container - The container id. Parameters: afterDate - if null, no date limit, else limited to only messages after this date. Parameters: limitedToLatest - if 0, no count limit, else limited to only the latest this number of messages. Parameters: draftsForId - how to handle drafts: null means no drafts, "*" means all, otherwise drafts only if created by this userId. Parameters: pubViewOnly - if true, include only messages marked pubview, else include any. | public boolean | isEmpty(String container) | protected Document | load() | public void | open() Open and be ready to read / write. | public Edit | putContainer(String ref) Add a new container with this id.
Parameters: ref - The channel reference. | public Edit | putResource(String container, String id, Object[] others) Add a new entry with this id. | public void | removeContainer(Edit edit) Remove this container and all it contains. | public void | removeResource(String container, Edit edit) Remove this entry. | protected void | setCaseInsensitivity(boolean setting) Enable / disable case insensitive ids. |
m_caseInsensitive | protected boolean m_caseInsensitive(Code) | | If set, we treat reasource ids as case insensitive.
|
m_containerTagName | protected String m_containerTagName(Code) | | The xml tag name for the element holding each container entry.
|
m_entryTagName | protected String m_entryTagName(Code) | | The xml tag name for the element holding each actual entry.
|
m_fileStoragePath | protected String m_fileStoragePath(Code) | | A full path and file name to the storage file.
|
m_locks | protected Hashtable m_locks(Code) | | Store all locks (across all containers), keyed by entry Resource reference.
|
m_rootTagName | protected String m_rootTagName(Code) | | The xml tag name for the root element holding the multiple entries.
|
m_store | protected Hashtable m_store(Code) | | Two level store: Hashtables keyed by container ref of Container.
|
m_user | protected StorageUser m_user(Code) | | The StorageUser to callback for new Resource and Edit objects.
|
BaseXmlFileStorage | public BaseXmlFileStorage(String path, String root, String container, String entry, StorageUser user)(Code) | | Construct.
Parameters: path - The storage path. Parameters: root - The xml tag name for the root element holding the multiple entries. Parameters: container - The xml tag name for the element holding each container entry (may be null if there's no container structure and all entries are in the root). Parameters: entry - The xml tag name for the element holding each actual entry. Parameters: user - The StorageUser class to call back for creation of Resource and Edit objects. |
cancelContainer | public void cancelContainer(Edit edit)(Code) | | Cancel the changes and release the locked container.
Parameters: container - The container id. Parameters: edit - The entry to cancel. |
cancelResource | public void cancelResource(String container, Edit edit)(Code) | | Cancel the changes and release the lock.
Parameters: container - The container id. Parameters: edit - The entry to cancel. |
caseId | protected String caseId(String id)(Code) | | Fix the case of resource ids to support case insensitive ids if enabled
Parameters: The - id to fix. The id, case modified as needed. |
checkContainer | public boolean checkContainer(String ref)(Code) | | Check if a container by this id exists.
Parameters: ref - The container reference. true if a resource by this id exists, false if not. |
checkResource | public boolean checkResource(String container, String id)(Code) | | Check if a resource by this id exists.
Parameters: container - The container id. Parameters: id - The id. true if a resource by this id exists, false if not. |
close | public void close()(Code) | | Close.
|
commitContainer | public void commitContainer(Edit edit)(Code) | | Commit the changes and release the locked container.
Parameters: container - The container id. Parameters: edit - The entry to commit. |
commitResource | public void commitResource(String container, Edit edit)(Code) | | Commit the changes and release the lock.
Parameters: container - The container id. Parameters: edit - The entry to commit. |
countAllResources | public int countAllResources(String container)(Code) | | Count all entries.
Parameters: container - The container id. The count of all entries. |
createDocument | protected Document createDocument()(Code) | | Create and return the XML Document for our storaghe
|
editContainer | public Edit editContainer(String ref)(Code) | | Return a lock on the container with this id, or null if a lock cannot be made.
Parameters: ref - The container reference. The locked object with this id, or null if a lock cannot be made. |
editResource | public Edit editResource(String container, String id)(Code) | | Return a lock on the entry with this id, or null if a lock cannot be made.
Parameters: container - The container id. Parameters: id - The id. The locked object with this id, or null if a lock cannot be made. |
finalize | protected void finalize()(Code) | | Clean up.
|
flush | protected void flush()(Code) | | flush
|
getAllContainers | public List getAllContainers()(Code) | | Get a list of all containers.
A list (Resource) of all containers, or empty if none defined. |
getAllResources | public List getAllResources(String container)(Code) | | Get all entries.
Parameters: container - The container id. The list (Resource) of all entries. |
getAllResources | public List getAllResources(String container, int first, int last)(Code) | | Get all entries within a range sorted by id.
Parameters: container - The container id. Parameters: first - The first position. Parameters: last - The last position. The list (Resource) of all entries within a range sorted by id. |
getContainer | public Entity getContainer(String ref)(Code) | | Get the container with this id, or null if not found.
Parameters: ref - The container reference. The container with this id, or null if not found. |
getContainerIdsMatching | public List getContainerIdsMatching(String context)(Code) | | Access a list of container ids that match (start with) the root.
Parameters: context - The reference root to match. A List (String) of container id which match the root. |
getResource | public Entity getResource(String container, String id)(Code) | | Get the entry with this id, or null if not found.
Parameters: container - The container id. Parameters: id - The id. The entry with this id, or null if not found. |
getResources | public List getResources(String container, Time afterDate, int limitedToLatest, String draftsForId, boolean pubViewOnly)(Code) | | Get resources filtered by date and count and drafts, in descending (latest first) order
Parameters: container - The container id. Parameters: afterDate - if null, no date limit, else limited to only messages after this date. Parameters: limitedToLatest - if 0, no count limit, else limited to only the latest this number of messages. Parameters: draftsForId - how to handle drafts: null means no drafts, "*" means all, otherwise drafts only if created by this userId. Parameters: pubViewOnly - if true, include only messages marked pubview, else include any. A list of Message objects that meet the criteria; may be empty |
isEmpty | public boolean isEmpty(String container)(Code) | | Determine if empty
true if empty, false if not. |
open | public void open()(Code) | | Open and be ready to read / write.
|
putContainer | public Edit putContainer(String ref)(Code) | | Add a new container with this id.
Parameters: ref - The channel reference. The locked object with this id, or null if the id is in use. |
putResource | public Edit putResource(String container, String id, Object[] others)(Code) | | Add a new entry with this id.
Parameters: container - The container id. Parameters: id - The id. Parameters: others - Other fields for the newResource call The locked object with this id, or null if the id is in use. |
removeContainer | public void removeContainer(Edit edit)(Code) | | Remove this container and all it contains.
Parameters: container - The container id. Parameters: edit - The entry to remove. |
removeResource | public void removeResource(String container, Edit edit)(Code) | | Remove this entry.
Parameters: container - The container id. Parameters: edit - The entry to remove. |
setCaseInsensitivity | protected void setCaseInsensitivity(boolean setting)(Code) | | Enable / disable case insensitive ids.
Parameters: setting - true to set case insensitivity, false to set case sensitivity. |
|
|