org.unitils.dbmaintainer.script.impl.DefaultScriptSource Maven / Gradle / Ivy
/*
* Copyright 2008, Unitils.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.unitils.dbmaintainer.script.impl;
import static org.unitils.util.PropertyUtils.getStringList;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.unitils.core.UnitilsException;
import org.unitils.core.util.BaseConfigurable;
import org.unitils.dbmaintainer.script.ExecutedScript;
import org.unitils.dbmaintainer.script.Script;
import org.unitils.dbmaintainer.script.ScriptContentHandle;
import org.unitils.dbmaintainer.script.ScriptSource;
import org.unitils.dbmaintainer.version.Version;
import org.unitils.util.FileUtils;
import org.unitils.util.PropertyUtils;
/**
* Implementation of {@link ScriptSource} that reads script files from the filesystem. Script
* files should be located in the directory configured by {@link #PROPKEY_SCRIPT_LOCATIONS}.
* Valid script files start with a version number followed by an underscore, and end with the
* extension configured by {@link #PROPKEY_SCRIPT_EXTENSIONS}.
*
* @author Filip Neven
* @author Tim Ducheyne
*/
public class DefaultScriptSource extends BaseConfigurable implements ScriptSource {
/* Logger instance for this class */
private static final Log logger = LogFactory.getLog(DefaultScriptSource.class);
/**
* Property key for the directory in which the script files are located
*/
public static final String PROPKEY_SCRIPT_LOCATIONS = "dbMaintainer.script.locations";
/**
* Property key for the extension of the script files
*/
public static final String PROPKEY_SCRIPT_EXTENSIONS = "dbMaintainer.script.fileExtensions";
/**
* Property key for the directory in which the code script files are located
*/
public static final String PROPKEY_POSTPROCESSINGSCRIPT_DIRNAME = "dbMaintainer.postProcessingScript.directoryName";
public static final String PROPKEY_USESCRIPTFILELASTMODIFICATIONDATES = "dbMaintainer.useScriptFileLastModificationDates.enabled";
protected List