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

use IO::File;

use lib '/app/tools/rps/lib';
use RPS::Statement::Artist::PDF;

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

use base 'RPS::Command';

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

use constant kPath => "/app/tools/rps/docs/metadata/metadata_template.xls";

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

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

    my $fullPath = kPath;
    my $prettyFileName = 'RoyaltyShare_Catalog_Template_v6_0.xls';

    my $fh = new IO::File;
    open($fh, "$fullPath") or die "ERROR: Unable to open $fullPath for reading: $!";

    my @stat = $fh->stat;
    my $fileSize = $stat[7];

	my $contentType = 'application/octet-stream';

    $response = RSApache::Response::Download->new($fh, $contentType, $prettyFileName, $fileSize);
	return $response;
}

1;
