NAME

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

VERSION

$Revision: 1.6.2.1 $

DATE

$Date: 2002/03/01 03:49:53 $

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

my $server = Bric::Dist::Server->new($init)

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

The active property will be set to true by default. Call $server->save() to save the new object.

Throws: NONE.

Side Effects: NONE.

Notes: NONE.

my $server = Bric::Dist::Server->lookup({ id => $id })

Looks up and instantiates a new Bric::Dist::Server object based on the Bric::Dist::Server object ID passed. If $id is not found in the database, lookup() returns undef.

Throws:

Side Effects: If $id is found, populates the new Bric::Dist::Server object with data from the database before returning it.

Notes: NONE.

my (@servers || $servers_aref) = Bric::Dist::Server->list($params)

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:

Throws:

Side Effects: Populates each Bric::Dist::Server object with data from the database before returning them all.

Notes: NONE.

my $servers_href = Bric::Dist::Server->href($params)

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:

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

my (@server_ids || $server_ids_aref) = Bric::Dist::Server->list_ids($params)

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:

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:

Throws: NONE.

Side Effects: NONE.

Notes: NONE.

my (@oses || $oses_aref) = Bric::Dist::Server->list_oses

Returns a list of supported server operating systems.

Throws: NONE.

Side Effects: NONE.

Notes: NONE.

Public Instance Methods

my $id = $server->get_id

Returns the ID of the Bric::Dist::Server object.

Throws:

Side Effects: NONE.

Notes: If the Bric::Dist::Server 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.

my $server_type_id = $server->get_server_type_id

Returns the ID of the Bric::Dist::ServerType object with which this server is associated.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $server->set_server_type_id($server_type_id)

Sets the ID of the Bric::Dist::ServerType object with which this server is associated.

Throws:

Side Effects: NONE.

Notes: NONE.

my $host_name = $server->get_host_name
my $host_name = $server->get_name

Returns the server's host name.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $server->set_host_name($host_name)

Sets the server's host name. The host name will be converted to lower case.

Throws:

Side Effects: NONE.

Notes: NONE.

my $os = $server->get_os

Returns the server's operating system.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $server->set_os($os)

Sets the server's operating system. Retreive a list of supported OSes from list_oses().

Throws:

Side Effects: NONE.

Notes: NONE.

my $doc_root = $server->get_doc_root

Returns the server's home path. This is the path that will serve as the root directory for all PUTs to the server.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $server->set_doc_root($doc_root)

Sets the server's home path. This is the path that will serve as the root directory for all PUTs to the server.

Throws:

Side Effects: NONE.

Notes: In the future, we may want to add platform-independent methods of handling paths.

my $login = $server->get_login

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:

Side Effects: NONE.

Notes: NONE.

$self = $server->set_login($login)

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:

Side Effects: NONE.

Notes: NONE.

my $password = $server->get_password

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:

Side Effects: NONE.

Notes: The password is stored in clear text in the database.

$self = $server->set_password($password)

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:

Side Effects: NONE.

Notes: The password is stored in clear text in the database.

my $cookie = $server->get_cookie

Returns the cookie that can be used by transfer protocols that require a cookie for authentication, such as WebDAV.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $server->set_cookie($cookie)

Sets the cookie that can be used by transfer protocols that require a cookie for authentication, such as WebDAV.

Throws:

Side Effects: NONE.

Notes: NONE.

$server = $server->del

Marks the Bric::Dist::Server object to be deleted from the database. Call $server->save to actually finish it off.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $server->activate

Activates the Bric::Dist::Server object. Call $server->save to make the change persistent. Bric::Dist::Server objects instantiated by new() are active by default.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $server->deactivate

Deactivates (deletes) the Bric::Dist::Server object. Call $server->save to make the change persistent.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $server->is_active

Returns $self if the Bric::Dist::Server object is active, and undef if it is not.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $server->save

Saves any changes to the Bric::Dist::Server object. Returns $self on success and undef on failure.

Throws:

Side Effects: NONE.

Notes: NONE.

PRIVATE

Private Class Methods

NONE.

Private Instance Methods

NONE.

Private Functions

my $server_aref = &$get_em( $pkg, $params )
my $server_ids_aref = &$get_em( $pkg, $params, 1 )
my $server_ids_href = &$get_em( $pkg, $params, 0, 1 )

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:

Side Effects: NONE.

Notes: NONE.

NOTES

NONE.

AUTHOR

David Wheeler <david@wheeler.net>

SEE ALSO

Bric, Bric::Dist::ServerType

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 395:

=back doesn't take any parameters, but you said =back 4

Around line 551:

Expected '=item *'

Around line 553:

Expected '=item *'

Around line 555:

Expected '=item *'

Around line 557:

Expected '=item *'

Around line 559:

Expected '=item *'

Around line 561:

Expected '=item *'

Around line 563:

Expected '=item *'

Around line 1415:

=back doesn't take any parameters, but you said =back 4