001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.sys.batch; 017 018 import java.util.Date; 019 import java.util.HashMap; 020 import java.util.List; 021 022 import org.kuali.kfs.sys.batch.service.FilePurgeService; 023 024 /** 025 * 026 * Purges old files from the reports directory specified in build.properties 027 */ 028 public class FilePurgeStep extends AbstractStep { 029 030 private List<String> directories; 031 private List<FilePurgeCustomAge> customAges; 032 private FilePurgeService filePurgeService; 033 034 /** 035 * Deletes all files in the temporary directory that are over 1 day old 036 * 037 * @see org.kuali.kfs.sys.batch.Step#execute(String, Date) 038 */ 039 public boolean execute(String jobName, Date jobRunDate) throws InterruptedException { 040 for (String directory : directories) { 041 getFilePurgeService().purgeFiles(directory, customAges); 042 } 043 044 return true; 045 } 046 047 /** 048 * Gets the directories attribute. 049 * @return Returns the directories. 050 */ 051 public List getDirectories() { 052 return directories; 053 } 054 055 /** 056 * Sets the directories attribute value. 057 * @param directories The directories to set. 058 */ 059 public void setDirectories(List directories) { 060 this.directories = directories; 061 } 062 063 /** 064 * Gets the customAges attribute. 065 * @return Returns the customAges. 066 */ 067 public List getCustomAges() { 068 return customAges; 069 } 070 071 /** 072 * Sets the customAges attribute value. 073 * @param customAges The customAges to set. 074 */ 075 public void setCustomAges(List customAge) { 076 this.customAges = customAge; 077 } 078 079 /** 080 * Gets the filePurgeService attribute. 081 * @return Returns the filePurgeService. 082 */ 083 public FilePurgeService getFilePurgeService() { 084 return filePurgeService; 085 } 086 087 /** 088 * Sets the filePurgeService attribute value. 089 * @param filePurgeService The filePurgeService to set. 090 */ 091 public void setFilePurgeService(FilePurgeService filePurgeService) { 092 this.filePurgeService = filePurgeService; 093 } 094 }