org.infoglue.cms.applications.workflowtool.util
Class InfoglueWorkflowBase

java.lang.Object
  extended by org.infoglue.cms.applications.workflowtool.util.InfoglueWorkflowBase
Direct Known Subclasses:
InfoglueCondition, InfoglueFunction

public abstract class InfoglueWorkflowBase
extends java.lang.Object

Base class containing logic used by both InfoglueFunction and InfoglueCondition. The main purpose of this class is to provide convenience methods for the parameters, arguments, and propertyset objects and to handle the DatabaseSession object.


Field Summary
static java.lang.String ERROR_PROPERTYSET_PREFIX
          The prefix for all keys representing errors in the propertyset.
static java.lang.String FUNCTION_STATUS_PROPERTYSET_KEY
          The key used for storing the function status in the propertyset.
protected static java.lang.String UTF8_ENCODING
          The default encoding.
static java.lang.String WORKFLOW_PROPERTYSET_PREFIX
          The prefix for all keys representing workflow specific information in the propertyset.
 
Constructor Summary
InfoglueWorkflowBase()
          Default constructor.
 
Method Summary
protected  boolean argumentExists(java.lang.String name)
          Returns true if the specified argument exists; false otherwise.
protected  java.lang.String getArgument(java.lang.String name)
          Returns the specified argument if it exists; otherwise an exception is thrown.
protected  java.lang.String getArgument(java.lang.String name, java.lang.String defaultValue)
          Returns the specified argument if it exists; otherwise the default value.
protected  org.exolab.castor.jdo.Database getDatabase()
          Returns the database associated with the current execution.
protected  org.apache.log4j.Logger getLogger()
          Returns the class logger.
protected  java.lang.Object getParameter(java.lang.String key)
          Returns the specified parameter if it exists; otherwise an exception is thrown.
protected  java.lang.Object getParameter(java.lang.String key, boolean required)
          Returns the specified parameter.
protected  java.lang.Object getParameter(java.lang.String key, java.lang.Object defaultValue)
          Returns the specified parameter if it exists; otherwise the default value.
protected  java.util.Map getParameters()
          Returns the parameters (transient variables) of the current execution context.
protected  InfogluePropertySet getPropertySet()
          Returns the propertyset associated with the current workflow.
protected  java.lang.String getPropertySetDataString(java.lang.String key)
          Returns the specified data property as a string.
protected  java.lang.String getPropertySetString(java.lang.String key)
          Returns the specified string property.
static java.lang.Object getVariableFromMaps(java.lang.String var, java.util.Map transientVars, com.opensymphony.module.propertyset.PropertySet ps)
           
protected  void initialize()
          Method used for initializing the object; will be called before any execution is performed.
protected  boolean parameterExists(java.lang.String key)
          Returns true if the specified parameter exists; false otherwise.
protected  boolean propertySetContains(java.lang.String key)
          Returns true if the specified property exists; false otherwise.
protected  void removeFromPropertySet(java.lang.String key)
          Removes the property with the specified key from the propertyset.
protected  void removeFromPropertySet(java.lang.String key, boolean isPrefix)
          Removes the property with the specified key from the propertyset.
protected  void setParameter(java.lang.String key, java.lang.Object value)
          Stores the specified parameter.
protected  void setPropertySetDataString(java.lang.String key, java.lang.String value)
          Stores the specified data property.
protected  void setPropertySetString(java.lang.String key, java.lang.String value)
          Stores the specified string property.
protected  void storeContext(java.util.Map transientVars, java.util.Map args, com.opensymphony.module.propertyset.PropertySet ps)
          Stores the execution context.
protected  void throwException(java.lang.Exception e)
          The preferred way to throw an exception from a subclass.
protected  void throwException(java.lang.String message)
          The preferred way to throw an exception from a subclass.
protected  java.lang.String translate(java.lang.String s)
           
