Bric::Dist::Action - Interface to actions that can be performed on resources for given server types.
$Revision: 1.1.1.1.2.2 $
$Date: 2001/11/06 23:18:34 $
use Bric::Dist::Action;
# Constructors.
# Create a new object.
my $action = Bric::Dist::Action->new;
# Look up an existing object. May return a subclass of Bric::Dist::Action.
$action = Bric::Dist::Action->lookup({ id => 1 });
# Get a list of action objects.
my @servers = Bric::Dist::Action->list({ type => 'Akamaize' });
# Class methods.
# Get a list of object IDs.
my @st_ids = Bric::Dist::Action->list_ids({ type => 'Akamaize' });
# Get an introspection hashref.
my $int = Bric::Dist::Action->my_meths;
my $bool = Bric::Dist::Action->has_more;
# Instance Methods.
my $id = $action->get_id;
my $type = $action->get_type;
# Changing the type will likely change the $action to a different subclass,
# and will delete any attributes associated with the previous type.
$action = $action->set_type($type);
# Description is only available for types that have been looked up in the
# database.
my $description = $action->get_description;
# The server type designation may be changed at will.
my $st_id = $action->get_server_type_id;
my $action = $action->set_server_type_id($st_id);
# The list of MEDIA types can only be fetched on existing actions. The list
# of MEDIA types is dependent on the type of action.
my @medias = $action->get_media_types;
my $medias = $action->get_media_href;
# Perform the action.
$action->do_it($job, $server_type);
# Delete the action.
$action->del
# Save the action.
$action->save;
This class manages the actions that are applied for a given server type to the files associated with a given job. The idea is that for any given server type, an ordered list of actions will be performed whenever a job is executed for that server type. For example, if there is a server type "Production Server", the list of actions (represented as Bric::Dist::Action objects) for that server type might be "Akamaize", "Ultraseek", "Gzip", and "Put". When a job (represented by a Bric::Dist::Job object) is executed for that server group, then each of those actions will be instantiated in turn, and their do_it() methods called on the job's resources.
The types of actions available to customers are created at development time, and are represented both in the database and by subclasses of Bric::Dist::Action. They can be changed and reordered for a given servery type via the Bric::Dist::ServerType interface. So Bric::Dist::Action will frequently not be accessed directly, but via Bric::Dist::ServerType accessors.
Instantiates a Bric::Dist::Action object. An anonymous hash of initial values may be passed. The supported initial value keys are:
type
server_type_id
class
The active property will be set to true by default. Call $act->save() to save the new object.
Throws:
Unable to load action subclass.
Invalid parameter passed to constructor method.
Incorrect number of args to Bric::_set().
Bric::set() - Problems setting fields.
Side Effects: NONE.
Notes: NONE.
Looks up and instantiates a new Bric::Dist::Action object based on the Bric::Dist::Action object ID passed. If $id is not found in the database, lookup() returns undef.
Throws:
Invalid parameter passed to constructor method.
Too many Bric::Dist::Action objects found.
Unable to connect to database.
Unable to prepare SQL statement.
Unable to select column into arrayref.
Unable to execute SQL statement.
Unable to bind to columns to statement handle.
Unable to fetch row from statement handle.
Side Effects: If $id is found, populates the new Bric::Dist::Action object with data from the database before returning it.
Notes: NONE.
Returns a list or anonymous array of Bric::Dist::Action objects based on the search parameters passed via an anonymous hash. The supported lookup keys are:
type
server_type_id
class
description
Throws:
Invalid parameter passed to constructor method.
Unable to connect to database.
Unable to prepare SQL statement.
Unable to select column into arrayref.
Unable to execute SQL statement.
Unable to bind to columns to statement handle.
Unable to fetch row from statement handle.
Side Effects: Populates each Bric::Dist::Action object with data from the database before returning them all.
Notes: NONE.
Returns an anonymous hash of Bric::Dist::Action objects, where the keys are the object IDs and the values are the objects themselves, based on the search parameters passed via an anonymous hash. The supported lookup keys are the same as for list().
Throws:
Unable to connect to database.
Unable to prepare SQL statement.
Unable to select column into arrayref.
Unable to execute SQL statement.
Unable to bind to columns to statement handle.
Unable to fetch row from statement handle.
Side Effects: Populates each Bric::Dist::Action object with data from the database before returning them all.
Notes: NONE.
Dummy method to prevent wasting time trying to AUTOLOAD DESTROY.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
################################################################################
my $ord = Bric::Dist::Action->next_ord($server_type_id)
Returns the next ordinal number in the sequence of actions for a given server_type_id.
Throws:
Unable to load action subclass.
Invalid parameter passed to constructor method.
Unable to connect to database.
Unable to prepare SQL statement.
Unable to select column into arrayref.
Side Effects: NONE.
Notes: NONE.
my (@act_ids || $act_ids_aref) = Bric::Dist::Action->list_ids($params)
Returns a list or anonymous array of Bric::Dist::Action object IDs based on the search criteria passed via an anonymous hash. The supported lookup keys are the same as those for list().
Throws:
Invalid parameter passed to constructor method.
Unable to connect to database.
Unable to prepare SQL statement.
Unable to select column into arrayref.
Unable to execute SQL statement.
Unable to bind to columns to statement handle.
Unable to fetch row from statement handle.
Side Effects: NONE.
Notes: NONE.
my (@types || $types_aref) = Bric::Dist::Action->list_types
Returns a list or anonymous array of the types of the supported actions.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
my $bool = Bric::Dist::Action->has_more()
Returns true if the action has more properties than does the base class (Bric::Dist::Action), and false if not. Here in Bric::Dist::Action it returns false, so it only needs to be overridden to return true in subclasses of Bric::Dist::Action that contain extra properties (such as Bric::Dist::Action::Akamaize).
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
$meths = Bric::Dist::ServerType >my_meths
(@meths || $meths_aref) = Bric::Dist::ServerType->my_meths(TRUE)
Returns an anonymous hash of instrospection data for this object. If called with a true argument, it will return an ordered list or anonymous array of intrspection data. The format for each introspection item introspection is as follows:
Each hash key is the name of a property or attribute of the object. The value for a hash key is another anonymous hash containing the following keys:
name - The name of the property or attribute. Is the same as the hash key when an anonymous hash is returned.
disp - The display name of the property or attribute.
get_meth - A reference to the method that will retrieve the value of the property or attribute.
get_args - An anonymous array of arguments to pass to a call to get_meth in order to retrieve the value of the property or attribute.
set_meth - A reference to the method that will set the value of the property or attribute.
set_args - An anonymous array of arguments to pass to a call to set_meth in order to set the value of the property or attribute.
type - The type of value the property or attribute contains. There are only three types:
len - If the value is a 'short' value, this hash key contains the length of the field.
search - The property is searchable via the list() and list_ids() methods.
req - The property or attribute is required.
props - An anonymous hash of properties used to display the property or attribute. Possible keys include:
type - The display field type. Possible values are
text
textarea
password
hidden
radio
checkbox
select
length - The Length, in letters, to display a text or password field.
maxlength - The maximum length of the property or value - usually defined by the SQL DDL.
rows - The number of rows to format in a textarea field.
cols - The number of columns to format in a textarea field.
vals - An anonymous hash of key/value pairs reprsenting the values and display names to use in a select list.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Returns the ID of the Bric::Dist::Action object.
Throws:
Bad AUTOLOAD method format.
Cannot AUTOLOAD private methods.
Access denied: READ access for field 'id' required.
No AUTOLOAD method.
Side Effects: NONE.
Notes: If the Bric::Dist::Action object has been instantiated via the new() constructor and has not yet been saved, the object will not yet have an ID, so this method call will return undef.
Returns the type of the action, e.g., "FTP" or "Akamaize."
Throws:
Cannot load action class.
Bad AUTOLOAD method format.
Cannot AUTOLOAD private methods.
Access denied: READ access for field 'type' required.
No AUTOLOAD method.
Side Effects: NONE.
Notes: NONE.
Sets the type of the action. The type must be the type of a supported action. Call Bric::Dist::Action->list_types() to get a list of supported actions.
Throws:
Unable to load action subclass.
Problems retrieving fields.
Incorrect number of args to Bric::_set().
Bric::set() - Problems setting fields.
Unable to connect to database.
Unable to prepare SQL statement.
Unable to execute SQL statement.
Unable to bind to columns to statement handle.
Unable to fetch row from statement handle.
Side Effects: NONE.
Notes: NONE.
Returns the number representing this action's place in the order of execution for all the actions associated with the server_type_id with which this action is associated.
Throws:
Bad AUTOLOAD method format.
Cannot AUTOLOAD private methods.
Access denied: READ access for field 'id' required.
No AUTOLOAD method.
Side Effects: NONE.
Notes: NONE.
Sets the order of the action. This number represents where in the sequence of actions associated with the server_type_id with which this action is associated that this action will be executed. If this property is never set on a new action, then the order will default to the last in the sequence of actions. If it is set, and it comes before other, pre-existing actions, those actions will be shifted down in the list of actions.
Throws:
Problems retrieving fields.
Incorrect number of args to Bric::_set().
Bric::set() - Problems setting fields.
Side Effects: NONE.
Notes: NONE.
Returns the description of the action.
Throws:
Bad AUTOLOAD method format.
Cannot AUTOLOAD private methods.
Access denied: READ access for field 'description' required.
No AUTOLOAD method.
Side Effects: NONE.
Notes: NONE.
Returns the ID of the Bric::Dist::ServerType object for which this action will be performed.
Throws:
Bad AUTOLOAD method format.
Cannot AUTOLOAD private methods.
Access denied: READ access for field 'server_type_id' required.
No AUTOLOAD method.
Side Effects: NONE.
Notes: NONE.
Associates this action with a Bric::Dist::ServerType object so that this action can be performed for servers of that type.
Throws:
Bad AUTOLOAD method format.
Cannot AUTOLOAD private methods.
Access denied: WRITE access for field 'server_type_id' required.
No AUTOLOAD method.
Side Effects: NONE.
Notes: NONE.
Returns a list or anonymous array of the MEDIA types that apply to this action. Returns an empty list (or undef in a scalar context) if this action applies to all MEDIA types.
Throws:
Bric::_get() - Problems retrieving fields.
Side Effects: NONE.
Notes: NONE.
Returns an anonymous hash of the MEDIA types that apply to this action. Returns undef if this action applies to all MEDIA types.
Throws:
Bric::_get() - Problems retrieving fields.
Side Effects: NONE.
Notes: NONE.
Marks the Bric::Dist::Action object to be deleted from the database. Call $action->save to actually finish it off.
Throws:
Incorrect number of args to Bric::_set().
Bric::set() - Problems setting fields.
Side Effects: NONE.
Notes: NONE.
Activates the Bric::Dist::Action object. Call $action->save to make the change persistent. Bric::Dist::Action objects instantiated by new() are active by default.
Throws:
Incorrect number of args to Bric::_set().
Bric::set() - Problems setting fields.
Side Effects: NONE.
Notes: NONE.
Deactivates (deletes) the Bric::Dist::Action object. Call $action->save to make the change persistent.
Throws:
Incorrect number of args to Bric::_set().
Bric::set() - Problems setting fields.
Side Effects: NONE.
Notes: NONE.
Returns $self if the Bric::Dist::Action object is active, and undef if it is not.
Throws:
Bric::_get() - Problems retrieving fields.
Side Effects: NONE.
Notes: NONE.
Saves any changes to the Bric::Dist::Action object. Returns $self on success and undef on failure.
Throws:
Bric::_get() - Problems retrieving fields.
Unable to connect to database.
Unable to prepare SQL statement.
Unable to execute SQL statement.
Unable to select row.
Incorrect number of args to _set.
Bric::_set() - Problems setting fields.
Side Effects: NONE.
Notes: NONE.
Performs the action on the resources associated with $job. Must be overridden in Bric::Dist::Action subclasses.
Throws:
Method not implemented.
Side Effects: NONE.
Notes: NONE.
Undoes the action on the resources associated with $job. Here is is actually a no-op that returns false, but when overridden, it should return true, as Bric::Dist::Job uses this return value to determine whether or not to log an event.
Throws:
Method not implemented.
Side Effects: NONE.
Notes: NONE.
NONE.
Used by subclasses to access an action's Bric::Util::Attribute::Action object.
Throws:
Problems retrieving fields.
Incorrect number of args to Bric::_set().
Bric::set() - Problems setting fields.
Side Effects: NONE.
Notes: NONE.
A No-op function that may be overridden in subclasses with attributes. It is called by set_type() above so that subclasses of Bric::Dist::Action can clear their attributes before the Bric::Dist::Action object is blessed into a different class. See Bric::Dist::Action::Akamaize for an example.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Function used by lookup() and list() to return a list of Bric::Dist::Action objects or, if called with an optional third argument, returns a listof Bric::Dist::Action object IDs (used by list_ids()).
Throws:
Unable to load action subclass.
Invalid parameter passed to constructor method.
Unable to connect to database.
Unable to prepare SQL statement.
Unable to select column into arrayref.
Unable to execute SQL statement.
Unable to bind to columns to statement handle.
Unable to fetch row from statement handle.
Side Effects: NONE.
Notes: NONE.
Instantiates a Bric::Dist::Action object. Used by &$get_em().
Throws:
Unable to load action subclass.
Invalid parameter passed to constructor method.
Incorrect number of args to Bric::_set().
Bric::set() - Problems setting fields.
Side Effects: NONE.
Notes: NONE.
Reorders the list of actions for a given server_type_id. Pass in the server_type_id and the ordinal number to change from to the ordinal number to change to. The action that was number $from_ord will be changed to number $to_ord, and the order of the other actions will be shifted to accommodate it. For example, if you had the following actions:
Order ID Action
----- -- ------------------
1 11 Clean HTML
2 12 Akamaize
3 13 Move
4 14 Go Home
To change the order so that "Akamaize" precedes "Clean HTML", call this function like so:
&$reorder(12, 2, 1);
And the Data will be reordered in this manner:
Order ID Action
----- -- ------------------
1 12 Akamaize
2 11 Clean HTML
3 13 Move
4 14 Go Home
Throws:
Unable to load action subclass.
Invalid parameter passed to constructor method.
Unable to connect to database.
Unable to prepare SQL statement.
Unable to select column into arrayref.
Unable to execute SQL statement.
Unable to bind to columns to statement handle.
Unable to fetch row from statement handle.
Side Effects: NONE.
Notes: NONE.
NONE.
David Wheeler <david@wheeler.net>
perl(1), Bric (2),
Hey! The above document had some coding errors, which are explained below:
=back doesn't take any parameters, but you said =back 4
You can't have =items (as at line 447) unless the first thing after the =over is an =item
Expected '=item *'
Expected '=item *'
Expected '=item *'
Expected '=item *'
Expected '=item *'
Expected '=item *'
Expected '=item *'
=back doesn't take any parameters, but you said =back 4