man Bric::Dist::Server () - Interface for managing servers to which content will be distributed.

NAME

Bric::Dist::Server - Interface for managing servers to which content will be distributed.

VERSION

$LastChangedRevision$

DATE

$LastChangedDate: 2004-08-12 17:13:34 -0700 (Thu, 12 Aug 2004) $

SYNOPSIS

  use Bric::Dist::Server;

  # Constructors.
  # Create a new object.
  my $server = Bric::Dist::Server->new;
  # Look up an existing object.
  $server = Bric::Dist::Server->lookup({ id => 1 });
  # Get a list of server objects.
  my @servers = Bric::Dist::Server->list({ server_type_id => 2 });
  # Get an anonymous hash of server objects.
  my $servers_href = Bric::Dist::Server->href({ home_path => '/home/www' });

  # Class methods.
  # Get a list of object IDs.
  my @server_ids = Bric::Dist::Server->list_ids({ server_type_id => 2 });
  # Get an introspection hashref.
  my $int = Bric::Dist::Server->my_meths;

  # Instance Methods.
  my $id = $server->get_id;
  my $server_type_id = $server->get_server_type_id;
  $server = $server->set_server_type_id($server_type_id);
  my $host_name = $server->get_host_name;
  $server = $server->set_host_name($host_name);
  my $doc_root = $server->get_doc_root;
  $server = $server->set_doc_root($doc_root);
  my $login = $server->get_login;
  $server = $server->set_login($login);
  my $password = $server->get_password;
  $server = $server->set_password($password);
  my $cookie = $server->get_cookie;
  $server = $server->set_cookie($cookie);

  # Save it.
  $server->save;

  # Delete it.
  $server->del;
  $server->save;

DESCRIPTION

This class manages server objects. Servers are individual instances of a type defined by Bric::Dist::ServerType. They are provide accessors to values that are unique to each server, such as host name, login, password, cookie, etc. Thus, when a job is scheduled to move files to the servers of a given server type, they can be successfully moved using the unique properties of each server.

INTERFACE

Constructors

Instantiates a Bric::Dist::Server object. An anonymous hash of initial values may be passed. The supported initial value keys are:

*
host_name
*
os
*
doc_root
*
login
*
password
*
cookie
*
server_type_id The active property will be set to true by default. Call CW$server->save() to save the new object. Throws: NONE. Side Effects: NONE. Notes: NONE. Looks up and instantiates a new Bric::Dist::Server object based on the Bric::Dist::Server object ID passed. If CW$id is not found in the database, lookup() returns undef. Throws:
*
Too many Bric::Dist::Server 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::Server object with data from the database before returning it. Notes: NONE. Returns a list or anonymous array of Bric::Dist::Server objects based on the search parameters passed via an anonymous hash. The supported lookup keys are:
*
host_name
*
os
*
doc_root
*
login
*
password
*
cookie
*
server_type_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::Server object with data from the database before returning them all. Notes: NONE. Returns an anonymous hash of Bric::Dist::Server 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::Server object with data from the database before returning them all. Notes: NONE.

Destructors

$server->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::Server 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.
$meths = Bric::Dist::Server->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. Returns a list of supported server operating systems. Throws: NONE. Side Effects: NONE. Notes: NONE.

Public Instance Methods

Returns the ID of the Bric::Dist::Server 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::Server 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 ID of the Bric::Dist::ServerType object with which this server is associated. 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. Sets the ID of the Bric::Dist::ServerType object with which this server is associated. Throws:
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Returns the server's host name. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'host_name' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the server's host name. The host name will be converted to lower case. Throws:
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Returns the server's operating system. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'os' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the server's operating system. Retreive a list of supported OSes from list_oses(). Throws:
*
Not a supported operating system.
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Returns the server's home path. This is the path that will serve as the root directory for all PUTs to the server. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'doc_root' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the server's home path. This is the path that will serve as the root directory for all PUTs to the server. Throws:
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: In the future, we may want to add platform-independent methods of handling paths. Returns the server's login name, which will be used with the password property to interact with the server via FTP and other protocols that require a login and password. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'login' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the server's login name, which will be used with the password property to interact with the server via FTP and other protocols that require a login and password. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: WRITE access for field 'login' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the server's password, which will be used with the login to interact with the server via FTP and other protocols that require a login and password. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'password' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: The password is stored in clear text in the database. Sets the server's password, which will be used with the login to interact with the server via FTP and other protocols that require a login and password. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: WRITE access for field 'password' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: The password is stored in clear text in the database. Returns the cookie that can be used by transfer protocols that require a cookie for authentication, such as WebDAV. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'cookie' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the cookie that can be used by transfer protocols that require a cookie for authentication, such as WebDAV. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: WRITE access for field 'cookie' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Marks the Bric::Dist::Server object to be deleted from the database. Call CW$server->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::Server object. Call CW$server->save to make the change persistent. Bric::Dist::Server 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::Server object. Call CW$server->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::Server 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::Server 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

NONE.

Private Functions

Function used by lookup() and list() to return a list of Bric::Dist::Server objects or, if called with an optional third argument, returns a listof Bric::Dist::Server object IDs (used by list_ids()). If called with an optional fourth argument, returns an anonymous hash where the keys are the object IDs and the values are the objects themselves. 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.

NOTES

NONE.

AUTHOR

David Wheeler <david@wheeler.net>

SEE ALSO

Bric, Bric::Dist::ServerType