things.thinger.service.httptool
Class ActionIzer

java.lang.Object
  extended by things.thinger.service.httptool.Action
      extended by things.thinger.service.httptool.ActionIzer

public abstract class ActionIzer
extends Action

ActionIzer helper wrapper for Actions.

Version:
1.0

Version History

EPG - Initial - 2 NOV 08
 EPG - Make Save and Load files man-readable. - 11 Oct 09
 
Author:
Erich P. Gatejen

Field Summary
static java.lang.String CHECKED_VALUE
           
static java.lang.String COMMENT_LINE
           
static char NAME_VALUE_SNAP
           
static java.lang.String PROP_LINE_END
           
static java.lang.String PROP_LINE_START
           
static java.lang.String VERSION_NOTE
           
 
Fields inherited from class things.thinger.service.httptool.Action
parameters, si, tags
 
Constructor Summary
ActionIzer()
          Constructor.
 
Method Summary
abstract  void declarations()
          Give the sub class a chance to make declarations.
protected  void DECLARE_BOOLEAN(java.lang.String name, boolean defaultValue, boolean required, java.lang.String trueValue, java.lang.String falseValue, java.lang.String trueTag, java.lang.String falseTag, java.lang.String propertyName)
          Declare a checked boolean parameter.
protected  void DECLARE_PROPS(java.lang.String name, boolean defaultValue, boolean required, java.lang.String tag)
          Declare a property parameter.
 ActionIzerItem DECLARE_TYPED(java.lang.String name, java.lang.String defaultValue, boolean required, ActionIzerItem.Type type, java.lang.String tag, java.lang.String propertyName)
          Declare by type.
protected  void DECLARE(java.lang.String name, java.lang.String defaultValue, boolean required, java.lang.String tag, java.lang.String propertyName)
          Declare a string parameter.
protected abstract  ActionResult defaultAction()
          Get the default action.
protected abstract  ActionResult doAction(java.lang.String action, ThingsPropertyView localProperties, java.util.HashMap<java.lang.String,ActionIzerItemValue> values, ThingsExceptionBundle<ThingsException> exceptions)
          Do the action.
 Head head(ThingsPropertyView parameters, ThingsPropertyView tags, SystemInterface si)
          Overload this if you want to manage HEAD processing on your own.
protected abstract  void manageErrors(ThingsExceptionBundle<ThingsException> exceptions, ActionResult result)
          Manage errors.
protected  ActionResult process()
          The implementation.
protected abstract  void processUndeclaredParameters(ThingsPropertyView actualParameters, ThingsPropertyView localProperties, ThingsPropertyView saveParameter, ThingsExceptionBundle<ThingsException> exceptions)
          Allow the subclass to process undeclared parameters.
protected abstract  ActionResult renderLoad(ThingsExceptionBundle<ThingsException> exceptions)
          Render any message for a load.
protected abstract  ActionResult renderSave(ThingsExceptionBundle<ThingsException> exceptions)
          Render any message for a save.
protected abstract  void renderUndeclared()
          Allow the subclass render undeclared.
protected abstract  void renderUndeclaredDefault()
          Allow the subclass render undeclared default values.
 void SET_ACTION_LOAD(java.lang.String actionValue, java.lang.String universe, java.lang.String pathParam, java.lang.String tag)
          Set the action parameter value to indicate a save as well as the name of the parameter that holds the path for the save.
 void SET_ACTION_PARAM(java.lang.String action, boolean errorOnUnknown, java.lang.String... actions)
          Set the action parameter.
 void SET_ACTION_SAVE(java.lang.String actionValue, java.lang.String universe, java.lang.String pathParam, java.lang.String tag)
          Set the action parameter value to indicate a save as well as the name of the parameter that holds the path for the save.
 
Methods inherited from class things.thinger.service.httptool.Action
ERROR, execute, PUNT
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHECKED_VALUE

public static final java.lang.String CHECKED_VALUE
See Also:
Constant Field Values

VERSION_NOTE

public static final java.lang.String VERSION_NOTE
See Also:
Constant Field Values

COMMENT_LINE

public static final java.lang.String COMMENT_LINE
See Also:
Constant Field Values

PROP_LINE_START

public static final java.lang.String PROP_LINE_START
See Also:
Constant Field Values

PROP_LINE_END

