Top Description Inners Fields Constructors Methods
liquibase.integration.commandline

public Class Main

extends Object
Class Inheritance
Imports
liquibase.*, liquibase.changelog.ChangeLogParameters, liquibase.changelog.visitor.ChangeExecListener, .DefaultChangeExecListener, liquibase.command.CommandResults, .CommandScope, liquibase.command.core.*, liquibase.command.core.helpers.*, liquibase.configuration.ConfiguredValue, .LiquibaseConfiguration, liquibase.configuration.core.DeprecatedConfigurationValueProvider, liquibase.database.Database, liquibase.database.jvm.JdbcConnection, liquibase.exception.*, liquibase.integration.IntegrationDetails, liquibase.io.WriterOutputStream, liquibase.license.LicenseInstallResult, .LicenseService, .LicenseServiceFactory, .Location, liquibase.logging.LogService, .Logger, liquibase.logging.core.JavaLogService, liquibase.logging.mdc.MdcKey, liquibase.resource.ClassLoaderResourceAccessor, .CompositeResourceAccessor, .DirectoryResourceAccessor, .ResourceAccessor, liquibase.ui.CompositeUIService, .ConsoleUIService, .LoggerUIService, .UIService, liquibase.util.ISODateFormat, .LiquibaseUtil, .StringUtil, .SystemUtil, java.io.*, java.lang.reflect.Field, java.net.MalformedURLException, .URL, .URLClassLoader, java.nio.file.Files, .Paths, java.security.AccessController, .PrivilegedAction, java.text.MessageFormat, .ParseException, java.util.*, java.util.jar.JarEntry, .JarFile, java.util.logging.*

Deprecated

use liquibase.integration.commandline.LiquibaseCommandLine.

Class for executing Liquibase via the command line.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
private static enum
private static enum
private static enum

Field Summary

Modifier and TypeField and Description
protected String
protected String
protected String
protected Map<String, Object>
protected String
protected String
protected ClassLoader
protected String
protected String
protected Set<String>
protected String
private static final ResourceBundle
protected String
protected String
protected String
protected String
protected String
protected String
protected Boolean
protected String
protected String
protected String
protected String
protected String
protected String
protected String
private static final String
protected String
protected String
protected Boolean
protected String
protected Boolean
protected Boolean
protected Boolean
protected String
protected String
protected String
protected String
protected String
private static final Logger
protected String
protected String
private static final Boolean
public static Map<String, String>
protected String
protected String
protected String
protected String
private static final boolean
private static PrintStream
protected String
protected String
protected Boolean
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected Boolean
protected String
public static boolean
protected List<CatalogAndSchema>
protected String
protected String
protected String
protected String
private static final int[]
protected String
protected String

Constructor Summary

AccessConstructor and Description
public
Main()

Method Summary

Modifier and TypeMethod and Description
private static void
addWarFileClasspathEntries(File classPathFile, List<URL> urls)

protected void
protected static Main.CodePointCheck

Returns:

int A CodePointCheck object, or null to indicate all good
checkArg
(String
Input parameter to check
arg
)

Check the string for known characters which cannot be handled

private void
checkForMalformedCommandParameters(final List<String>
an array of Strings to which messages for issues found will be added
messages
)

Checks for incorrectly written command line parameters and, if any problems are found, returns the list of issues in String form.

private void
checkForMissingCommandParameters(final List<String>
an array of Strings to which messages for issues found will be added
messages
)

Checks for missing command line parameters and, if any problems are found, returns the list of issues in String form.

private void
checkForUnexpectedCommandParameter(List<String>
an array of Strings to which messages for issues found will be added
messages
)

Checks for unexpected (unknown) command line parameters and, if any problems are found, returns the list of issues in String form.

protected List<String>

Returns:

an empty List if successful, or a list of error messages
checkSetup
()

After parsing, checks if the given combination of main command and can be executed.

protected ClassLoader
private CommandScope
createLiquibaseCommand(Database database, Liquibase liquibase, String commandName, Map<String, Object> argsMap)

protected void
doMigration()

Do the actual database migration, i.e. apply the ChangeSets.

private static File

Returns:

a File object with the temporary file containing the extracted object
extract
(JarFile
the JAR file from which we will extract
jar
,
JarEntry
the object inside the JAR file that to be extracted
entry
)

Extract a single object from a JAR file into a temporary file.

protected String[]
fixupArgs(String[] args)

On windows machines, it splits args on '=' signs.

private String

Returns:

the command argument, if one is given. Otherwise null.
getCommandArgument
()

Return the first "parameter" from the command line that does NOT have the form of parameter=value.

private String

