liquibase.resource.ResourceAccessor Java Examples

The following examples show how to use liquibase.resource.ResourceAccessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LiquibaseIT.java    From liquibase-spatial with Apache License 2.0 6 votes vote down vote up
/**
 * Tests Liquibase updating the database.
 *
 * @param changeLogFile
 *           the database change log to use in the {@link Liquibase#update(Contexts) update}.
 * @throws LiquibaseException
 *            if Liquibase fails to initialize or run the update.
 * @throws SQLException
 *            if unable to get the database connection.
 */
@Test(dataProvider = "databaseUrlProvider")
public void testLiquibaseUpdate(final String changeLogFile) throws LiquibaseException,
SQLException {
   final Connection connection = getConnection();
   final JdbcConnection jdbcConnection = new JdbcConnection(connection);
   try {
      final ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
      final Liquibase liquibase = createLiquibase(changeLogFile, resourceAccessor,
            jdbcConnection);
      final Contexts contexts = null;
      liquibase.update(contexts);
      final List<ChangeSet> unrunChangeSets = liquibase.listUnrunChangeSets(contexts);
      assertTrue(unrunChangeSets.isEmpty(), "All change sets should have run");
   } finally {
      jdbcConnection.rollback();
      jdbcConnection.close();
   }
}
 
Example #2
Source File: LiquibaseIT.java    From liquibase-spatial with Apache License 2.0 6 votes vote down vote up
/**
 * Tests Liquibase updating and rolling back the database.
 *
 * @param changeLogFile
 *           the database change log to use in the {@link Liquibase#update(Contexts) update}.
 * @throws LiquibaseException
 *            if Liquibase fails to initialize or run the update.
 * @throws SQLException
 *            if unable to get the database connection.
 */
@Test(dataProvider = "databaseUrlProvider", enabled = false)
public void testLiquibaseUpdateTestingRollback(final String changeLogFile)
      throws LiquibaseException, SQLException {
   final Connection connection = getConnection();
   final JdbcConnection jdbcConnection = new JdbcConnection(connection);
   try {
      final ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
      final Liquibase liquibase = createLiquibase(changeLogFile, resourceAccessor,
            jdbcConnection);
      final Contexts contexts = null;
      final LabelExpression labels = new LabelExpression();
      liquibase.updateTestingRollback(contexts, labels);
      final List<ChangeSet> unrunChangeSets = liquibase.listUnrunChangeSets(contexts, labels);
      assertTrue(unrunChangeSets.isEmpty(), "All change sets should have run");
   } finally {
      jdbcConnection.rollback();
      jdbcConnection.close();
   }
}
 
Example #3
Source File: QuarkusLiquibaseConnectionProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public Liquibase getLiquibaseForCustomUpdate(Connection connection, String defaultSchema, String changelogLocation, ClassLoader classloader, String changelogTableName) throws LiquibaseException {
    Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
    if (defaultSchema != null) {
        database.setDefaultSchemaName(defaultSchema);
    }

    ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor(classloader);
    database.setDatabaseChangeLogTableName(changelogTableName);

    logger.debugf("Using changelog file %s and changelogTableName %s", changelogLocation, database.getDatabaseChangeLogTableName());

    return new Liquibase(changelogLocation, resourceAccessor, database);
}
 
Example #4
Source File: DefaultLiquibaseConnectionProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public Liquibase getLiquibaseForCustomUpdate(Connection connection, String defaultSchema, String changelogLocation, ClassLoader classloader, String changelogTableName) throws LiquibaseException {
    Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
    if (defaultSchema != null) {
        database.setDefaultSchemaName(defaultSchema);
    }

    ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor(classloader);
    database.setDatabaseChangeLogTableName(changelogTableName);

    logger.debugf("Using changelog file %s and changelogTableName %s", changelogLocation, database.getDatabaseChangeLogTableName());

    return new Liquibase(changelogLocation, resourceAccessor, database);
}
 
Example #5
Source File: DefaultLiquibaseConnectionProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public Liquibase getLiquibase(Connection connection, String defaultSchema) throws LiquibaseException {
    Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
    if (defaultSchema != null) {
        database.setDefaultSchemaName(defaultSchema);
    }

    String changelog = LiquibaseJpaUpdaterProvider.CHANGELOG;
    ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor(getClass().getClassLoader());

    logger.debugf("Using changelog file %s and changelogTableName %s", changelog, database.getDatabaseChangeLogTableName());
    
    return new Liquibase(changelog, resourceAccessor, database);
}
 
Example #6
Source File: LiquibaseProducer.java    From tutorials with MIT License 5 votes vote down vote up
@Produces
public Liquibase produceLiquibase() throws Exception {
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    ResourceAccessor classLoaderResourceAccessor = new ClassLoaderResourceAccessor(classLoader);
    Liquibase liquibase = new Liquibase(liquibaseConfig.changeLog, classLoaderResourceAccessor, new JdbcConnection(dataSource.getConnection()));
    return liquibase;
}
 
Example #7
Source File: LiquibaseH2AsSAIT.java    From liquibase-spatial with Apache License 2.0 5 votes vote down vote up
/**
 * @see liquibase.ext.spatial.LiquibaseIT#createLiquibase(java.lang.String,
 *      liquibase.resource.ResourceAccessor, liquibase.database.DatabaseConnection)
 */