static java.lang.Object translateVariables(java.lang.String s, java.util.Map transientVars, com.opensymphony.module.propertyset.PropertySet ps)
          Parses a string for instances of "${foo}" and returns a string with all instances replaced with the string value of the foo object (foo.toString()).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF8_ENCODING

protected static final java.lang.String UTF8_ENCODING
The default encoding.

See Also:
Constant Field Values

WORKFLOW_PROPERTYSET_PREFIX

public static final java.lang.String WORKFLOW_PROPERTYSET_PREFIX
The prefix for all keys representing workflow specific information in the propertyset.

See Also:
Constant Field Values

FUNCTION_STATUS_PROPERTYSET_KEY

public static final java.lang.String FUNCTION_STATUS_PROPERTYSET_KEY
The key used for storing the function status in the propertyset.

See Also:
Constant Field Values

ERROR_PROPERTYSET_PREFIX

public static final java.lang.String ERROR_PROPERTYSET_PREFIX
The prefix for all keys representing errors in the propertyset.

See Also:
Constant Field Values
Constructor Detail

InfoglueWorkflowBase

public InfoglueWorkflowBase()
Default constructor.

Method Detail

initialize

protected void initialize()
                   throws com.opensymphony.workflow.WorkflowException
Method used for initializing the object; will be called before any execution is performed.

Note! You must call super.initialize() first.

Throws:
com.opensymphony.workflow.WorkflowException - if an error occurs during the initialization.

storeContext

protected void storeContext(java.util.Map transientVars,
                            java.util.Map args,
                            com.opensymphony.module.propertyset.PropertySet ps)
Stores the execution context.

Parameters:
transientVars - the transient variables of the current execution context.
args - the arguments of the function.
ps - the propertyset associated with the current workflow.

throwException

protected void throwException(java.lang.String message)
                       throws com.opensymphony.workflow.WorkflowException
The preferred way to throw an exception from a subclass. Logs the error, sets the mode of the database to rollback only and throws an exception.

Parameters:
message - the exception message.
Throws:
com.opensymphony.workflow.WorkflowException - always throws an exception with the specified message.

throwException

protected void throwException(java.lang.Exception e)
                       throws com.opensymphony.workflow.WorkflowException
The preferred way to throw an exception from a subclass. Logs the error, sets the mode of the database to rollback only and throws an exception.

Parameters:
e - the exception to chain.
Throws:
com.opensymphony.workflow.WorkflowException - always throws an exception. If the specified exception is a workflow exception, that exception is thrown. Otherwise a chained workflow exception is thrown.

argumentExists

protected final boolean argumentExists(java.lang.String name)
Returns true if the specified argument exists; false otherwise.

Parameters:
name - the name of the argument.
Returns:
true if the specified argument exists; false otherwise.

getArgument

protected final java.lang.String getArgument(java.lang.String name)
                                      throws com.opensymphony.workflow.WorkflowException
Returns the specified argument if it exists; otherwise an exception is thrown. Only use this method if the argument is absolutely required.

Parameters:
name - the name of the argument.
Returns:
the specified argument.
Throws:
com.opensymphony.workflow.WorkflowException - if the specified argument doesn't exists.

getArgument

protected final java.lang.String getArgument(java.lang.String name,
                                             java.lang.String defaultValue)
                                      throws com.opensymphony.workflow.WorkflowException
Returns the specified argument if it exists; otherwise the default value.

Parameters:
name - the name of the argument.
defaultValue - the default value.
Returns:
the specified argument if it exists; otherwise the default value.
Throws:
com.opensymphony.workflow.WorkflowException

parameterExists

protected final boolean parameterExists(java.lang.String key)
Returns true if the specified parameter exists; false otherwise.

Parameters:
name - the name of the parameter.
Returns:
true if the specified parameter exists; false otherwise.

getParameter

protected final java.lang.Object getParameter(java.lang.String key)
                                       throws com.opensymphony.workflow.WorkflowException
Returns the specified parameter if it exists; otherwise an exception is thrown. Only use this method if the parameter is absolutely required.