public static final java.lang.String PROP_LINE_END
See Also:
Constant Field Values

NAME_VALUE_SNAP

public static final char NAME_VALUE_SNAP
See Also:
Constant Field Values
Constructor Detail

ActionIzer

public ActionIzer()
           throws java.lang.Throwable
Constructor.

Throws:
java.lang.Throwable - if the declarations failed.
Method Detail

declarations

public abstract void declarations()
                           throws java.lang.Throwable
Give the sub class a chance to make declarations. Never call this directly. It'll be called once when the class is loaded.

Throws:
java.lang.Throwable

processUndeclaredParameters

protected abstract void processUndeclaredParameters(ThingsPropertyView actualParameters,
                                                    ThingsPropertyView localProperties,
                                                    ThingsPropertyView saveParameter,
                                                    ThingsExceptionBundle<ThingsException> exceptions)
                                             throws java.lang.Throwable
Allow the subclass to process undeclared parameters.

Parameters:
actualParameters - Use this instead of the superclass 'parameter's so that load functionality will work.
localProperties - local properties.
saveParameters - all parameters that may be saved should be set here. Remember, these are PARAMETERS, as found in actualParameters, not Properties, as found in localProperties.
exceptions - Add non-fatal exceptions here, things you'd rather have rendered within the page rather than given to the platform.
Throws:
java.lang.Throwable - an fatal exceptions. It'll let the platform give the error screen,

renderUndeclared

protected abstract void renderUndeclared()
                                  throws java.lang.Throwable
Allow the subclass render undeclared.

Throws:
java.lang.Throwable - any exception (exception interruptions) will be trapped in the bundle for later examination. Exceptions that aren't ThingsException will be promoted to a FAULT.

renderUndeclaredDefault

protected abstract void renderUndeclaredDefault()
                                         throws java.lang.Throwable
Allow the subclass render undeclared default values.

Throws:
java.lang.Throwable - any exception (exception interruptions) will be trapped in the bundle for later examination. Exceptions that aren't ThingsException will be promoted to a FAULT.

renderSave

protected abstract ActionResult renderSave(ThingsExceptionBundle<ThingsException> exceptions)
Render any message for a save. Keep all errors and exceptions and render them if you want.

Parameters:
exceptions - problems that may have happened during automated processing.
Returns:
the action result

renderLoad

protected abstract ActionResult renderLoad(ThingsExceptionBundle<ThingsException> exceptions)
Render any message for a load. Keep all errors and exceptions and render them if you want.

Parameters:
exceptions - problems that may have happened during automated processing.
Returns:
the action result

doAction

protected abstract ActionResult doAction(java.lang.String action,
                                         ThingsPropertyView localProperties,
                                         java.util.HashMap<java.lang.String,ActionIzerItemValue> values,
                                         ThingsExceptionBundle<ThingsException> exceptions)
                                  throws java.lang.Throwable
Do the action.

Parameters:
action - The action parameter's value. Null if it wasn't set or found in the post.
localProperties - local properties derived from the items.
values - the values of the declared items.
exceptions - problems that may have happened during automated processing.
Returns:
the action result.
Throws:
java.lang.Throwable - these exceptions will not be trapped.

defaultAction

protected abstract ActionResult defaultAction()
                                       throws java.lang.Throwable
Get the default action.

Returns:
the default action result.
Throws:
java.lang.Throwable - any exception (exception interruptions) will be trapped in the bundle for later examination.

manageErrors

protected abstract void manageErrors(ThingsExceptionBundle<ThingsException> exceptions,
                                     ActionResult result)
                              throws java.lang.Throwable
Manage errors. Render them yourself or let them fly to the system itself.

Parameters:
exceptions - the final exception bundle.
result - the current result.
Throws:
java.lang.Throwable - unlike the other methods, this will let exceptions fly back to the Action.

DECLARE

protected void DECLARE(java.lang.String name,
                       java.lang.String defaultValue,
                       boolean required,
                       java.lang.String tag,
                       java.lang.String propertyName)
                throws java.lang.Throwable
Declare a string parameter.

Parameters:
name. - it just be unique per ActionIzer class.
defaultValue -
required -
tag - tag name. If null, there is no associated tag name.
propertyName - property name. If null, there is no associated property name.
Throws:
java.lang.Throwable

DECLARE_BOOLEAN