Returns:

the user-specified value for paramName, or defaultValue
getCommandParam
(String
name of the parameter
paramName
,
String
return value if parameter is not given
defaultValue
)

Returns the value for a command line parameter of the form parameterName=value, or defaultValue if that parameter has not been specified by the user.

private Field
getDeclaredField(String attributeName)

private ResourceAccessor
getFileOpenerResourceAccessor()

Encapsulate code used to load the correct resource accessor providing legacy Cli compatibility

private String
private OutputStream
private Writer
private String
private void
handleUpdateException(Database database, LiquibaseException exception, DefaultChangeExecListener defaultChangeExecListener, boolean rollbackOnError)

private static boolean

Returns:

true if a ChangeLog is required, false if not.
isChangeLogRequired
(String
the command to test
command
)

Returns true if the parameter --changeLogFile is requited for a given command

private static boolean

Returns:

true if it is a valid main command, false if not
isCommand
(String
the String to test
arg
)

Returns true if the given arg is a valid main command of Liquibase.

private boolean
private static boolean

Returns:

true if arg is a valid main command and needs no special parameters, false in all other cases
isNoArgCommand
(String
the main command to test
arg
)

Returns true if the given main command arg needs no special parameters.

private static boolean

Returns:

true if stdout needs for a command, false if not
isStandardOutputRequired
(String
the command to check
command
)

Returns true if the given command requires stdout

public boolean

Returns:

true if running under some variant of MS Windows, false otherwise.
isWindows
()

Determines if this program is executed on a Microsoft Windows-type of operating system.

private void
public static void
main(String[]
the command line arguments
args
)

Entry point.

private void
parseDefaultPropertyFileFromFile(final File
path and file name to the the property file
potentialPropertyFile
)

Open a regular property file (not embedded in a resource - use parseDefaultPropertyFileFromResource for that) and parse it.

private void
parseDefaultPropertyFileFromResource(File
location and file name of the property file
potentialPropertyFile
)

Open a property file that is embedded as a Java resource and parse it.

protected void
parseDefaultPropertyFiles()

Search for both liquibase.properties (or whatever the name of the current defaultsFile is) and the "local" variant liquibase.local.properties.

private static Level
parseLogLevel(String logLevelName, UIService ui)

private void
parseOptionArgument(String
the option to parse (including the "--")
arg
,
boolean okIfNotAField)

Parses an option ("--someOption") from the command line

protected void
parseOptions(String[]
the arguments to parse
paramArgs
)

Parses the command line options.

protected void
parsePropertiesFile(InputStream
an InputStream from a Java properties file
propertiesInputStream
)

Reads various execution parameters from an InputStream and sets our internal state according to the values found.

private void
parsePropertiesFileForNewCli(Properties props)

Most of the properties file is handled by the new CLI.

protected void
printHelp(List<String>
List of error messages
errorMessages
,
PrintStream
the output stream to write the text to
stream
)

If any errors have been found, print the list of errors first, then print the command line help text.

protected void
printHelp(PrintStream
the output stream to write the help text to
stream
)

Print instructions on how to use this program from the command line.

public static int

Returns:

the errorlevel to be returned to the operating system, e.g. for further processing by scripts
run
(String[]
the command line arguments
args
)

Process the command line arguments and perform the appropriate main action (update, rollback etc.)

private void
private void
private void
private void
private void
private void
runRollbackCommand(Writer outputWriter)

private void
private void
private void
private void
private void
private void
private void
runUsingCommandFramework()

Run commands using the CommandFramework instead of directly setting up and calling other classes

private void
setDatabaseArgumentsToCommand(CommandScope command)

Set database arguments values received by Main class to the provided command scope.

protected static void
setLogLevel(LogService logService, Logger rootLogger, Logger liquibaseLogger, Level level)

public static PrintStream
setOutputStream(PrintStream outputStream)

Sets the default outputstream to use.

private void
setPreCompareArgumentsToCommand(CommandScope command)

Set database compare arguments values received by Main class to the provided command scope.

private void
setReferenceDatabaseArgumentsToCommand(CommandScope command)

Set reference database arguments values received by Main class to the provided command scope.

private static boolean
setupNeeded(Main main)
References Deprecated Main is deprecated or references (maybe indirectly) at least one deprecated element.

private static String[]

Returns:

An array of exactly 2 entries
splitArg
(String
The String expression to split
arg
)

Splits a String of the form "key=value" into the respective parts.

private void
validateCommandParameters(final List<String>
an array of Strings to which messages for issues found will be added
messages
)

Checks the command line for correctness and reports on unexpected, missing and/or malformed parameters.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait