| 1 |  |  package liquibase.precondition.core; | 
  | 2 |  |   | 
  | 3 |  |  import liquibase.changelog.DatabaseChangeLog; | 
  | 4 |  |  import liquibase.changelog.ChangeSet; | 
  | 5 |  |  import liquibase.database.Database; | 
  | 6 |  |  import liquibase.exception.PreconditionErrorException; | 
  | 7 |  |  import liquibase.exception.PreconditionFailedException; | 
  | 8 |  |  import liquibase.exception.ValidationErrors; | 
  | 9 |  |  import liquibase.exception.Warnings; | 
  | 10 |  |  import liquibase.precondition.Precondition; | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |  public class DBMSPrecondition implements Precondition { | 
  | 17 |  |      private String type; | 
  | 18 |  |   | 
  | 19 | 13 |      public DBMSPrecondition() { | 
  | 20 | 13 |      } | 
  | 21 |  |   | 
  | 22 |  |      public String getType() { | 
  | 23 | 0 |          return type; | 
  | 24 |  |      } | 
  | 25 |  |   | 
  | 26 |  |      public void setType(String atype) { | 
  | 27 | 5 |          this.type = atype.toLowerCase(); | 
  | 28 | 5 |      } | 
  | 29 |  |   | 
  | 30 |  |      public Warnings warn(Database database) { | 
  | 31 | 0 |          return new Warnings(); | 
  | 32 |  |      } | 
  | 33 |  |   | 
  | 34 |  |      public ValidationErrors validate(Database database) { | 
  | 35 | 0 |          return new ValidationErrors(); | 
  | 36 |  |      } | 
  | 37 |  |   | 
  | 38 |  |      public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet) | 
  | 39 |  |              throws PreconditionFailedException, PreconditionErrorException { | 
  | 40 |  |          try { | 
  | 41 | 1 |              String dbType = database.getTypeName(); | 
  | 42 | 1 |              if (!type.equals(dbType)) { | 
  | 43 | 1 |                  throw new PreconditionFailedException("DBMS Precondition failed: expected " + type + ", got " + dbType, | 
  | 44 |  |                          changeLog, this); | 
  | 45 |  |              } | 
  | 46 | 1 |          } catch (PreconditionFailedException e) { | 
  | 47 | 1 |              throw e; | 
  | 48 | 0 |          } catch (Exception e) { | 
  | 49 | 0 |              throw new PreconditionErrorException(e, changeLog, this); | 
  | 50 | 0 |          } | 
  | 51 | 0 |      } | 
  | 52 |  |   | 
  | 53 |  |      public String getName() { | 
  | 54 | 10 |          return "dbms"; | 
  | 55 |  |      } | 
  | 56 |  |   | 
  | 57 |  |  } |