protected void DECLARE_BOOLEAN(java.lang.String name,
                               boolean defaultValue,
                               boolean required,
                               java.lang.String trueValue,
                               java.lang.String falseValue,
                               java.lang.String trueTag,
                               java.lang.String falseTag,
                               java.lang.String propertyName)
                        throws java.lang.Throwable
Declare a checked boolean parameter.

Parameters:
name. - it just be unique per ActionIzer class.
defaultValue -
required -
trueValue - the text value that indicates true
falseValue - the text value that indicates true
trueTag - associated tag name for the true value
falseTag - associated tag name for the false value
tag - tag name. If null, there is no associated tag name.
propertyName - property name. If null, there is no associated property name.
Throws:
java.lang.Throwable

DECLARE_PROPS

protected void DECLARE_PROPS(java.lang.String name,
                             boolean defaultValue,
                             boolean required,
                             java.lang.String tag)
                      throws java.lang.Throwable
Declare a property parameter.

Parameters:
name. - it just be unique per ActionIzer class.
defaultValue -
required -
tag - tag name. If null, there is no associated tag name.
Throws:
java.lang.Throwable

DECLARE_TYPED

public ActionIzerItem DECLARE_TYPED(java.lang.String name,
                                    java.lang.String defaultValue,
                                    boolean required,
                                    ActionIzerItem.Type type,
                                    java.lang.String tag,
                                    java.lang.String propertyName)
                             throws java.lang.Throwable
Declare by type.

Parameters:
name - the name. it just be unique per ActionIzer class.
defaultValue -
required -
type - the type.
tag - tag name. If null, there is no associated tag name.
propertyName - property name. If null, there is no associated property name.
Throws:
java.lang.Throwable

SET_ACTION_PARAM

public void SET_ACTION_PARAM(java.lang.String action,
                             boolean errorOnUnknown,
                             java.lang.String... actions)
                      throws java.lang.Throwable
Set the action parameter.

Parameters:
action - the action parameter
errorOnUnknown - if true, it will generate an error if it encounters and unknown param.
actions - possible values.
Throws:
java.lang.Throwable

SET_ACTION_SAVE

public void SET_ACTION_SAVE(java.lang.String actionValue,
                            java.lang.String universe,
                            java.lang.String pathParam,
                            java.lang.String tag)
                     throws java.lang.Throwable
Set the action parameter value to indicate a save as well as the name of the parameter that holds the path for the save.

Parameters:
actionValue - the value to indicate the save action.
universe - name of the universe in which we will save. This will overlap with SET_ACTION_LOAD, so keep them in sync.
pathParam - the parameter with the path information. This will overlap with SET_ACTION_LOAD, so keep them in sync.
tag - the tag for rendering the path information. . This will overlap with SET_ACTION_LOAD, so keep them in sync.
Throws:
java.lang.Throwable

SET_ACTION_LOAD

public void SET_ACTION_LOAD(java.lang.String actionValue,
                            java.lang.String universe,
                            java.lang.String pathParam,
                            java.lang.String tag)
                     throws java.lang.Throwable
Set the action parameter value to indicate a save as well as the name of the parameter that holds the path for the save.

Parameters:
actionValue - the value to indicate the save action.
universe - name of the universe in which we will save. This will overlap with SET_ACTION_LOAD, so keep them in sync.
pathParam - the parameter with the path information. This will overlap with SET_ACTION_SAVE, so keep them in sync.
tag - the tag for rendering the path information. . This will overlap with SET_ACTION_SAVE, so keep them in sync.
Throws:
java.lang.Throwable

process

protected ActionResult process()
                        throws java.lang.Throwable
The implementation. Assume the DATA is available.

Specified by:
process in class Action
Throws:
java.lang.Throwable

head

public Head head(ThingsPropertyView parameters,
                 ThingsPropertyView tags,
                 SystemInterface si)
          throws java.lang.Throwable
Overload this if you want to manage HEAD processing on your own. Be careful with these! They will not render a default page if the head processing fails.

Overrides:
head in class Action
Parameters:
parameters - This is what comes from the commands.
tags - This is what will be merged to the result page.
si - The system interface.
Returns:
the head. The default implementation returns a null which will let the server manage it (and almost always invalidate the cache).
Throws:
java.lang.Throwable


Things.