Search in sources :

Example 6 with ChangeLogSerializer

use of liquibase.serializer.ChangeLogSerializer in project liquibase by liquibase.

the class GenerateChangeLogTask method executeWithLiquibaseClassloader.

@Override
public void executeWithLiquibaseClassloader() throws BuildException {
    Liquibase liquibase = getLiquibase();
    Database database = liquibase.getDatabase();
    CatalogAndSchema catalogAndSchema = buildCatalogAndSchema(database);
    DiffOutputControl diffOutputControl = getDiffOutputControl();
    DiffToChangeLog diffToChangeLog = new DiffToChangeLog(diffOutputControl);
    for (ChangeLogOutputFile changeLogOutputFile : changeLogOutputFiles) {
        String encoding = getOutputEncoding(changeLogOutputFile);
        PrintStream printStream = null;
        try {
            FileResource outputFile = changeLogOutputFile.getOutputFile();
            ChangeLogSerializer changeLogSerializer = changeLogOutputFile.getChangeLogSerializer();
            log("Writing change log file " + outputFile.toString(), Project.MSG_INFO);
            printStream = new PrintStream(outputFile.getOutputStream(), true, encoding);
            liquibase.generateChangeLog(catalogAndSchema, diffToChangeLog, printStream, changeLogSerializer);
        } catch (UnsupportedEncodingException e) {
            throw new BuildException("Unable to generate a change log. Encoding [" + encoding + "] is not supported.", e);
        } catch (IOException e) {
            throw new BuildException("Unable to generate a change log. Error creating output stream.", e);
        } catch (ParserConfigurationException e) {
            throw new BuildException("Unable to generate a change log. Error configuring parser.", e);
        } catch (DatabaseException e) {
            throw new BuildException("Unable to generate a change log: " + e.getMessage(), e);
        } finally {
            FileUtils.close(printStream);
        }
    }
}
Also used : PrintStream(java.io.PrintStream) FileResource(org.apache.tools.ant.types.resources.FileResource) DiffOutputControl(liquibase.diff.output.DiffOutputControl) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ChangeLogSerializer(liquibase.serializer.ChangeLogSerializer) JsonChangeLogSerializer(liquibase.serializer.core.json.JsonChangeLogSerializer) StringChangeLogSerializer(liquibase.serializer.core.string.StringChangeLogSerializer) IOException(java.io.IOException) CatalogAndSchema(liquibase.CatalogAndSchema) ChangeLogOutputFile(liquibase.integration.ant.type.ChangeLogOutputFile) Liquibase(liquibase.Liquibase) Database(liquibase.database.Database) DiffToChangeLog(liquibase.diff.output.changelog.DiffToChangeLog) BuildException(org.apache.tools.ant.BuildException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) DatabaseException(liquibase.exception.DatabaseException)

Example 7 with ChangeLogSerializer

use of liquibase.serializer.ChangeLogSerializer in project liquibase by liquibase.

the class DiffToChangeLog method print.

public void print(String changeLogFile) throws ParserConfigurationException, IOException, DatabaseException {
    this.changeSetPath = changeLogFile;
    ChangeLogSerializer changeLogSerializer = ChangeLogSerializerFactory.getInstance().getSerializer(changeLogFile);
    this.print(changeLogFile, changeLogSerializer);
}
Also used : ChangeLogSerializer(liquibase.serializer.ChangeLogSerializer)

Aggregations

ChangeLogSerializer (liquibase.serializer.ChangeLogSerializer)7 IOException (java.io.IOException)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 PrintStream (java.io.PrintStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 Change (liquibase.change.Change)2 ChangeLogParameters (liquibase.changelog.ChangeLogParameters)2 DatabaseChangeLog (liquibase.changelog.DatabaseChangeLog)2 DiffOutputControl (liquibase.diff.output.DiffOutputControl)2 DiffToChangeLog (liquibase.diff.output.changelog.DiffToChangeLog)2 DatabaseException (liquibase.exception.DatabaseException)2 LiquibaseException (liquibase.exception.LiquibaseException)2 HubService (liquibase.hub.HubService)2 HubServiceFactory (liquibase.hub.HubServiceFactory)2 LiquibaseHubException (liquibase.hub.LiquibaseHubException)2 HubChangeLog (liquibase.hub.model.HubChangeLog)2