1 /* 2 * Copyright 2007-2009 The Kuali Foundation 3 * 4 * Licensed under the Educational Community License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.opensource.org/licenses/ecl2.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.kuali.ole.sys.batch; 17 18 import java.util.Date; 19 import java.util.List; 20 21 import org.kuali.ole.sys.batch.service.FilePurgeService; 22 23 /** 24 * 25 * Purges old files from the reports directory specified in build.properties 26 */ 27 public class FilePurgeStep extends AbstractStep { 28 29 private List<String> directories; 30 private List<FilePurgeCustomAge> customAges; 31 private FilePurgeService filePurgeService; 32 33 /** 34 * @see org.kuali.ole.sys.batch.AbstractStep#getRequiredDirectoryNames() 35 */ 36 @Override 37 public List<String> getRequiredDirectoryNames() { 38 return directories; 39 } 40 41 /** 42 * Deletes all files in the temporary directory that are over 1 day old 43 * 44 * @see org.kuali.ole.sys.batch.Step#execute(String, Date) 45 */ 46 public boolean execute(String jobName, Date jobRunDate) throws InterruptedException { 47 for (String directory : directories) { 48 getFilePurgeService().purgeFiles(directory, customAges); 49 } 50 51 return true; 52 } 53 54 /** 55 * Gets the directories attribute. 56 * @return Returns the directories. 57 */ 58 public List<String> getDirectories() { 59 return directories; 60 } 61 62 /** 63 * Sets the directories attribute value. 64 * @param directories The directories to set. 65 */ 66 public void setDirectories(List<String> directories) { 67 this.directories = directories; 68 } 69 70 /** 71 * Gets the customAges attribute. 72 * @return Returns the customAges. 73 */ 74 public List<FilePurgeCustomAge> getCustomAges() { 75 return customAges; 76 } 77 78 /** 79 * Sets the customAges attribute value. 80 * @param customAges The customAges to set. 81 */ 82 public void setCustomAges(List<FilePurgeCustomAge> customAge) { 83 this.customAges = customAge; 84 } 85 86 /** 87 * Gets the filePurgeService attribute. 88 * @return Returns the filePurgeService. 89 */ 90 public FilePurgeService getFilePurgeService() { 91 return filePurgeService; 92 } 93 94 /** 95 * Sets the filePurgeService attribute value. 96 * @param filePurgeService The filePurgeService to set. 97 */ 98 public void setFilePurgeService(FilePurgeService filePurgeService) { 99 this.filePurgeService = filePurgeService; 100 } 101 }