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.Calendar;
019    
020    import org.apache.commons.io.filefilter.AgeFileFilter;
021    import org.apache.commons.io.filefilter.AndFileFilter;
022    import org.apache.commons.io.filefilter.IOFileFilter;
023    import org.kuali.kfs.sys.batch.service.FilePurgeService;
024    import org.kuali.kfs.sys.context.SpringContext;
025    import org.kuali.rice.kns.service.DateTimeService;
026    
027    /**
028     * A customized age for a file prefix.
029     */
030    public class FilePurgeCustomAge {
031    
032        private String directory;
033        private String parameterPrefix;
034        
035        /**
036         * Gets the directory attribute. 
037         * @return Returns the directory.
038         */
039        public String getDirectory() {
040            return directory;
041        }
042        /**
043         * Sets the directory attribute value.
044         * @param directory The directory to set.
045         */
046        public void setDirectory(String directory) {
047            this.directory = directory;
048        }
049        /**
050         * Gets the parameterPrefix attribute. 
051         * @return Returns the parameterPrefix.
052         */
053        public String getParameterPrefix() {
054            return parameterPrefix;
055        }
056        /**
057         * Sets the parameterPrefix attribute value.
058         * @param parameterPrefix The parameterPrefix to set.
059         */
060        public void setParameterPrefix(String parameterPrefix) {
061            this.parameterPrefix = parameterPrefix;
062        }
063        
064        /**
065         * @return an IOFileFilter which represents the files that should be culled by this FilePurgeCustomAge
066         */
067        public IOFileFilter getFileFilter() {
068            AndFileFilter andFileFilter = new AndFileFilter();
069            MaxAgePurgeFileFilter maxAgeFilter = new MaxAgePurgeFileFilter(this);
070            DirectoryNameFileFilter directoryNameFilter = new DirectoryNameFileFilter(this);
071            andFileFilter.addFileFilter(maxAgeFilter);
072            andFileFilter.addFileFilter(directoryNameFilter);
073            return andFileFilter;
074        }
075        
076    }