public String execute() throws Exception
{
User user = SharedUtils.getUser(userDAO);
Job j = jobDAO.getJobByIdForUser(jobId, user);
if(j != null)
{
if(type.equals("upload"))
{
srcLocation = j.createOriginalPath();
setContentDisposition("attachment; filename=" + j.getJobName() + "_input.zip");
}
else if(type.equals("output"))
{
//The job must be finished first before you can download!
if(j.getJobStatus() == STATUS.FINISHED || j.getPreprocessorStatus() == STATUS.FAILED)
{
File outputZip = new File(j.createOutputZipFilePath());
setContentDisposition("attachment; filename=" + j.getJobName() + "_output.zip");
if(outputZip.exists())
{
outputZip.delete();
}
if(outputZip.createNewFile())
{
ZipFunctions.compressDirectory(j.createScriptOutputDir(), outputZip.getAbsolutePath());
srcLocation = outputZip.getAbsolutePath();
}
else
{
this.addActionError("Error while creating the download package. Please contact the site administrator for help.");