Package liquibase.exception

Examples of liquibase.exception.UnexpectedLiquibaseException


            return null;
        }
        try {
            return getConnection().getCatalog();
        } catch (DatabaseException e) {
            throw new UnexpectedLiquibaseException(e);
        }
    }
View Full Code Here


                buffer.append("<strong>Database version:</strong> ").append(StringUtils.escapeHtml(database.getDatabaseProductVersion())).append("<br>\n");
                buffer.append("<strong>Database user:</strong> ").append(StringUtils.escapeHtml(database.getConnection().getConnectionUserName())).append("<br>\n");

                Set<Schema> schemas = snapshot.get(Schema.class);
                if (schemas.size() > 1) {
                    throw new UnexpectedLiquibaseException("Can only display one schema");
                }
                Schema schema = schemas.iterator().next();
                if (database.supportsSchemas()) {
                    buffer.append("<strong>Catalog & Schema:</strong> ").append(schema.getCatalogName()).append(" / ").append(schema.getName()).append("<br>\n");
                } else {
                    buffer.append("<strong>Catalog:</strong> ").append(schema.getCatalogName()).append("<br>\n");
                }

                buffer.append("</div>\n");
                buffer.append("</div>\n");

                SnapshotControl snapshotControl = snapshot.getSnapshotControl();
                List<Class> includedTypes = sort(snapshotControl.getTypesToInclude());

                StringBuilder catalogBuffer = new StringBuilder();

                StringBuilder detailsBuilder = new StringBuilder();

                catalogBuffer.append("<ul class='nav nav-tabs' id='tabs'>\n");
                catalogBuffer.append("<li><a href='#databasechangelog-tab' data-toggle='tab'>DatabaseChangeLog</a></li>\n");
                for (Class type : includedTypes) {
                    if (schema.getDatabaseObjects(type).size() > 0) {
                        catalogBuffer.append("<li><a href='#").append(type.getSimpleName()).append("-tab' data-toggle='tab'>").append(type.getSimpleName()).append("(s)</a></li>\n");
                    }
                }
                catalogBuffer.append("</ul>\n");

                catalogBuffer.append("<div class='tab-content' style='margin-bottom:20px;'>\n");

                catalogBuffer.append("<div class='tab-pane' style='border: 1px #ddd solid; border-top:none' id='databasechangelog-tab'>\n");
                writeDatabaseChangeLogTab(context);
                detailsBuilder.append(context.get("changeLogDetails"));
                catalogBuffer.append(context.get("changeLog"));
                catalogBuffer.append("</div>");

                for (Class type : includedTypes) {
                    List<? extends DatabaseObject> databaseObjects = sort(schema.getDatabaseObjects(type));
                    if (databaseObjects.size() > 0) {
                        catalogBuffer.append("<div class='tab-pane' style='border: 1px #ddd solid; border-top:none' id='").append(type.getSimpleName()).append("-tab'>\n");

                        catalogBuffer.append("<div style='padding:10px; font-color:black'><ol>\n");

                        StringBuilder typeBuffer = new StringBuilder();
                        for (DatabaseObject databaseObject : databaseObjects) {
                            String id = databaseObject.getClass().getName() + "-" + databaseObject.getName();
                            id = cleanHtmlId(id);
                            typeBuffer.append("<li><a style='color:black' class='object-name' href='#" + id + "'>").append(StringUtils.escapeHtml(databaseObject.getName())).append("</a></li>\n");
                            detailsBuilder.append(wrapDetails(id, type.getSimpleName()+" "+databaseObject.getName(), writeDatabaseObject(databaseObject, new HashSet<String>(), databaseObject.getName()))).append("\n");
                        }

                        catalogBuffer.append(StringUtils.indent(typeBuffer.toString(), 4)).append("\n");

                        catalogBuffer.append("</ol></div>\n");
                        catalogBuffer.append("</div>\n");
                    }
                }
                catalogBuffer.append("</div>\n");
                buffer.append(StringUtils.indent(catalogBuffer.toString(), 4));


                context.put("snapshot", buffer.toString()); //standardize all newline chars
                context.put("details", detailsBuilder.toString()); //standardize all newline chars

            } catch (Exception e) {
                throw new UnexpectedLiquibaseException(e);
            }

        }
