Class LiquibaseRunnerContext
- java.lang.Object
-
- fr.paris.lutece.plugins.liquibase.LiquibaseRunnerContext
-
public class LiquibaseRunnerContext extends java.lang.ObjectStatic context holder for shared data during a liquibase run. This class offers a static API so that filters instantiated by liquibase can access its state.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceLiquibaseRunnerContext.ResultSetExtractor<T>Because Functiondoes not throw
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLAST_RUN_SCRIPT_TYPE_CREATELast run script type (create/init)static java.lang.StringLAST_RUN_SCRIPT_TYPE_UPDATELast run script type (update)
-
Constructor Summary
Constructors Constructor Description LiquibaseRunnerContext()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static fr.paris.lutece.utils.sql.PluginVersioncomponentVersion(fr.paris.lutece.utils.sql.SqlPathInfo info)Looks the component version in the DB.static java.sql.ConnectiongetConnection()static booleanisAcceptSnapshotVersion()static booleanisAcceptUnstableVersion()static booleanisEmptyDb()static booleanisEnableMigrationMode()Migration mode is enabled when the property "liquibase.migration.mode" is set to truestatic booleanisLiquibaseNeverRan()static java.lang.StringpluginLastRunScriptType(java.lang.String pluginName)Looks the type of the last run script (create/init or update) in the DB.static voidreportInvalidPrerun(java.lang.String path)Reports a prerun_db_* file that does not sit at its component's expected path (sql/plugins/<plugin>[/modules/<module>]/plugin/prerun_db_<component>.sql), or whose component is declared by no plugin descriptor : a packaging fault, handled like an unresolved component (LUT-33232).static voidreportUnresolvedComponent(java.lang.String path, java.lang.String componentName)Reports a SQL file whose path resolves to a component declared by no plugin descriptor (nor themes.<name>.version property).static voidsetComponentVersion(java.lang.String componentName, java.lang.String version, boolean isTheme)Sets the plugin version in the datastore (later, when all SQL files have been executed)static voidsetPluginLastRunScriptType(java.lang.String pluginName, java.lang.String strLastRunTypeScript)Sets the type of the last run script (create/init or update) in the datastore (later, when all SQL files have been executed)static voidsetThemeLastRunScriptType(java.lang.String themeName, java.lang.String strLastRunTypeScript)Sets the type of the last run script (create/init or update) in the datastore (later, when all SQL files have been executed)
-
-
-
Field Detail
-
LAST_RUN_SCRIPT_TYPE_CREATE
public static final java.lang.String LAST_RUN_SCRIPT_TYPE_CREATE
Last run script type (create/init)- See Also:
- Constant Field Values
-
LAST_RUN_SCRIPT_TYPE_UPDATE
public static final java.lang.String LAST_RUN_SCRIPT_TYPE_UPDATE
Last run script type (update)- See Also:
- Constant Field Values
-
-
Method Detail
-
isEmptyDb
public static boolean isEmptyDb()
-
isLiquibaseNeverRan
public static boolean isLiquibaseNeverRan()
-
isAcceptSnapshotVersion
public static boolean isAcceptSnapshotVersion()
-
isAcceptUnstableVersion
public static boolean isAcceptUnstableVersion()
-
isEnableMigrationMode
public static boolean isEnableMigrationMode()
Migration mode is enabled when the property "liquibase.migration.mode" is set to true
-
getConnection
public static java.sql.Connection getConnection()
-
componentVersion
public static fr.paris.lutece.utils.sql.PluginVersion componentVersion(fr.paris.lutece.utils.sql.SqlPathInfo info) throws java.sql.SQLExceptionLooks the component version in the DB. "core" is a special case and always has a version : Integer.MAX_VALUE if no true version can be found, which is newer than all other versions and ensures that no attempt to run any core scripts is attempted when running liquibase for the first time on a existing DB.- Returns:
- the version as a string (for example "1.0.1"), or null if not found
- Throws:
java.sql.SQLException
-
reportUnresolvedComponent
public static void reportUnresolvedComponent(java.lang.String path, java.lang.String componentName)Reports a SQL file whose path resolves to a component declared by no plugin descriptor (nor themes.<name>.version property). This is a packaging fault (LUT-33232) : the file's directory and the shipping artifact's descriptor disagree. When liquibase.safeRun is true (the default), startup is aborted before any changeset is executed (this method is called while liquibase parses the changelog, before execution). Otherwise the fault is only logged, and the caller excludes the file.- Parameters:
path- the SQL file pathcomponentName- the unresolved component name derived from the path
-
reportInvalidPrerun
public static void reportInvalidPrerun(java.lang.String path)
Reports a prerun_db_* file that does not sit at its component's expected path (sql/plugins/<plugin>[/modules/<module>]/plugin/prerun_db_<component>.sql), or whose component is declared by no plugin descriptor : a packaging fault, handled like an unresolved component (LUT-33232).- Parameters:
path- the misplaced or misnamed pre-execution SQL file path
-
pluginLastRunScriptType
public static java.lang.String pluginLastRunScriptType(java.lang.String pluginName)
Looks the type of the last run script (create/init or update) in the DB.- Parameters:
pluginName- a name such as 'forms'- Returns:
- the type of the last run script as a string ("create/init" or "update"), or null if not found
- Throws:
java.sql.SQLException
-
setComponentVersion
public static void setComponentVersion(java.lang.String componentName, java.lang.String version, boolean isTheme)Sets the plugin version in the datastore (later, when all SQL files have been executed)- Parameters:
pluginName-version-
-
setPluginLastRunScriptType
public static void setPluginLastRunScriptType(java.lang.String pluginName, java.lang.String strLastRunTypeScript)Sets the type of the last run script (create/init or update) in the datastore (later, when all SQL files have been executed)- Parameters:
pluginName-version-
-
setThemeLastRunScriptType
public static void setThemeLastRunScriptType(java.lang.String themeName, java.lang.String strLastRunTypeScript)Sets the type of the last run script (create/init or update) in the datastore (later, when all SQL files have been executed)- Parameters:
pluginName-version-
-
-