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

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

use lib '/app/tools/admin/lib';
use Admin::Permission::Form;
use Admin::Command;

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

# !!! The theory here is to use a command that does not redirect to login
# !!! if the session is invalid.
#
use base 'RSApache::Command::XMLCommand';

use lib '/app/tools/job/lib';
use Job::Queue;

use Data::Dumper;

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

sub cmd  { return "queuetoken"; }
sub area { return "jobqueue"; }

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::Job->StateToken() . "'";
    $response = RSApache::Response::JSON->new($token);

    return $response;
}

1;