View Full Code Here

        if (database instanceof MSSQLDatabase) {
             String productVersion = null;
             try {
                 productVersion = database.getDatabaseProductVersion();
             } catch (DatabaseException e) {
                 throw new UnexpectedLiquibaseException(e);
             }
             if(productVersion == null || productVersion.startsWith("9") || productVersion.startsWith("10") || productVersion.startsWith("11") || productVersion.startsWith("12")) { // SQL Server 2005/2008/2012/2014
                // SQL Server 2005 does not often work with the simpler query shown below
                String query = "DECLARE @default sysname\n";
                query += "SELECT @default = object_name(default_object_id) FROM sys.columns WHERE object_id=object_id('" + escapedTableName + "') AND name='" + statement.getColumnName() + "'\n";
View Full Code Here

                } else if (target.equalsIgnoreCase("WARN") || target.equalsIgnoreCase("WARNING")) {
                    LogFactory.getInstance().getLog().warning(getMessage());
                } else if (target.equalsIgnoreCase("SEVERE") || target.equalsIgnoreCase("FATAL") || target.equalsIgnoreCase("ERROR")) {
                    LogFactory.getInstance().getLog().severe(getMessage());
                } else {
                    throw new UnexpectedLiquibaseException("Unknown target: "+target);
                }
                return null;
            }
        }};
    }
View Full Code Here

        try {
            for (Setup setup : this.setupCommands) {
                SetupResult result = setup.run();

                if (result == null) {
                    throw new UnexpectedLiquibaseException("No result returned by setup");
                } else {
                    if (!result.isValid()) {
                        valid = false;
                        canVerify = false;
                        notRanMessage = result.getMessage();
View Full Code Here

                        } else if (section.equals(Section.NOTES)) {
                            currentPermutation.note(multiLineKey, multiLineValue, OutputFormat.FromFile);
                        } else if (section.equals(Section.DATA)) {
                            currentPermutation.data(multiLineKey, multiLineValue, OutputFormat.FromFile);
                        } else {
                            throw new UnexpectedLiquibaseException("Unknown multiline section on line " + lineNumber + ": " + section);
                        }
                        multiLineKey = null;
                        multiLineValue = null;
                    }
                }

                if (StringUtils.trimToEmpty(line).equals("")) {
                    continue;
                }

                if (line.equals("#### Notes ####")) {
                    section = Section.NOTES;
                    continue;
                } else if (line.equals("#### Data ####")) {
                    section = Section.DATA;
                    continue;
                }

                Matcher permutationStartMatcher = permutationStartPattern.matcher(line);
                if (permutationStartMatcher.matches()) {
                    currentPermutation = new TestPermutation(results);
                    section = Section.DEFINITION;
                    continue;
                }

                Matcher permutationGroupStartMatcher = permutationGroupStartPattern.matcher(line);
                if (permutationGroupStartMatcher.matches()) {
                    currentPermutation = null;
                    currentPermutationGroup = new HashMap<String, String>();
                    permutationDefinitionKey = permutationGroupStartMatcher.group(1);
                    permutationColumns = new ArrayList<String>();
                    section = Section.GROUP_DEFINITION;
                    continue;
                }


                Matcher internalKeyValueMatcher = internalKeyValuePattern.matcher(line);
                if (internalKeyValueMatcher.matches()) {
                    String key = internalKeyValueMatcher.group(1);
                    String value = internalKeyValueMatcher.group(2);
                    if (key.equals("VERIFIED")) {
                        setVerifiedFromString(currentPermutation, value);
                    } else {
                        throw new UnexpectedLiquibaseException("Unknown internal parameter " + key);
                    }
                    continue;
                }

                Matcher keyValueMatcher = keyValuePattern.matcher(line);
                if (keyValueMatcher.matches()) {
                    String key = keyValueMatcher.group(1);
                    String value = keyValueMatcher.group(2);

                    if (section.equals(Section.DEFINITION)) {
                        currentPermutation.describe(key, value, OutputFormat.FromFile);
                    } else if (section.equals(Section.GROUP_DEFINITION)) {
                        currentPermutationGroup.put(key, value);
                    } else if (section.equals(Section.NOTES)) {
                        currentPermutation.note(key, value, OutputFormat.FromFile);
                    } else if (section.equals(Section.DATA)) {
                        currentPermutation.data(key, value, OutputFormat.FromFile);
                    } else {
                        throw new UnexpectedLiquibaseException("Unknown section " + section);
                    }
                    continue;
                }

                if (line.startsWith("|")) {
                    String unlikelyStringForSplit = "OIPUGAKJNGAOIUWDEGKJASDG";
                    String lineToSplit = line.replaceFirst("\\|", unlikelyStringForSplit).replaceAll("([^\\\\])\\|", "$1" + unlikelyStringForSplit);
                    String[] values = lineToSplit.split("\\s*" + unlikelyStringForSplit + "\\s*");
                    if (line.startsWith("| Permutation ")) {
                        for (int i = 3; i < values.length - 1; i++) { //ignoring first value that is an empty string and last value that is DETAILS
                            permutationColumns.add(values[i]);
                        }
                    } else {
                        if (values[1].equals("")) {
                            ; //continuing row
                        } else {
                            currentPermutation = new TestPermutation(results);
                            for (Map.Entry<String, String> entry : currentPermutationGroup.entrySet()) {
                                currentPermutation.describe(entry.getKey(), entry.getValue(), OutputFormat.FromFile);
                            }
                            setVerifiedFromString(currentPermutation, values[2]);
                            int columnNum = 0;
                            Map<String, TestPermutation.Value> valueDescription = new HashMap<String, TestPermutation.Value>();
                            try {
                                for (int i = 3; i < values.length - 1; i++) {
                                    if (!values[i].equals("")) {
                                        valueDescription.put(permutationColumns.get(columnNum), new TestPermutation.Value(decode(values[i]), OutputFormat.FromFile));
                                    }
                                    columnNum++;
                                }
                            } catch (Throwable e) {
                                throw new UnexpectedLiquibaseException("Error parsing line " + line);
                            }
                            currentPermutation.describeAsTable(permutationDefinitionKey, valueDescription);
                        }
                        String details = values[values.length - 1];
                        Matcher dataMatcher = dataDetailsMatcher.matcher(details);
                        Matcher notesMatcher = notesDetailsMatcher.matcher(details);
                        if (dataMatcher.matches()) {
                            currentPermutation.data(dataMatcher.group(1), decode(dataMatcher.group(2)), OutputFormat.FromFile);
                        } else if (notesMatcher.matches()) {
                            currentPermutation.note(notesMatcher.group(1), decode(notesMatcher.group(2)), OutputFormat.FromFile);
                        } else {
                            throw new RuntimeException("Unknown details column format: " + details);
                        }
                    }
                    continue;
                }

                Matcher multiLineKeyValueMatcher = multiLineKeyValuePattern.matcher(line);
                if (multiLineKeyValueMatcher.matches()) {
                    multiLineKey = multiLineKeyValueMatcher.group(1);
                    multiLineValue = "";
                    continue;
                }

                if (currentPermutation == null) {
                    //in the header section describing what the file is for
                } else {
                    throw new UnexpectedLiquibaseException("Could not parse line " + lineNumber + ": " + line);
                }
            }
        }

        return results;
