man Bric::Dist::ServerType () - Interface for managing types of servers to which to distribute content.
NAME
Bric::Dist::ServerType - Interface for managing types of servers to which to distribute content.
VERSION
$LastChangedRevision$
DATE
$LastChangedDate: 2004-08-12 17:13:34 -0700 (Thu, 12 Aug 2004) $
SYNOPSIS
use Bric::Dist::ServerType;
# Constructors. # Create a new object. my $st = Bric::Dist::ServerType->new; # Look up an existing object. $st = Bric::Dist::ServerType->lookup({ id => 1 }); # Get a list of server type objects. my @sts = Bric::Dist::ServerType->list({ move_method => 'FTP Transport' }); # Get an anonymous hash of server type objects. my $sts_href = Bric::Dist::ServerType->href({ description => 'Preview%' });
# Class methods. # Get a list of object IDs. my @st_ids = Bric::Dist::ServerType->list_ids({ description => 'Prev%' }); # Get an introspection hashref. my $int = Bric::Dist::ServerType->my_meths; # Get a list of mover types. my @move_methods = Bric::Dist::ServerType->list_move_methods;
# Instance Methods. my $id = $st->get_id; my $name = $st->get_name; $st = $st->set_name($name); my $description = $st->get_description; $st = $st->set_description($description); my $move_method = $st->get_move_method; $st = $st->set_move_method($move_method); my $site_id = $st->get_site_id; $st = $st->set_site_id($site_id); print "ST is ", $st->can_copy ? '' : 'not ', "copyable.\n"; $st->copy; $st->no_copy;
print "ST ", $st->can_publish ? 'publishes' : "does not publish.\n"; $st = $st->on_publish; # Used for publish event. $st = $st->no_publish; # Not used for publish event.
print "ST ", $st->can_preview ? 'previews' : "does not preview.\n"; $st = $st->on_preview; # Used for preview event. $st = $st->no_preview; # Not used for preview event.
print "ST is ", $st->is_active ? '' : 'not ', "active.\n"; $st->deactivate; $st->activate;
# Accessors to servers of this type. my @servers = $st->get_servers; my $server = $st->new_server; $st->del_servers;
# Accessors to output channels associated with this server type. my @ocs = $st->get_output_channels; $st = $st->add_output_channels(@ocs); $st = $st->del_output_channels(@ocs);
# Accessors to actions associated with this type. my @actions = $st->get_actions; my $action = $st->new_action; $st->del_actions;
# Save it. $st->save;
DESCRIPTION
This class manages types of servers. A server type represents a class of servers on which a list of actions should be performed upon the execution of a job. A server type, therefore, simply describes a list of servers for which the actions will be performed and a list of actions to be executed on the files associated with a given job. The last action should be a move statement, to move each file to each of the servers.
So use this class a the central management point for figuring out what happens to files, and in what order, and what servers they are sent to, in the event of a publish or preview event.
INTERFACE
Constructors
Instantiates a Bric::Dist::ServerType object. An anonymous hash of initial values may be passed. The supported initial value keys are:
- *
- name
- *
- description
- *
- site_id
- *
- move_method The active property will be set to true and the copy property to false by default. Call CW$st->save() to save the new object. Throws: NONE. Side Effects: NONE. Notes: NONE. Looks up and instantiates a new Bric::Dist::ServerType object based on the Bric::Dist::ServerType object ID or name and site ID passed. If CW$id or CW$name and CW$site_id is not found in the database, CWlookup() returns CWundef. Throws:
- *
- Too many Bric::Dist::ServerType 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 CW$id is found, populates the new Bric::Dist::ServerType object with data from the database before returning it. Notes: NONE. Returns a list or anonymous array of Bric::Dist::ServerType objects based on the search parameters passed via an anonymous hash. The supported lookup keys are:
- *
- move_method
- *
- description
- *
- site_id
- *
- job_id
- *
- output_channel_id
- *
- can_copy
- *
- can_publish
- *
- can_preview
- *
- grp_id
- *
- active 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::ServerType object with data from the database before returning them all. Notes: NONE. Returns an anonymous hash of Bric::Dist::ServerType objects, where the keys are object IDs and the values or the objects themselves, based on the search parameters passed via an anonymous hash. The supported lookup keys are 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::ServerType object with data from the database before returning them all. Notes: NONE.
Destructors
- $st->DESTROY
- Dummy method to prevent wasting time trying to AUTOLOAD DESTROY. Throws: NONE. Side Effects: NONE. Notes: NONE.
Public Class Methods
Returns a list or anonymous array of Bric::Dist::ServerType object IDs based on the search criteria passed via an anonymous hash. The supported lookup keys are the same as those 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: NONE. Notes: NONE. Returns a list or anonymous array of the names of classes that feature a method to move resources. Throws:
- *
- Unable to connect to database.
- *
- Unable to prepare SQL statement.
- *
- Unable to select column into arrayref. Side Effects: NONE. Notes: NONE.
- $meths = Bric::Dist::ServerType->my_meths
- Returns an anonymous hash of introspection data for this object. If called with a true argument, it will return an ordered list or anonymous array of introspection data. If a second true argument is passed instead of a first, then a list or anonymous array of introspection data will be returned for properties that uniquely identify an object (excluding CWid, which is assumed). 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:
- short
- date
- blob
- 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.
Public Instance Methods
Returns the ID of the Bric::Dist::ServerType 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::ServerType object has been instantiated via the new() constructor and has not yet been CWsaved, the object will not yet have an ID, so this method call will return undef. Returns the server type name. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: READ access for field 'name' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the server type name. The name must be unique. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: WRITE access for field 'name' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the server type description. 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. Sets the server type description. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: WRITE access for field 'description' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the site ID with which this ServerType is associated. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Associate this ServerType with a site. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the display name of the Bricolage class responible for moving resources to servers of this type. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: READ access for field 'move_method' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the name of the class responible for moving resources to servers of this type. Get a list of supporte mover types from list_move_methods(). Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: WRITE access for field 'move_method' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns a list or anonymous array of the Bric::Biz::OutputChannel objects that represent the directories and/or files on which this server type acts. Throws:
- *
- Bric::_get() - 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 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. Adds Output Channels to this server type. Call save() to save the relationship. Throws:
- *
- Bric::_get() - Problems retrieving fields.
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: NONE. Notes: Uses Bric::Util::Coll::Server internally. Dissociates Output Channels, represented as Bric::Biz::OutputChannel objects, from the server type. call save() to save the dissociations to the database. Throws:
- *
- Bric::_get() - 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 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. Returns a list or anonymous array of Bric::Dist::Server objects that are of this type. Pass in a list of Bric::Dist::Server object IDs to get back only those Bric::Dist::Server objects. If no IDs are passed, all the Bric::Dist::Server objects of this type will be returned. Throws:
- *
- Bric::_get() - 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 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: Uses Bric::Util::Coll::Server internally. Adds a new server to this server type. The initial values for the CW$init anonymous hash are the same as those for Bric::Dist::Server->new(), although the server_type_id property will be set automatically to associate the new server object with this server type. Throws:
- *
- Bric::_get() - 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 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: Uses Bric::Util::Coll::Server internally. Deletes Bric::Dist::Server objects from this type. Pass in a list of Bric::Dist::Server object IDs to delete only those servers. If no IDs are passed, all of the Bric::Dist::Server objects of this type will be deleted. Throws:
- *
- Bric::_get() - 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 select column into arrayref.
- *
- Unable to execute SQL statement.
- *
- Unable to bind to columns to statement handle. Side Effects: NONE. Notes: Uses Bric::Util::Coll::Server internally. Returns a list or anonymous array of Bric::Dist::Action objects that are of this type. Pass in a list of Bric::Dist::Action object IDs to get back only those Bric::Dist::Action objects. If no IDs are passed, all the Bric::Dist::Action objects of this type will be returned. Throws:
- *
- Bric::_get() - 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 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: Uses Bric::Util::Coll::Action internally. Adds a new action to this action type. The initial values for the CW$init anonymous hash are the same as those for Bric::Dist::Action->new(), although the server_type_id property will be set automatically to associate the new action object with this server type. Throws:
- *
- Bric::_get() - 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 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: Uses Bric::Util::Coll::Action internally. Deletes Bric::Dist::Action objects from this type. Pass in a list of Bric::Dist::Action object IDs to delete only those actions. If no IDs are passed, all of the Bric::Dist::Action objects of this type will be deleted. Throws:
- *
- Bric::_get() - 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 select column into arrayref.
- *
- Unable to execute SQL statement.
- *
- Unable to bind to columns to statement handle. Side Effects: NONE. Notes: Uses Bric::Util::Coll::Action internally. Sets the copy property to true, meaning that when a job is executed for this server type, all the resources should be copied to a temporary directory before the actions are applied to them. Throws:
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Sets the copy property to false, meaning that when a job is executed for this server type, all the resources will have the actions applied to them in place, without first moving them to a temporary directory. Throws:
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Returns CW$self if the resources should be copied to a temporary directory before performing actions on them, and false if the actions can be applied to the resources in place. Throws:
- *
- Bric::_get() - Problems retrieving fields. Side Effects: NONE. Notes: NONE. Sets the copy publish to true, meaning that this server type should be used for publish events. Throws:
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Sets the publish property to false, meaning that this server type should be used for jobs triggered by publish events. Throws:
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Returns CW$self if this server type is used to move files for a publish event. Throws:
- *
- Bric::_get() - Problems retrieving fields. Side Effects: NONE. Notes: NONE. Sets the copy preview to true, meaning that this server type should be used for preview events. Throws:
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Sets the preview property to false, meaning that this server type should be used for jobs triggered by preview events. Throws:
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Returns CW$self if this server type is used to move files for a preview event. Throws:
- *
- Bric::_get() - Problems retrieving fields. Side Effects: NONE. Notes: NONE. Activates the Bric::Dist::ServerType object. Call CW$st->save to make the change persistent. Bric::Dist::ServerType 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::ServerType object. Call CW$st->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 CW$self if the Bric::Dist::ServerType 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::ServerType object. Returns CW$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.
PRIVATE
Private Class Methods
NONE.
Private Instance Methods
Returns the Class (package) name of the class used to move resources. Used by Bric::Dist::Action::Mover so that it knows who to tell to do the moving. Throws:
- *
- Bric::_get() - Problems retrieving fields. Side Effects: If the move method has been changed via set_move_method() since the current object was instantiated, this method will return the old package name rather than the new one. To get the new one, instantiate the object but don't change its method. If you really want to change it, do so, save it, and then re-instantiate it via Bric::Dist::ServerType->lookup(). Notes: NONE>
Private Functions
Function used by CWlookup() and CWlist() to return a list of Bric::Dist::ServerType objects or, if called with an optional third argument, returns a list of Bric::Dist::ServerType object IDs (used by CWlist_ids()). 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: NONE. Notes: Returns the collection of objects stored under CW$key in CW$self. The collection is a subclass Bric::Util::Coll object, identified by CW$class. See Bric::Util::Coll for interface details. Throws:
- *
- Bric::_get() - Problems retrieving fields.
- *
- Unable to prepare SQL statement.
- *
- Unable to connect to database.
- *
- 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.
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE.
NOTES
NONE.
AUTHOR
David Wheeler <david@wheeler.net>
SEE ALSO
Bric