Search in sources :

Example 11 with ChangeLogParser

use of liquibase.parser.ChangeLogParser in project liquibase by liquibase.

the class RegisterChangelogCommandStep method parseChangeLogFile.

private DatabaseChangeLog parseChangeLogFile(String changeLogFile) throws LiquibaseException {
    ResourceAccessor resourceAccessor = Scope.getCurrentScope().getResourceAccessor();
    ChangeLogParser parser = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor);
    ChangeLogParameters changeLogParameters = new ChangeLogParameters();
    return parser.parse(changeLogFile, changeLogParameters, resourceAccessor);
}
Also used : ResourceAccessor(liquibase.resource.ResourceAccessor) ChangeLogParameters(liquibase.changelog.ChangeLogParameters) ChangeLogParser(liquibase.parser.ChangeLogParser)

Example 12 with ChangeLogParser

use of liquibase.parser.ChangeLogParser in project keycloak by keycloak.

the class QuarkusLiquibaseConnectionProvider method baseLiquibaseInitialization.

protected void baseLiquibaseInitialization(KeycloakSession session) {
    resourceAccessor = new ClassLoaderResourceAccessor(getClass().getClassLoader());
    // disables XML validation
    for (ChangeLogParser parser : ChangeLogParserFactory.getInstance().getParsers()) {
        if (parser instanceof XMLChangeLogSAXParser) {
            Method getSaxParserFactory = null;
            try {
                getSaxParserFactory = XMLChangeLogSAXParser.class.getDeclaredMethod("getSaxParserFactory");
                getSaxParserFactory.setAccessible(true);
                SAXParserFactory saxParserFactory = (SAXParserFactory) getSaxParserFactory.invoke(parser);
                saxParserFactory.setValidating(false);
                saxParserFactory.setSchema(null);
            } catch (Exception e) {
                logger.warnf("Failed to disable liquibase XML validations");
            } finally {
                if (getSaxParserFactory != null) {
                    getSaxParserFactory.setAccessible(false);
                }
            }
        }
    }
}
Also used : ChangeLogParser(liquibase.parser.ChangeLogParser) XMLChangeLogSAXParser(liquibase.parser.core.xml.XMLChangeLogSAXParser) Method(java.lang.reflect.Method) ClassLoaderResourceAccessor(liquibase.resource.ClassLoaderResourceAccessor) LiquibaseException(liquibase.exception.LiquibaseException) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Aggregations

ChangeLogParser (liquibase.parser.ChangeLogParser)12 ChangeLogParameters (liquibase.changelog.ChangeLogParameters)5 ResourceAccessor (liquibase.resource.ResourceAccessor)5 XMLChangeLogSAXParser (liquibase.parser.core.xml.XMLChangeLogSAXParser)4 File (java.io.File)3 MockChangeLogParser (liquibase.parser.MockChangeLogParser)3 SqlChangeLogParser (liquibase.parser.core.sql.SqlChangeLogParser)3 ClassLoaderResourceAccessor (liquibase.resource.ClassLoaderResourceAccessor)3 Test (org.junit.Test)3 FileOutputStream (java.io.FileOutputStream)2 ArrayList (java.util.ArrayList)2 DatabaseChangeLog (liquibase.changelog.DatabaseChangeLog)2 PreconditionContainer (liquibase.precondition.core.PreconditionContainer)2 CompositeResourceAccessor (liquibase.resource.CompositeResourceAccessor)2 FileSystemResourceAccessor (liquibase.resource.FileSystemResourceAccessor)2 ChangeLogSerializer (liquibase.serializer.ChangeLogSerializer)2 JUnitResourceAccessor (liquibase.test.JUnitResourceAccessor)2 Method (java.lang.reflect.Method)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 CommandResult (liquibase.command.CommandResult)1