@Override
protected Liquibase createLiquibase(final String changeLogFile,
      final ResourceAccessor resourceAccessor, final DatabaseConnection databaseConnection)
      throws LiquibaseException {
   final Liquibase liquibase = super.createLiquibase(changeLogFile, resourceAccessor,
         databaseConnection);
   liquibase.getDatabase().setDefaultSchemaName(getUserName());
   return liquibase;
}
 
Example #8
Source File: LiquibasePostgreSQLIT.java    From liquibase-spatial with Apache License 2.0 5 votes vote down vote up
/**
 * @see liquibase.ext.spatial.LiquibaseIT#createLiquibase(java.lang.String,
 *      liquibase.resource.ResourceAccessor, liquibase.database.DatabaseConnection)
 */
@Override
protected Liquibase createLiquibase(final String changeLogFile,
      final ResourceAccessor resourceAccessor, final DatabaseConnection databaseConnection)
      throws LiquibaseException {
   final Liquibase liquibase = super.createLiquibase(changeLogFile, resourceAccessor,
         databaseConnection);
   liquibase.getDatabase().setDefaultSchemaName(getUserName());
   return liquibase;
}
 
Example #9
Source File: SpatialIndexExistsPrecondition.java    From liquibase-spatial with Apache License 2.0 5 votes vote down vote up
/**
 * @see liquibase.precondition.Precondition#load(liquibase.parser.core.ParsedNode,
 *      liquibase.resource.ResourceAccessor)
 */
@Override
public void load(final ParsedNode parsedNode, final ResourceAccessor resourceAccessor)
      throws ParsedNodeException {
   final String namespace = null;
   this.catalogName = parsedNode.getChildValue(namespace, "catalogName", String.class);
   this.schemaName = parsedNode.getChildValue(namespace, "schemaName", String.class);
   this.tableName = parsedNode.getChildValue(namespace, "tableName", String.class);
   this.columnNames = parsedNode.getChildValue(namespace, "columnNames", String.class);
   this.indexName = parsedNode.getChildValue(namespace, "indexName", String.class);
}
 
Example #10
Source File: LiquibaseFactory.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the liquibase instance.
 * 
 * @return the liquibase.
 */
public Liquibase createLiquibase() {
    try {
        ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor(Thread.currentThread().getContextClassLoader());

        Database database = DatabaseFactory.getInstance()
                .findCorrectDatabaseImplementation(new JdbcConnection(dataSource.getConnection()));
        ;
        if (database != null) {
            database.setDatabaseChangeLogLockTableName(config.databaseChangeLogLockTableName);
            database.setDatabaseChangeLogTableName(config.databaseChangeLogTableName);
            config.liquibaseCatalogName.ifPresent(database::setLiquibaseCatalogName);
            config.liquibaseSchemaName.ifPresent(database::setLiquibaseSchemaName);
            config.liquibaseTablespaceName.ifPresent(database::setLiquibaseTablespaceName);

            if (config.defaultCatalogName.isPresent()) {
                database.setDefaultCatalogName(config.defaultCatalogName.get());
            }
            if (config.defaultSchemaName.isPresent()) {
                database.setDefaultSchemaName(config.defaultSchemaName.get());
            }
        }
        return new Liquibase(config.changeLog, resourceAccessor, database);

    } catch (Exception ex) {
        throw new IllegalStateException(ex);
    }
}
 
Example #11
Source File: FlatCollection.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resourceAccessor)
{

}
 
Example #12
Source File: GenerateSearchUUIDs.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}
 
Example #13
Source File: GenerateRestrictionUUIDs.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}
 
Example #14
Source File: EncryptExistingUserPasswords.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}
 
Example #15
Source File: ForceEncryptPassword.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resourceAccessor)
{

}
 
Example #16
Source File: UserSettingsJsonTablePopulation.java    From airsonic-advanced with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener(ResourceAccessor resourceAccessor) {
}
 
Example #17
Source File: GeneratePreferenceUUIDs.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}
 
Example #18
Source File: TransformActionRecordUsers.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}
 
Example #19
Source File: GenerateCollectionUUIDs.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}
 
Example #20
Source File: DataManagerRoleCreation.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}
 
Example #21
Source File: TransformUserCountry.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}
 
Example #22
Source File: GenerateUserUUIDs.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}
 
Example #23
Source File: CopyProductImages.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}
 
Example #24
Source File: ExtractProductDatesAndDownloadSize.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}
 
Example #25
Source File: SpatialSupportedPrecondition.java    From liquibase-spatial with Apache License 2.0 4 votes vote down vote up
/**
 * @see liquibase.precondition.Precondition#load(liquibase.parser.core.ParsedNode,
 *      liquibase.resource.ResourceAccessor)
 */
@Override
public void load(final ParsedNode parsedNode, final ResourceAccessor resourceAccessor)
      throws ParsedNodeException {
}
 
Example #26
Source File: RemoveDuplicateRoles.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resourceAccessor)
{
}
 
Example #27
Source File: UserRolesJsonColumnPopulation.java    From airsonic-advanced with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener(ResourceAccessor resourceAccessor) {
}
 
Example #28
Source File: AbstractChange.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
@Override
public void setFileOpener(ResourceAccessor resourceAccessor) {
}
 
Example #29
Source File: MoveOwnerInProduct.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}
 
Example #30
Source File: RemoveLFUStrategy.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFileOpener (ResourceAccessor resource_accessor)
{
}