#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package Support::JobQueue::Command::HostStatusTokenAjax;

use lib '/app/tools/common/lib';
use RSApache::Response::JSON;
use RSApache::Command::XMLCommand;
use RSApache::Message;

use lib '/app/tools/job/lib';
use Job::DB::Item::JobHost;
use Job::Queue;

# !!! The theory here is to use a command that does not redirect to login
# !!! if the session is invalid.
#
use lib '/app/tools/support/lib';
use base 'Support::Command::AJAX';

use constant kTemplate => '/app/tools/admin/templates/jobqueue/hoststatus.xsl';

sub cmd  { return "hoststatustoken"; }
sub area { return "job_queue"; }

sub execute {
    my ($self) = @_;

    # Give any inherited methods the first crack at this.
    # (This checks for login and basic access permissions).
    #
    my $response = $self->SUPER::execute();
    return $response if $response;

    # Fetch the state straight from the table_state table
    #
    my $token = "'" . Job::DB::Item::JobHost->StateToken() . "'";
    $response = RSApache::Response::JSON->new($token);

    return $response;
}

1;

