#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2010 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#---------------------------------------------------------------
package BookPub::Tracker::Command::DownloadRoyaltyReport::RowmanLittlefield;
use strict;
use warnings;

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

sub getResponse {
    my ( $self, $report ) = @_;

    my $periodID = $report->periodID();
    my $tempdir = File::Temp::tempdir( "/tmp/dmtv_346_" . $periodID . "XXXXXXXX", CLEANUP => 1 );

    # Let's create symlinks for the two output files that we want to zip up.
    #
    my $baseDir               = $report->_baseDir();
    my $salesOutputFileName   = $report->fileName();
    my $returnsOutputFileName = $report->returnsFileName();

    system("ln -s $baseDir/$salesOutputFileName $tempdir/$salesOutputFileName");
    system("ln -s $baseDir/$returnsOutputFileName $tempdir/$returnsOutputFileName");

    my $response = RSApache::Response::DownloadZipDirectory->new( $tempdir, 'application/octet-stream', $report->zipFileName() );

    return $response;
}

1;