View Full Code Here

            } else if (type.equals(SequenceCurrentValueFunction.class)) {
                return (T) new SequenceCurrentValueFunction(rawValue.toString());
            } else if (type.equals(DatabaseFunction.class)) {
                return (T) new DatabaseFunction(rawValue.toString());
            } else {
                throw new UnexpectedLiquibaseException("Cannot convert " + rawValue.getClass().getName() + " '" + rawValue + "' to " + type.getName());
            }
        } catch (Throwable e) {
            if (e instanceof UnexpectedLiquibaseException) {
                throw (UnexpectedLiquibaseException) e;
            }
View Full Code Here

            for (Class<? extends SnapshotSerializer> clazz : classes) {
                register((SnapshotSerializer) clazz.getConstructor().newInstance());
            }
        } catch (Exception e) {
            throw new UnexpectedLiquibaseException(e);
        }

    }
View Full Code Here

            for (Class<? extends ChangeLogSerializer> clazz : classes) {
                    register((ChangeLogSerializer) clazz.getConstructor().newInstance());
            }
        } catch (Exception e) {
            throw new UnexpectedLiquibaseException(e);
        }

    }
View Full Code Here

                    node.addChild((ParsedNode) fieldValue);
                } else {
                    node.addChild(new ParsedNode(null, field).setValue(fieldValue));
                }
            } else {
                throw new UnexpectedLiquibaseException("Unknown type: "+type);
            }
        }
        return node;
    }
View Full Code Here

TOP

Related Classes of liquibase.exception.UnexpectedLiquibaseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.