org.jboss.shotoku
Class ContentManager

java.lang.Object
  extended by org.jboss.shotoku.ContentManager

public abstract class ContentManager
extends java.lang.Object

A base class which provides access to nodes and directories.
Warning: all shotoku classes are not thread-safe.

Author:
Adam Warski (adamw@aster.pl), Damon Sicore (damon@sicore.com)

Field Summary
static java.util.Map<java.lang.String,Pair<java.lang.String,org.apache.commons.configuration.Configuration>> contentManagersImplementations
          Map (content manager id -> pair (content manager class name, content manager configuration)
 
Constructor Summary
protected ContentManager(java.lang.String id, java.lang.String prefix)
          Standard constructor.
 
Method Summary
abstract  void delete(java.util.Collection<Resource> resources)
          Deletes the given resources at one time.
 void delete(Resource... resources)
          Deletes the given resources at one time.
 void delete(Resource resource)
          Deletes the given resource.
static ContentManager getContentManager()
          Gets a content manager with a default id and an empty prefix.
static ContentManager getContentManager(java.lang.String prefix)
          Gets a content manager with a default id and the given prefix.
static ContentManager getContentManager(java.lang.String id, java.lang.String prefix)
          Gets a content manager with the given id and prefix.
static int getDefaultServiceInterval()
          Gets the default Shotoku service interval.
abstract  Directory getDirectory(java.lang.String path)
          Gets a directory which can be found under the given path (to get nodes from subdirectories, use / to separate them).
 java.lang.String getId()
          Gets the id of this repository.
abstract  Node getNode(java.lang.String path)
          Gets the most recent version of a node which can be found under the given path (to get nodes from subdirectories, use / to separate them).
 java.lang.String getPrefix()
          Gets the prefix of this content manager.
static int getProperty(java.lang.String name, int defaultValue)
          Gets a property of this content manager, as it is written in the configuration file (helper method for implementations).
static long getProperty(java.lang.String name, long defaultValue)
          Gets a property of this content manager, as it is written in the configuration file (helper method for implementations).
static java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
          Gets a property of this content manager, as it is written in the configuration file (helper method for implementations).
abstract  Directory getRootDirectory()
          Gets a root directory that is represented by this content manager.
static int getTransferBufferSize()
          Gets the transfer buffer size.
 org.apache.velocity.app.VelocityEngine getVelocityEngine()
          Gets a velocity engine, initialized with default properties, as defined in velocity.properties in the shotoku-base jar.
 org.apache.velocity.app.VelocityEngine getVelocityEngine(boolean addIdPrefix)
          Gets a velocity engine, initialized with default properties, as defined in velocity.properties in the shotoku-base jar.
 org.apache.velocity.app.VelocityEngine getVelocityEngine(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> overProps, boolean addIdPrefix)
          Gets a velocity engine, initialized with default properties, overwritten by the given propeties.
static void initializeContentManager(java.lang.String implementation)
           
static boolean isEmbedded()
          Checks if Shotoku is configured to run in embedded mode or not.
abstract  void save(java.lang.String logMessage, java.util.Collection<Resource> resources)
          Saves the given resources at one time.
 void save(java.lang.String logMessage, Resource... resources)
          Saves the given resources at one time.
 void save(java.lang.String logMessage, Resource res)
          Saves the given resource.
 void save(java.lang.String logMessage, Resource res1, Resource res2)
          Saves the given resources at one time.
 void save(java.lang.String logMessage, Resource res1, Resource res2, Resource res3)
          Saves the given resources at one time.
 void save(java.lang.String logMessage, Resource res1, Resource res2, Resource res3, Resource res4)
          Saves the given resources at one time.
 void save(java.lang.String logMessage, Resource res1, Resource res2, Resource res3, Resource res4, Resource res5)
          Saves the given resources at one time.
 NodeList search(Search search)
          Performs the given search in this content manager.
static void setup()
          Setups the content managers before first used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contentManagersImplementations

public static java.util.Map<java.lang.String,Pair<java.lang.String,org.apache.commons.configuration.Configuration>> contentManagersImplementations
Map (content manager id -> pair (content manager class name, content manager configuration)

Constructor Detail

ContentManager

protected ContentManager(java.lang.String id,
                         java.lang.String prefix)
                  throws RepositoryException
Standard constructor.

Parameters:
id - Id of this content manager.
prefix - Prefix of this content manager, as stated in properties.
Throws:
RepositoryException
Method Detail

getRootDirectory

public abstract Directory getRootDirectory()
                                    throws RepositoryException
Gets a root directory that is represented by this content manager.

Returns:
A directory that is the root directory of this content manager.
Throws:
RepositoryException

getNode

public abstract Node getNode(java.lang.String path)
                      throws ResourceDoesNotExist,
                             RepositoryException
Gets the most recent version of a node which can be found under the given path (to get nodes from subdirectories, use / to separate them).

Parameters:
path - Path for which to get the node.
Returns:
A node corresponding to the given path.
Throws:
ResourceDoesNotExist
RepositoryException

getDirectory

public abstract Directory getDirectory(java.lang.String path)
                                throws ResourceDoesNotExist,
                                       RepositoryException
Gets a directory which can be found under the given path (to get nodes from subdirectories, use / to separate them).

Parameters:
path - Path for which to get the directory.
Returns:
A directory corresponding to the given path.
Throws:
ResourceDoesNotExist
RepositoryException

search

public NodeList search(Search search)
                throws ResourceDoesNotExist
Performs the given search in this content manager.

Parameters:
search - Search to perform.
Returns:
A node list that is the result of the search.
Throws:
ResourceDoesNotExist

getId

public java.lang.String getId()
Gets the id of this repository.

Returns:
Id of this repository.

getPrefix

public java.lang.String getPrefix()
Gets the prefix of this content manager.

Returns:
Prefix of this content manager.

save

public abstract void save(java.lang.String logMessage,
                          java.util.Collection<Resource> resources)
                   throws SaveException,
                          RepositoryException
Saves the given resources at one time. Recommended if you have multiple resources to save.

Parameters:
logMessage - Log message to save with.
resources - Resources to save.
Throws:
SaveException
RepositoryException

delete

public abstract void delete(java.util.Collection<Resource> resources)
                     throws DeleteException,
                            RepositoryException
Deletes the given resources at one time. Recommended if you have multiple resources to delete.

Parameters:
resources - Resources to delete.
Throws:
DeleteException
RepositoryException

delete

public void delete(Resource resource)
            throws DeleteException,
                   RepositoryException
Deletes the given resource. Equivalent to resource.delete().

Parameters:
resource - Resources to delete.
Throws:
DeleteException
RepositoryException

save

public void save(java.lang.String logMessage,
                 Resource res)
          throws SaveException,
                 RepositoryException
Saves the given resource. Equivalent to res.save(String).

Parameters:
res - First resource to save.
logMessage - Log message to save with.
Throws:
SaveException
RepositoryException

save

public void save(java.lang.String logMessage,
                 Resource... resources)
          throws RepositoryException,
                 SaveException
Saves the given resources at one time. Recommended if you have multiple resources to save.

Parameters:
logMessage - Log message to save with.
resources - Any number of resources
Throws:
RepositoryException
SaveException

delete

public void delete(Resource... resources)
            throws DeleteException,
                   RepositoryException
Deletes the given resources at one time. Recommended if you have multiple resources to delete.

Parameters:
resources - Any number of resources to delete
Throws:
DeleteException
RepositoryException

save

public void save(java.lang.String logMessage,
                 Resource res1,
                 Resource res2)
          throws SaveException,
                 RepositoryException
Saves the given resources at one time. Equivalent to save(Collection, String), where the collection is filled with the two given resources.

Parameters:
logMessage - Log message to save with.
res1 - First resource to save.
res2 - Second resource to save.
Throws:
SaveException
RepositoryException

save

public void save(java.lang.String logMessage,
                 Resource res1,
                 Resource res2,
                 Resource res3)
          throws SaveException,
                 RepositoryException
Saves the given resources at one time. Equivalent to save(Collection, String), where the collection is filled with the three given resources.

Parameters:
logMessage - Log message to save with.
res1 - First resource to save.
res2 - Second resource to save.
res3 - Third resource to save.
Throws:
SaveException
RepositoryException

save

public void save(java.lang.String logMessage,
                 Resource res1,
                 Resource res2,
                 Resource res3,
                 Resource res4)
          throws SaveException,
                 RepositoryException
Saves the given resources at one time. Equivalent to save(Collection, String), where the collection is filled with the four given resources.

Parameters:
logMessage - Log message to save with.
res1 - First resource to save.
res2 - Second resource to save.
res3 - Third resource to save.
res4 - Fourth resource to save.
Throws:
SaveException
RepositoryException

save

public void save(java.lang.String logMessage,
                 Resource res1,
                 Resource res2,
                 Resource res3,
                 Resource res4,
                 Resource res5)
          throws SaveException,
                 RepositoryException
Saves the given resources at one time. Equivalent to save(Collection, String), where the collection is filled with the five given resources.

Parameters:
logMessage - Log message to save with.
res1 - First resource to save.
res2 - Second resource to save.
res3 - Third resource to save.
res4 - Fourth resource to save.
res5 - Fifth resource to save.
Throws:
SaveException
RepositoryException

getVelocityEngine

public org.apache.velocity.app.VelocityEngine getVelocityEngine()
                                                         throws java.lang.Exception
Gets a velocity engine, initialized with default properties, as defined in velocity.properties in the shotoku-base jar. Additionaly, the shotoku resource loader will be set to read templates from this content manager (if shotoku resource loader is defined to be used).

Returns:
A velocity engine initialized with default properties.
Throws:
java.lang.Exception - In case of a velocity exception/ properties reading exception.

getVelocityEngine

public org.apache.velocity.app.VelocityEngine getVelocityEngine(boolean addIdPrefix)
                                                         throws java.lang.Exception
Gets a velocity engine, initialized with default properties, as defined in velocity.properties in the shotoku-base jar.

Parameters:
addIdPrefix - True iff id/ prefix properties should be added to the properties.
Returns:
A velocity engine initialized with default properties.
Throws:
java.lang.Exception - In case of a velocity exception/ properties reading exception.

getVelocityEngine

public org.apache.velocity.app.VelocityEngine getVelocityEngine(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> overProps,
                                                                boolean addIdPrefix)
                                                         throws java.lang.Exception
Gets a velocity engine, initialized with default properties, overwritten by the given propeties.

Parameters:
overProps - Properties which will be added to velocity configuration.
Returns:
An initialized velocity engine.
Throws:
java.lang.Exception - In case of a velocity exception/ properties reading exception.

isEmbedded

public static boolean isEmbedded()
Checks if Shotoku is configured to run in embedded mode or not.

Returns:
True iff Shotoku is configured to run in embedded mode.

setup

public static void setup()
Setups the content managers before first used. In embedded mode, should be always called once, before any usage of Shotoku classes. In app server mode, should be never called by the user.


initializeContentManager

public static void initializeContentManager(java.lang.String implementation)

getContentManager

public static ContentManager getContentManager()
Gets a content manager with a default id and an empty prefix.

Returns:
A ""-prefixed, default content manager, or null, if a default content manager is not registered.

getContentManager

public static ContentManager getContentManager(java.lang.String prefix)
Gets a content manager with a default id and the given prefix.

Parameters:
prefix - Prefix for the new content manager (all paths will have this prepended).
Returns:
A prefixed, default content manager, or null, if a default content manager is not registered.

getContentManager

public static ContentManager getContentManager(java.lang.String id,
                                               java.lang.String prefix)
Gets a content manager with the given id and prefix.

Parameters:
id - Id of the content manager.
prefix - Prefix for the new content manager (all paths will have this prepended).
Returns:
A prefixed content manager with the given id or null, if a content manager with the given id registers.

getProperty

public static long getProperty(java.lang.String name,
                               long defaultValue)
Gets a property of this content manager, as it is written in the configuration file (helper method for implementations). Only internal properties! (long parameter value).

Parameters:
name - Name of the property to get.
defaultValue - Value to return in case the given property is not set.
Returns:
Value of the given property or null, if no such property exists.

getProperty

public static int getProperty(java.lang.String name,
                              int defaultValue)
Gets a property of this content manager, as it is written in the configuration file (helper method for implementations). Only internal properties! (int parameter value).

Parameters:
name - Name of the property to get.
defaultValue - Value to return in case the given property is not set.
Returns:
Value of the given property or null, if no such property exists.

getProperty

public static java.lang.String getProperty(java.lang.String name,
                                           java.lang.String defaultValue)
Gets a property of this content manager, as it is written in the configuration file (helper method for implementations). Only internal properties!

Parameters:
name - Name of the property to get.
defaultValue - Value to return in case the given property is not set.
Returns:
Value of the given property or null, if no such property exists.

getTransferBufferSize

public static int getTransferBufferSize()
Gets the transfer buffer size.

Returns:
Transfer buffer size.

getDefaultServiceInterval

public static int getDefaultServiceInterval()
Gets the default Shotoku service interval.

Returns:
Default Shotoku service interval.


Copyright © -2006 . All Rights Reserved.