Bric::Util::Job::Pub(3p)

NAME
Bric::Util::Job::Pub - Manages Bricolage publishing jobs.

VERSION
$LastChangedRevision$

DATE
$LastChangedDate: 2005-10-13 01:27:24 +0200 (Thu, 13 Oct 2005) $

SYNOPSIS
  use Bric::Util::Job::Pub;

  my $id = 1;
  my $format = "%D %T";

  # Constructors.
  my $job = Bric::Util::Job::Pub->new($init);
  $job = Bric::Util::Job::Pub->lookup({ id => $id });
  my @jobs = Bric::Util::Job::Pub->list($params);

  # Class Methods.
  my @job_ids = Bric::Util::Job::Pub->list_ids($params);

  # Instance Methods
  my $id = $job->get_id;

  my $type = $job->get_type;
  $job = $job->set_type($type);

  my $sched_time = $job->get_sched_time($format);
  $job = $job->set_sched_time($sched_time);
  my $comp_time = $job->get_comp_time($format);

  my @resources = $job->get_resources;
  my @resource_ids = $job->get_resource_ids;
  $job = $job->set_resource_ids(@resource_ids);

  my @server_types = $job->get_server_types;
  my @server_type_ids = $job->get_server_type_ids;
  $job = $job->set_server_type_ids(@server_type_ids);

  # Save the job.
  $job = $job->save;

  # Cancel the job.
  $job = $job->cancel;

  # Execute the job.
  $job = $job->execute_me;

DESCRIPTION
This class manages publishing jobs. A publishing job designates that a given Story or Media object will be published by a Burner at a given time. Publishing jobs create distribution jobs as they are run. Jobs which fail in execution are tried again, and eventually if the failure continues marked as 'failed'.

  Constructors
my (@jobs || $jobs_aref) = Bric::Util::Job::Pub->list($params)

Inherited from Bric::Util::Job

my (@job_ids || $job_ids_aref) = Bric::Util::Job->list_ids($params)

Inherited from Bric::Util::Job

  Private Instance Methods
$self = $job->_do_it

Carries out the actions that constitute the job. This method is called by "execute_me()" in Bric::Dist::Job and should therefore never be called directly.

Sends the Story or Media object contained by the job to the burner. In case of a template error the job is released to be executed again. Three such errors are considered a failure, in which case the job is marked as such. The most recent error message is stored in the error_message field. At the end of the process, a completion time will be saved to the database. Attempting to execute a job before its scheduled time will throw an exception.

Throws: Quite a few exceptions can be thrown here. Check the do_it() methods on all Bric::Publish::Action subclasses, as well as the put_res() methods of the mover classes (e.g., Bric::Util::Trans::FS). Here are the exceptions thrown from withing this method itself.

•   Cannot execute job before its scheduled time.

•   Cannot execute job that has already been executed.

•   Can't get a lock on job.

•   Unable to connect to database.

•   Unable to prepare SQL statement.

•   Unable to execute SQL statement.

•   Incorrect number of args to Bric::_set().

•   Bric::set() - Problems setting fields.

Side Effects: NONE.

Notes: NONE.

NOTES
NONE.

AUTHOR
Mark Jaroski <jaroskim@who.int>

SEE ALSO
Bric, Bric::Util::Job