#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::Distribution::Command::ExcelDump;
use strict;
use warnings;

use base 'RSApache::Command::XMLCommand';

use lib '/app/tools/common/lib';
use RSApache::Response::DownloadStream;

use lib '/app/tools/appuser/lib';
use AppUser::DB::Item::AccessLevel;

use lib '/app/tools/metadata/lib';
use Metadata::Exporter::Excel;

sub cmd  { return 'exceldump'; }
sub area { return 'distribution'; }

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

    my $exporter = new Metadata::Exporter::Excel( criteria => $self->getParam('show') );

    my $excel = $exporter->export_to_var();

    my $response = $self->SUPER::execute();
    return $response if $response;

    $response = RSApache::Response::DownloadStream->new( $excel, "application/octet-stream", "rs_export.xls" );

    Common::Log::Debug($response);
    return $response;
}

1;
