Search in sources :

Example 6 with LiquibaseHubException

use of liquibase.hub.LiquibaseHubException in project liquibase by liquibase.

the class DropAllCommand method getHubChangeLog.

// 
// Return a HubChangeLog object if available
// If not available then return null
// If the HubChangeLog has been deleted then throw
// a LiquibaseHubException
// 
private HubChangeLog getHubChangeLog(DatabaseChangeLog changeLog) throws LiquibaseHubException {
    String apiKey = StringUtil.trimToNull(HubConfiguration.LIQUIBASE_HUB_API_KEY.getCurrentValue());
    HubConfiguration.HubMode hubMode = HubConfiguration.LIQUIBASE_HUB_MODE.getCurrentValue();
    String changeLogId = changeLog.getChangeLogId();
    final HubServiceFactory hubServiceFactory = Scope.getCurrentScope().getSingleton(HubServiceFactory.class);
    if (apiKey == null || hubMode == HubConfiguration.HubMode.OFF || !hubServiceFactory.isOnline()) {
        return null;
    }
    final HubService service = Scope.getCurrentScope().getSingleton(HubServiceFactory.class).getService();
    HubChangeLog hubChangeLog = (changeLogId != null ? service.getHubChangeLog(UUID.fromString(changeLogId), "*") : null);
    if (hubChangeLog == null) {
        return null;
    }
    // 
    if (hubChangeLog.isDeleted()) {
        // 
        // Complain and stop the operation
        // 
        String message = "\n" + "The operation did not complete and will not be reported to Hub because the\n" + "" + "registered changelog has been deleted by someone in your organization.\n" + "Learn more at http://hub.liquibase.com";
        throw new LiquibaseHubException(message);
    }
    return hubChangeLog;
}
Also used : LiquibaseHubException(liquibase.hub.LiquibaseHubException) HubConfiguration(liquibase.hub.HubConfiguration) HubChangeLog(liquibase.hub.model.HubChangeLog) HubServiceFactory(liquibase.hub.HubServiceFactory) HubService(liquibase.hub.HubService)

Aggregations

LiquibaseHubException (liquibase.hub.LiquibaseHubException)6 IOException (java.io.IOException)4 HubService (liquibase.hub.HubService)4 HubServiceFactory (liquibase.hub.HubServiceFactory)4 HubChangeLog (liquibase.hub.model.HubChangeLog)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 HttpURLConnection (java.net.HttpURLConnection)2 Change (liquibase.change.Change)2 LiquibaseException (liquibase.exception.LiquibaseException)2 OperationChangeEvent (liquibase.hub.model.OperationChangeEvent)2 ChangeLogSerializer (liquibase.serializer.ChangeLogSerializer)2 Sql (liquibase.sql.Sql)2 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 UUID (java.util.UUID)1 Database (liquibase.database.Database)1