Parameters:
name - the name of the parameter.
Returns:
the specified parameter.
Throws:
com.opensymphony.workflow.WorkflowException - if the specified parameter doesn't exists.

getParameter

protected final java.lang.Object getParameter(java.lang.String key,
                                              java.lang.Object defaultValue)
                                       throws com.opensymphony.workflow.WorkflowException
Returns the specified parameter if it exists; otherwise the default value.

Parameters:
name - the name of the parameter.
defaultValue - the default value.
Returns:
the specified parameter if it exists; otherwise the default value.
Throws:
com.opensymphony.workflow.WorkflowException

getParameter

protected final java.lang.Object getParameter(java.lang.String key,
                                              boolean required)
                                       throws com.opensymphony.workflow.WorkflowException
Returns the specified parameter. If the parameter is required and not found, an exception is thrown.

Parameters:
key - the key.
required - indicates if the parameter is required.
Returns:
the specified parameter.
Throws:
com.opensymphony.workflow.WorkflowException - if a required parameter is missing.

setParameter

protected final void setParameter(java.lang.String key,
                                  java.lang.Object value)
Stores the specified parameter.

Parameters:
key - the lookup key.
value - the value.

getParameters

protected final java.util.Map getParameters()
Returns the parameters (transient variables) of the current execution context.

Returns:
the parameters (transient variables) of the current execution context.

propertySetContains

protected final boolean propertySetContains(java.lang.String key)
Returns true if the specified property exists; false otherwise.

Returns:
true if the specified property exists; false otherwise.

getPropertySetDataString

protected final java.lang.String getPropertySetDataString(java.lang.String key)
Returns the specified data property as a string.

Parameters:
key - the key.

setPropertySetDataString

protected final void setPropertySetDataString(java.lang.String key,
                                              java.lang.String value)
Stores the specified data property.

Parameters:
key - the key.
value - the value.

getPropertySetString

protected final java.lang.String getPropertySetString(java.lang.String key)
Returns the specified string property.

Parameters:
key - the key.

setPropertySetString

protected final void setPropertySetString(java.lang.String key,
                                          java.lang.String value)
Stores the specified string property.

Parameters:
key - the key.
value - the value.

removeFromPropertySet

protected final void removeFromPropertySet(java.lang.String key)
Removes the property with the specified key from the propertyset.

Parameters:
key - the property key.

removeFromPropertySet

protected final void removeFromPropertySet(java.lang.String key,
                                           boolean isPrefix)
Removes the property with the specified key from the propertyset. If key is a prefix, all properties having keys starting with the specified key will be removed.

Parameters:
key - the property key.
isPrefix - indicates if the key should be used as key prefix.

translate

protected final java.lang.String translate(java.lang.String s)

getPropertySet

protected final InfogluePropertySet getPropertySet()
Returns the propertyset associated with the current workflow.

Returns:
the propertyset associated with the current workflow.

getLogger

protected final org.apache.log4j.Logger getLogger()
Returns the class logger.

Returns:
the class logger.

getDatabase

protected final org.exolab.castor.jdo.Database getDatabase()
                                                    throws com.opensymphony.workflow.WorkflowException
Returns the database associated with the current execution.

Returns:
the database associated with the current execution.
Throws:
com.opensymphony.workflow.WorkflowException - if an error occurs when opening/starting the database/transaction.

translateVariables

public static java.lang.Object translateVariables(java.lang.String s,
                                                  java.util.Map transientVars,
                                                  com.opensymphony.module.propertyset.PropertySet ps)
Parses a string for instances of "${foo}" and returns a string with all instances replaced with the string value of the foo object (foo.toString()). If the string being passed in only refers to a single variable and contains no other characters (for example: ${foo}), then the actual object is returned instead of converting it to a string.


getVariableFromMaps

public static java.lang.Object getVariableFromMaps(java.lang.String var,
                                                   java.util.Map transientVars,
                                                   com.opensymphony.module.propertyset.PropertySet ps)


Copyright © 2005 InfoGlue.org All Rights Reserved.